[antlr-interest] Extra right parenthesis in "An Introduction to
ANTLR" not failing - why?
Jeff Steward
jeffsteward at hotmail.com
Tue Jun 28 08:27:10 PDT 2005
Dear ANTLR interest,
I'm going to send an e-mail that I already sent privately to Professor Parr,
so if he gets it twice I hope he won't mind. :-)
Thank you all for your continued support of ANTLR. I have just started
using this tool and I must say I am impressed with the tool's ease of use,
power, and flexibility.
I do have a question, however, that it seems difficult to get past even
going through the documentation for a day or two. If this is really basic,
please forgive my ignorance.
I am using ANTLR to generate a small language much like the Expr example
from the article "An Introduction to ANTLR." The definition for the lexer
and parser can be found there:
http://www.cs.usfca.edu/~parrt/course/652/lectures/antlr.html . The trouble
is that it appears the generated ExprParser will give an incorrect parse of
the following (that is, it seems to me that the following should fail):
3+3)
The same occurs for any combination of incorrectly matched right
parenthesis, such as 3+3)))))) . In addition, something such as 3+3)+2 will
not only parse without error, it will evaluate as 3+3 - behavior that would
be highly undesirable for my user-defined input. However, incorrectly
matched left parenthesis - such as (3+3 - *will* fail, which is desirable
behavior for my app.
Therefore, what I would really like to do is check for exact matching of
parenthesis. Is there a simple way to do this with ANTLR grammar?
Thank you very much for your time.
Sincerely,
Jeff Steward
More information about the antlr-interest
mailing list