[antlr-interest] Superclasses = best practise ...?
Hans-Juergen Rennau
hrennau at yahoo.de
Tue May 24 01:14:06 PDT 2011
Hello People,
this is a question about best practices when augmenting lexer and parser with
Java code providing helper methods (or even inner classes for storare purposes).
The Maven prototype "antlr3-maven-archetype" creates example grammars which use
super classes (AbstractTParser and AbstractTLexer). The comments in those super
classes suggest to honour this as a general pattern: put helper methods in a
grammar base class in order to keep the grammar light and clean. I think this
has pros and a con. The con is that this way the compactness of
"all-in-one-unit" is sacrificed; and reading the grammar one has to consult a
second source. Also I noted that the Definitive Guide never made any suggestions
to employ superclasses.
So this is my question: would you recommend the superclass approach indeed as
the best practise, or rather regard it as a good practise one might follow or
not, perhaps depending on complexity?
Thank you,
cheers,
-- Hans-Juergen Rennau
More information about the antlr-interest
mailing list