I don't see in this patch that you've added your new keywords to any of the
lists of reserved words towards the bottom of gram.y.  Have a look down and
see the lists.  You need to add the keywords to the first list in the file
that doesn't give a shift/reduce error.  (ie. make the words the least
reserved as possible.)

Also, make sure you've put them in keywords.c as well.

Chris

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Neil Conway
> Sent: Thursday, 11 April 2002 9:29 AM
> To: PostgreSQL Hackers
> Subject: [HACKERS] help with bison
>
>
> Hi all,
>
> I'm working on a fairly large patch (cleaning up Karel Zak's
> PREPARE/EXECUTE work), and I'm having some problems with bison (I'm
> a yacc newbie). In fact, my grammar currently has an obscene
> 20 shift/reduce and 4 reduce/reduce conflicts!
>
> Would someone to be kind enough to let me know what I'm doing wrong,
> and what I'll need to change? (Unfortunately, bison isn't very
> helpful: it doesn't provide line-numbers when it warns me about
> the # of conflicts). The patch for gram.y is below.
>
> Thanks in advance,
>
> Neil
>
> --
> Neil Conway <[EMAIL PROTECTED]>
> PGP Key ID: DB3C29FC
>
> Index: gram.y
> ===================================================================
> RCS file: /var/lib/cvs/pgsql/src/backend/parser/gram.y,v
> retrieving revision 2.299
> diff -c -r2.299 gram.y
> *** gram.y    1 Apr 2002 04:35:38 -0000       2.299
> --- gram.y    11 Apr 2002 01:26:21 -0000
> ***************
> *** 133,144 ****
>               ClosePortalStmt, ClusterStmt, CommentStmt,
> ConstraintsSetStmt,
>               CopyStmt, CreateAsStmt, CreateDomainStmt,
> CreateGroupStmt, CreatePLangStmt,
>               CreateSchemaStmt, CreateSeqStmt, CreateStmt, CreateTrigStmt,
> !             CreateUserStmt, CreatedbStmt, CursorStmt,
> DefineStmt, DeleteStmt,
> !             DropGroupStmt, DropPLangStmt, DropSchemaStmt,
> DropStmt, DropTrigStmt,
> !             DropUserStmt, DropdbStmt, ExplainStmt, FetchStmt,
>               GrantStmt, IndexStmt, InsertStmt, ListenStmt,
> LoadStmt, LockStmt,
> !             NotifyStmt, OptimizableStmt, ProcedureStmt, ReindexStmt,
> !             RemoveAggrStmt, RemoveFuncStmt, RemoveOperStmt,
>               RenameStmt, RevokeStmt, RuleActionStmt,
> RuleActionStmtOrEmpty,
>               RuleStmt, SelectStmt, TransactionStmt, TruncateStmt,
>               UnlistenStmt, UpdateStmt, VacuumStmt, VariableResetStmt,
> --- 133,145 ----
>               ClosePortalStmt, ClusterStmt, CommentStmt,
> ConstraintsSetStmt,
>               CopyStmt, CreateAsStmt, CreateDomainStmt,
> CreateGroupStmt, CreatePLangStmt,
>               CreateSchemaStmt, CreateSeqStmt, CreateStmt, CreateTrigStmt,
> !             CreateUserStmt, CreatedbStmt, CursorStmt,
> DeallocatePrepareStmt,
> !             DefineStmt, DeleteStmt, DropGroupStmt,
> !             DropPLangStmt, DropSchemaStmt, DropStmt, DropTrigStmt,
> !             DropUserStmt, DropdbStmt, ExecuteStmt, ExplainStmt,
> FetchStmt,
>               GrantStmt, IndexStmt, InsertStmt, ListenStmt,
> LoadStmt, LockStmt,
> !             NotifyStmt, OptimizableStmt, ProcedureStmt,
> PrepareStmt, prepare_query,
> !             ReindexStmt, RemoveAggrStmt, RemoveFuncStmt, RemoveOperStmt,
>               RenameStmt, RevokeStmt, RuleActionStmt,
> RuleActionStmtOrEmpty,
>               RuleStmt, SelectStmt, TransactionStmt, TruncateStmt,
>               UnlistenStmt, UpdateStmt, VacuumStmt, VariableResetStmt,
> ***************
> *** 204,210 ****
>               any_name, any_name_list, expr_list, dotted_name, attrs,
>               target_list, update_target_list, insert_column_list,
>               def_list, opt_indirection, group_clause, TriggerFuncArgs,
> !             select_limit, opt_select_limit
>
>   %type <range>       into_clause, OptTempTableName
>
> --- 205,214 ----
>               any_name, any_name_list, expr_list, dotted_name, attrs,
>               target_list, update_target_list, insert_column_list,
>               def_list, opt_indirection, group_clause, TriggerFuncArgs,
> !             select_limit, opt_select_limit, types_list,
> !             types_prepare_clause, execute_using
> !
> ! %type <ival>        prepare_store
>
>   %type <range>       into_clause, OptTempTableName
>
> ***************
> *** 319,325 ****
>               COALESCE, COLLATE, COLUMN, COMMIT,
>               CONSTRAINT, CONSTRAINTS, CREATE, CROSS, CURRENT_DATE,
>               CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,
> !             DAY_P, DEC, DECIMAL, DECLARE, DEFAULT, DELETE, DESC,
>               DISTINCT, DOUBLE, DROP,
>               ELSE, ENCRYPTED, END_TRANS, ESCAPE, EXCEPT,
> EXECUTE, EXISTS, EXTRACT,
>               FALSE_P, FETCH, FLOAT, FOR, FOREIGN, FROM, FULL,
> --- 323,329 ----
>               COALESCE, COLLATE, COLUMN, COMMIT,
>               CONSTRAINT, CONSTRAINTS, CREATE, CROSS, CURRENT_DATE,
>               CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,
> !             DAY_P, DEALLOCATE, DEC, DECIMAL, DECLARE, DEFAULT,
> DELETE, DESC,
>               DISTINCT, DOUBLE, DROP,
>               ELSE, ENCRYPTED, END_TRANS, ESCAPE, EXCEPT,
> EXECUTE, EXISTS, EXTRACT,
>               FALSE_P, FETCH, FLOAT, FOR, FOREIGN, FROM, FULL,
> ***************
> *** 329,335 ****
>               MATCH, MINUTE_P, MONTH_P, NAMES,
>               NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF,
> NULL_P, NUMERIC,
>               OF, OLD, ON, ONLY, OPTION, OR, ORDER, OUTER_P, OVERLAPS,
> !             PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR,
> PRIVILEGES, PROCEDURE, PUBLIC,
>               READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
>               SCHEMA, SCROLL, SECOND_P, SELECT, SESSION,
> SESSION_USER, SET, SOME, SUBSTRING,
>               TABLE, TEMPORARY, THEN, TIME, TIMESTAMP,
> --- 333,339 ----
>               MATCH, MINUTE_P, MONTH_P, NAMES,
>               NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF,
> NULL_P, NUMERIC,
>               OF, OLD, ON, ONLY, OPTION, OR, ORDER, OUTER_P, OVERLAPS,
> !             PARTIAL, POSITION, PRECISION, PREPARE, PRIMARY,
> PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
>               READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
>               SCHEMA, SCROLL, SECOND_P, SELECT, SESSION,
> SESSION_USER, SET, SOME, SUBSTRING,
>               TABLE, TEMPORARY, THEN, TIME, TIMESTAMP,
> ***************
> *** 363,372 ****
>               DATABASE, DELIMITERS, DO,
>               EACH, ENCODING, EXCLUSIVE, EXPLAIN,
>               FORCE, FORWARD, FREEZE, FUNCTION, HANDLER,
> !             ILIKE, INCREMENT, INDEX, INHERITS, INSTEAD, ISNULL,
>               LANCOMPILER, LIMIT, LISTEN, LOAD, LOCATION, LOCK_P,
>               MAXVALUE, MINVALUE, MODE, MOVE,
> !             NEW, NOCREATEDB, NOCREATEUSER, NONE, NOTHING,
> NOTIFY, NOTNULL,
>               OFFSET, OIDS, OPERATOR, OWNER, PASSWORD, PROCEDURAL,
>               REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
>               SEQUENCE, SETOF, SHARE, SHOW, START, STATEMENT,
> --- 367,376 ----
>               DATABASE, DELIMITERS, DO,
>               EACH, ENCODING, EXCLUSIVE, EXPLAIN,
>               FORCE, FORWARD, FREEZE, FUNCTION, HANDLER,
> !             ILIKE, INCREMENT, INDEX, INHERITS, INSTEAD, ISNULL,
> INTERNAL,
>               LANCOMPILER, LIMIT, LISTEN, LOAD, LOCATION, LOCK_P,
>               MAXVALUE, MINVALUE, MODE, MOVE,
> !             NEW, NOCREATEDB, NOCREATEUSER, NONE, NOSHARE,
> NOTHING, NOTIFY, NOTNULL,
>               OFFSET, OIDS, OPERATOR, OWNER, PASSWORD, PROCEDURAL,
>               REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
>               SEQUENCE, SETOF, SHARE, SHOW, START, STATEMENT,
> ***************
> *** 460,465 ****
> --- 464,470 ----
>               | CreateTrigStmt
>               | CreateUserStmt
>               | ClusterStmt
> +             | DeallocatePrepareStmt
>               | DefineStmt
>               | DropStmt
>               | DropSchemaStmt
> ***************
> *** 469,474 ****
> --- 474,480 ----
>               | DropPLangStmt
>               | DropTrigStmt
>               | DropUserStmt
> +             | ExecuteStmt
>               | ExplainStmt
>               | FetchStmt
>               | GrantStmt
> ***************
> *** 477,482 ****
> --- 483,489 ----
>               | UnlistenStmt
>               | LockStmt
>               | NotifyStmt
> +             | PrepareStmt
>               | ProcedureStmt
>               | ReindexStmt
>               | RemoveAggrStmt
> ***************
> *** 3489,3494 ****
> --- 3496,3594 ----
>               | DeleteStmt                                    /*
> by default all are $$=$1 */
>               ;
>
> +
> /*****************************************************************
> ************
> +  *
> +  *                          PREPARE STATEMENTS
> +  *
> +
> ******************************************************************
> ***********/
> + PrepareStmt:  PREPARE name AS prepare_query
> types_prepare_clause prepare_store
> +                             {
> +                                     PrepareStmt *n =
> makeNode(PrepareStmt);
> +                                     n->name = $2;
> +                                     n->query = (Query *) $4;
> +                                     n->types = (List *) $5;
> +                                     n->store = $6;
> +                                     $$ = (Node *) n;
> +                             }
> +             ;
> +
> + prepare_query:  SelectStmt
> +             | UpdateStmt
> +             | InsertStmt
> +             | DeleteStmt
> +             ;
> +
> + types_list:  SimpleTypename
> +                             { $$ = makeList1($1); }
> +             | types_list ',' SimpleTypename
> +                             { $$ = lappend($1, $3); }
> +             ;
> +
> + types_prepare_clause:  USING types_list             { $$ = $2; }
> +             | /*EMPTY*/
>       { $$ = NIL; }
> +             ;
> +
> + prepare_store: NOSHARE              { $$ = 1; }
> +             | GLOBAL                        { $$ = 2; }
> +             | SHARE                         { $$ = 0; }     /*
> default */
> +             | /* EMPTY */           { $$ = 0; }
> +             ;
> +
> +
> /*****************************************************************
> ************
> +  *
> +  *                          EXECUTE STATEMENTS
> +  *
> +
> ******************************************************************
> ***********/
> + ExecuteStmt: EXECUTE name into_clause USING execute_using prepare_store
> +                             {
> +                                     ExecuteStmt *n =
> makeNode(ExecuteStmt);
> +                                     n->name = $2;
> +                                     n->into = $3;
> +                                     n->using = $5;
> +                                     n->store = $6;
> +                                     $$ = (Node *) n;
>
> +                             }
> +             ;
> +
> + execute_using: a_expr
> +                             { $$ = makeList1($1); }
> +             | execute_using ',' a_expr
> +                             { $$ = lappend($1, $3); }
> +             ;
> +
> +
> /*****************************************************************
> ************
> +  *
> +  *                          DEALLOCATE PREPARE STATEMENTS
> +  *
> +
> ******************************************************************
> ***********/
> + DeallocatePrepareStmt: DEALLOCATE PREPARE ALL
> +                             {
> +                                     DeallocatePrepareStmt *n =
> makeNode(DeallocatePrepareStmt);
> +                                     n->name = NULL;
> +                                     n->store = 0;
> +                                     n->all = TRUE;
> +                                     n->internal = FALSE;
> +                                     $$ = (Node *) n;
> +                             }
> +             | DEALLOCATE PREPARE ALL INTERNAL
> +                             {
> +                                     DeallocatePrepareStmt *n =
> makeNode(DeallocatePrepareStmt);
> +                                     n->name = NULL;
> +                                     n->store = 0;
> +                                     n->all = FALSE;
> +                                     n->internal = TRUE;
> +                                     $$ = (Node *) n;
> +                             }
> +             | DEALLOCATE PREPARE name prepare_store
> +                             {
> +                                     DeallocatePrepareStmt *n =
> makeNode(DeallocatePrepareStmt);
> +                                     n->name = $3;
> +                                     n->store = $4;
> +                                     n->all = FALSE;
> +                                     n->internal = FALSE;
> +                                     $$ = (Node *) n;
> +                             }
> +             ;
>
>
> /*****************************************************************
> ************
>    *
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to