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

Jim Idle jimi at temporal-wave.com
Wed Nov 21 09:57:28 PST 2007


fragment STAR
: '*' ;

TRISTAR
	: '*'
		(  '*' '*'
		  | { $type = STAR; }
            )
	;

> -----Original Message-----
> From: Guntis Ozols [mailto:guntiso at latnet.lv]
> Sent: Wednesday, November 21, 2007 2:55 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Can antlr v3 lex star | tristar properly?
> 
> 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