Friday, December 3, 2004 01:55 AM
The following will nicely do this:
class MyLexer extends Lexer;
charVocabulary = '3'..'377';
Note the k=3 - it is necessary so that the lexer can look ahead more than the length of "te" and check whether the next character is an 's' or (in this case only a) 't'.
This will correctly parse
However, with more complex grammars it may not be so easy.
A fundamentally different approach is to use "keywords" with a keyword lookup table. See the ANTLR documentation for doing this (you would have something like
and then look up the string in a table.