[antlr-interest] newbie lookahead question
John B. Brodie
jbb at acm.org
Fri Apr 21 18:43:08 PDT 2006
Sir :-
>Well maybe not. It seems I was wrong about the tokens section. It
>doesn't specify lexer rules so the tokens aren't detected and put into
>the token stream for the parser. Ah well. It seemed like a good idea at
>the time.
>
>Lance
You are not wrong about the tokens{...} lexer section.
The tokens{...} section operates in concert with the testLiterals=true
option. Please review the antlr documentation for testLiterals.
You are able to set the options{ testLiterals=true; } either at the global
level so that all rules in your lexical inspect the tokens{...} generated map
or you can set the options{ testLiterals=true; } on only those specific lexer
rules that are pertinent (i prefer the latter).
And, oh by the way, that stuff between the "s in the tokens{...} section *IS*
a lexer rule --- it means:
'match this explicit string literal when testLiterals is true'
(now if we only had a way to specify synonyms in the tokens{...} section,
e.g. tokens{ TRUE="true","YES"; FALSE="false","NO"; } then life really would
be easy ;-)
Hope this helps...
-jbb
More information about the antlr-interest
mailing list