summary refs log tree commit diff
path: root/grammar
diff options
context:
space:
mode:
authorErik Oosting2023-12-11 16:11:59 +0100
committerErik Oosting2023-12-11 16:11:59 +0100
commit60c8f636596de722a91f9dba1f2ae631a61a6484 (patch)
tree6a393f9c7550769ce1dce6eb8dbf8bbcc6db2890 /grammar
parent2824d28a6fd65e0a1f70a1f8b149a198e7e7fa8d (diff)
add more operators
Diffstat (limited to 'grammar')
-rw-r--r--grammar/ANF.g413
1 files changed, 12 insertions, 1 deletions
diff --git a/grammar/ANF.g4 b/grammar/ANF.g4
index 408439c..07e199e 100644
--- a/grammar/ANF.g4
+++ b/grammar/ANF.g4
@@ -1,12 +1,22 @@
 grammar ANF;
 
 aexp
-    : IDENT #var
+    : 'true' #true
+    | 'false' # false
+    | IDENT #var
     | NUMBER #num
     | '(' aexp '+' aexp ')' #add
     | '(' aexp '-' aexp ')' #sub
     | '(' aexp '*' aexp ')' #mul
     | '(' aexp '/' aexp ')' #div
+    | '(' aexp '>' aexp ')' #gt
+    | '(' aexp '<' aexp ')' #lt
+    | '(' aexp '==' aexp ')' #eq
+    | '(' aexp '<<' aexp ')' #bsl
+    | '(' aexp '>>' aexp ')' #bsr
+    | '(' aexp '&&' aexp ')' #and
+    | '(' aexp '||' aexp ')' #or
+    | '(' aexp '^^' aexp ')' #xor
     | '(' IDENT ':' cexp ')' #lam
     ;
 
@@ -16,6 +26,7 @@ funcall
     ;
 cexp
     : 'let' IDENT '=' funcall 'in' cexp #let
+    | 'if' aexp 'then' cexp 'else' cexp #if
     | funcall #fc
     ;