Re: Hierarchical query

From: Vadim Tropashko <vadimtro_invalid_at_yahoo.com>
Date: Wed, 13 Jun 2007 13:58:20 -0700
Message-ID: <1181768300.069954.66580_at_i13g2000prf.googlegroups.com>


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! Received on Wed Jun 13 2007 - 22:58:20 CEST

Original text of this message