[antlr-interest] Fun with ANTLR3: mystery of the huge lexer

Gavin Lambert antlr at mirality.co.nz
Sat Jun 30 16:59:34 PDT 2007


At 11:12 1/07/2007, David Piepgrass wrote:
 >It's too bad I can't assign "priorities" to each rule. I
 >would like to match /* as a comment whenever possible, with
 >/regular-expressions/ having the next-highest priority and
 >PUNC having the lowest.

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.



More information about the antlr-interest mailing list