[antlr-interest] Thoughts on tree construction

Tiller, Michael (M.M.) mtiller at ford.com
Fri May 7 13:31:12 PDT 2004


OK, fair enough.  People seem to think that DOM is overkill for AST
construction.  I don't necessarily disagree but one of the issues I'm
faced with is that instance variables are also problematic on the C++
side (at least in my experience).

Perhaps the way to do is some kind of "mapping" between AST and DOM
rather than using DOM to build the actual tree.

One last comment thought on this idea.  As far as I can tell, there
really isn't a formal mechanism for validating an AST in ANTLR or
formally stating it.  The tree walker grammar formally describes this,
but it isn't very useful outside of ANTLR.  I could imagine that if ASTs
were based on XML, part of the compiler process could be to
automatically formulate a DTD (or other type of schema) for the AST that
would be generated.  If you work completely within ANTLR, this might not
be useful, but if you were to interact with other tools, such a formal
statement of the tree structure might be useful.

Oh well.

--
Mike

> -----Original Message-----
> From: Mark Lentczner [mailto:markl at glyphic.com]
> Sent: Friday, May 07, 2004 3:56 PM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] Thoughts on tree construction
> 
> While I see the correspondence between DOM and AST, and I see the
> appeal of dividing information from a parse into attributes and
> elements, I think any real convergence is wrong.
> 
> 1st: The DOM has a tremendous amount of cruft that is very XML
> specific.  None of this would be applicable to parsing.
> 
> 2nd: By encoding information from a parse in both attributes and
> elements, the complexity of the structure of the AST is increased.
> Similarly, the structure of tree parsers would also have to be
> increased.  There would need to be a more complex syntax for matching
> since attributes and elements would need to be matched.
> 
> XML schema languages are precisely this sort of thing.  The results
are
> a mixed bag: XML Schema does not handle attributes and elements in a
> particularly graceful way, whereas RelaxNG does a decent job of it.
> However, if one is starting from designing tree structure grammar
> parsers, I don't think attributes and elements lead to elegant or more
> expressive solutions.  XML schema languages do it because they have
to.
> 
> I could imagine a DOM layer on top of the AST layer.  Then that DOM
API
> could be used w/other software that works with DOM.  In this case,
many
> features of the DOM would go unused (ASTs have no need for anything
> like a processing instruction...)  I can see the utility of this.  It
> could even be used to walk the AST and produce a canonical XML
> representation of it.  BUT, I don't think it means that the features
of
> DOM should be integrated into AST.
> 
> 	- Mark
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 



 
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