[antlr-interest] Problem with lexer
Emond Papegaaij
e.papegaaij at student.utwente.nl
Thu Nov 2 05:15:17 PST 2006
Hello,
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?
Best regards,
Emond Papegaaij
-------------- next part --------------
lexer grammar ActionMacroGenerate;
NODE_SELECTION
: '#' IDENTIFIER (WS? '[]')? {
System.out.println("MATCH: "+getText());
}
;
ANY_TEXT
: . {System.out.println("MATCH ANY: "+getText());}
;
fragment
WS
: ( ' ' | '\t' | '\f' | '\r' | '\n')+
;
fragment
IDENTIFIER
: ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'$')*
;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.java
Type: text/x-java
Size: 379 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20061102/aef98619/attachment.bin
More information about the antlr-interest
mailing list