[antlr-interest] Can antlr v3 lex star | tristar properly?

Guntis Ozols guntiso at latnet.lv
Wed Nov 21 02:54:31 PST 2007


Is there a way to lex this simple grammar (I am using ANTLRWorks 1.1.4):

stars        :        (STAR | TRISTAR)* EOF;
STAR : '*' ;
TRISTAR : STAR STAR STAR;

For '**' I keep getting: mismatched character '<EOF>' expecting '*'.

I am out of options. Below is what I've tried:
//tokens { STAR; TRISTAR;}
//options { backtrack = true; }
//options { k = 3; }
//ST        :        ('***') => '***' {type = TRISTAR;}
//        |        '*' {type = STAR;};
//STAR options {greedy=false;}: '*' ;
//TRISTAR : '***';
//TRISTAR : ('***')=>'***';
//TRISTAR options { greedy=true; } : '***';
//TRISTAR options { greedy=true; } : ('***')=>'***';
//TRISTAR options {greedy=false;} : '***';

Guntis




More information about the antlr-interest mailing list