[antlr-interest] Subclass a subclass of TreeParser?

Alan Larkin nobrow at eircom.net
Mon Jan 22 17:13:14 PST 2007


Would really appreciate some suggestions as to the problem below ...

Is it possible to subclass a subclass of TreeParser?

Working with the C grammar (cgram.tgz) from the archives, I am trying subclass GnuCEmitter (which
subclasses GnuCTreeParser, which subclasses TreeParser) but I get the following error:

   GnuCEmitterTokenTypes.txt:1:1: expecting ID, found 'null'

(GnuCEmitterTokenTypes.txt is empty). The goal is to override the output for just a couple of the
productions, and leverage the work of the authors of GnuCEmitter.g to output the rest of the
productions in a standard form (essentially, unchanged).

The following snippet is the Ant task Im using to build:

<antlr dir="${out.dir}/c" outputdirectory="${out.dir}/myC" target="${src.dir}/myC/MyCEmitter.g"
glib="${out.dir}/c/GnuCEmitter.g;${out.dir}/c/GnuCTreeParser.g">
   <classpath>
      <pathelement path="${out.dir}"/>
      <pathelement path="${antlr.jar}"/>
   </classpath>
</antlr>

The following is my MyCEmitter.g:

header
{
package myC;
}
	
{
import java.io.*;
}

class MyCEmitter extends GnuCEmitter;

options
{}

{}

<snip> OVERRIDDED PRODUCTIONS HERE <snip>

Im somewhat confused!

Thanks.


More information about the antlr-interest mailing list