[antlr-interest] "explosion" rewrite

Steve Ebersole steve at hibernate.org
Fri May 1 17:03:46 PDT 2009


Lets say sortKey comes back as 
^( VECTOR_EXPR 
    ^( COLUMN 
        ALIAS_REF["a"] IDENTIFIER["col1"]
    )
    ^( COLUMN 
        ALIAS_REF["a"] IDENTIFIER["col2"]
    )
)

I'd really like sortSpecification to go from:

^( SORT_SPEC ^( VECTOR_EXPR["see above"] ) )

to:

^( SORT_SPEC ^( COLUMN ALIAS_REF["a"] IDENTIFIER["col1"] ) )
^( SORT_SPEC ^( COLUMN ALIAS_REF["a"] IDENTIFIER["col2"] ) )

so its gets split from one Tree to two

On Fri, 2009-05-01 at 13:39 -0700, Terence Parr wrote:
> Hi Steve, what's the tree you need rather than the output?
> Thanks,
> T
> On May 1, 2009, at 1:14 PM, Steve Ebersole wrote:
> 
> > Is there a syntax to "explode" a subrule result (sorry don't know a
> > better term).
> >
> > I have a rule:
> >
> > sortSpecification
> >    : sortKey collationSpecification? orderingSpecification?
> >        -> ^( SORT_SPEC sortKey collationSpecification?
> > orderingSpecification? )
> >    ;
> >
> > The result of the sortKey subrule could be a Tree of type VECTOR_EXPR
> > (its a "row value constructor" for those familiar with SQL).
> >
> > In terms of eventual output, this rule translates as "(sort_key1,
> > sort_key2) asc" where "sort_key1, sort_key2)" is the VECTOR_EXPR.
> >
> > Instead what I need to have happen is "sort_key1 asc, sort_key2 asc".
> >
> > I started down the path of trying an @after in the sortSpecification  
> > and
> > calling out to some java code to mutate the tree manually.  But I'd
> > prefer to keep this in the grammar if at all possible.
> >
> >
> > -- 
> > Steve Ebersole <steve at hibernate.org>
> > Hibernate.org
> >
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 
-- 
Steve Ebersole <steve at hibernate.org>
Hibernate.org



More information about the antlr-interest mailing list