[antlr-interest] "explosion" rewrite

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


The problem is that sometimes you want the VECTOR_EXPR as such.  And
when you want which is not evident from the context of executing these
'expression' rules.  Perhaps this is a use-case for scopes?

And we haven't even gotten to the difficult cases of handling these
tuples (think something like VECTOR_EXPR = VECTOR_EXPR) ;)


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