strange bison, cannot remove reduce

Started by Pavel Stehuleabout 18 years ago3 messages
#1Pavel Stehule
pavel.stehule@gmail.com

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 are
bison 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 reduce using 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 reduce using 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 reduce using rule 1442 (ColLabel)

Any ideas?
Regards
Pavel

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Pavel Stehule (#1)
Re: strange bison, cannot remove reduce

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/

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Peter Eisentraut (#2)
Re: strange bison, cannot remove reduce

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

Show quoted text

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