[antlr-interest] difference between tokens and string literals
Gavin Lambert
antlr at mirality.co.nz
Mon Dec 31 16:03:32 PST 2007
At 11:40 1/01/2008, Mark Volkmann wrote:
>I found out that you can't assign literal values to tokens in a
>lexer-only grammar. ANTLR outputs an error message when you do
>that.
>As far as I can tell, there's no point in using a tokens
>specification (section 4.4 in the book) in a lexer-only
>grammar.
Well, that'll learn me to test my suggestions rather than just
using air code. Maybe :)
>Instead of the line above, I was able to use the following.
>
>list: LIST list_option terminator -> ^(LIST listOption);
Presumably you meant "^(LIST list_option)" there.
That's good. I couldn't remember off-hand whether ANTLR would
automatically insert the appropriate content for named rules or if
you needed to explicitly specify it in order to get the content
and source line information to carry across, so I tried to play it
safe by being more explicit than was actually necessary.
Glad you got it working, anyway.
More information about the antlr-interest
mailing list