mirror of
https://github.com/github/semantic.git
synced 2024-11-23 08:27:56 +03:00
Label compound and assignment parsers and use infix chainl1.
This commit is contained in:
parent
e9b0c4548f
commit
01a4bd2ed4
@ -47,7 +47,7 @@ core :: (TokenParsing m, Monad m) => m Core
|
|||||||
core = expr
|
core = expr
|
||||||
|
|
||||||
expr :: (TokenParsing m, Monad m) => m Core
|
expr :: (TokenParsing m, Monad m) => m Core
|
||||||
expr = chainl1 atom go where
|
expr = atom `chainl1` go where
|
||||||
go = choice [ (:.) <$ dot
|
go = choice [ (:.) <$ dot
|
||||||
, (:$) <$ notFollowedBy dot
|
, (:$) <$ notFollowedBy dot
|
||||||
]
|
]
|
||||||
@ -64,7 +64,7 @@ atom = choice
|
|||||||
]
|
]
|
||||||
|
|
||||||
comp :: (TokenParsing m, Monad m) => m Core
|
comp :: (TokenParsing m, Monad m) => m Core
|
||||||
comp = braces (sconcat <$> sepEndByNonEmpty expr semi)
|
comp = braces (sconcat <$> sepEndByNonEmpty expr semi) <?> "compound statement"
|
||||||
|
|
||||||
ifthenelse :: (TokenParsing m, Monad m) => m Core
|
ifthenelse :: (TokenParsing m, Monad m) => m Core
|
||||||
ifthenelse = If
|
ifthenelse = If
|
||||||
@ -74,7 +74,7 @@ ifthenelse = If
|
|||||||
<?> "if-then-else statement"
|
<?> "if-then-else statement"
|
||||||
|
|
||||||
assign :: (TokenParsing m, Monad m) => m Core
|
assign :: (TokenParsing m, Monad m) => m Core
|
||||||
assign = (:=) <$> try (lvalue <* symbolic '=') <*> core
|
assign = (:=) <$> try (lvalue <* symbolic '=') <*> core <?> "assignment"
|
||||||
|
|
||||||
edge :: (TokenParsing m, Monad m) => m Core
|
edge :: (TokenParsing m, Monad m) => m Core
|
||||||
edge = kw <*> expr where kw = choice [ Edge Lexical <$ reserved "lexical"
|
edge = kw <*> expr where kw = choice [ Edge Lexical <$ reserved "lexical"
|
||||||
|
Loading…
Reference in New Issue
Block a user