[antlr-interest] problem with rule to match 'any other' text

Prashant Deva prashant.deva at gmail.com
Thu Mar 24 11:29:46 PST 2005


Hi,
 I have a little problem. I have this grammer (the antlr 2.7.xx
grammar, that is) and i am trying to add a rule to match 'any other
text'. basically text that is not matched by any rule.
But there seems to be a conflict with it and Whitespace rule. 
Here are the rules- 

TEXT_ERROR : (options{ greedy = false;}: .)+ ; //match any text not
matched by any other //rule

WS_LOOP
	:	(	// grab as much WS as you can
			options {
				greedy=true;
			}
		:
			WS
		|	COMMENT
		)*
	;

Thing is, when i type a whitespace, it is detected as a 'TEXT_ERROR'
token instead of a ws token. how do i correct the rules so that the ws
is handled correctly.

PRASHANT


More information about the antlr-interest mailing list