[antlr-interest] Tree parser

rkevinburton at charter.net rkevinburton at charter.net
Thu Jul 31 11:56:25 PDT 2008


Thank you. This syntax came from 

http://antlr.org/share/list
kcsparse - an ECMA-334 C# Grammar Sample for ANTLR v2.7.6 (C#)

Kevin

---- Johannes Luber <jaluber at gmx.de> wrote: 
> rkevinburton at charter.net schrieb:
> > I would like to generate a tree parser. Unfortunateliy the ANTLR book has very little to say of the issue (or I just don't know where to look) and the sample grammars that I see seem to implement the 'walker' different from the way ANTLR does it now. For example in the CSharp grammar there is syntax like (the 'walker grammar names are different):
> > 
> >                CSharpwalker = new CSharpWalker();
> >                 walker.setASTFactory(new ASTNodeFactory());
> >                 CSharpParser.initializeASTFactory(walker.getASTFactory());
> > 
> > where the constructor for the waler no longer takes '0' arguments. There isn't a method 'setASTFactory' and there also isn't a method 'initializedASTFactory'. If I have a TreeParser grammar how do I integrate it with the parser?
> > 
> > Thank you.
> > 
> > Kevin
> > 
> I don't know where the syntax above comes actually from, but my own tree 
> grammar used a driver like this:
> 
> CSharpParser.grammarDef_return r = parser.startRule();
> CommonTree r0 = ((CommonTree) r.tree);
> CommonTreeNodeStream nodes = new CommonTreeNodeStream(r0);
> nodes.TokenStream = tokens;
> CSharpGenerator walker = new CSharpGenerator(nodes);
> RuleReturnScope r1 = walker.startRule();
> Console.Out.WriteLine(r1.Template.ToString());
> 
> Hope this helps



More information about the antlr-interest mailing list