[antlr-interest] "explosion" rewrite
Steve Ebersole
steve at hibernate.org
Mon May 4 08:08:40 PDT 2009
One thing I could not decode here...
What is it that sortKey should be returning in this case we are
discussing, assuming I have changed the sortSpecification rule?
sortSpecification
: sortKey collationSpecification? orderingSpecification?
-> ^( SORT_SPEC sortKey collationSpecification?
orderingSpecification? )+
;
(I can remove the collationSpecification and orderingSpecification
subrules if need be later, just wanted to try as is and see what
happened).
On Fri, 2009-05-01 at 17:08 -0700, Terence Parr wrote:
> On May 1, 2009, at 5:03 PM, Steve Ebersole wrote:
>
> > 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
>
> Ok, that's easy enough I think. Have sortKey not return VECTOR_EXPR as
> the root; you don't want it. THen, if we are ignoring the other rules
> for now, this is what you want:
>
> > sortSpecification : sortKey -> ^( SORT_SPEC sortKey )+ ;
>
> The + on the outside duplicates the root, one for each child pulled
> from sortKey...ack, wait. Will it see the tree coming back from
> sortKey as a "list" or a single element...hmm...try that first and see
> what happens.
>
> Then, if that works, we can think about the rule references I deleted.
>
> Ter
--
Steve Ebersole <steve at hibernate.org>
Hibernate.org
More information about the antlr-interest
mailing list