[antlr-interest] Does lexer EVER use longest match?

Graham Wideman gwlist at grahamwideman.com
Mon Oct 12 19:45:52 PDT 2009


Hi folks:

I've been scouring the list archives trying to scrape together a better understanding of what variants of lexer code ANTLR might generate.

I keep seeing assertions that ANTLR lexers use longest match to select between otherwise ambiguous alternatives, and other assertions that it doesn't.  

In the code I see generated, I don't see any longest match logic, but maybe it only appears under particluar grammar arrangements or options?

Or are people using "longest match" when they really mean "once mToken has chosen a rule, then that rule will act greedy" (unless greedy=false)?

I'd appreciate if someone could clarify with an example that shows where longest match comes into play.  Or confirm that ANTLR actually doesn't use that strategy?

Thanks,

Graham


More information about the antlr-interest mailing list