summary refs log tree commit diff
path: root/grammar
diff options
context:
space:
mode:
authorErik Oosting2023-12-11 16:04:26 +0100
committerErik Oosting2023-12-11 16:04:26 +0100
commit2824d28a6fd65e0a1f70a1f8b149a198e7e7fa8d (patch)
treebac8ff6fe46ea823614caca28f17c80e470bb97a /grammar
parent0e96e69659c7c31927b7eee5c40d017b035a6471 (diff)
added labels to each rule
Diffstat (limited to 'grammar')
-rw-r--r--grammar/ANF.g422
1 files changed, 11 insertions, 11 deletions
diff --git a/grammar/ANF.g4 b/grammar/ANF.g4
index 95ab835..408439c 100644
--- a/grammar/ANF.g4
+++ b/grammar/ANF.g4
@@ -1,22 +1,22 @@
 grammar ANF;
 
 aexp
-    : IDENT
-    | NUMBER
-    | aexp '+' aexp
-    | aexp '-' aexp
-    | aexp '*' aexp
-    | aexp '/' aexp
-    | '(' IDENT ':' cexp ')'
+    : IDENT #var
+    | NUMBER #num
+    | '(' aexp '+' aexp ')' #add
+    | '(' aexp '-' aexp ')' #sub
+    | '(' aexp '*' aexp ')' #mul
+    | '(' aexp '/' aexp ')' #div
+    | '(' IDENT ':' cexp ')' #lam
     ;
 
 funcall
-    : IDENT '(' aexp (',' aexp)* ')'
-    | aexp
+    : IDENT '(' aexp (',' aexp)* ')' #call
+    | aexp #atom
     ;
 cexp
-    : 'let' IDENT '=' funcall 'in' cexp
-    | funcall
+    : 'let' IDENT '=' funcall 'in' cexp #let
+    | funcall #fc
     ;
 
 IDENT: Letter (Letter | Digit)*;