Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f69ff0c

Browse files
committed
Give 'a_expr ::= a_expr Op' production a slightly lower precedence than
Op, so that the sequence 'a_expr Op Op a_expr' will be parsed as a_expr Op (Op a_expr) not (a_expr Op) Op a_expr as formerly. In other words, prefer treating user-defined operators as prefix operators to treating them as postfix operators, when there is an ambiguity. Also clean up a couple of other infelicities in production priority assignment --- for example, BETWEEN wasn't being given the intended priority, but that of AND.
1 parent edfca4b commit f69ff0c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/backend/parser/gram.y

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.217 2001/01/20 17:37:52 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.218 2001/01/23 22:39:08 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -383,16 +383,16 @@ static void doNegateFloat(Value *v);
383383
%nonassoc OVERLAPS
384384
%nonassoc BETWEEN
385385
%nonassoc IN
386+
%left POSTFIXOP /* dummy for postfix Op rules */
386387
%left Op /* multi-character ops and user-defined operators */
387388
%nonassoc NOTNULL
388389
%nonassoc ISNULL
389-
%nonassoc NULL_P
390-
%nonassoc IS
390+
%nonassoc IS NULL_P TRUE_P FALSE_P /* sets precedence for IS NULL, etc */
391391
%left '+' '-'
392392
%left '*' '/' '%'
393393
%left '^'
394394
/* Unary Operators */
395-
%left AT
395+
%left AT ZONE /* sets precedence for AT TIME ZONE */
396396
%right UMINUS
397397
%left '.'
398398
%left '[' ']'
@@ -4355,7 +4355,7 @@ a_expr: c_expr
43554355
{ $$ = makeA_Expr(OP, $2, $1, $3); }
43564356
| Op a_expr
43574357
{ $$ = makeA_Expr(OP, $1, NULL, $2); }
4358-
| a_expr Op
4358+
| a_expr Op %prec POSTFIXOP
43594359
{ $$ = makeA_Expr(OP, $2, $1, NULL); }
43604360

43614361
| a_expr AND a_expr
@@ -4463,13 +4463,13 @@ a_expr: c_expr
44634463
n->typename->typmod = -1;
44644464
$$ = makeA_Expr(OP, "=", $1,(Node *)n);
44654465
}
4466-
| a_expr BETWEEN b_expr AND b_expr
4466+
| a_expr BETWEEN b_expr AND b_expr %prec BETWEEN
44674467
{
44684468
$$ = makeA_Expr(AND, NULL,
44694469
makeA_Expr(OP, ">=", $1, $3),
44704470
makeA_Expr(OP, "<=", $1, $5));
44714471
}
4472-
| a_expr NOT BETWEEN b_expr AND b_expr
4472+
| a_expr NOT BETWEEN b_expr AND b_expr %prec BETWEEN
44734473
{
44744474
$$ = makeA_Expr(OR, NULL,
44754475
makeA_Expr(OP, "<", $1, $4),
@@ -4529,7 +4529,7 @@ a_expr: c_expr
45294529
$$ = n;
45304530
}
45314531
}
4532-
| a_expr all_Op sub_type select_with_parens
4532+
| a_expr all_Op sub_type select_with_parens %prec Op
45334533
{
45344534
SubLink *n = makeNode(SubLink);
45354535
n->lefthand = makeList1($1);
@@ -4591,7 +4591,7 @@ b_expr: c_expr
45914591
{ $$ = makeA_Expr(OP, $2, $1, $3); }
45924592
| Op b_expr
45934593
{ $$ = makeA_Expr(OP, $1, NULL, $2); }
4594-
| b_expr Op
4594+
| b_expr Op %prec POSTFIXOP
45954595
{ $$ = makeA_Expr(OP, $2, $1, NULL); }
45964596
;
45974597

0 commit comments

Comments
 (0)