[antlr-interest] special characters in string literals?

fooblah2003 dbrumley at cs.stanford.edu
Fri Jul 11 18:27:23 PDT 2003


Does anyone know if ANTLR imposes keyword restrictions in the parser?

I can define:
class MyParser extends Parser;
list: 
|ID {/* reduce 0 */ } 
|"readonly" { /* reduce 1 */ } 
|"read-only" {/* reduce 2 */ } 
;


class MyLexer extends Lexer;
ID options {testLiterals=true; }: ('a'..'z')+;


If I run the parser w/ input "readonly", then reduce1 is executed.
However, with "read-only" reduce0 is executed, not reduce 2.

When I look at MyParserTokenTypes.java, I see:

        int LITERAL_readonly = 6;
// "read-only" = 7


i.e. the literal "read-only" is commented out.
Is this a bug, and can I get around it?  I have a similar problem
with wanting to define in the parser "http://" as a string literal,
with similar problems.

thanks,
david


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list