[antlr-interest] Wrong Java code generated for semantic predicates?

Terence Parr parrt at jguru.com
Wed Nov 13 15:14:04 PST 2002


On Sunday, November 10, 2002, at 01:19  PM, Paul J. Lucas wrote:

> Given an earlier suggestion:
>
> 	FOO
> 		: BAR ( { cond }? BAZ | ) ;
>
> The Java code generated looks for BAZ before it checks the semantic 
> predicate.  I want it to check the semantic predicate immediately 
> after it matches BAR.  The Java code seems wrong to me.

You must check the syntactic context always before executing a sem pred 
so you know if it's valid to do so...not obvious here, but for hoisting 
you must keep the context.  It won't actually enter rule BAZ though. It 
just checks for the lookahead.

Ter
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list