summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nl/parentest.nl4
-rw-r--r--parser.hs9
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
diff --git a/parser.hs b/parser.hs
index 211c044..1b103d4 100644
--- a/parser.hs
+++ b/parser.hs
@@ -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)