[antlr-interest] A few questions about AST

G R relationalalgebra at gmail.com
Mon Jun 25 06:53:38 PDT 2007


Hi,
I'm actually testing ANTLR to translate a relational algebra query into SQL
query for my "end of school project". Anyway, reading the wiki and FAQ on
the web site there are still a few things that i don't know how to do.

So here is my first question :
I got this Parser rules
projection
    :    PROJ LBRACK listAttribut RBRACK relation
    -> ^(PROJ listAttribut relation);

listAttribut
    :    (attribut) (','! attribut)*;
When i look at my AST, i got every attributes as child of my node PROJ. I'd
like to know how can I create an imaginary children "Attributes" to PROJ and
list every attributes in the subtree Attributes.
Instead of having :
PROJ
|______attribut1
|______attribut2
|...
|______relation
I'd like to have
PROJ
|_____Attributs
|         |______attribut1
|         |______attribut2
|_____relation

The second question is... How can i make a node using a parser rule ? here
is an example : I got the following rule
predicat:    elementaryPredicat (logicalOperator elementaryPredicat)*;
//    -> ^(logicalOperator elementaryPredicat elementaryPredicat);
logicalOperator
    :    AND
        | OR;
As you can see I've try to make my node using the logical operator but this
don't work.
Is there anyway of doing such things?

Finally, a simple question...How do i parse the AST from my main program in
java ?
Thanks.

G. R.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070625/4abfe03f/attachment.html 


More information about the antlr-interest mailing list