nitcc: introduce nitcc
[nit.git] / contrib / nitcc / t / inf5000-06-grammaire2-instructions.sablecc
1 Grammar instuctions;
2 Lexer
3 id = ('a'..'z')+;
4 blank = ' ' | #9 | #10 | #13;
5
6 Parser
7 Ignored blank;
8
9 prog = stmt* ;
10 stmt =
11   {assign:} id '=' expr ';' |
12   {print:} 'print' '(' expr ')' ';' |
13   {while:} 'while' '(' expr ')' '{' stmt* '}'
14 //alt1 | {until:} 'do' '{' stmt* '}' 'until' '(' expr ')' ';'
15 //alt2 | {if:} 'if' '('expr')' '{'stmt*'}' elsex?
16 //alt3 | {call:} id '(' args ')' ';'
17   ;
18
19 //alt2 elsex = 'else' '{' stmt* '}' ;
20 //alt3 args = (expr Separator ',')* ;
21
22 expr = id;