Re: Hierarchical query

From: Jan Hidders <hidders_at_gmail.com>
Date: Thu, 14 Jun 2007 07:58:15 -0700
Message-ID: <1181833095.871608.148630_at_x35g2000prf.googlegroups.com>


On 14 jun, 12:47, "David Cressey" <cresse..._at_verizon.net> wrote:
> "Jan Hidders" <hidd..._at_gmail.com> wrote in message
>
> news:1181771087.949362.286440_at_d30g2000prg.googlegroups.com...
>
>
>
> > On 13 jun, 22:58, Vadim Tropashko <vadimtro_inva..._at_yahoo.com> wrote:
> > > On Jun 13, 9:11 am, Vadim Tropashko <vadimtro_inva..._at_yahoo.com>
> > > wrote:
>
> > > Actually, here is quite simple method. Write down the parse tree as a
> > > set of paths, using grammar varibles and constants (terminals and
> > > nonterminals) as path elements. In the example above we get:
>
> > > statement_block
> > > statement_block.'declare'
> > > statement_block.declaration_item_list
> > > statement_block.declaration_item_list.identifier"i"
> > > statement_block.declaration_item_list.'integer'
> > > ... and so on ...
>
> > > Query this set with regular expressions.
>
> > > XML, good bye!
>
> > Not so fast. An enumeration of the paths in a tree does not always
> > give you enough information to reconstruct the tree, so you would be
> > losing expressive power. Never mind that you ignore the order, which
> > may be a factor for the scope of declarations.
>
> I don't understand why enumerating the paths ignores the order.

Take the trees a( b( c ), d ) and a( d, b( c) ). The *set* of paths is in both cases: { a, a.b, a.b.c, a.d }.

Of course, making it a list and making sure you notice the end of

subtrees solves that problem. So the tree a( b( c ), b( c )) would
generate the list [a, a.b, a.b.c, a.b, a.b.c] and a( b( c, c)) would
generate the list [a, a.b, a.b.c, a.b.c].

  • Jan Hidders
Received on Thu Jun 14 2007 - 16:58:15 CEST

Original text of this message