[antlr-interest] Composite Grammar problem/CoomonToken suggestion

Gavin Lambert antlr at mirality.co.nz
Fri May 16 00:39:28 PDT 2008


At 10:42 16/05/2008, Johannes Luber wrote:
 >Thinking about the "first comes first"-rule precendence in
 >inheriting the grammars, I came up with a case that doesn't seem 
to
 >be supported. If grammar A defines the rules r and s, as does
 >grammar B, then the rules in B are ignored. What if you want 
only
 >the rule s in B instead of s in A taking precedence? Switching 
the
 >grammars around doesn't help.

Bear in mind that I haven't so much as even glanced at the grammar 
inheritance stuff yet, but assuming it operates similar to general 
inheritance -- can you factor out one of the rules to a common 
base grammar?  That ought to sort it out.

 >Also did you see my suggestion regarding CommonToken? If you add 
a
 >string field then "!" can be made work in the lexer without
 >sacrificing speed for the normal cases. It just requires an
 >overhead for the pointer.

I would love for ! to work in the lexer again.  Although for my 
purposes it's not especially useful unless it also works in 
fragment rules, which is a bit of a trickier task (with the 
current design).



More information about the antlr-interest mailing list