summaryrefslogtreecommitdiff
path: root/DSL/Parsing.hs
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-02-18 17:35:13 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-02-18 17:35:13 +1300
commit77d84c1539851f096b2c632cc6381ac72b2bfd1b (patch)
treedcdb7e649e481f40a389c07c1d6664961d43d8ca /DSL/Parsing.hs
parent28ab4a097fb73a138850a3fb7f6e480765c702ee (diff)
Implement multline comments
Diffstat (limited to 'DSL/Parsing.hs')
-rw-r--r--DSL/Parsing.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/DSL/Parsing.hs b/DSL/Parsing.hs
index fad68f1..6dcc4bf 100644
--- a/DSL/Parsing.hs
+++ b/DSL/Parsing.hs
@@ -19,6 +19,12 @@ fromTableL table = firstOf $ map (uncurry fromStringL) table
wsL :: DSLLexer
wsL = buildDSLLexer (mult1 $ satisfy isSpace) T_WHITESPACE
+commentL :: DSLLexer
+commentL = buildDSLLexer go T_COMMENT
+ where
+ delim = list "'''"
+ go = delim *> (fmap fst $ stopAfter delim)
+
keywordL :: DSLLexer
keywordL = fromTableL [ ("PROC", T_PROC)
, ("IF", T_IF)
@@ -81,14 +87,18 @@ intrinsicL = fromTableL [ (".", T_INTRINSIC I_DUMP)
]
lexemeL :: DSLLexer
-lexemeL = firstOf [ keywordL
+lexemeL = firstOf [ commentL
+ , keywordL
, literalL
, intrinsicL
, identifierL
]
tokenizer :: Parser Char [Token]
-tokenizer = optional wsL *> lexemeL `sepBy` wsL <* optional wsL
+tokenizer = filter f <$> go
+ where
+ go = optional wsL *> lexemeL `sepBy` wsL <* optional wsL
+ f Token { tTag=t } = t /= T_COMMENT
------------------------------------------------------------------------------
-- Parsing