Add a debugParseScript for development
This commit is contained in:
parent
8b8aeb4409
commit
c8cd9dd09c
|
@ -2826,12 +2826,32 @@ readScriptFile = do
|
||||||
|
|
||||||
readScript = readScriptFile
|
readScript = readScriptFile
|
||||||
|
|
||||||
-- Interactively run a parser in ghci:
|
-- Interactively run a specific parser in ghci:
|
||||||
-- debugParse readScript "echo 'hello world'"
|
-- debugParse readSimpleCommand "echo 'hello world'"
|
||||||
debugParse p string = runIdentity $ do
|
debugParse p string = runIdentity $ do
|
||||||
(res, _) <- runParser testEnvironment p "-" string
|
(res, _) <- runParser testEnvironment p "-" string
|
||||||
return res
|
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 =
|
testEnvironment =
|
||||||
Environment {
|
Environment {
|
||||||
systemInterface = (mockedSystemInterface []),
|
systemInterface = (mockedSystemInterface []),
|
||||||
|
|
Loading…
Reference in New Issue