[antlr-interest] bug in java.g?
parrt at cs.usfca.edu
Tue Feb 3 12:03:47 PST 2004
On Feb 3, 2004, at 11:55 AM, SainTiss wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> when parsing a file containing nothing but the following line:
> m = (TEST) d;
> I get the following exception:
> parser exception: emp.java:1:1: unexpected token: m
> emp.java:1:1: unexpected token: m
> at JavaRecognizer.statement(JavaRecognizer.java:2058)
> at Main.parseFile(Main.java:81)
> at Main.doFile(Main.java:54)
> at Main.main(Main.java:24)
> I'm calling the "statement()" method from the JavaRecognizer, so the
> should be valid.
> What's more, if I add a word (e.g. "smdfjmkj") on a line after the
> in the file, the parser does *not* throw the exception...
> Is there an explanation for this?
Yes, statement is not a "start symbol" EOF cannot follow it normally.
YOu must make a rule liek this:
stat_entry : stat ;
not called by anybody so ANTLR does the right thing. Then invoke the
grammar from stat_entry.
The second problem you have is that you told antlr to match a
statement, not two. It ignores what it doesn't care. It did theone
statement and returned :)
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com pure link sharing
Yahoo! Groups Links
To visit your group on the web, go to:
To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to:
More information about the antlr-interest