[antlr-interest] Can a lexer rule have user defined attributes?
Jan van Mansum
janvanmansum at gmail.com
Fri Jul 25 02:24:35 PDT 2008
Hello group,
I am afraid I already now the answer: no. I tried the following grammar:
grammar TestAttributes;
r returns [int x, int y] : ID {System.out.println($ID.rv);}
;
ID returns [int rv]
: 'a'..'z'+ {$rv = 3;}
;
If I check the grammar in AntlrWorks it accepts it, but the generated lexer
code cannot be compiled because ID is a Token and not an ID_return instance.
In fact there is not ID_return class generated.
My questions:
- Why does the grammar check out as correct?
- Why can lexer rules not have user defined attributes?
Thanks for any help,
regards,
--
Jan van Mansum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080725/3ef9a775/attachment.html
More information about the antlr-interest
mailing list