[antlr-interest] vocabulary inheritance and tokens

Christian Nentwich christian.nentwich at gmail.com
Mon May 29 04:16:45 PDT 2006


Hi,

I have a smallish problem with vocabulary inheritance: my custom AST
nodes are not being inherited.

I have two grammars, A and B. Grammar A is defined as:

class A extends Parser;
options {
  ...
}
tokens {
  X<AST=my.ast.node.X};
}
...

and Grammar B:

class B extends A;
options {
  ...
}
tokens {
  Y<AST=my.ast.node.Y>;
}


Now, the problem is that whenever an X occurs in an output file, it is
assigned just a base AST, not the AST node I explicitly specify in
grammar A. The only solution I have found to this is to repeat the
entire token section of A in B, which is slightly less than
satisfactory...

Am I getting something basic wrong?

thanks!

Christian


More information about the antlr-interest mailing list