[antlr-interest] Manual tree construction - using existing tokensfile

Sam Harwell sharwell at pixelminegames.com
Thu Oct 16 10:37:05 PDT 2008


If your target language is C#, then the tokens are declared as constants
in the parser class which are updated whenever the parser is generated.
For example, if your grammar is MyGrammar which generates
MyGrammarLexer.cs and MyGrammarParser.cs, then you could do the
following:

switch ( token.Type )
{
case MyGrammarParser.NEWLINE:
  break;
case MyGrammarParser.IDENTIFIER:
  break;
}

etc.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Bill Andersen
Sent: Thursday, October 16, 2008 12:28 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Manual tree construction - using existing
tokensfile

Folks,

I'm working on some code that needs to manipulate ASTs constructed  
manually except that I want to use code generated from a tree grammar  
to do it.  So I'm looking for some way to get the tokens file the tree  
grammars use bound to the code I'm using to build the trees.  I don't  
think it would be too hard to write, but does anyone have an easy way  
to do this?

	.bill

Bill Andersen
Ontology Works, Inc. (www.ontologyworks.com)
3600 O'Donnell Street, Suite 600
Baltimore, MD 21224
Office: +1.410.675.1201
Cell: +1.443.858.6444
Fax: +1.410.675.1204





List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess



More information about the antlr-interest mailing list