[antlr-interest] Unit testing grammar productions and injecting EOF

Daniels, Troy (US SSA) troy.daniels at baesystems.com
Tue Oct 6 07:13:04 PDT 2009


 

> -----Original Message-----
> 
> 
> As a workaround, I changed my production, adding EOF as an 
> optional terminal as follows:
> 
> objectMember : functionExpression EOF? | ID EOF?;
> 
> Everything now works but I'm curious if a better solution for 
> testing individual grammar productions exists.  Suggestions 
> or alternatives?
> 

While it's not the best answer, you could change your test code so that
instead of passing "foo", it passed "foo junk".  That way, your fix is
in the test code, and the production grammar says what you want it to
say.  Better would be for Antlr to include EOF in the follow set if it's
possible.

Troy

> Thanks.
> 
> --Kaleb
> 
> http://twitter.com/kalebpederson
> http://kalebpederson.com
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 


More information about the antlr-interest mailing list