From d897cbadf51bb213acf4acc2a067cb8b9ff35d32 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Mon, 16 Dec 2019 09:21:57 -0500 Subject: [PATCH] Remove single chararter literal tokens from the core grammar By default, when Bison generates token symbols, it starts numbering them at 258, so that numbers below 256 can be used for character literals. The internal token number is looked up via the yytranslate[] array. Bison 3.5 has a new directive "%define api.token.raw", which causes Bison to write out the same ("raw") token numbers it would use internally, and thus skip building the yytranslate[] array as well as the code to access it. To be compatible with this directive, arrange for the core scanner to map single characters to new named tokens. Any invalid single characters now cause an error in the scanner rather than the parser. The speedup in raw parsing (Flex + Bison) is modest, at best 2%, and it'll be years before we can make the new directive the default, but making it possible to remove one useless array access and its cache pollution seems a worthwhile thing to do. --- src/backend/parser/gram.y | 749 ++++++++++++----------- src/backend/parser/scan.l | 81 ++- src/fe_utils/psqlscan.l | 4 +- src/include/parser/scanner.h | 3 + src/interfaces/ecpg/preproc/ecpg.addons | 6 +- src/interfaces/ecpg/preproc/ecpg.trailer | 142 ++--- src/interfaces/ecpg/preproc/parse.pl | 22 +- src/interfaces/ecpg/preproc/pgc.l | 115 +++- src/pl/plpgsql/src/pl_gram.y | 184 +++--- src/pl/plpgsql/src/pl_scanner.c | 18 +- src/test/regress/expected/strings.out | 5 + src/test/regress/sql/strings.sql | 3 + 12 files changed, 749 insertions(+), 583 deletions(-) diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index c5086846de..d7a885e78a 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -605,6 +605,21 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %token ICONST PARAM %token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER %token LESS_EQUALS GREATER_EQUALS NOT_EQUALS +/* + * Single character non-keyword token types. We use named tokens to refer + * to single character literal tokens, rather than the character itself. + * + * This enables using the '%define api.token.raw' directive, available in + * Bison 3.5 and up, saving one table lookup per token. + * Note: If this is done, then you must add '%define api.token.raw' to + * pl_gram.y as well, so that the token numbers match. + * + * LBRACE and RBRACE are unused in the core SQL grammar, and so will always + * provoke parse errors. They are here to avoid adding special cases to ECPG. + */ +%token COMMA LPAREN RPAREN LBRACKET RBRACKET LBRACE RBRACE DOT +%token SEMICOLON COLON PLUS MINUS STAR SLASH +%token PERCENT CARET LESS GREATER EQUALS /* * If you want to make any keyword changes, update the keyword table in @@ -727,7 +742,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %left AND %right NOT %nonassoc IS ISNULL NOTNULL /* IS sets precedence for IS NULL, etc */ -%nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS +%nonassoc LESS GREATER EQUALS LESS_EQUALS GREATER_EQUALS NOT_EQUALS %nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA %nonassoc ESCAPE /* ESCAPE must be just above LIKE/ILIKE/SIMILAR */ %left POSTFIXOP /* dummy for postfix Op rules */ @@ -745,7 +760,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); * postfix-operator problems. * * To support CUBE and ROLLUP in GROUP BY without reserving them, we give them - * an explicit priority lower than '(', so that a rule with CUBE '(' will shift + * an explicit priority lower than LPAREN, so that a rule with CUBE LPAREN will shift * rather than reducing a conflicting rule that takes CUBE as a function name. * Using the same precedence as IDENT seems right for the reasons given above. * @@ -761,17 +776,17 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %nonassoc UNBOUNDED /* ideally should have same precedence as IDENT */ %nonassoc IDENT GENERATED NULL_P PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP %left Op OPERATOR /* multi-character ops and user-defined operators */ -%left '+' '-' -%left '*' '/' '%' -%left '^' +%left PLUS MINUS +%left STAR SLASH PERCENT +%left CARET /* Unary Operators */ %left AT /* sets precedence for AT TIME ZONE */ %left COLLATE %right UMINUS -%left '[' ']' -%left '(' ')' +%left LBRACKET RBRACKET +%left LPAREN RPAREN %left TYPECAST -%left '.' +%left DOT /* * These might seem to be low-precedence, but actually they are not part * of the arithmetic hierarchy at all in their use as JOIN operators. @@ -804,7 +819,7 @@ stmtblock: stmtmulti * we'd get -1 for the location in such cases. * We also take care to discard empty statements entirely. */ -stmtmulti: stmtmulti ';' stmt +stmtmulti: stmtmulti SEMICOLON stmt { if ($1 != NIL) { @@ -1452,7 +1467,7 @@ generic_set: n->args = $3; $$ = n; } - | var_name '=' var_list + | var_name EQUALS var_list { VariableSetStmt *n = makeNode(VariableSetStmt); n->kind = VAR_SET_VALUE; @@ -1467,7 +1482,7 @@ generic_set: n->name = $1; $$ = n; } - | var_name '=' DEFAULT + | var_name EQUALS DEFAULT { VariableSetStmt *n = makeNode(VariableSetStmt); n->kind = VAR_SET_DEFAULT; @@ -1567,12 +1582,12 @@ set_rest_more: /* Generic SET syntaxes: */ ; var_name: ColId { $$ = $1; } - | var_name '.' ColId + | var_name DOT ColId { $$ = psprintf("%s.%s", $1, $3); } ; var_list: var_value { $$ = list_make1($1); } - | var_list ',' var_value { $$ = lappend($1, $3); } + | var_list COMMA var_value { $$ = lappend($1, $3); } ; var_value: opt_boolean_or_string @@ -1631,7 +1646,7 @@ zone_value: t->typmods = $3; $$ = makeStringConstCast($2, @2, t); } - | ConstInterval '(' Iconst ')' Sconst + | ConstInterval LPAREN Iconst RPAREN Sconst { TypeName *t = $1; t->typmods = list_make2(makeIntConst(INTERVAL_FULL_RANGE, -1), @@ -2016,7 +2031,7 @@ AlterTableStmt: alter_table_cmds: alter_table_cmd { $$ = list_make1($1); } - | alter_table_cmds ',' alter_table_cmd { $$ = lappend($1, $3); } + | alter_table_cmds COMMA alter_table_cmd { $$ = lappend($1, $3); } ; partition_cmd: @@ -2619,7 +2634,7 @@ replica_identity: ; reloptions: - '(' reloption_list ')' { $$ = $2; } + LPAREN reloption_list RPAREN { $$ = $2; } ; opt_reloptions: WITH reloptions { $$ = $2; } @@ -2628,12 +2643,12 @@ opt_reloptions: WITH reloptions { $$ = $2; } reloption_list: reloption_elem { $$ = list_make1($1); } - | reloption_list ',' reloption_elem { $$ = lappend($1, $3); } + | reloption_list COMMA reloption_elem { $$ = lappend($1, $3); } ; /* This should match def_elem and also allow qualified names */ reloption_elem: - ColLabel '=' def_arg + ColLabel EQUALS def_arg { $$ = makeDefElem($1, (Node *) $3, @1); } @@ -2641,12 +2656,12 @@ reloption_elem: { $$ = makeDefElem($1, NULL, @1); } - | ColLabel '.' ColLabel '=' def_arg + | ColLabel DOT ColLabel EQUALS def_arg { $$ = makeDefElemExtended($1, $3, (Node *) $5, DEFELEM_UNSPEC, @1); } - | ColLabel '.' ColLabel + | ColLabel DOT ColLabel { $$ = makeDefElemExtended($1, $3, NULL, DEFELEM_UNSPEC, @1); } @@ -2687,7 +2702,7 @@ alter_identity_column_option: PartitionBoundSpec: /* a HASH partition */ - FOR VALUES WITH '(' hash_partbound ')' + FOR VALUES WITH LPAREN hash_partbound RPAREN { ListCell *lc; PartitionBoundSpec *n = makeNode(PartitionBoundSpec); @@ -2740,7 +2755,7 @@ PartitionBoundSpec: } /* a LIST partition */ - | FOR VALUES IN_P '(' expr_list ')' + | FOR VALUES IN_P LPAREN expr_list RPAREN { PartitionBoundSpec *n = makeNode(PartitionBoundSpec); @@ -2753,7 +2768,7 @@ PartitionBoundSpec: } /* a RANGE partition */ - | FOR VALUES FROM '(' expr_list ')' TO '(' expr_list ')' + | FOR VALUES FROM LPAREN expr_list RPAREN TO LPAREN expr_list RPAREN { PartitionBoundSpec *n = makeNode(PartitionBoundSpec); @@ -2790,7 +2805,7 @@ hash_partbound: { $$ = list_make1($1); } - | hash_partbound ',' hash_partbound_elem + | hash_partbound COMMA hash_partbound_elem { $$ = lappend($1, $3); } @@ -2818,7 +2833,7 @@ AlterCompositeTypeStmt: alter_type_cmds: alter_type_cmd { $$ = list_make1($1); } - | alter_type_cmds ',' alter_type_cmd { $$ = lappend($1, $3); } + | alter_type_cmds COMMA alter_type_cmd { $$ = lappend($1, $3); } ; alter_type_cmd: @@ -2952,7 +2967,7 @@ CopyStmt: COPY opt_binary qualified_name opt_column_list n->options = list_concat(n->options, $10); $$ = (Node *)n; } - | COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options + | COPY LPAREN PreparableStmt RPAREN TO opt_program copy_file_name opt_with copy_options { CopyStmt *n = makeNode(CopyStmt); n->relation = NULL; @@ -2995,7 +3010,7 @@ copy_file_name: ; copy_options: copy_opt_list { $$ = $1; } - | '(' copy_generic_opt_list ')' { $$ = $2; } + | LPAREN copy_generic_opt_list RPAREN { $$ = $2; } ; /* old COPY option syntax */ @@ -3041,7 +3056,7 @@ copy_opt_item: { $$ = makeDefElem("force_quote", (Node *)$3, @1); } - | FORCE QUOTE '*' + | FORCE QUOTE STAR { $$ = makeDefElem("force_quote", (Node *)makeNode(A_Star), @1); } @@ -3088,7 +3103,7 @@ copy_generic_opt_list: { $$ = list_make1($1); } - | copy_generic_opt_list ',' copy_generic_opt_elem + | copy_generic_opt_list COMMA copy_generic_opt_elem { $$ = lappend($1, $3); } @@ -3104,8 +3119,8 @@ copy_generic_opt_elem: copy_generic_opt_arg: opt_boolean_or_string { $$ = (Node *) makeString($1); } | NumericOnly { $$ = (Node *) $1; } - | '*' { $$ = (Node *) makeNode(A_Star); } - | '(' copy_generic_opt_arg_list ')' { $$ = (Node *) $2; } + | STAR { $$ = (Node *) makeNode(A_Star); } + | LPAREN copy_generic_opt_arg_list RPAREN { $$ = (Node *) $2; } | /* EMPTY */ { $$ = NULL; } ; @@ -3114,7 +3129,7 @@ copy_generic_opt_arg_list: { $$ = list_make1($1); } - | copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item + | copy_generic_opt_arg_list COMMA copy_generic_opt_arg_list_item { $$ = lappend($1, $3); } @@ -3133,7 +3148,7 @@ copy_generic_opt_arg_list_item: * *****************************************************************************/ -CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' +CreateStmt: CREATE OptTemp TABLE qualified_name LPAREN OptTableElementList RPAREN OptInherit OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace { @@ -3152,8 +3167,8 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' n->if_not_exists = false; $$ = (Node *)n; } - | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' - OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause + | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name LPAREN + OptTableElementList RPAREN OptInherit OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace { CreateStmt *n = makeNode(CreateStmt); @@ -3292,7 +3307,7 @@ OptTableElementList: ; OptTypedTableElementList: - '(' TypedTableElementList ')' { $$ = $2; } + LPAREN TypedTableElementList RPAREN { $$ = $2; } | /*EMPTY*/ { $$ = NIL; } ; @@ -3301,7 +3316,7 @@ TableElementList: { $$ = list_make1($1); } - | TableElementList ',' TableElement + | TableElementList COMMA TableElement { $$ = lappend($1, $3); } @@ -3312,7 +3327,7 @@ TypedTableElementList: { $$ = list_make1($1); } - | TypedTableElementList ',' TypedTableElement + | TypedTableElementList COMMA TypedTableElement { $$ = lappend($1, $3); } @@ -3470,7 +3485,7 @@ ColConstraintElem: n->indexspace = $4; $$ = (Node *)n; } - | CHECK '(' a_expr ')' opt_no_inherit + | CHECK LPAREN a_expr RPAREN opt_no_inherit { Constraint *n = makeNode(Constraint); n->contype = CONSTR_CHECK; @@ -3500,7 +3515,7 @@ ColConstraintElem: n->location = @1; $$ = (Node *)n; } - | GENERATED generated_when AS '(' a_expr ')' STORED + | GENERATED generated_when AS LPAREN a_expr RPAREN STORED { Constraint *n = makeNode(Constraint); n->contype = CONSTR_GENERATED; @@ -3637,7 +3652,7 @@ TableConstraint: ; ConstraintElem: - CHECK '(' a_expr ')' ConstraintAttributeSpec + CHECK LPAREN a_expr RPAREN ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); n->contype = CONSTR_CHECK; @@ -3650,7 +3665,7 @@ ConstraintElem: n->initially_valid = !n->skip_validation; $$ = (Node *)n; } - | UNIQUE '(' columnList ')' opt_c_include opt_definition OptConsTableSpace + | UNIQUE LPAREN columnList RPAREN opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); @@ -3681,7 +3696,7 @@ ConstraintElem: NULL, yyscanner); $$ = (Node *)n; } - | PRIMARY KEY '(' columnList ')' opt_c_include opt_definition OptConsTableSpace + | PRIMARY KEY LPAREN columnList RPAREN opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); @@ -3712,7 +3727,7 @@ ConstraintElem: NULL, yyscanner); $$ = (Node *)n; } - | EXCLUDE access_method_clause '(' ExclusionConstraintList ')' + | EXCLUDE access_method_clause LPAREN ExclusionConstraintList RPAREN opt_c_include opt_definition OptConsTableSpace ExclusionWhereClause ConstraintAttributeSpec { @@ -3731,7 +3746,7 @@ ConstraintElem: NULL, yyscanner); $$ = (Node *)n; } - | FOREIGN KEY '(' columnList ')' REFERENCES qualified_name + | FOREIGN KEY LPAREN columnList RPAREN REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec { Constraint *n = makeNode(Constraint); @@ -3757,13 +3772,13 @@ opt_no_inherit: NO INHERIT { $$ = true; } ; opt_column_list: - '(' columnList ')' { $$ = $2; } + LPAREN columnList RPAREN { $$ = $2; } | /*EMPTY*/ { $$ = NIL; } ; columnList: columnElem { $$ = list_make1($1); } - | columnList ',' columnElem { $$ = lappend($1, $3); } + | columnList COMMA columnElem { $$ = lappend($1, $3); } ; columnElem: ColId @@ -3772,7 +3787,7 @@ columnElem: ColId } ; -opt_c_include: INCLUDE '(' columnList ')' { $$ = $3; } +opt_c_include: INCLUDE LPAREN columnList RPAREN { $$ = $3; } | /* EMPTY */ { $$ = NIL; } ; @@ -3800,7 +3815,7 @@ key_match: MATCH FULL ExclusionConstraintList: ExclusionConstraintElem { $$ = list_make1($1); } - | ExclusionConstraintList ',' ExclusionConstraintElem + | ExclusionConstraintList COMMA ExclusionConstraintElem { $$ = lappend($1, $3); } ; @@ -3809,14 +3824,14 @@ ExclusionConstraintElem: index_elem WITH any_operator $$ = list_make2($1, $3); } /* allow OPERATOR() decoration for the benefit of ruleutils.c */ - | index_elem WITH OPERATOR '(' any_operator ')' + | index_elem WITH OPERATOR LPAREN any_operator RPAREN { $$ = list_make2($1, $5); } ; ExclusionWhereClause: - WHERE '(' a_expr ')' { $$ = $3; } + WHERE LPAREN a_expr RPAREN { $$ = $3; } | /*EMPTY*/ { $$ = NULL; } ; @@ -3853,7 +3868,7 @@ key_action: | SET DEFAULT { $$ = FKCONSTR_ACTION_SETDEFAULT; } ; -OptInherit: INHERITS '(' qualified_name_list ')' { $$ = $3; } +OptInherit: INHERITS LPAREN qualified_name_list RPAREN { $$ = $3; } | /*EMPTY*/ { $$ = NIL; } ; @@ -3862,7 +3877,7 @@ OptPartitionSpec: PartitionSpec { $$ = $1; } | /*EMPTY*/ { $$ = NULL; } ; -PartitionSpec: PARTITION BY part_strategy '(' part_params ')' +PartitionSpec: PARTITION BY part_strategy LPAREN part_params RPAREN { PartitionSpec *n = makeNode(PartitionSpec); @@ -3879,7 +3894,7 @@ part_strategy: IDENT { $$ = $1; } ; part_params: part_elem { $$ = list_make1($1); } - | part_params ',' part_elem { $$ = lappend($1, $3); } + | part_params COMMA part_elem { $$ = lappend($1, $3); } ; part_elem: ColId opt_collate opt_class @@ -3904,7 +3919,7 @@ part_elem: ColId opt_collate opt_class n->location = @1; $$ = n; } - | '(' a_expr ')' opt_collate opt_class + | LPAREN a_expr RPAREN opt_collate opt_class { PartitionElem *n = makeNode(PartitionElem); @@ -4207,7 +4222,7 @@ OptSeqOptList: SeqOptList { $$ = $1; } | /*EMPTY*/ { $$ = NIL; } ; -OptParenthesizedSeqOptList: '(' SeqOptList ')' { $$ = $2; } +OptParenthesizedSeqOptList: LPAREN SeqOptList RPAREN { $$ = $2; } | /*EMPTY*/ { $$ = NIL; } ; @@ -4280,8 +4295,8 @@ opt_by: BY {} NumericOnly: FCONST { $$ = makeFloat($1); } - | '+' FCONST { $$ = makeFloat($2); } - | '-' FCONST + | PLUS FCONST { $$ = makeFloat($2); } + | MINUS FCONST { $$ = makeFloat($2); doNegateFloat($$); @@ -4290,7 +4305,7 @@ NumericOnly: ; NumericOnly_list: NumericOnly { $$ = list_make1($1); } - | NumericOnly_list ',' NumericOnly { $$ = lappend($1, $3); } + | NumericOnly_list COMMA NumericOnly { $$ = lappend($1, $3); } ; /***************************************************************************** @@ -4334,7 +4349,7 @@ opt_trusted: ; /* This ought to be just func_name, but that causes reduce/reduce conflicts - * (CREATE LANGUAGE is the only place where func_name isn't followed by '('). + * (CREATE LANGUAGE is the only place where func_name isn't followed by LPAREN). * Work around by using simple names, instead. */ handler_name: @@ -4539,7 +4554,7 @@ AlterExtensionContentsStmt: n->object = (Node *) $6; $$ = (Node *)n; } - | ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')' + | ALTER EXTENSION name add_drop CAST LPAREN Typename AS Typename RPAREN { AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt); n->extname = $3; @@ -4836,7 +4851,7 @@ AlterFdwStmt: ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_op /* Options definition for CREATE FDW, SERVER and USER MAPPING */ create_generic_options: - OPTIONS '(' generic_option_list ')' { $$ = $3; } + OPTIONS LPAREN generic_option_list RPAREN { $$ = $3; } | /*EMPTY*/ { $$ = NIL; } ; @@ -4845,7 +4860,7 @@ generic_option_list: { $$ = list_make1($1); } - | generic_option_list ',' generic_option_elem + | generic_option_list COMMA generic_option_elem { $$ = lappend($1, $3); } @@ -4853,7 +4868,7 @@ generic_option_list: /* Options definition for ALTER FDW, SERVER and USER MAPPING */ alter_generic_options: - OPTIONS '(' alter_generic_option_list ')' { $$ = $3; } + OPTIONS LPAREN alter_generic_option_list RPAREN { $$ = $3; } ; alter_generic_option_list: @@ -4861,7 +4876,7 @@ alter_generic_option_list: { $$ = list_make1($1); } - | alter_generic_option_list ',' alter_generic_option_elem + | alter_generic_option_list COMMA alter_generic_option_elem { $$ = lappend($1, $3); } @@ -4995,7 +5010,7 @@ AlterForeignServerStmt: ALTER SERVER name foreign_server_version alter_generic_o CreateForeignTableStmt: CREATE FOREIGN TABLE qualified_name - '(' OptTableElementList ')' + LPAREN OptTableElementList RPAREN OptInherit SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); @@ -5015,7 +5030,7 @@ CreateForeignTableStmt: $$ = (Node *) n; } | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name - '(' OptTableElementList ')' + LPAREN OptTableElementList RPAREN OptInherit SERVER name create_generic_options { CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt); @@ -5136,7 +5151,7 @@ import_qualification_type: ; import_qualification: - import_qualification_type '(' relation_expr_list ')' + import_qualification_type LPAREN relation_expr_list RPAREN { ImportQual *n = (ImportQual *) palloc(sizeof(ImportQual)); n->type = $1; @@ -5273,12 +5288,12 @@ AlterPolicyStmt: ; RowSecurityOptionalExpr: - USING '(' a_expr ')' { $$ = $3; } + USING LPAREN a_expr RPAREN { $$ = $3; } | /* EMPTY */ { $$ = NULL; } ; RowSecurityOptionalWithCheck: - WITH CHECK '(' a_expr ')' { $$ = $4; } + WITH CHECK LPAREN a_expr RPAREN { $$ = $4; } | /* EMPTY */ { $$ = NULL; } ; @@ -5355,7 +5370,7 @@ am_type: CreateTrigStmt: CREATE TRIGGER name TriggerActionTime TriggerEvents ON qualified_name TriggerReferencing TriggerForSpec TriggerWhen - EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')' + EXECUTE FUNCTION_or_PROCEDURE func_name LPAREN TriggerFuncArgs RPAREN { CreateTrigStmt *n = makeNode(CreateTrigStmt); n->trigname = $3; @@ -5377,7 +5392,7 @@ CreateTrigStmt: | CREATE CONSTRAINT TRIGGER name AFTER TriggerEvents ON qualified_name OptConstrFromTable ConstraintAttributeSpec FOR EACH ROW TriggerWhen - EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')' + EXECUTE FUNCTION_or_PROCEDURE func_name LPAREN TriggerFuncArgs RPAREN { CreateTrigStmt *n = makeNode(CreateTrigStmt); n->trigname = $4; @@ -5511,7 +5526,7 @@ TriggerForType: ; TriggerWhen: - WHEN '(' a_expr ')' { $$ = $3; } + WHEN LPAREN a_expr RPAREN { $$ = $3; } | /*EMPTY*/ { $$ = NULL; } ; @@ -5522,7 +5537,7 @@ FUNCTION_or_PROCEDURE: TriggerFuncArgs: TriggerFuncArg { $$ = list_make1($1); } - | TriggerFuncArgs ',' TriggerFuncArg { $$ = lappend($1, $3); } + | TriggerFuncArgs COMMA TriggerFuncArg { $$ = lappend($1, $3); } | /*EMPTY*/ { $$ = NIL; } ; @@ -5590,7 +5605,7 @@ ConstraintAttributeElem: CreateEventTrigStmt: CREATE EVENT TRIGGER name ON ColLabel - EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')' + EXECUTE FUNCTION_or_PROCEDURE func_name LPAREN RPAREN { CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt); n->trigname = $4; @@ -5601,7 +5616,7 @@ CreateEventTrigStmt: } | CREATE EVENT TRIGGER name ON ColLabel WHEN event_trigger_when_list - EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')' + EXECUTE FUNCTION_or_PROCEDURE func_name LPAREN RPAREN { CreateEventTrigStmt *n = makeNode(CreateEventTrigStmt); n->trigname = $4; @@ -5620,14 +5635,14 @@ event_trigger_when_list: ; event_trigger_when_item: - ColId IN_P '(' event_trigger_value_list ')' + ColId IN_P LPAREN event_trigger_value_list RPAREN { $$ = makeDefElem($1, (Node *) $4, @1); } ; event_trigger_value_list: SCONST { $$ = list_make1(makeString($1)); } - | event_trigger_value_list ',' SCONST + | event_trigger_value_list COMMA SCONST { $$ = lappend($1, makeString($3)); } ; @@ -5656,7 +5671,7 @@ enable_trigger: *****************************************************************************/ CreateAssertionStmt: - CREATE ASSERTION any_name CHECK '(' a_expr ')' ConstraintAttributeSpec + CREATE ASSERTION any_name CHECK LPAREN a_expr RPAREN ConstraintAttributeSpec { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -5729,7 +5744,7 @@ DefineStmt: n->definition = NIL; $$ = (Node *)n; } - | CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')' + | CREATE TYPE_P any_name AS LPAREN OptTableFuncElementList RPAREN { CompositeTypeStmt *n = makeNode(CompositeTypeStmt); @@ -5738,7 +5753,7 @@ DefineStmt: n->coldeflist = $6; $$ = (Node *)n; } - | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')' + | CREATE TYPE_P any_name AS ENUM_P LPAREN opt_enum_val_list RPAREN { CreateEnumStmt *n = makeNode(CreateEnumStmt); n->typeName = $3; @@ -5828,14 +5843,14 @@ DefineStmt: } ; -definition: '(' def_list ')' { $$ = $2; } +definition: LPAREN def_list RPAREN { $$ = $2; } ; def_list: def_elem { $$ = list_make1($1); } - | def_list ',' def_elem { $$ = lappend($1, $3); } + | def_list COMMA def_elem { $$ = lappend($1, $3); } ; -def_elem: ColLabel '=' def_arg +def_elem: ColLabel EQUALS def_arg { $$ = makeDefElem($1, (Node *) $3, @1); } @@ -5854,11 +5869,11 @@ def_arg: func_type { $$ = (Node *)$1; } | NONE { $$ = (Node *)makeString(pstrdup($1)); } ; -old_aggr_definition: '(' old_aggr_list ')' { $$ = $2; } +old_aggr_definition: LPAREN old_aggr_list RPAREN { $$ = $2; } ; old_aggr_list: old_aggr_elem { $$ = list_make1($1); } - | old_aggr_list ',' old_aggr_elem { $$ = lappend($1, $3); } + | old_aggr_list COMMA old_aggr_elem { $$ = lappend($1, $3); } ; /* @@ -5866,7 +5881,7 @@ old_aggr_list: old_aggr_elem { $$ = list_make1($1); } * the item names needed in old aggregate definitions are likely to become * SQL keywords. */ -old_aggr_elem: IDENT '=' def_arg +old_aggr_elem: IDENT EQUALS def_arg { $$ = makeDefElem($1, (Node *)$3, @1); } @@ -5879,7 +5894,7 @@ opt_enum_val_list: enum_val_list: Sconst { $$ = list_make1(makeString($1)); } - | enum_val_list ',' Sconst + | enum_val_list COMMA Sconst { $$ = lappend($1, makeString($3)); } ; @@ -5969,7 +5984,7 @@ CreateOpClassStmt: opclass_item_list: opclass_item { $$ = list_make1($1); } - | opclass_item_list ',' opclass_item { $$ = lappend($1, $3); } + | opclass_item_list COMMA opclass_item { $$ = lappend($1, $3); } ; opclass_item: @@ -6003,7 +6018,7 @@ opclass_item: n->number = $2; $$ = (Node *) n; } - | FUNCTION Iconst '(' type_list ')' function_with_argtypes + | FUNCTION Iconst LPAREN type_list RPAREN function_with_argtypes { CreateOpClassItem *n = makeNode(CreateOpClassItem); n->itemtype = OPCLASS_ITEM_FUNCTION; @@ -6085,11 +6100,11 @@ AlterOpFamilyStmt: opclass_drop_list: opclass_drop { $$ = list_make1($1); } - | opclass_drop_list ',' opclass_drop { $$ = lappend($1, $3); } + | opclass_drop_list COMMA opclass_drop { $$ = lappend($1, $3); } ; opclass_drop: - OPERATOR Iconst '(' type_list ')' + OPERATOR Iconst LPAREN type_list RPAREN { CreateOpClassItem *n = makeNode(CreateOpClassItem); n->itemtype = OPCLASS_ITEM_OPERATOR; @@ -6097,7 +6112,7 @@ opclass_drop: n->class_args = $4; $$ = (Node *) n; } - | FUNCTION Iconst '(' type_list ')' + | FUNCTION Iconst LPAREN type_list RPAREN { CreateOpClassItem *n = makeNode(CreateOpClassItem); n->itemtype = OPCLASS_ITEM_FUNCTION; @@ -6351,22 +6366,22 @@ drop_type_name_on_any_name: any_name_list: any_name { $$ = list_make1($1); } - | any_name_list ',' any_name { $$ = lappend($1, $3); } + | any_name_list COMMA any_name { $$ = lappend($1, $3); } ; any_name: ColId { $$ = list_make1(makeString($1)); } | ColId attrs { $$ = lcons(makeString($1), $2); } ; -attrs: '.' attr_name +attrs: DOT attr_name { $$ = list_make1(makeString($2)); } - | attrs '.' attr_name + | attrs DOT attr_name { $$ = lappend($1, makeString($3)); } ; type_name_list: Typename { $$ = list_make1($1); } - | type_name_list ',' Typename { $$ = lappend($1, $3); } + | type_name_list COMMA Typename { $$ = lappend($1, $3); } ; /***************************************************************************** @@ -6573,7 +6588,7 @@ CommentStmt: n->comment = $7; $$ = (Node *) n; } - | COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text + | COMMENT ON CAST LPAREN Typename AS Typename RPAREN IS comment_text { CommentStmt *n = makeNode(CommentStmt); n->objtype = OBJECT_CAST; @@ -6983,14 +6998,14 @@ privileges: privilege_list { $$ = NIL; } | ALL PRIVILEGES { $$ = NIL; } - | ALL '(' columnList ')' + | ALL LPAREN columnList RPAREN { AccessPriv *n = makeNode(AccessPriv); n->priv_name = NULL; n->cols = $3; $$ = list_make1(n); } - | ALL PRIVILEGES '(' columnList ')' + | ALL PRIVILEGES LPAREN columnList RPAREN { AccessPriv *n = makeNode(AccessPriv); n->priv_name = NULL; @@ -7000,7 +7015,7 @@ privileges: privilege_list ; privilege_list: privilege { $$ = list_make1($1); } - | privilege_list ',' privilege { $$ = lappend($1, $3); } + | privilege_list COMMA privilege { $$ = lappend($1, $3); } ; privilege: SELECT opt_column_list @@ -7203,7 +7218,7 @@ privilege_target: grantee_list: grantee { $$ = list_make1($1); } - | grantee_list ',' grantee { $$ = lappend($1, $3); } + | grantee_list COMMA grantee { $$ = lappend($1, $3); } ; grantee: @@ -7370,7 +7385,7 @@ defacl_privilege_target: *****************************************************************************/ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name - ON relation_expr access_method_clause '(' index_params ')' + ON relation_expr access_method_clause LPAREN index_params RPAREN opt_include opt_reloptions OptTableSpace where_clause { IndexStmt *n = makeNode(IndexStmt); @@ -7398,7 +7413,7 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name $$ = (Node *)n; } | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS index_name - ON relation_expr access_method_clause '(' index_params ')' + ON relation_expr access_method_clause LPAREN index_params RPAREN opt_include opt_reloptions OptTableSpace where_clause { IndexStmt *n = makeNode(IndexStmt); @@ -7448,7 +7463,7 @@ access_method_clause: ; index_params: index_elem { $$ = list_make1($1); } - | index_params ',' index_elem { $$ = lappend($1, $3); } + | index_params COMMA index_elem { $$ = lappend($1, $3); } ; /* @@ -7478,7 +7493,7 @@ index_elem: ColId opt_collate opt_class opt_asc_desc opt_nulls_order $$->ordering = $4; $$->nulls_ordering = $5; } - | '(' a_expr ')' opt_collate opt_class opt_asc_desc opt_nulls_order + | LPAREN a_expr RPAREN opt_collate opt_class opt_asc_desc opt_nulls_order { $$ = makeNode(IndexElem); $$->name = NULL; @@ -7491,12 +7506,12 @@ index_elem: ColId opt_collate opt_class opt_asc_desc opt_nulls_order } ; -opt_include: INCLUDE '(' index_including_params ')' { $$ = $3; } +opt_include: INCLUDE LPAREN index_including_params RPAREN { $$ = $3; } | /* EMPTY */ { $$ = NIL; } ; index_including_params: index_elem { $$ = list_make1($1); } - | index_including_params ',' index_elem { $$ = lappend($1, $3); } + | index_including_params COMMA index_elem { $$ = lappend($1, $3); } ; opt_collate: COLLATE any_name { $$ = $2; } @@ -7543,7 +7558,7 @@ CreateFunctionStmt: $$ = (Node *)n; } | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults - RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list + RETURNS TABLE LPAREN table_func_column_list RPAREN createfunc_opt_list { CreateFunctionStmt *n = makeNode(CreateFunctionStmt); n->is_procedure = false; @@ -7586,18 +7601,18 @@ opt_or_replace: | /*EMPTY*/ { $$ = false; } ; -func_args: '(' func_args_list ')' { $$ = $2; } - | '(' ')' { $$ = NIL; } +func_args: LPAREN func_args_list RPAREN { $$ = $2; } + | LPAREN RPAREN { $$ = NIL; } ; func_args_list: func_arg { $$ = list_make1($1); } - | func_args_list ',' func_arg { $$ = lappend($1, $3); } + | func_args_list COMMA func_arg { $$ = lappend($1, $3); } ; function_with_argtypes_list: function_with_argtypes { $$ = list_make1($1); } - | function_with_argtypes_list ',' function_with_argtypes + | function_with_argtypes_list COMMA function_with_argtypes { $$ = lappend($1, $3); } ; @@ -7643,13 +7658,13 @@ function_with_argtypes: * defaults in CREATE FUNCTION, not in ALTER etc. */ func_args_with_defaults: - '(' func_args_with_defaults_list ')' { $$ = $2; } - | '(' ')' { $$ = NIL; } + LPAREN func_args_with_defaults_list RPAREN { $$ = $2; } + | LPAREN RPAREN { $$ = NIL; } ; func_args_with_defaults_list: func_arg_with_default { $$ = list_make1($1); } - | func_args_with_defaults_list ',' func_arg_with_default + | func_args_with_defaults_list COMMA func_arg_with_default { $$ = lappend($1, $3); } ; @@ -7742,13 +7757,13 @@ func_return: * is next best choice. */ func_type: Typename { $$ = $1; } - | type_function_name attrs '%' TYPE_P + | type_function_name attrs PERCENT TYPE_P { $$ = makeTypeNameFromNameList(lcons(makeString($1), $2)); $$->pct_type = true; $$->location = @1; } - | SETOF type_function_name attrs '%' TYPE_P + | SETOF type_function_name attrs PERCENT TYPE_P { $$ = makeTypeNameFromNameList(lcons(makeString($2), $3)); $$->pct_type = true; @@ -7767,7 +7782,7 @@ func_arg_with_default: $$ = $1; $$->defexpr = $3; } - | func_arg '=' a_expr + | func_arg EQUALS a_expr { $$ = $1; $$->defexpr = $3; @@ -7796,7 +7811,7 @@ aggr_arg: func_arg * (ORDER BY aggr_arg,...) - ordered-set agg with no direct args * (aggr_arg,... ORDER BY aggr_arg,...) - ordered-set agg with direct args * - * The zero-argument case is spelled with '*' for consistency with COUNT(*). + * The zero-argument case is spelled with STAR for consistency with COUNT(*). * * An additional restriction is that if the direct-args list ends in a * VARIADIC item, the ordered-args list must contain exactly one item that @@ -7816,19 +7831,19 @@ aggr_arg: func_arg * on existing aggregates, we can just apply extractArgTypes to the first * sublist. */ -aggr_args: '(' '*' ')' +aggr_args: LPAREN STAR RPAREN { $$ = list_make2(NIL, makeInteger(-1)); } - | '(' aggr_args_list ')' + | LPAREN aggr_args_list RPAREN { $$ = list_make2($2, makeInteger(-1)); } - | '(' ORDER BY aggr_args_list ')' + | LPAREN ORDER BY aggr_args_list RPAREN { $$ = list_make2($4, makeInteger(0)); } - | '(' aggr_args_list ORDER BY aggr_args_list ')' + | LPAREN aggr_args_list ORDER BY aggr_args_list RPAREN { /* this is the only case requiring consistency checking */ $$ = makeOrderedSetArgs($2, $5, yyscanner); @@ -7837,7 +7852,7 @@ aggr_args: '(' '*' ')' aggr_args_list: aggr_arg { $$ = list_make1($1); } - | aggr_args_list ',' aggr_arg { $$ = lappend($1, $3); } + | aggr_args_list COMMA aggr_arg { $$ = lappend($1, $3); } ; aggregate_with_argtypes: @@ -7852,7 +7867,7 @@ aggregate_with_argtypes: aggregate_with_argtypes_list: aggregate_with_argtypes { $$ = list_make1($1); } - | aggregate_with_argtypes_list ',' aggregate_with_argtypes + | aggregate_with_argtypes_list COMMA aggregate_with_argtypes { $$ = lappend($1, $3); } ; @@ -7961,7 +7976,7 @@ createfunc_opt_item: ; func_as: Sconst { $$ = list_make1(makeString($1)); } - | Sconst ',' Sconst + | Sconst COMMA Sconst { $$ = list_make2(makeString($1), makeString($3)); } @@ -7969,7 +7984,7 @@ func_as: Sconst { $$ = list_make1(makeString($1)); } transform_type_list: FOR TYPE_P Typename { $$ = list_make1($3); } - | transform_type_list ',' FOR TYPE_P Typename { $$ = lappend($1, $5); } + | transform_type_list COMMA FOR TYPE_P Typename { $$ = lappend($1, $5); } ; opt_definition: @@ -7993,7 +8008,7 @@ table_func_column_list: { $$ = list_make1($1); } - | table_func_column_list ',' table_func_column + | table_func_column_list COMMA table_func_column { $$ = lappend($1, $3); } @@ -8169,7 +8184,7 @@ RemoveOperStmt: ; oper_argtypes: - '(' Typename ')' + LPAREN Typename RPAREN { ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -8177,24 +8192,24 @@ oper_argtypes: errhint("Use NONE to denote the missing argument of a unary operator."), parser_errposition(@3))); } - | '(' Typename ',' Typename ')' + | LPAREN Typename COMMA Typename RPAREN { $$ = list_make2($2, $4); } - | '(' NONE ',' Typename ')' /* left unary */ + | LPAREN NONE COMMA Typename RPAREN /* left unary */ { $$ = list_make2(NULL, $4); } - | '(' Typename ',' NONE ')' /* right unary */ + | LPAREN Typename COMMA NONE RPAREN /* right unary */ { $$ = list_make2($2, NULL); } ; any_operator: all_Op { $$ = list_make1(makeString($1)); } - | ColId '.' any_operator + | ColId DOT any_operator { $$ = lcons(makeString($1), $3); } ; operator_with_argtypes_list: operator_with_argtypes { $$ = list_make1($1); } - | operator_with_argtypes_list ',' operator_with_argtypes + | operator_with_argtypes_list COMMA operator_with_argtypes { $$ = lappend($1, $3); } ; @@ -8247,7 +8262,7 @@ dostmt_opt_item: * *****************************************************************************/ -CreateCastStmt: CREATE CAST '(' Typename AS Typename ')' +CreateCastStmt: CREATE CAST LPAREN Typename AS Typename RPAREN WITH FUNCTION function_with_argtypes cast_context { CreateCastStmt *n = makeNode(CreateCastStmt); @@ -8258,7 +8273,7 @@ CreateCastStmt: CREATE CAST '(' Typename AS Typename ')' n->inout = false; $$ = (Node *)n; } - | CREATE CAST '(' Typename AS Typename ')' + | CREATE CAST LPAREN Typename AS Typename RPAREN WITHOUT FUNCTION cast_context { CreateCastStmt *n = makeNode(CreateCastStmt); @@ -8269,7 +8284,7 @@ CreateCastStmt: CREATE CAST '(' Typename AS Typename ')' n->inout = false; $$ = (Node *)n; } - | CREATE CAST '(' Typename AS Typename ')' + | CREATE CAST LPAREN Typename AS Typename RPAREN WITH INOUT cast_context { CreateCastStmt *n = makeNode(CreateCastStmt); @@ -8288,7 +8303,7 @@ cast_context: AS IMPLICIT_P { $$ = COERCION_IMPLICIT; } ; -DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior +DropCastStmt: DROP CAST opt_if_exists LPAREN Typename AS Typename RPAREN opt_drop_behavior { DropStmt *n = makeNode(DropStmt); n->removeType = OBJECT_CAST; @@ -8311,7 +8326,7 @@ opt_if_exists: IF_P EXISTS { $$ = true; } * *****************************************************************************/ -CreateTransformStmt: CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')' +CreateTransformStmt: CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name LPAREN transform_element_list RPAREN { CreateTransformStmt *n = makeNode(CreateTransformStmt); n->replace = $2; @@ -8323,11 +8338,11 @@ CreateTransformStmt: CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name } ; -transform_element_list: FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes +transform_element_list: FROM SQL_P WITH FUNCTION function_with_argtypes COMMA TO SQL_P WITH FUNCTION function_with_argtypes { $$ = list_make2($5, $11); } - | TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes + | TO SQL_P WITH FUNCTION function_with_argtypes COMMA FROM SQL_P WITH FUNCTION function_with_argtypes { $$ = list_make2($11, $5); } @@ -8382,7 +8397,7 @@ ReindexStmt: n->options = 0; $$ = (Node *)n; } - | REINDEX '(' reindex_option_list ')' reindex_target_type opt_concurrently qualified_name + | REINDEX LPAREN reindex_option_list RPAREN reindex_target_type opt_concurrently qualified_name { ReindexStmt *n = makeNode(ReindexStmt); n->kind = $5; @@ -8392,7 +8407,7 @@ ReindexStmt: n->options = $3; $$ = (Node *)n; } - | REINDEX '(' reindex_option_list ')' reindex_target_multitable opt_concurrently name + | REINDEX LPAREN reindex_option_list RPAREN reindex_target_multitable opt_concurrently name { ReindexStmt *n = makeNode(ReindexStmt); n->kind = $5; @@ -8414,7 +8429,7 @@ reindex_target_multitable: ; reindex_option_list: reindex_option_elem { $$ = $1; } - | reindex_option_list ',' reindex_option_elem { $$ = $1 | $3; } + | reindex_option_list COMMA reindex_option_elem { $$ = $1 | $3; } ; reindex_option_elem: VERBOSE { $$ = REINDEXOPT_VERBOSE; } @@ -9311,7 +9326,7 @@ AlterObjectSchemaStmt: *****************************************************************************/ AlterOperatorStmt: - ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')' + ALTER OPERATOR operator_with_argtypes SET LPAREN operator_def_list RPAREN { AlterOperatorStmt *n = makeNode(AlterOperatorStmt); n->opername = $3; @@ -9321,12 +9336,12 @@ AlterOperatorStmt: ; operator_def_list: operator_def_elem { $$ = list_make1($1); } - | operator_def_list ',' operator_def_elem { $$ = lappend($1, $3); } + | operator_def_list COMMA operator_def_elem { $$ = lappend($1, $3); } ; -operator_def_elem: ColLabel '=' NONE +operator_def_elem: ColLabel EQUALS NONE { $$ = makeDefElem($1, NULL, @1); } - | ColLabel '=' operator_def_arg + | ColLabel EQUALS operator_def_arg { $$ = makeDefElem($1, (Node *) $3, @1); } ; @@ -9652,7 +9667,7 @@ publication_name_list: { $$ = list_make1($1); } - | publication_name_list ',' publication_name_item + | publication_name_list COMMA publication_name_item { $$ = lappend($1, $3); } @@ -9776,12 +9791,12 @@ RuleStmt: CREATE opt_or_replace RULE name AS RuleActionList: NOTHING { $$ = NIL; } | RuleActionStmt { $$ = list_make1($1); } - | '(' RuleActionMulti ')' { $$ = $2; } + | LPAREN RuleActionMulti RPAREN { $$ = $2; } ; /* the thrashing around here is to discard "empty" statements... */ RuleActionMulti: - RuleActionMulti ';' RuleActionStmtOrEmpty + RuleActionMulti SEMICOLON RuleActionStmtOrEmpty { if ($3 != NULL) $$ = lappend($1, $3); else @@ -9839,7 +9854,7 @@ NotifyStmt: NOTIFY ColId notify_payload ; notify_payload: - ',' Sconst { $$ = $2; } + COMMA Sconst { $$ = $2; } | /*EMPTY*/ { $$ = NULL; } ; @@ -9858,7 +9873,7 @@ UnlistenStmt: n->conditionname = $2; $$ = (Node *)n; } - | UNLISTEN '*' + | UNLISTEN STAR { UnlistenStmt *n = makeNode(UnlistenStmt); n->conditionname = NULL; @@ -10008,7 +10023,7 @@ transaction_mode_item: transaction_mode_list: transaction_mode_item { $$ = list_make1($1); } - | transaction_mode_list ',' transaction_mode_item + | transaction_mode_list COMMA transaction_mode_item { $$ = lappend($1, $3); } | transaction_mode_list transaction_mode_item { $$ = lappend($1, $2); } @@ -10030,7 +10045,7 @@ opt_transaction_chain: /***************************************************************************** * * QUERY: - * CREATE [ OR REPLACE ] [ TEMP ] VIEW '('target-list ')' + * CREATE [ OR REPLACE ] [ TEMP ] VIEW LPARENtarget-list RPAREN * AS [ WITH [ CASCADED | LOCAL ] CHECK OPTION ] * *****************************************************************************/ @@ -10061,7 +10076,7 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions n->withCheckOption = $11; $$ = (Node *) n; } - | CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions + | CREATE OptTemp RECURSIVE VIEW qualified_name LPAREN columnList RPAREN opt_reloptions AS SelectStmt opt_check_option { ViewStmt *n = makeNode(ViewStmt); @@ -10079,7 +10094,7 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions parser_errposition(@12))); $$ = (Node *) n; } - | CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions + | CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name LPAREN columnList RPAREN opt_reloptions AS SelectStmt opt_check_option { ViewStmt *n = makeNode(ViewStmt); @@ -10188,7 +10203,7 @@ createdb_opt_name: * Though the equals sign doesn't match other WITH options, pg_dump uses * equals for backward compatibility, and it doesn't seem worth removing it. */ -opt_equal: '=' {} +opt_equal: EQUALS {} | /*EMPTY*/ {} ; @@ -10258,7 +10273,7 @@ DropdbStmt: DROP DATABASE database_name n->options = NULL; $$ = (Node *)n; } - | DROP DATABASE database_name opt_with '(' drop_option_list ')' + | DROP DATABASE database_name opt_with LPAREN drop_option_list RPAREN { DropdbStmt *n = makeNode(DropdbStmt); n->dbname = $3; @@ -10266,7 +10281,7 @@ DropdbStmt: DROP DATABASE database_name n->options = $6; $$ = (Node *)n; } - | DROP DATABASE IF_P EXISTS database_name opt_with '(' drop_option_list ')' + | DROP DATABASE IF_P EXISTS database_name opt_with LPAREN drop_option_list RPAREN { DropdbStmt *n = makeNode(DropdbStmt); n->dbname = $5; @@ -10281,7 +10296,7 @@ drop_option_list: { $$ = list_make1((Node *) $1); } - | drop_option_list ',' drop_option + | drop_option_list COMMA drop_option { $$ = lappend($1, (Node *) $3); } @@ -10614,7 +10629,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relati n->is_vacuumcmd = true; $$ = (Node *)n; } - | VACUUM '(' vac_analyze_option_list ')' opt_vacuum_relation_list + | VACUUM LPAREN vac_analyze_option_list RPAREN opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = $3; @@ -10635,7 +10650,7 @@ AnalyzeStmt: analyze_keyword opt_verbose opt_vacuum_relation_list n->is_vacuumcmd = false; $$ = (Node *)n; } - | analyze_keyword '(' vac_analyze_option_list ')' opt_vacuum_relation_list + | analyze_keyword LPAREN vac_analyze_option_list RPAREN opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = $3; @@ -10650,7 +10665,7 @@ vac_analyze_option_list: { $$ = list_make1($1); } - | vac_analyze_option_list ',' vac_analyze_option_elem + | vac_analyze_option_list COMMA vac_analyze_option_elem { $$ = lappend($1, $3); } @@ -10698,7 +10713,7 @@ opt_freeze: FREEZE { $$ = true; } ; opt_name_list: - '(' name_list ')' { $$ = $2; } + LPAREN name_list RPAREN { $$ = $2; } | /*EMPTY*/ { $$ = NIL; } ; @@ -10712,7 +10727,7 @@ vacuum_relation: vacuum_relation_list: vacuum_relation { $$ = list_make1($1); } - | vacuum_relation_list ',' vacuum_relation + | vacuum_relation_list COMMA vacuum_relation { $$ = lappend($1, $3); } ; @@ -10755,7 +10770,7 @@ ExplainStmt: n->options = list_make1(makeDefElem("verbose", NULL, @2)); $$ = (Node *) n; } - | EXPLAIN '(' explain_option_list ')' ExplainableStmt + | EXPLAIN LPAREN explain_option_list RPAREN ExplainableStmt { ExplainStmt *n = makeNode(ExplainStmt); n->query = $5; @@ -10781,7 +10796,7 @@ explain_option_list: { $$ = list_make1($1); } - | explain_option_list ',' explain_option_elem + | explain_option_list COMMA explain_option_elem { $$ = lappend($1, $3); } @@ -10822,7 +10837,7 @@ PrepareStmt: PREPARE name prep_type_clause AS PreparableStmt } ; -prep_type_clause: '(' type_list ')' { $$ = $2; } +prep_type_clause: LPAREN type_list RPAREN { $$ = $2; } | /* EMPTY */ { $$ = NIL; } ; @@ -10883,7 +10898,7 @@ ExecuteStmt: EXECUTE name execute_param_clause } ; -execute_param_clause: '(' expr_list ')' { $$ = $2; } +execute_param_clause: LPAREN expr_list RPAREN { $$ = $2; } | /* EMPTY */ { $$ = NIL; } ; @@ -10971,13 +10986,13 @@ insert_rest: $$->override = $2; $$->selectStmt = $4; } - | '(' insert_column_list ')' SelectStmt + | LPAREN insert_column_list RPAREN SelectStmt { $$ = makeNode(InsertStmt); $$->cols = $2; $$->selectStmt = $4; } - | '(' insert_column_list ')' OVERRIDING override_kind VALUE_P SelectStmt + | LPAREN insert_column_list RPAREN OVERRIDING override_kind VALUE_P SelectStmt { $$ = makeNode(InsertStmt); $$->cols = $2; @@ -11000,7 +11015,7 @@ override_kind: insert_column_list: insert_column_item { $$ = list_make1($1); } - | insert_column_list ',' insert_column_item + | insert_column_list COMMA insert_column_item { $$ = lappend($1, $3); } ; @@ -11042,7 +11057,7 @@ opt_on_conflict: ; opt_conf_expr: - '(' index_params ')' where_clause + LPAREN index_params RPAREN where_clause { $$ = makeNode(InferClause); $$->indexElems = $2; @@ -11166,16 +11181,16 @@ UpdateStmt: opt_with_clause UPDATE relation_expr_opt_alias set_clause_list: set_clause { $$ = $1; } - | set_clause_list ',' set_clause { $$ = list_concat($1,$3); } + | set_clause_list COMMA set_clause { $$ = list_concat($1,$3); } ; set_clause: - set_target '=' a_expr + set_target EQUALS a_expr { $1->val = (Node *) $3; $$ = list_make1($1); } - | '(' set_target_list ')' '=' a_expr + | LPAREN set_target_list RPAREN EQUALS a_expr { int ncolumns = list_length($2); int i = 1; @@ -11211,7 +11226,7 @@ set_target: set_target_list: set_target { $$ = list_make1($1); } - | set_target_list ',' set_target { $$ = lappend($1,$3); } + | set_target_list COMMA set_target { $$ = lappend($1,$3); } ; @@ -11274,13 +11289,13 @@ opt_hold: /* EMPTY */ { $$ = 0; } * * This approach is implemented by defining a nonterminal select_with_parens, * which represents a SELECT with at least one outer layer of parentheses, - * and being careful to use select_with_parens, never '(' SelectStmt ')', + * and being careful to use select_with_parens, never LPAREN SelectStmt RPAREN, * in the expression grammar. We will then have shift-reduce conflicts - * which we can resolve in favor of always treating '(' RPAREN as * a select_with_parens. To resolve the conflicts, the productions that * conflict with the select_with_parens productions are manually given - * precedences lower than the precedence of ')', thereby ensuring that we - * shift ')' (and then reduce to select_with_parens) rather than trying to + * precedences lower than the precedence of RPAREN, thereby ensuring that we + * shift RPAREN (and then reduce to select_with_parens) rather than trying to * reduce the inner