[antlr-interest] bug in java.g?
Terence Parr
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
>
> Hi,
>
> 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
> file
> should be valid.
> What's more, if I add a word (e.g. "smdfjmkj") on a line after the
> statement
> in the file, the parser does *not* throw the exception...
>
> Is there an explanation for this?
Howdy.
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 :)
:)
Terence
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
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:
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