following: [antlr-interest] learning pitfall....

Lloyd Dupont lloyd at galador.net
Tue Apr 2 15:25:08 PST 2002


> > But if I add this production in the grammar "java.g":
> > // ------- added in java.g, in JavaRecognizer class ----------
> > script : (statement | importDefinition) *  ;
> > //---------------------------------------------------------------------
> > the grammar (in examples/java/java) no longer work
>
> The problem is that this rule can be empty (zero or more times something).
> Which will not work (antlr needs lookahead to decide things if a rule can
> be empty there's nothing to decide with...) Rewriting to something like
> ....

after more reflexion I am not really satisfyied.
It appear that this help me find solution but:

1st/
the script is not EMPTY, there is at least "EOF" (implictly added), you
could have blank script (file empty) and it should work !

2n/
// --------------------------
script: ( statement ) * ;
// --------------------------
work perfectly without problem. but I do want to have import !

.....
so anyidea about what's wrong with importDefinition rule ?
(examples/java/java/java.g grammar)


 

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



More information about the antlr-interest mailing list