[antlr-interest] Fix in token type file for Tree Parsers in C# codegen

Ney, Richard richard.ney at aspect.com
Mon Nov 4 16:24:25 PST 2002


I fixed a bug today dealing with the tree parser codegen. My grammer files
uses all three types: a parser, a lexer and a tree parser. The token file
generated for the tree parser had the correct name but the class name
internally was the same as the token class for the parser. I modified the
code in genTokenTypes. It now generates the class name based on the
TokenManager that is passed in instead of calling getTokenTypesClassName
which accesses the grammer's main TokenManager.

-Richard

/** Generate the token types CSharp file */
	protected void genTokenTypes(TokenManager tm) throws IOException
	{
		// Open the token output CSharp file and set the
currentOutput stream
		// SAS: file open was moved to a method so a subclass can
override
		//      This was mainly for the VAJ interface
		setupOutput(tm.getName() + TokenTypesFileSuffix);

		tabs = 0;

		// Generate the header common to all CSharp files
		genHeader();
		// Do not use printAction because we assume tabs==0
		println(behavior.getHeaderAction(""));

      // Generate the CSharp namespace declaration (if specified)
		if (nameSpace != null)
		{
			nameSpace.emitDeclarations(currentOutput);
		}
		tabs++;

		// Encapsulate the definitions in a class.  This has to be
done as a class because 
		// they are all constants and CSharp inteface  types cannot
contain constants.
		println("public class " + tm.getName() +
TokenTypesFileSuffix);
		println("{");
		tabs++;
		...


----------------------------------------------------------------------------
------------------------
Richard Ney	Aspect Communications
Principal Software Engineer
http://www.aspect.com <http://www.aspect.com>
Main:  408.325.2200
mailto:richard.ney at aspect.com <mailto:richard.ney at aspect.com>
SJ Office: 408.325.2464
    	Home Office: 916.797.9602
----------------------------------------------------------------------------
------------------------

The Three Laws of Infernal Dynamics:
1. An object in motion will always be headed in the wrong direction.
2. An object at rest will always be in the wrong place.
3. The energy required to change either of these states will always be more
than you wish to expend, but never so much as to make the task appear
prospectively impossible.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20021104/53f349b6/attachment.html


More information about the antlr-interest mailing list