[antlr-interest] Grammar seems to produce incorrect parser
Ric Klaren
klaren at cs.utwente.nl
Thu Jan 22 06:35:39 PST 2004
On Thu, Jan 22, 2004 at 12:58:58AM -0000, stanhuff wrote:
> grammar throws exceptions if "is null" is not found. How can I change
> my grammar to get the desired parser?
>
> class ExpressionParser extends Parser;
> options {defaultErrorHandler=false;}
> expression
> : simpleExpression ("is" "null")?
> ;
For starters try:
expression
: simpleExpression ("is" "null")? EOF
;
This of course will only work for input with a single expression followed
by end of file. If you want it to stop parsing after one expression leaving
the rest of the stream untouched then it won't work :/
Intuitively I wouldn't expect the throw in the generated code.... But my
intuition might be wrong ;)
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722 ----
-----+++++*****************************************************+++++++++-------
Before they invented drawing boards, what did they go back to?
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