diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index e08ed1a..fefe325 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -2826,12 +2826,32 @@ readScriptFile = do readScript = readScriptFile --- Interactively run a parser in ghci: --- debugParse readScript "echo 'hello world'" +-- Interactively run a specific parser in ghci: +-- debugParse readSimpleCommand "echo 'hello world'" debugParse p string = runIdentity $ do (res, _) <- runParser testEnvironment p "-" string return res +-- Interactively run the complete parser in ghci: +-- debugParseScript "#!/bin/bash\necho 'Hello World'\n" +debugParseScript string = + result { + -- Remove the noisiest parts + prTokenPositions = Map.fromList [ + (Id 0, Position { + posFile = "removed for clarity", + posLine = -1, + posColumn = -1 + })] + } + where + result = runIdentity $ + parseScript (mockedSystemInterface []) $ ParseSpec { + psFilename = "debug", + psScript = string, + psCheckSourced = False + } + testEnvironment = Environment { systemInterface = (mockedSystemInterface []),