[antlr-interest] Antlr missing getTree() method? C#
Johannes Luber
jaluber at gmx.de
Wed Jul 23 16:05:00 PDT 2008
Gavin Lambert schrieb:
> At 08:28 24/07/2008, Setia, Namit wrote:
> >For some reason, I don't see any methods to extract the AST
> >tree from the parser (i.e., from the "qpar" variable). I've
> >seen in other posts people calling qpar.getTree() or
> >qpar.program(). Am I missing something critical from my grammar?
>
> You need to call the top-level rule in your parser. Which in your case
> appears to be 'qexprlist'. So call qpar.qexprlist() and it'll either
> return the tree directly or the tree will be one of the members of the
> structure it returns. (Things vary a little depending on target and
> grammar structure, but it's not hard to work out.)
>
And unless I missed it the name of getTree() is simply Tree in the C#
target.
Johannes
More information about the antlr-interest
mailing list