...
No Format |
---|
parse_expr[int p]
: primary
( {prec[input.LA(1)]>=p}?=> bop r= parse_expr[nextp(p)]
{
switch ( $bop.start.getType() ) {
case '+' :
case '-' :
action-for-this-alt
break;
...
case '=' :
action-for-this-alt
break;
default : // no action
}
}
| {postprec[input.LA(1)]>=p}?=> suffix[$e.tree]
)*
;
|
Trees for the binary operators could also be automatically done using the standard ANTLR mechanisms.
...
No Format |
---|
suffix[CommonTree lhs] : t='[' expre ']' -> ^(INDEX[$t] {$lhs} expre) | t='(' (expre (',' expre)*)? ')' -> ^(CALL[$t] {$lhs} expre*) | t='++' -> ^(POSTINC[$t] {$lhs}) ; |
...