[antlr-interest] action syntax
Akhilesh Mritunjai
mritun at gmail.com
Wed Nov 23 01:34:12 PST 2005
> If I do
> type:("char"|"int") name:IDENTIFIER
> { do something with 'type' and 'name' }
> in the parser, ANTLR tells me there's no variable 'type'.
Its my favorite pet-peeve with ANTLR. Labels are extremely limited in how
they can be used.
> If I make TYPE:"char"|"int"; in the lexer and say type:TYPE instead in
> the parser and try to parse some sensible data, I always get "unexpected
> token: char" or "unexpected token: int" as if it doesn't see I said to
Nope. It'd conflict with identifier.
The solution is:
typeName: "int" | "char";
decl:
type:typeName name:IDENTIFIER
{
// do whatever
}
;
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the antlr-interest
mailing list