[antlr-interest] Re: Again Infinite recursion on SQL table_ref <-> join_table

Sinan sinan.karasu at boeing.com
Wed Sep 4 11:01:45 PDT 2002


Ruslan Zasukhin wrote:
> 
> Hi Terrence,
> Hi Sinan,
> Hi Alan,
> Hi All,
> 
> Before ask on list I have search list archive, and found that with the same
> problem have meet before Sinan and Alan. I have not found solution on list,
> so I CC to you guys, may be you already have resolve this problem in your
> SQL grammar?
> 
> For all, I will show here where problem happens.
> In Standard SQL 92 we have the next rules. I have simplify them to extract
> only important part here:
> 
> joined_table
>     :    table_reference "join" table_reference
>     ;
> 
> table_reference
>     :    table_name             // IDENT
>     |    subquery               // '(' query ')'
>     |    joined_table
>     ;
> 

yacc would resolve this with precedence rules. So
what is needed is the determination of the meaning

 a join b join c.
is it left associative? right assoc? or non.

I suspect it is non, so 

joined_table
     :    table_reference ("join"^ joined_table)?
     ;
 
 table_reference
     :    table_name             // IDENT
     |    subquery               // '(' query ')'
     ;
 

is probably the right approach. So

a join b join c

would become
join
|
a--join
   |
   b--c

Sinan (who likes tail recursion...)

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list