parser: first work on comments, hacky

This commit is contained in:
2017-06-03 22:58:37 -04:00
parent c7777dec03
commit 37379b6cad

View File

@@ -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]