[antlr-interest] Re: Beginner question, about syntactic predicates.

micheal_jor <open.zone at virgin.net> open.zone at virgin.net
Wed Feb 5 17:55:44 PST 2003


> I have the following rules :
> 
> ---
> entSetAtt
> 	:	entityComponent (COLON entityComponent)* 
simpleAttribute
> // Alt1
> 	|	entityComponent (COLON entityComponent)*
> // Alt2
> ;
> 
> entityComponent // (supplier WHERE name="Telys")
> 	:	LPAREN IDENTIFIER CLAUSE RPAREN
> 	|	IDENTIFIER 
> ;
> 
> simpleAttribute	// .name
> 	:	DOT IDENTIFIER 
> ;
> ---
> 
> I have a non-determinism between Alt 1 and Alt2 on the rule 
entSetAtt.
> 
> ..but i cannot find a way to predict between alt1 and Alt2, even 
using
> syntactic predictates. The Only difference is the 'simpleAttribute' 
at
> the end of the Alt1.

And that is the answer:

entSetAtt
: entityComponent (COLON entityComponent)* (simpleAttribute)?
;

What you are really trying to say is that simpleAttibute may (or may 
not) follow all the other terminal/non-terminals in your grammar.

Micheal



 

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



More information about the antlr-interest mailing list