Re: Hierarchical query

From: Jan Hidders <hidders_at_gmail.com>
Date: Wed, 13 Jun 2007 14:44:47 -0700
Message-ID: <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:
>
> > 1 statement_block
> > 1.1 'declare' (matches token #1)
> > 1.2 declaration_item_list
> > 1.2.1 identifier (matches token #2)
> > 1.2.2 'integer' (matches token #3)
> > 1.2.3 ';' (matches token #4)
> > 1.3 'begin' (matches token #5)
> > 1.4 statements
> > 1.4.1 assignment
> > 1.4.1.1 identifier
> > 1.4.1.2 ':='
> > 1.4.1.3 number
> > 1.4.1.4 ';'
> > 1.4.2 statements (matches empty token)
> > 1.5 'end';
>
> 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.

  • Jan Hidders
Received on Wed Jun 13 2007 - 23:44:47 CEST

Original text of this message