summary refs log tree commit diff
path: root/grammar
diff options
context:
space:
mode:
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)*;