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