[antlr-interest] Tree parser

rkevinburton at charter.net rkevinburton at charter.net
Thu Jul 31 14:58:19 PDT 2008


it returns void. The rule in the grammar is:

program
	: statement*
	;

Kevin
---- Johannes Luber <jaluber at gmx.de> wrote: 
> rkevinburton at charter.net schrieb:
> > There must be some changes to the grammar as well. The lines:
> > 
> >     	ECMAScriptWalker walker = new ECMAScriptWalker(nodes); 
> >      	RuleReturnScope rs = walker.program(); 
> >     	Console.Out.WriteLine(rs.Template.ToString()); 
> > 
> > It seems that my walker start rule does not return RuleReturnScope.
> > 
> > Kevin
> 
> What does program() return then?
> 
> Johannes
> > 
> > ---- 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