diff options
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/ANF.g4 | 13 |
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 ; |