[antlr-interest] Epsilon productions and end of file

Marcin Rze¼nicki marcin-rzeznicki at wp.pl
Mon Dec 15 23:51:13 PST 2003


Hi. How should I specify epsilon productions in my grammar? So far I've been
using following pattern:

    production: other_prodution | ();

But it doesn't seem to work. Theory says that end-of-input char (usually
marked as $) is a member of starting production's follow set. Therefore,
supposing we have grammar:

    S -> AS`
    S`-> aS | "epsilon"

we should end up with $ in follow set of S`, which will result in placing
production:

     S`->"epsilon"

in parsing table, to be chosen by parser when it reads EOF from input
stream. But my parser, generated by ANTLR for Java, do not respect this and
throws exception when meeting EOF. After inspection of its source code I
have discovered that it has not placed EOF condition in its switch
instructions. I do not suppose this a bug (if it was so, it would be
horrible), I'd rather say I had not specified my intention clearly and
parser did not discover it as "epsilon" production.
--
Greetings
Marcin Rzeznicki



 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

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




More information about the antlr-interest mailing list