parser: first work on comments, hacky
This commit is contained in:
@@ -71,6 +71,7 @@ block = do
|
||||
_ <- optspace
|
||||
body <- P.sepBy parser newline
|
||||
_ <- optspace
|
||||
_ <- P.optionMaybe P.newline
|
||||
_ <- P.string "}"
|
||||
return body
|
||||
where newline = do
|
||||
@@ -149,9 +150,16 @@ call = do
|
||||
return $ BCall name args
|
||||
|
||||
|
||||
comment :: P.Parser Value
|
||||
comment = do
|
||||
_ <- P.string "#"
|
||||
_ <- P.manyTill P.anyChar P.newline
|
||||
return $ BBool True
|
||||
|
||||
|
||||
expr :: P.Parser Value
|
||||
expr = P.try bool
|
||||
P.<|> P.try comment
|
||||
P.<|> P.try def
|
||||
P.<|> P.try while
|
||||
P.<|> P.try parseIf
|
||||
@@ -167,7 +175,7 @@ parser = P.sepBy expr (P.string " " P.<|> P.string "\t")
|
||||
|
||||
|
||||
outerparser :: P.Parser [Value]
|
||||
outerparser = P.sepBy expr P.spaces
|
||||
outerparser = P.sepBy expr (P.spaces)
|
||||
|
||||
|
||||
parse :: String -> [Value]
|
||||
|
Reference in New Issue
Block a user