[antlr-interest] Why no children in tree generated by C++ parser?

Ric Klaren klaren at cs.utwente.nl
Fri Oct 8 10:01:11 PDT 2004


On Thu, Oct 07, 2004 at 10:42:03PM +0200, Maurice van der Pot wrote:
> I must say upfront I'm very new to using lexers/parsers etc.
> The code that I downloaded from the ANTLR website for parsing C++ parses my 
> preprocessed C++ files fine, but the AST that I get seems to have only 
> siblings of the root.

AFAIK that grammar has no treebuilding embedded, so if you only turned on
the buildAST option then the generated tree might not be usefull at all.

> Is this because the C++ grammar does not define any structure for ASTs?
> If so, how am I supposed to create a useful tree? Should I modify the 
> grammar, subclass the parser or is there something else I'm missing?

You should modify the grammar for treebuilding actions. But it depends on
what you'll want to do in the subsequent tree parsers how you'll strucutre
the tree.

Cheers,

Ric
- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
 Why don't we just invite them to dinner and massacre them all when they're
  drunk? You heard the man. There's seven hundred thousand of them. Ah? ..
           So it'd have to be something simple with pasta, then.
                 From: Interesting Times by Terry Pratchet



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list