[antlr-interest] Lexer superclass not supported

Thomas Brandon tbrandonau at gmail.com
Wed Aug 8 10:56:33 PDT 2007


This was brought up in relation to combined grammars a few days ago
but the problem also applies to standalone lexers. Currently there is
no support for the superclass option in lexers.
The fix for standalone lexers is simple. Change the first couple of
lines of lexer in Java.stg to:
lexer(grammar, name, tokens, scopes, rules, numRules, labelType="Token",
      filterMode, superClass="Lexer") ::= <<
public class <name> extends <@superClassName><superClass><@end> {

Then add superClass to lexer arguments in ANTLRCore.sti. Other targets
would need to be updated as well to avoid ST interface mismatches.

Supporting it in combined grammars looks more involved. Currently
there does not look to be any way to have options go only to the
lexer. The Grammar.doNotCopyOptionsToLexer set stops parser only
options in combined files going to the lexer but I couldn't see any
way of having options go only to the lexer.

Tom.


More information about the antlr-interest mailing list