Обсуждение: strange bison, cannot remove reduce

Поиск
Список
Период
Сортировка

strange bison, cannot remove reduce

От
"Pavel Stehule"
Дата:
hello

I am playing with methods. It's +/- function with first hidden arguments.

example: sin(10)  ~ (10).sin() is equivalent.
legal is substring('aaaa',1,3).upper() too etc

I spent some time with bison (without success).

indirection_el:                       '.' attr_name                               {
 $$ = (Node *) makeString($2);                               }                       | '.' attr_name '(' ')'
                  {                                       $$ = (Node *) makeString($2);                               }
                     | '.' attr_name '(' expr_list ')'                               {
    $$ = (Node *) makeString($2);                               }                       | '.' '*'
       {                                       $$ = (Node *) makeString("*");                               }
 
this is correct but doesn't work
postgres=# select (10).aaa.aaaa.bbbb.procedure(10);
ERROR:  syntax error at or near "("
LINE 1: select (10).aaa.aaaa.bbbb.procedure(10);                                          ^
postgres=# select (10).aaa.aaaa.bbbb.procedure();
ERROR:  syntax error at or near "("
LINE 1: select (10).aaa.aaaa.bbbb.procedure();

correct is
indirection_el:                       '.' attr_name                               {
 $$ = (Node *) makeString($2);                               }                       | '.' type_function_name '(' ')'
                           {                                       $$ = (Node *) makeString($2);
      }                       | '.' type_function_name '(' expr_list ')'                               {
                      $$ = (Node *) makeString($2);                               }                       | '.' '*'
                         {                                       $$ = (Node *) makeString("*");
     }
 

It works
postgres=# select (10).aaa(10).ajjaja(10).qqq();
ERROR:  column notation .aaa applied to type integer, which is not a
composite type

but there arebison gram.y
gram.y: conflicts: 3 reduce/reduce

state 1160
 1436 type_function_name: IDENT . 1439 ColLabel: IDENT .
   '('       reduce using rule 1436 (type_function_name)   '('       [reduce using rule 1439 (ColLabel)]   $default
reduceusing rule 1439 (ColLabel)
 

state 1165
 1437 type_function_name: unreserved_keyword . 1440 ColLabel: unreserved_keyword .
   '('       reduce using rule 1437 (type_function_name)   '('       [reduce using rule 1440 (ColLabel)]   $default
reduceusing rule 1440 (ColLabel)
 

state 1167
 1438 type_function_name: type_func_name_keyword . 1442 ColLabel: type_func_name_keyword .
   '('       reduce using rule 1438 (type_function_name)   '('       [reduce using rule 1442 (ColLabel)]   $default
reduceusing rule 1442 (ColLabel)
 

Any ideas?
Regards
Pavel


Re: strange bison, cannot remove reduce

От
Peter Eisentraut
Дата:
Pavel Stehule wrote:
> I am playing with methods. It's +/- function with first hidden arguments.
>
> example: sin(10)  ~ (10).sin() is equivalent.
> legal is substring('aaaa',1,3).upper() too etc
>
> I spent some time with bison (without success).

I don't think you can actually resolve this in the parser.  For example

a.b(x)

could be, call function b(x) in schema a, or call function b(a, x).

You need to resolve this later, with catalog access, it appears.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


Re: strange bison, cannot remove reduce

От
"Pavel Stehule"
Дата:
On 22/11/2007, Peter Eisentraut <peter_e@gmx.net> wrote:
> Pavel Stehule wrote:
> > I am playing with methods. It's +/- function with first hidden arguments.
> >
> > example: sin(10)  ~ (10).sin() is equivalent.
> > legal is substring('aaaa',1,3).upper() too etc
> >
> > I spent some time with bison (without success).
>
> I don't think you can actually resolve this in the parser.  For example
>
> a.b(x)
>
> could be, call function b(x) in schema a, or call function b(a, x).
>
> You need to resolve this later, with catalog access, it appears.
>

yes, I know, but I have to go across parser first

Pavel

> --
> Peter Eisentraut
> http://developer.postgresql.org/~petere/
>