[antlr-interest] literals in 2.7.6

Xue Yong Zhi zhixueyong at hotmail.com
Thu Feb 8 12:10:57 PST 2007


You do not have to list RESERVED as a rule, just use it as a string in 
the parser.

For example:

...
parser_rule_1
   : "keyword"  IDENTIFIER
   ;
...
class FooLexer extends Lexer;
options {
	testLiterals=false;	
}
...
IDENTIFIER
options{testLiterals=true;}:
...

You can use java.g as a reference.

Omry Yadan wrote:
> Here is a simple example that demonstrate my problem:
> 
> class TestLexter extends Lexer;
> protected CHAR : ('a'..'z' | 'A'..'Z');
> RESERVED     : "foo";
> SYMBOL  : CHAR (CHAR)* ;
> 


-- 
Xue Yong Zhi
http://xruby.blogspot.com



More information about the antlr-interest mailing list