[antlr-interest] Grammar seems to produce incorrect parser
stanhuff
stanhuff at yahoo.com
Wed Jan 21 16:58:58 PST 2004
In the following grammar, I desire to have the "is null" clause
optional after the 'simpleExpression' non-terminal. The resultant
parser doesn't work as expected. The parser generated from my little
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")?
;
simpleExpression
: Digits
| LParen expression RParen
;
class ExpressionLexer extends Lexer;
Identifier: ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z'
| '0'..'9' | '_')*;
Digits: ('0'..'9')+;
LParen: '(';
RParen: ')';
WS_ : (' ' | '\t' | '\n' | '\r')
{ _ttype = antlr::Token::SKIP; }
;
Thanks,
Stan
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