[antlr-interest] Grammar inheritance?

Ric Klaren ric.klaren at gmail.com
Wed Oct 4 07:59:23 PDT 2006


Hi,

On 10/4/06, Hill, Robert <rhill03 at eds.com> wrote:
> Does this work in 3.0b4?
> Im trying to create a base class using the grammar option {
> superClass=baseGrammar; }
> But for the derived grammar file its generating 'null.java' which contains
> about 20 lines of code :(

Last I heart it's not supported. And may even be replaced by something
different. The superclass thing is only to use a different java class
as the superclass for the generated parser.

Is it maybe an idea to use some literate programming tool for you
problem? There should be something in the archives about noweb and
antlr2. Think the cgrammar used it:

http://www.antlr.org/grammar/cgram/

It should let you maintain one 'base' grammar with plugholes for
different actions.

If you only do read only access on your tree you might even get
somewhere by having one main treewalker and call from that one other
tree walkers for nodes/subtrees you find interesting. (at least that
worked with antlr2) Depending on your grammar/needs the subtreewalkers
only need to be subsets of the big one.

Cheers,

Ric


More information about the antlr-interest mailing list