summary refs log tree commit diff
path: root/grammar/ANF.g4
blob: 95ab83566044e0449908183705e7e0c9bcb3992e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;