XQuery

From: Vadim Tropashko <vadimtro_invalid_at_yahoo.com>
Date: Tue, 12 Jun 2007 16:05:57 -0700
Message-ID: <1181689557.321704.281460_at_d30g2000prg.googlegroups.com>


On Jun 11, 10:24 am, Jan Hidders <hidd..._at_gmail.com> wrote:
> So I'm afraid it's quite
> possible that I suddenly disappear again without further notice.

Hi Jan, welcome back. XQuery question for you. Suppose I have a BNF grammar and a source text parsed into a tree. How would I query an identifier declaration? I committed a sin and went down to XQuery tutorials for some ideas, but all they can suggest are pitiful methods like filtering all the descendants of /bookstore/book. If there is indeed some clever query I would be forever converted. Until then, the "NO XML" icon would stay on my homepage (mimicked after Leonid Libkin's "No SQL":-).

Perhaps some example is needed. A simplified garmmar:

statement_block:
'declare'

    declaration_item_list;
'begin'

    statements ';'
'end';

statements: (statement_block | assignment) statements;

assignment:
  identifier ':=' (identifier | number)
;

declaration_item_list:
  identifier 'integer' ';'
;

Suppose we parse the following text

declare

   i integer;
begin
  i := 1;
end;

So that we get the parse tree. Now, given a parse tree and the leaf node corresponding to the varible i where it is assigned 1, how do we find the node that declares it? Received on Wed Jun 13 2007 - 01:05:57 CEST

Original text of this message