Sam,
I'm using Java, but your solution would work there just as well.
Ashamed I didn't think of it myself. Thanks!
.bill
On Oct 16, 2008, at 13:37 , Sam Harwell wrote:
> 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: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Bill Andersen
> Sent: Thursday, October 16, 2008 12:28 PM
> To: [EMAIL PROTECTED]
> 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:8080/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-addr
> ess
>
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:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---