Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > d6ed6c5147aa2cde3d48cc9fb4d84ac5 > files > 28

ant-antlr3-20110110-11.mga5.noarch.rpm

grammar Poly;
options {output=AST;}
tokens { MULT; } // imaginary token

poly: term ('+'^ term)*
    ;

term: INT ID  -> ^(MULT["*"] INT ID)
    | INT exp -> ^(MULT["*"] INT exp)
    | exp
    | INT
	| ID
    ;

exp : ID '^'^ INT
    ;
    
ID	: 'a'..'z'+ ;

INT	: '0'..'9'+ ;

WS	: (' '|'\t'|'\r'|'\n')+ {skip();} ;