diff options
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/ANF.g4 | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/grammar/ANF.g4 b/grammar/ANF.g4 new file mode 100644 index 0000000..95ab835 --- /dev/null +++ b/grammar/ANF.g4 @@ -0,0 +1,28 @@ +grammar ANF; + +aexp + : IDENT + | NUMBER + | aexp '+' aexp + | aexp '-' aexp + | aexp '*' aexp + | aexp '/' aexp + | '(' IDENT ':' cexp ')' + ; + +funcall + : IDENT '(' aexp (',' aexp)* ')' + | aexp + ; +cexp + : 'let' IDENT '=' funcall 'in' cexp + | funcall + ; + +IDENT: Letter (Letter | Digit)*; +NUMBER: Digit+; + +fragment Letter: 'A' .. 'Z' | 'a' .. 'z'; +fragment Digit: '0'..'9'; + +WS: [ \t\n\r]+ -> skip; |