main
| Line | |
|---|
| 1 | grammar Simple;
|
|---|
| 2 |
|
|---|
| 3 | options {output=AST;}
|
|---|
| 4 |
|
|---|
| 5 | tokens{
|
|---|
| 6 | IF;
|
|---|
| 7 | BAR;
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | start : foo{System.out.println($foo.tree);}
|
|---|
| 11 | ;
|
|---|
| 12 |
|
|---|
| 13 | foo : b=bar WS* -> ^(IF {new CommonTree((CommonTree)((CommonTree)$b.tree).getChild(1))} {new CommonTree((CommonTree)((CommonTree)$b.tree).getChild(0))});
|
|---|
| 14 |
|
|---|
| 15 | bar : ID WS+ INT -> ID INT;
|
|---|
| 16 |
|
|---|
| 17 | //foo : bar WS* -> ^(IF bar);
|
|---|
| 18 | //bar : ID WS+ ID -> ID ID ;
|
|---|
| 19 | INT : '0'..'9'+ ;
|
|---|
| 20 | ID : ('a'..'z'|'A'..'Z')+ ;
|
|---|
| 21 | NEWLINE:'\r'? '\n' ;
|
|---|
| 22 | WS : (' '|'\t')+ ; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.