aboutsummaryrefslogtreecommitdiff
path: root/src/cljcc/parser.clj
diff options
context:
space:
mode:
authorShagun Agrawal <agrawalshagun07@gmail.com>2024-07-31 21:34:19 +0530
committerShagun Agrawal <agrawalshagun07@gmail.com>2024-07-31 21:34:19 +0530
commit35eae1f6626f6a18ae352a8a6adb9da747969c57 (patch)
tree64e04507e5c2e2380ca0009f23012382e2a06d99 /src/cljcc/parser.clj
parentb1457b664b6e6d5933297c79a7d0497c5db311ac (diff)
Fix parser bug for unary operations
Diffstat (limited to 'src/cljcc/parser.clj')
-rw-r--r--src/cljcc/parser.clj7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cljcc/parser.clj b/src/cljcc/parser.clj
index a4d7492..77482f1 100644
--- a/src/cljcc/parser.clj
+++ b/src/cljcc/parser.clj
@@ -12,7 +12,7 @@
function = #'int\\b' identifier <'('> #'void\\b' <')'> <'{'> statement <'}'>
statement = #'return\\b' exp <';'>
exp = constant | unop exp | <'('> exp <')'>
- unop = #'-\\b' | #'~\\b'
+ unop = #'-' | #'~'
identifier = #'[a-zA-Z_]\\w*\\b'
constant = #'[0-9]+\\b'
keyword = #'int\\b' | #'return\\b' | #'void\\b'"
@@ -26,4 +26,9 @@
(comment
(parse "int main(void) {return 2;}")
+
+ (parse "int main(void) {
+return -(((((10)))));
+}")
+
,)