diff options
-rw-r--r-- | nl/parentest.nl | 4 | ||||
-rw-r--r-- | parser.hs | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/nl/parentest.nl b/nl/parentest.nl new file mode 100644 index 0000000..3fe69e9 --- /dev/null +++ b/nl/parentest.nl @@ -0,0 +1,4 @@ +i32 main() { + 1 + (2 + 3); + return 0; +}
\ No newline at end of file @@ -102,7 +102,14 @@ pExpression :: Parser Expression pExpression = E.buildExpressionParser exprTable pExLit pExLit :: Parser Expression -pExLit = exLit_ <$> pLiteral +pExLit = (exLit_ <$> pLiteral) <|> pParenExpr + +pParenExpr :: Parser Expression +pParenExpr = do + symbol "(" + e <- pExpression + symbol ")" + return e pLiteral :: Parser Literal pLiteral = (LitInt <$> pInteger) <|> (LitInt <$> pCharStr) <|> (LitString <$> pString) |