[antlr-interest] Fun with ANTLR3: mystery of the huge lexer
Wincent Colaiuta
win at wincent.com
Sun Jul 1 07:59:40 PDT 2007
El 1/7/2007, a las 1:59, Gavin Lambert escribió:
> Lexer rules are implicitly assigned priorities based on what order
> they appear in the grammar -- rules that appear first are preferred
> over ones that are listed later.
>
> Having said that, I think there's also a longest-match-wins rule
> too, and I'm not sure how they interact.
I made some notes in that very subject here:
<http://wincent.com/knowledge-base/
ANTLR_lexers_in_depth#Precedence_among_lexer_rules>
Not sure if my conclusions are correct, but I've been making notes
while working with ANTLR for a few months trying to turn all those
mysterious "black art" aspects of ANTLR's workings into deterministic
certainties; it's pretty hard to write a grammar unless you
understand *exactly* what it happening behind the scenes.
Wincent
More information about the antlr-interest
mailing list