[antlr-interest] Lexer semantic predicate syntax?

Terence Parr parrt at cs.usfca.edu
Tue Nov 20 08:50:27 PST 2007


On Nov 19, 2007, at 9:14 PM, Steve Bennett wrote:

> Quick question about predicates in the lexer:
>
> Both of these seem to be acceptable:
>
> FOO: {...}? 'foo';

This one is a validating predicate and can also be hoisted into a  
rule that invokes FOO if necessary.

>
> FOO: {...}? => 'foo';

This one should be a validating one also but is FORCED into the  
lookahead DFA for any rule that invokes FOO.  Now if you only do

BLORT : FOO ;

then no pred is hoisted as there is no decision.

> seems to behave exactly as expected. Is this an error, or is there
> some distinction between the two?

Is there a pred test in both in the output?

Ter


More information about the antlr-interest mailing list