[antlr-interest] tree parsers vs visitors & xml translators etc...

Terence Parr parrt at jguru.com
Fri May 10 09:08:11 PDT 2002


On Thursday, May 9, 2002, at 11:33  PM, Silvain Piree wrote:

>> Can anybody comment on the visitor/xslt side?
>> How would you do this "find class defs" problem efficiently?
>
> The problem with Java is that you also have anonymous
> classes that can be defined within methods as part of an
> expression.

Fortunately for me I care only about named classes ;)  Man do I hate 
this inner class crap...really made Java complicated just because we 
can't have function pointers...ick.  Add generics and we're right back 
to C++ (well, nothing can be that complicated) ;)

> So, if you really want to find ALL class definitions, then
> you also have to analyze methods and expressions :-(
>
> A good XPath implementation will support indexing
> of elements, so that a query like "//class" will not need
> to traverse the tree, but instead only needs to look in the
> index (which is very efficient).

Ah...i wondered if anybody would actually do that.  That is good.  Now, 
can they do two-level indexing so I can find all nested classes?  I know 
it can do it by asking about the parent for context, but can it do it 
via the index so it is fast?

> ANTLR tree transformation certainly can be usefull,
> but the simplicity of XPath queries nested in your java
> source is difficult to beat for many simple purposes.

I would totally agree.  When I used to build a lot of translators, 
having a simple inline capability with a method call to find subtrees 
within a tree was very useful even for just printing stuff out.

Ter
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org


 

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



More information about the antlr-interest mailing list