[antlr-interest] All choices need a predicate?
James Ladd
james_ladd at hotmail.com
Fri Mar 25 14:57:17 PDT 2011
Hi All,
I have a rule with multiple choices.
Do I have to add a predicate to all choices or can I add just the predicates
that I want, ie: leaving the more complicated choice without a predicate?
For example:
primary returns [Primary n]
: ('(') => l = '(' expression {$n = new PrimaryExpression($expression.n, $l.line);} ')'
| (NAME) => variable {$n = $variable.n;}
| (OPEN_BLOCK) => block {$n = $block.n;}
| literal {$n = $literal.n;}
| ('{') => array {$n = $array.n;}
;
Also, is it possible to add multiple choices to a predicate?
eg: ( this | that | thing ) => xxxx
Rgs, James.
More information about the antlr-interest
mailing list