[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qexo-general] XQParser
From: |
Per Bothner |
Subject: |
Re: [Qexo-general] XQParser |
Date: |
Mon, 05 Aug 2002 08:17:47 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1b) Gecko/20020722 |
Chen Ya Bing wrote:
You can create an instance of XQuery, and then call
the parseFile method. That returns a Compilation state.
Calling getModule on the latter gives you an abstract
syntax tree of the parser.
but I found the parseFile method returns ModuleExp object, right? and the
object do not have a method called getModule.
Sorry, I should have explained: I've recently changed how Compilation
is used, and this changed a number of other things. It used to be
that a Compilation was allocated late in the process, *after* parsing
and conversion to Expression. I've recently changed the logic so that
the Translation class (used for Scheme/Lisp but not XQuery) inherits
from Compilation, and a Compilation is now created as part of the
parsing process.
So I was referring to the CVS version of Kawa, where parseFile does
return a Compilation. However, in the released 1.6.99 version
parseFile returns a ModuleExp, which is the actual syntax tree.
there is print method only.
or can I use print method to print the syntax expression?
Yes.
> another question
is, can I separate different parts of a xquery, such as For/Let clause,
Where clause and Return clause using some methods?
You can, but there aren't any convenience methods. The framework is
designed for synthesis, not analysis.
To analyzie and/or modify the syntax tree, Kawa uses the ExpWalker
framework. This recurses through the tree, making various changes,
tests, optimizations, and collecting information. There are 5
sub-classes of ExpWalker, one for each (intermediate) pass through the
tree. (Some of them could possibly be combined.)
yes, I printed it out, but I am sorry to say that it is hard for me
understand the syntax tree. can I get a picture of how the tree is like in
terms of query operator tree?
The structure of the tree is language-independent: There are no
XQuery-specific Expression sub-classes. Instead, XQuery-specific
operators are represented as function calls using ApplyExp.
The various clauses of a FLWR-expression are represented using
LambdaExp (lambda expressions), which are expression that are
anonymous functions.
in the case where the xquery is in FLWR expression, I wonder whether the
tree is constructed clause by clause. I mean, is the tree composed of
different parts cooresponding to different clauses?
Yes, mostly, but the tree is designed for optimizatio and code
generation, as well as language-independence, so things may
represented in a way that may seem strange.
--
--Per Bothner
address@hidden http://www.bothner.com/per/