[antlr-interest] Problem with lexer

Emond Papegaaij e.papegaaij at student.utwente.nl
Fri Nov 3 01:30:08 PST 2006


On Thursday 02 November 2006 21:55, Rick Morgan wrote:
> >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());
> >	}
> >	;
>
> 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.
>

This is ANTLR v3, which uses single quotes in the lexer, so '[]' should be 
ok.

Best regards,
Emond


More information about the antlr-interest mailing list