From 37379b6cad832d29cbf2de46967fb398daa7b948 Mon Sep 17 00:00:00 2001 From: hellerve Date: Sat, 3 Jun 2017 22:58:37 -0400 Subject: [PATCH] parser: first work on comments, hacky --- src/BC/Parse.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/BC/Parse.hs b/src/BC/Parse.hs index 56835da..e5f19c6 100644 --- a/src/BC/Parse.hs +++ b/src/BC/Parse.hs @@ -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]