[antlr-interest] "explosion" rewrite
Terence Parr
parrt at cs.usfca.edu
Fri May 1 17:08:41 PDT 2009
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
More information about the antlr-interest
mailing list