[antlr-interest] Problem with lexer

Rick Morgan r.morgan at verizonbusiness.com
Thu Nov 2 12:55:41 PST 2006


Emond,

I'm a total beginner at this stuff, but could I suggest that '[]' is not a
valid lexer character? Maybe "[]" is needed. Others who know better would
have to confirm or deny that.

Rick

>I'm having a problem with the attached lexer (v3). When it is run with the 
>Test class, the NODE_SELECTION token is never matched, even though the 
>input contains a NODE_SELECTION. The problem is that the lexer does not 
>look past the WS? in NODE_SELECTION. It first matches '#value'. Now it 
>checks the LA and decides to take the (WS? '[]') branch, even though there 
>is no '[]'. I've tried adding syntactic predicates and changing k, but to 
>no avail. Am I doing something wrong here?
>
>lexer grammar ActionMacroGenerate;
>NODE_SELECTION
>	: '#' IDENTIFIER (WS? '[]')? {
>		System.out.println("MATCH: "+getText());
>	}
>	;





More information about the antlr-interest mailing list