Replies: 1 comment
-
Why can't you use something like this? A8: 'Mr' '.' [A-Za-z]*
A27: [A-Za-z]+ '.' [A-Za-z]+ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I am trying to develop a lexer that was previously written in lex. And I don't know how to handle the following case:
A8: 'Mr' '.' {self.LOOKAHEAD("[A-Z][a-z]+")}?
A27: [A-Za-z]+ '.' [A-Za-z]+
And I have the input string "Mr.George".
The correct tokens should be A8, followed by other lexer tokens. But my lexer grammar matches A27, just because it is a longer match.
The initial lex scanner matches A8, because lookahead is native to the scanner, and is used in the calculation of the match length, and A8 is before A27.
In antlr, I have simulated lookahead in a semantic predicate, but I don't know how to make antlr lexer to select the A8 rule over A27.
Beta Was this translation helpful? Give feedback.
All reactions