From 60c8f636596de722a91f9dba1f2ae631a61a6484 Mon Sep 17 00:00:00 2001 From: Erik Oosting Date: Mon, 11 Dec 2023 16:11:59 +0100 Subject: add more operators --- grammar/ANF.g4 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'grammar') 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 ; -- cgit 1.4.1-2-gfad0