From b12553b0c9d7620253bb4cf41fadada85247436a Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Mon, 22 Feb 1988 19:12:00 +0000 Subject: [PATCH] ING_DB --- WEGA/contrib/ingres/dbs/src/eql/grammar.8 | 1304 +++++++++++++++++ WEGA/contrib/ingres/dbs/src/parser/grammar.8 | 1318 ++++++++++++++++++ 2 files changed, 2622 insertions(+) create mode 100644 WEGA/contrib/ingres/dbs/src/eql/grammar.8 create mode 100644 WEGA/contrib/ingres/dbs/src/parser/grammar.8 diff --git a/WEGA/contrib/ingres/dbs/src/eql/grammar.8 b/WEGA/contrib/ingres/dbs/src/eql/grammar.8 new file mode 100644 index 0000000..b4e4862 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/eql/grammar.8 @@ -0,0 +1,1304 @@ +/* +** GRAMMAR.Y -- Equel 6.2 grammar +** +** Yacc grammar and semantic rules for Quel +** embedded in C. +** +** The grammar is organized in the following manner: +** a) control structure +** b) quel statments +** c) equel statements +** d) declaration and use of C vars +** e) special objects +** f) expressions +** g) keywords +** h) noise words and punctuation +** Within a single classification, major objects are ordered +** alphabetically, and minor objects under the major ones they +** are in. +** +** Side Effects: +** performs the translation of an Equel program into +** a C program with calls on the Equel run-time +** support +** +** NOTE: +** There are two shift/reduce conflicts associated +** with the non-terminals "[o_]gen_while". It is resolved +** correctly by yacc. +*/ + + + +%{ + /* STANDARD SCANNER & PARSER GLOBALS */ + +# include "constants.h" +# include +# include "globals.h" +# include + +SCCSID(@(#)grammar.y 8.2 3/1/85) + + +%} +%union +{ + struct disp_node *u_dn; +}; + + + /* QUEL keywords */ +%token APPEND COPY CREATE DEFINE +%token DELETE DELIM DESTROY HELP +%token INDEX MODIFY PRINT INTEGRITY +%token RANGE REPLACE RETRIEVE SAVE +%token UNIQUE UNUSE USE PERMIT +%token VIEW + + /* special embedded QUEL commands */ +%token INGRES EXIT PARAM + + /* C variable usages */ +%token TYPE ALLOC STRUCT STRUCT_VAR + + /* QUEL noise words */ +%token ALL BY FROM IN +%token INTO IS OF ON +%token ONTO TO WHERE UNTIL +%token AT + + /* constants */ + +%token NAME SCONST I2CONST I4CONST +%token F8CONST C_CODE + + /* punctuation */ +%token COMMA LPAREN RPAREN PERIOD +%token QUOTE BGNCMNT ENDCMNT LBRACE +%token RBRACE LBRKT RBRKT NONREF +%token SEMICOL POINTER COLON DOLLAR +%token PCT + + /* operator classes */ +%token UOP +%token BOP +%token UAOP +%token BDOP +%token EOP +%token LBOP LUOP +%token FOP FBOP +%token AOP + + /* define ascending precedence for operators */ + +%left LBOP +%left LUOP +%left UAOP +%left BOP LBRKT +%left UOP +%nonassoc unaryop + + /* non-teriminal type info */ +%type endblock +%type c_variable +%type cvarx +%type struct_var +%type ptr +%type selector_part +%type str_var_key +%type id + + + +%% +%{ + struct cvar *cvarp; +%} + +/* + * Program Control Structure + */ + +program: program statement = + { + /* for each "statement", free the symbol space + * used by that query (lookahed space must not + * be freed), and catch up on output lines + */ + symspfree(); + equate_lines(); + } + | ; +; +statement: startquel quel_statement = + { + w_sync(); + /* the purpose of the actions for startquel + * and this action is to make each query + * a single compound C statement (if (x) "{query}") + */ + w_op("}"); + } + | startquel equel_statement = + { + end_quote(); + w_op("}"); + } + | c_code + | declaration + | error +; +startquel: = + w_op("{"); +; +/* + * C_CODE is a token returned by the lexical analyzer + * when it recognizes that the following line is not + * equel code. On the NEXT call to the lexical analyzer, + * the code will be copied from the source to the output file. + */ +c_code: C_CODE + | beginblock = + Block_level += 1; + | endblock = + { + if (Block_level == 0) + yyserror("extra '}'", $1); + else if ((Block_level -= 1) == 0) + { + freecvar(&C_locals); + freecvar(&F_locals); + } + } +; + + /* the %prec is to resolve conflicts with the { after a + * "tupret". + */ +beginblock: LBRACE %prec LBOP = + w_op($1->d_elm); +; +endblock: RBRACE = + w_op($1->d_elm); +; +quel_statement: append + | copy + | create + | delete + | delim + | destroy + | help + | index + | integrity + | modify + | permit + | print + | range + | replace + | retrieve + | save + | unuse + | use + | view +; + + /* commands particular to Equel */ + +equel_statement:append_p + { + w_sync(); + } + | copy_p + | create_p + { + w_sync(); + } + | exit + | ingres + | replace_p + { + w_sync(); + } + | retrieve_p + | tupret + | view_p +; +/* + * QUEL statements + */ + +append: append_key apclause tlclause qualclause +; +apclause: apkword id +; + +copy: copy_key id lparen ctl rparen cp_kword filename + | copy_key id lparen rparen cp_kword filename +; +filename: sconst + | id +; + +create: create_key id lparen ctl rparen +; + +delete: delete_key delclause qualclause +; +delclause: delnoise id +; + +delim: define_key delim_key id lparen id comma sconst rparen +; + +destroy: destroy_key idlist + | destroy_key integ_permit id int_list_all + | destroy_key delim_key id +; +integ_permit: integ_key + | permit_key +; +int_list_all: int_list + | all +; + +help: help_key + | help_key all + | help_key hlist + | help_key delim_key + | help_key delim_key hlist + | help_key int_perm_view idlist +; +hlist: hparam + | hlist comma hparam +; +hparam: id + | sconst +; +int_perm_view: integ_permit + | view_key +; + +index: index_key id is id lparen idlist rparen +; + +integrity: define_key integ_key integnoise id isnoise qual +; + +modify: modify_key id to id on modkeylist density + | modify_key id to id +; +modkeylist: modkey + | modkeylist comma modkey +; +modkey: id + | id colon id +; +density: where modfill + | ; +; +modfill: id is mod_var + | modfill comma id is mod_var +; + /* mod_var can be an integer constant or var, or a string var + * or a quel name + */ +mod_var: I2CONST = + w_con(I2CONST, $1->d_elm); + | c_variable = + { + if ($1) + { + if (!Cvarp) + w_key($1->d_elm); + else if (Fieldp && Fieldp->c_type == opINT + || Cvarp->c_type == opINT) + w_var(Cv_display, opINT); + else if (Fieldp && Fieldp->c_type == opSTRING + || Cvarp->c_type == opSTRING) + w_var(Cv_display, opIDSTRING); + else + yyserror("in MODIFY, qual var must be in or string", + $1); + } + else + yyserror("bad modify qualification", 0); + free_display(Cv_display); + Cvarp = Fieldp = 0; + } +; + +permit: def_perm permit_list on_of_to id perm_tl + perm_who perm_term perm_time perm_day qualclause +; +def_perm: define_key permit_key +; +permit_list: permlistelm + | permit_list comma permlistelm +; +permlistelm: RETRIEVE = + w_key($1->d_elm); + | APPEND = + w_key($1->d_elm); + | DELETE = + w_key($1->d_elm); + | REPLACE = + w_key($1->d_elm); + | all +; +on_of_to: on + | of + | to +; +perm_tl: lparen idlist rparen + | ; +; +perm_who: to id + | to all + | ; +; +perm_term: at id + | at all + | ; +; +perm_time: from integer colon integer to + integer colon integer + | ; +; +perm_day: on id to id + | ; +; + +print: print_key idlist +; + +range: range_of id is id +; + +replace: replace_key repclause tlclause qualclause +; +repclause: repkword id +; + +retrieve: retrieve_key resclause tlclause qualclause +; +resclause: retkword id +; + +save: save_key id until date +; +date: id integer integer +; + +unuse: unuse_key id +; + +use: use_key id +; + +view: define_key view_key id tlclause qualclause +; + +/* + * Statements Particular to Equel + */ + +append_p: append_p_key apclause param_tl qualclause +; + +copy_p: copy_p_key id param_tl fr_in_id filename +; +fr_in_id: cp_kword + | c_variable = + { + if ($1 && Cvarp) + { + if (Fieldp && Fieldp->c_type != opSTRING + || !Fieldp && Cvarp->c_type != opSTRING) + yyserror("string var expected for from/into in COPY", + $1); + else + w_var(Cv_display, opIDSTRING); + } + else + yyserror("into/from expected in COPY", $1); + free_display(Cv_display); + Fieldp = Cvarp = 0; + } +; + +create_p: create_p_key id param_tl +; + +exit: EXIT = + { + Opflag = mdEXIT; + w_new("IIexit();"); + } +; + +ingres: ingres_key param_list = + w_op(");"); +; +param_list: param = + w_op("0"); + | param param_list +; +param: id = + w_op(","); + | SCONST = + { + w_string($1->d_elm, 0); + w_op(","); + } +; + +replace_p: replace_p_key repclause param_tl qualclause +; + +retrieve_p: retrieve_p_key resclause param_tl qualclause +; + +tupret: tupret_keyw xc_code = + w_flush(); + | tupret_p o_xc_code = + w_flush(); +; +tupret_keyw: retrieve_key unique c_tlclause qualclause = + { + w_new("IIsetup();"); + } +; +unique: UNIQUE = + { + Opflag = mdTUPRET; + w_key($1->d_elm); + } + | = + Opflag = mdTUPRET; +; +c_tlclause: lparen c_tlist rparen +; +c_tlist: c_tlelm + | c_tlelm comma c_tlist +; +c_tlelm: reduc cvar is_key afcn +; +reduc: = + Opflag = mdCTLELM; +; +xc_code: LBRACE gen_while c_code RBRACE %prec LBRACE = + w_op("}"); + | gen_while %prec LBOP = + w_op("}"); +; +gen_while: = + { + w_new("while(IIn_get("); + w_file(); + w_op(")){"); + w_ret(); + free_ret(); + w_op("if(IIerrtest())continue;"); + equate_lines(); + } +; +o_xc_code: LBRACE o_gen_while c_code RBRACE %prec LBRACE = + w_op("}"); + | o_gen_while %prec LBOP = + w_op("}"); +; +o_gen_while: = + { + w_new("while(IIgettup("); + w_file(); + w_op(")){"); + equate_lines(); + } +; +tupret_p: tupret_p_key unique param_tl qualclause = + { + w_new("IIsetup();"); + } +; + +view_p: PARAM define_key view_key id param_tl qualclause +; + +/* + * Declarations and use of C variables + */ + +declaration: decl_specifer declarator_list SEMICOL = + { + w_op($3->d_elm); + Type_spec = 0; + } + | decl_specifer SEMICOL = + { + w_op($2->d_elm); + Type_spec = 0; + } +; +decl_specifer: type_specifier + | sc_specifier + | type_specifier sc_specifier + | sc_specifier type_specifier + | struct_dec = + { + Struct_flag = 0; + Type_spec = opSTRUCT; + } + | sc_specifier struct_dec = + { + Struct_flag = 0; + Type_spec = opSTRUCT; + } +; +sc_specifier: ALLOC = + { + Opflag = mdDECL; + w_key($1->d_elm); + /* in case the default "int" should be assumed, + * the Type_spec is set up for it, if a previous + * type hasn't been given + */ + if (!Type_spec) + Type_spec = opINT; + } +; +type_specifier: TYPE = + { + Opflag = mdDECL; + w_key($1->d_elm); + Type_spec = Opcode; + } +; +struct_dec: struct_name field_declaration + | struct_name + | struct_key field_declaration +; +struct_name: struct_key NAME = + w_key($2->d_elm); +; +field_declaration: lbrace field_seq RBRACE = + { + w_op($3->d_elm); + Type_spec = 0; + } +; +field_seq: field_seq field + | ; +; +field: type_specifier declarator_list SEMICOL = + { + w_op($3->d_elm); + Type_spec = 0; + } + | C_CODE +; +declarator_list: cvar_dec + | declarator_list comma cvar_dec +; +cvar_dec: cvarx = + { + if (Type_spec == opSTRING) + Indir_level -= 1; + if (Struct_flag) + decl_field($1->d_elm, Type_spec, + Indir_level, Block_level); + else + decl_cvar($1->d_elm, Type_spec, + Indir_level, Block_level); + free_display(Cv_display); + Indir_level = Field_indir = 0; + Fieldp = Cvarp = 0; + } +; +c_variable: cvarx = + { + $$ = $1; + if (Cvarp && Cvarp->c_indir != Indir_level) + { + yyserror("bad indirection on a C variable", $1); + $$ = 0; + } + Indir_level = Field_indir = 0; + } + | NONREF NAME = + { + enter_display(Cv_display, salloc($1->d_elm)); + Cvarp = Fieldp = 0; + $$ = $2; + } + | NONREF STRUCT_VAR = + { + enter_display(Cv_display, salloc($1->d_elm)); + Cvarp = Fieldp = 0; + $$ = $2; + } + | struct_var = + { + if (!Fieldp) + { + yyserror("undeclared field", $1); + $$ = $0; + } + else if (Fieldp->c_indir != Field_indir) + { + yyserror("bad indirection on a structure's field", + $1); + $$ = 0; + } + if (Cvarp->c_indir != Indir_level) + { + yysemerr("bad indirection a structure variable", + Cvarp->c_indir); + $$ = 0; + } + Indir_level = Field_indir = 0; + } +; +struct_var: ptr struct_var %prec unaryop = + { + if ($1->d_elm[1] == '*') + Field_indir += 1; + Field_indir += 1; + $$ = $2; + } + | struct_var arraysub %prec LBRKT = + Field_indir += 1; + | str_var_key selector_part +; +str_var_key: STRUCT_VAR = + { + Cvarp = getcvar($1->d_elm); + enter_display(Cv_display, $1->d_elm); + } +; +selector_part: arraysub selector_part = + { + Indir_level += 1; + $$ = $2; + } + | select_op NAME = + { + enter_display(Cv_display, $2->d_elm); + Fieldp = getfield($2->d_elm); + $$ = $2; + } +; +select_op: PERIOD = + enter_display(Cv_display, $1->d_elm); + | POINTER = + { + enter_display(Cv_display, $1->d_elm); + Indir_level += 1; + } +; + +/* use of a C variable */ +cvar: c_variable = + { + if ($1) + { + if (!Fieldp && ! Cvarp) + { + if (!Field_indir && !Indir_level + && (sequal($1->d_elm, "dba") + || sequal($1->d_elm, "usercode"))) + /* constant operator COP */ + w_key($1->d_elm); + else + yyserror("C var expected", $1); + } + else if (Opflag == mdCTLELM) + { + w_con(NAME, + Fieldp ? Fieldp->c_id: Cvarp->c_id); + enter_ret(Cv_display, + Fieldp ? Fieldp->c_type: Cvarp->c_type); + } + else + w_var(Cv_display, + Fieldp ? Fieldp->c_type: Cvarp->c_type); + } + free_display(Cv_display); + Fieldp = Cvarp = 0; + Indir_level = Field_indir = 0; + } +cvarx: NAME = + { + if (Opflag == mdDECL) + w_con(NAME, $1->d_elm); + else + { + Cvarp = getcvar($1->d_elm); + enter_display(Cv_display, salloc($1->d_elm)); + } + } + | ptr cvarx %prec unaryop = + { + if ($1->d_elm [1] == '*') + Indir_level += 1; + Indir_level += 1; + $$ = $2; + } + | cvarx arraysub %prec LBRKT = + { + Indir_level += 1; + } +; +ptr: BOP = + { + if (!sequal($1->d_elm, "*") && !sequal((struct disp_node *)($1)->d_elm, "**")) + yyserror(Opflag == mdDECL ? + "invalid operator in declaration": + "invalid operator in C variable", + $1); + if (Opflag == mdDECL) + w_op($1->d_elm); + else + enter_display(Cv_display, salloc($1->d_elm)); + } +; +arraysub: LBRKT = + { + if (Opflag == mdDECL) + eat_display(0, '[', ']'); + else + eat_display(Cv_display, '[', ']'); + } +; + +/* + * Special Objects used throughout grammar + */ + +id: c_variable = + { + if ($1) + { + if (Cvarp) + { + if (Fieldp && Fieldp->c_type != opSTRING + || !Fieldp && Cvarp->c_type != opSTRING) + yyserror("string var expected", $1); + else if (Opflag == mdFILENAME) + w_var(Cv_display, opSTRING); + else if (Opflag == mdINGRES) + w_display(Cv_display); + else + w_var(Cv_display, opIDSTRING); + } + else if (Opflag == mdINGRES) + w_string($1->d_elm, 0); + else if (Opflag == mdFILENAME) + yyserror("file for a COPY must be a string or string variable", + $1); + else + w_key($1->d_elm); + } + free_display(Cv_display); + Fieldp = Cvarp = 0; + } +; + +idlist: id + | idlist comma id +; + +integer: I2CONST = + w_con(I2CONST, $1->d_elm); + | c_variable = + { + if ($1) + { + if (Cvarp) + if (Fieldp && Fieldp->c_type == opINT + || Cvarp->c_type == opINT) + w_var(Cv_display, opINT); + else + yyserror("integer variable required", + $1); + else + yyserror("integer variable required", $1); + } + free_display(Cv_display); + } +; + +int_list: integer + | int_list comma integer +; + +param_tl: LPAREN = + { + w_op("("); + end_quote(); + if (Opflag == mdTUPRET) + w_key("IIw_left"); + else + w_key("IIw_right"); + eat_display(0, '(', ')'); + w_op(";"); + begin_quote(); + w_op(")"); + + } +; + +qualclause: where qual + | where c_variable = + { + if (!$2 || !Cvarp) + yyserror("C var (string) expected", $2); + else if (Fieldp && Fieldp->c_type == opSTRING + || Cvarp->c_type == opSTRING) + { + end_quote(); + w_op("IIwrite("); + w_display(Cv_display); + w_op(");"); + } + else + yyserror("var must be string valued for qualification", + $2); + free_display(Cv_display); + Cvarp = Fieldp = 0; + } + | ; +; +qual: lparen qual rparen + | luop qual %prec LUOP + | qual lbop qual %prec LBOP + | clause + | ; +; +clause: afcn rop afcn + | afcn rop afcn bdop afcn +; +ctl: id is id + | ctl comma id is id +; + +sconst: SCONST = + w_con(SCONST, $1->d_elm); +; + +tlclause: lparen tlist rparen +; +tlist: tlelm + | tlelm comma tlist +; +tlelm: id is_key afcn + | attrib +; + +/* + * Expressions + */ + +afcn: aggrfcn + | aggr + | attribfcn + | afcn bop afcn %prec BOP + | afcn uaop afcn %prec UAOP + | lparen afcn rparen + | uop afcn %prec unaryop + | fop lparen afcn rparen + | fbop lparen afcn comma afcn rparen +; +aggr: aop lparen afcn qualclause rparen +; +aggrfcn: aop lparen afcn by aseq qualclause rparen +; +attribfcn: I2CONST = + w_con(I2CONST, $1->d_elm); + | I4CONST = + w_con(I4CONST, $1->d_elm); + | F8CONST = + w_con(F8CONST, $1->d_elm); + | SCONST = + w_con(SCONST, $1->d_elm); + | cvar + | attrib +; +aseq: aseq comma afcn + | afcn +; +attrib: id period id + | id period all= + { + if (Opflag != mdVIEW && Opflag != mdRETRIEVE + && Opflag != mdAPPEND) + yyserror( + "'all' applied to this range variable illegal in this kind of statement", + $1); + } + | attrib stringpart +; +stringpart: leftclose subelm rightclose + | leftclose grpelm rightclose +; +leftclose: pct + | lparen +; +rightclose: pct + | rparen +; +subelm: integer nameprt + | integer nameprt dollar + | dollar + | nameprt + | nameprt dollar +; +grpelm: subelm comma subelm +; +nameprt: id + | sconst +; +lbop: LBOP = + w_key($1->d_elm); +; +luop: LUOP = + w_key($1->d_elm); +; +bdop: BDOP = + w_op($1->d_elm); +; +rop: EOP = + w_op($1->d_elm); + | BDOP = + w_op($1->d_elm); + | IS = + w_op("="); +; +uop: UOP = + w_op($1->d_elm); +; +fop: FOP = + w_key($1->d_elm); +; +fbop: FBOP = + w_key($1->d_elm); +; +bop: BOP = + w_op($1->d_elm); + | UOP = + w_op($1->d_elm); +; +by: BY = + w_key($1->d_elm); +; +aop: AOP = + w_key($1->d_elm); +; +uaop: UAOP = + w_key($1->d_elm); +; + +/* + * Keywords + */ + +append_p_key: PARAM APPEND = + { + begin_quote(); + w_key($2->d_elm); + Opflag = mdAPPEND; + } +; +append_key: APPEND = + { + Opflag = mdAPPEND; + begin_quote(); + w_key($1->d_elm); + } +; +copy_key: COPY = + { + Opflag = mdCOPY; + begin_quote(); + w_key($1->d_elm); + } +; +copy_p_key: PARAM COPY = + { + Opflag = mdCOPY; + begin_quote(); + w_key($2->d_elm); + } +; +cp_kword: INTO = + { + w_key($1->d_elm); + Opflag = mdFILENAME; + } + | FROM = + { + w_key($1->d_elm); + Opflag = mdFILENAME; + } +; +create_key: CREATE = + { + Opflag = mdCREATE; + begin_quote(); + w_key($1->d_elm); + } +; +create_p_key: PARAM CREATE = + { + Opflag = mdCREATE; + begin_quote(); + w_key($2->d_elm); + } +; +define_key: DEFINE = + { + Opflag = mdDEFINE; + begin_quote(); + w_key($1->d_elm); + } +; +delete_key: DELETE = + { + Opflag = mdDELETE; + begin_quote(); + w_key($1->d_elm); + } +; +delim_key: DELIM = + { + w_key($1->d_elm); + } +; +destroy_key: DESTROY = + { + Opflag = mdDESTROY; + begin_quote(); + w_key($1->d_elm); + } +; +help_key: HELP = + { + Opflag = mdHELP; + begin_quote(); + w_key($1->d_elm); + } +; +index_key: INDEX ON = + { + Opflag = mdINDEX; + begin_quote(); + w_key($1->d_elm); + w_key($2->d_elm); + } +; +ingres_key: INGRES = + { + Opflag = mdINGRES; + w_new("IIingres("); + } +; +integ_key: INTEGRITY= + { + if (Opflag == mdDEFINE) + Opflag = mdINTEGRITY; + w_key($1->d_elm); + } +; +is_key: IS = + { + if (Opflag == mdCTLELM) + Opflag = mdTUPRET; + w_op("="); + } + | BY = + w_key($1->d_elm); +; +modify_key: MODIFY = + { + Opflag = mdMODIFY; + begin_quote(); + w_key($1->d_elm); + } +; +permit_key: PERMIT= + { + if (Opflag == mdDEFINE) + Opflag = mdPROT; + w_key($1->d_elm); + } +; +print_key: PRINT = + { + Opflag = mdPRINT; + begin_quote(); + w_key($1->d_elm); + } +; +range_of: RANGE OF = + { + Opflag = mdRANGE; + begin_quote(); + w_key($1->d_elm); + w_key($2->d_elm); + } +; +replace_key: REPLACE = + { + Opflag = mdREPLACE; + begin_quote(); + w_key($1->d_elm); + } +; +replace_p_key: PARAM REPLACE = + { + begin_quote(); + Opflag = mdREPLACE; + w_key($2->d_elm); + } +; +retrieve_key: RETRIEVE = + { + Opflag = mdRETRIEVE; + begin_quote(); + w_key($1->d_elm); + } +; +retrieve_p_key: PARAM RETRIEVE = + { + Opflag = mdRETRIEVE; + begin_quote(); + w_key($2->d_elm); + } +; +save_key: SAVE = + { + Opflag = mdSAVE; + begin_quote(); + w_key($1->d_elm); + } +; +struct_key: STRUCT = + { + Opflag = mdDECL; + Struct_flag = 1; + w_key($1->d_elm); + } +; +tupret_p_key: PARAM RETRIEVE = + { + begin_quote(); + w_key($2->d_elm); + Opflag = mdTUPRET; + } +; +unuse_key: UNUSE = + { + begin_quote(); + w_key($1->d_elm); + } +; +use_key: USE = + { + begin_quote(); + w_key($1->d_elm); + } +; +view_key: VIEW = + { + if (Opflag == mdDEFINE) + Opflag = mdVIEW; + w_key($1->d_elm); + } +; + +/* + * Noise words and punctuation + */ + +all: ALL= + w_key($1->d_elm); +; +apkword: INTO + | ONTO + | TO + | ON + | ; +; +at: AT = + w_key($1->d_elm); +; +colon: COLON = + w_op($1->d_elm); +; +comma: COMMA = + w_op($1->d_elm); +; +delnoise: IN + | ON + | FROM + | ; +; +dollar: DOLLAR = + w_key($1->d_elm); +; +from: FROM = + w_key($1->d_elm); +; +integnoise: ON + | ONTO + | IN + | OF +; +is: IS = + w_op("="); +; +isnoise: IS + | ; +; +lbrace: LBRACE = + w_op($1->d_elm); +; +lparen: LPAREN = + w_op($1->d_elm); +; +of: OF= + w_key($1->d_elm); +; +on: ON = + w_key($1->d_elm); +; +pct: PCT = + w_op($1->d_elm); +; +period: PERIOD = + w_op($1->d_elm); +; +repkword: INTO + | IN + | ON + | ; +; +rparen: RPAREN = + w_op($1->d_elm); +; +to: TO = + w_key($1->d_elm); +; +retkword: INTO + | TO + | ; +; +until: UNTIL = + w_key($1->d_elm); +; +where: WHERE = + w_key($1->d_elm); +; +%% + +# include "tokens.y" diff --git a/WEGA/contrib/ingres/dbs/src/parser/grammar.8 b/WEGA/contrib/ingres/dbs/src/parser/grammar.8 new file mode 100644 index 0000000..1191020 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/parser/grammar.8 @@ -0,0 +1,1318 @@ + +/* +** GRAMMAR.Y +** +** This file contains a grammar for ingres parsing. It is setup +** for the (7-31-78) version of yacc. +** +** Use: +** to use for non-distributed ingres: +** grep -v "DDD" > grammar.y +** +** Trace Flags: +** Grammar.y ~~ 38, 39 +*/ + +%{ +/* SCANNER/PARSER GLOBALS & TABLES */ +# include +# include +# include +# include +# include +# include "parser.h" +# include +# include + +SCCSID(@(#)grammar.y 8.4 3/2/85) + +# ifdef xPTR1 +# define YYDEBUG +# endif + +int i; +struct atstash *aptr; +char permbuf[3]; +/* space for two names, their null bytes and the seperator */ +char modbuf[(2 * (MAXNAME + 1)) + 1]; +static char hqmbuf[2]; + +extern DESC Reldesc; +extern int Opflag; +extern QTREE *Lastree; +extern QTREE *Tidnode; +extern int Rsdmno; +extern int Resrng; +extern int Qrymod; +extern int Permcomd; +extern char *Trname; +extern int Qlflag; +extern struct atstash Faketid; +extern char *Tuple; +extern TID tid; + +# ifdef DISTRIB +extern struct atstash Fakesid; +# endif + +extern char *Indexname; + +extern QTREE *tree(); +extern QTREE *tlprepend(); +extern QTREE *addresdom(); +extern QTREE *xdot(); +extern QTREE *norml(); +extern struct atstash *attlookup(); +extern int rngent(); +extern int rnglook(); +extern PARRNG Parrng[]; +extern STRKEEPER *substring(),*endvals(); +%} + +/* NEW BEGIN-END THINGS */ +%start program + +/* UNION YYSTYPE DEFINED */ +%union +{ + int type_type; /* OPERATOR TYPES ETC. */ + QTREE *tree_type; + int rng_type; + char char_type; + int int_type; + short *I2_type; + long *I4_type; + float *F4_type; + double *F8_type; + char *string_type; + STRKEEPER *substr_type; +} + +/* COMMANDS */ +%token APPEND COPY CREATE DELETE DESTROY HELP INDEX MODIFY +%token PRINT RANGE REPLACE RETRIEVE SAVE +%token DEFINE PERMIT VIEW INTEGRITY +%token DELIM USE UNUSE +/*DDD*/%token DISTRIBUTE + +/* 'NOISE' WORDS */ +%token ALL BY FROM IN INTO UNIQUE AT +%token IS OF ON ONTO TO UNTIL WHERE +/*DDD*/%token DISTRD + +/* CONSTANTS */ +%token NAME SCONST I2CONST I4CONST F4CONST F8CONST + +/* PUNCTUATION */ +%token COMMA LPAREN PERIOD RPAREN COLON BGNCMNT ENDCMNT +%token LBRAC RBRAC DOLLAR PCT + +/* UNARY ARITHMETIC OPERATORS */ +%token UAOP + +/* BINARY ARITHMETIC OPERATORS */ +%token BAOP BAOPH + +/* BOUNDS OPERATORS */ +%token BDOP + +/* EQUALITY OPERATORS */ +%token EOP + +/* LOGICAL OPERATORS */ +%token LBOP LUOP + +/* FUNCTIONAL OPERATORS */ +%token FOP FBOP + +/* AGGREGATE OPERATORS */ +%token AGOP + +/* TYPES FOR INGRES TOKENS */ +%type IS +%type NAME SCONST +%type I2CONST +%type I4CONST +%type F4CONST +%type F8CONST +%type UAOP +%type BAOP BAOPH +%type BDOP +%type EOP +%type LBOP LUOP +%type FOP FBOP +%type AGOP +%type LPAREN RPAREN LBRAC RBRAC PCT + +/* TYPES FOR INGRES NON-TERMINALS */ +%type permtarg permtlist permtlelm +/*DDD*/%type distribute distcrits dcriterion +%type tlclause tlist tlelm +%type qualclause qual clause afcn aggrfcn +%type relop +%type domseq targdom attrib +%type var +%type attribfcn +%type uop +%type alias +%type subelm stringpart grpelm nameprt +%type leftclose rightclose + +/* DEFINE ASCENDING PRECEDENCE FOR OPERATORS */ +%left LBOP +%left LUOP +%left UAOP +%left BAOP +%left BAOPH +%nonassoc unaryop + +%% +program: program stmnt = + { +# ifdef xPTR1 + tTfp(38, 0, "*** [program stmnt] parsed.\n"); +# endif + + if (endquelst(Opflag) < 0) + return (-1); + } + | stmnt = + { +# ifdef xPTR1 + tTfp(38, 1, "*** [stmnt] parsed.\n"); +# endif + + if (endquelst(Opflag) < 0) + return (-1); + } + | + { +# ifdef xPTR1 + tTfp(38, 2, "*** [(NULL)] parsed.\n"); +# endif + } +; +stmnt: append + | copy + | create + | delete + | destroy +/*DDD*/ | distribute + | help + | index + | integrity + | modify + | permit + | print + | range + | replace + | retrieve + | save + | view + | use + | unuse + | delim + | error + { +# ifdef xPTR1 + tTfp(38, 0, "*** [error] parsed.\n"); +# endif + } + +; +range: rngstmnt OF NAME IS NAME = + { + if ((i = openr(&Reldesc, OR_RELTID, $5)) < 0) + syserr("relname: error in openr '%d'", i); + if (i > 0) + { + /* invalid relation name */ + par_error(RNGEXIST, WARN, $5, 0); + YYERROR; + } + else + rngent(R_EXTERNAL, $3, &Reldesc); + } +; +rngstmnt: RANGE = + { + Opflag = mdRANGE; + } +; +append: apstmnt apto relation tlclause qualclause = + { + /* make root node */ + Lastree = tree($4, $5, ROOT, sizeof(struct rootnode), 1); + } +; +apstmnt: APPEND = + { + Opflag = mdAPP; + } +; +apto: INTO + | ONTO + | TO + | ON + | ; +; +delete: delstmnt delwd relation qualclause = + { + /* make root node for delete, with a TIDNODE at leftmost */ + Lastree = tree(tree(NULL, Tidnode, RESDOM, sizeof(struct resdomnode), NULL), $4, ROOT, sizeof(struct rootnode), 1); + } +; +delstmnt: DELETE = + { + Opflag = mdDEL; + } +; +delwd: IN + | ON + | FROM + | ; +; +replace: repstmnt repkwd relation tlclause qualclause = + { + /* make root node for replace */ + Lastree = tree($4, $5, ROOT, sizeof(struct rootnode), 1); + } +; +repstmnt: REPLACE = + { + Opflag = mdREPL; + } +; +repkwd: INTO + | IN + | ON + | ; +; +retrieve: retstmnt retclause tlclause qualclause = + { + /* make root node for retrieve */ + Lastree = tree($3, $4, ROOT, sizeof(struct rootnode), 1); + } +; +retstmnt: RETRIEVE = + { + Opflag = mdRETR; + } +; +retclause: retkwd relation = + { + /* set up pipe block and save relname for create */ +# ifdef xPTR2 + tTfp(38, 4, "retclause: Rsdmno %d", Rsdmno); +# endif + Rsdmno = 0; + setp(PV_STR, "0"); /* relstat = nil */ + setp(PV_STR, trim_relname(Parrng[Resrng].vardesc.reldum.relid)); + } + | = + { + /* no result relation, output to terminal */ + Rsdmno = 0; + Resrng = -1; + } + | UNIQUE = + { + Opflag = mdRET_UNI; + Rsdmno = 0; + Resrng = -1; + } +; +retkwd: INTO + | TO + | ; +; + +delim: DEFINE DELIM NAME LPAREN NAME COMMA SCONST RPAREN = + { + Opflag = mdSTOP; + if ((i = openr(&Reldesc, OR_WRITE, "rdelim")) < 0) + syserr("relname: error in openr '%d'", i); + if (i > 0) + { + /* invalid relation name */ + par_error(RNGEXIST, WARN, "rdelim", 0); + YYERROR; + } + else + { + if (( i = make_tuples(&Reldesc, $3, $5, $7)) < 0) + { + closer(&Reldesc); + par_error(BADBNF, WARN, "rdelim", 0); + } + } + closer(&Reldesc); + } +; +use: USE NAME = + { + Opflag = mdSTOP; + if ((i = openr(&Reldesc, OR_WRITE, "rdelim")) < 0) + syserr("relname: error in openr '%d'", i); + if (i > 0) + { + /* invalid relation name */ + par_error(RNGEXIST, WARN, "rdelim", 0); + YYERROR; + } + else + { + if ((i = make_list(&Reldesc, $2)) < 0) + { + closer(&Reldesc); + par_error(DELEXIST, WARN, 0); + } + } + closer(&Reldesc); + } +; +unuse: UNUSE NAME = + { + Opflag = mdSTOP; + if ( i = shrink_list($2) < 0) + { + par_error(NOGRP,WARN,0); + } + } +; + +view: viewclause tlclause qualclause = + { + Lastree = tree($2, $3, ROOT, sizeof(struct rootnode), 1); + } +; +viewclause: viewstmnt relation = + { + Rsdmno = 0; + setp(PV_STR, "0040"); /* relstat = S_VIEW */ + setp(PV_STR, trim_relname(Parrng[Resrng].vardesc.reldum.relid)); + } +; +viewstmnt: DEFINE VIEW = + { + Opflag = mdVIEW; + if (!Qrymod) + { + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + } + } +; +permit: permstmnt permlist permrel permtarg permwho permplace permtd qualclause = + { + Lastree = tree($4, $8, ROOT, sizeof(struct rootnode), 1); + } +; +permstmnt: DEFINE PERMIT = + { + Opflag = mdPROT; + if (!Qrymod) + { + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + } + } +; +permlist: permxlist + | permlist COMMA permxlist +; +permxlist: ALL = + { + permcom(-1); /* means 'all' commands */ + } + | RETRIEVE = + { + permcom(mdRETR); + } + | DELETE = + { + permcom(mdDEL); + } + | APPEND = + { + permcom(mdAPP); + } + | REPLACE = + { + permcom(mdREPL); + } +; +permrel: permword relation = + { + /* put command vector into list now since this always happens */ + setp(PV_INT, Permcomd); + Permcomd = 0; /* reset command map */ + setp(PV_STR, trim_relname(Parrng[Resrng].vardesc.reldum.relid)); + bmove(Parrng[Resrng].vardesc.reldum.relowner, permbuf, 2); + permbuf[2] = 0; + setp(PV_STR, permbuf); + } +; +permword: ON + | OF + | TO +; +permtarg: LPAREN permtlist RPAREN = + { + $$ = $2; + } + | = + { + $$ = NULL; + } +; +permtlist: permtlelm + | permtlist COMMA permtlelm = + { + /* + ** attach bulk of permit tl to leftmost node of new elem + */ + if (!Err_current) + $$ = tlprepend($1, $3); + } +; +permtlelm: NAME = + { + /* Resrng is set by the "relation" production */ + if (!Err_current) + { + Trname = $1; + aptr = attlookup(Resrng, Trname); + $$ = tree(NULL, NULL, VAR, sizeof(struct varnode), Resrng, aptr); + $$ = addresdom(NULL, $$); + } + } +; +permwho: TO NAME = + { + setp(PV_STR, $2); + } + | TO ALL = + { + setp(PV_STR, "all"); + } +; +permplace: AT NAME = + { + setp(PV_STR, $2); + } + | AT ALL = + { + setp(PV_STR, "all"); + } + | = + { + setp(PV_STR, "all"); /* default is all */ + } +; +permtd: permtime permday + | permdeftime permday + | permtime permdefday + | permdeftime permdefday +; +permdeftime: = + { + setp(PV_INT, 0); + setp(PV_INT, 1440); + } +; +permdefday: = + { + setp(PV_STR, "sun"); + setp(PV_STR, "sat"); + } +; +permtime: FROM I2CONST COLON I2CONST TO I2CONST COLON I2CONST = + { + setp(PV_INT, timeofday($2, $4)); + setp(PV_INT, timeofday($6, $8)); + } +; +permday: ON NAME TO NAME = + { + setp(PV_STR, $2); + setp(PV_STR, $4); + } +; +integrity: integstmnt integnoise relation integis qual = + { + Lastree = tree(NULL, norml($5), ROOT, sizeof(struct rootnode), 1); + Qlflag--; /* turn off here */ + } +; +integstmnt: DEFINE INTEGRITY = + { + Opflag = mdINTEG; + Qlflag++; /* OK to turn on here because integrity doesn't have a targ list */ + if (!Qrymod) + { + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + } + } +; +integnoise: ON + | ONTO + | IN + | OF + | /* null */ +; +integis: IS + | /* null*/ +; +/*DDD*/distribute: diststmnt relation AT distcrits = +/*DDD*/ { +/*DDD*/ if (!Err_current) +/*DDD*/ { +/*DDD*/ $$ = tree(NULL, NULL, QLEND, 0); +/*DDD*/ Lastree = tree($4, $$, ROOT, sizeof(struct rootnode), 1); +/*DDD*/ } +/*DDD*/ } +/*DDD*/; +/*DDD*/diststmnt: DISTRIBUTE = +/*DDD*/ Opflag = mdDISTRIB; +/*DDD*/; +/*DDD*/distcrits: dcriterion = +/*DDD*/ { +/*DDD*/ $$ = $1; +/*DDD*/ } +/*DDD*/ | distcrits dcriterion = +/*DDD*/ { +/*DDD*/ $$ = tlprepend($1, $2); +/*DDD*/ } +/*DDD*/; +/*DDD*/dcriterion: NAME where qual = +/*DDD*/ { +/*DDD*/ Qlflag--; +/*DDD*/ syserr("Warning this node may be the wrong size\n"); +/*DDD*/ if (!Err_current) +/*DDD*/ $$ = tree(NULL, norml($3), SITE, 2, $1); +/*DDD*/ } +/*DDD*/; +relation: NAME = + { +# ifdef xPTR2 + tTfp(38, 3, "res rel name/var: '%s'\n", $1); +# endif + switch (Opflag) + { + case mdRETR: + case mdVIEW: + /* result better not be a rel name */ + if ((i = openr(&Reldesc, OR_RELTID, $1)) < 0) + syserr("relation: err openr '%d'", i); + if (i == 0) + { + /* reln exists */ + if (bequal(Reldesc.reldum.relowner, Usercode, UCODE_SZ)) + { + /* same owner, can't duplicate name */ + par_error(RESEXIST, WARN, $1, 0); + YYERROR; + } + else if (!Err_current) + { + /* owned by dba -- purge range table */ + rngdel($1); + } + } + if (!Err_current) + { + bmove(Usercode, Reldesc.reldum.relowner, UCODE_SZ); + pmove($1, Reldesc.reldum.relid, MAXNAME, ' '); + Resrng = rngent(R_INTERNAL, "", &Reldesc); + } + break; + + case mdAPP: + /* result is a rel name */ + if (!Err_current) + { + Resrng = rnglook($1, LOOKREL); + if (Resrng < 0) + { + if ((i = openr(&Reldesc, OR_RELTID, $1)) < 0) + syserr("relation: err openr '%d'", i); + if (i) + { + /* invalid relation name */ + par_error(RESAPPEX, WARN, $1, 0); + YYERROR; + } + Resrng = rngent(R_INTERNAL, "", &Reldesc); + } + else + ctlmod_decl(Resrng); + checkupd(Resrng); + } + break; + + case mdPROT: + case mdINTEG: +# ifdef DISTRIB + case mdDISTRIB: +# endif + /* the result is a tuple variable */ + Resrng = rnglook($1, LOOKVAR); + if (Resrng < 0) + { + /* variable not declared */ + par_error(NOVBLE, WARN, $1, 0); + YYERROR; + } + else + ctlmod_decl(Resrng); + break; + + case mdREPL: + case mdDEL: + /* the result is a tuple variable */ + Resrng = rnglook($1, LOOKVAR); + if (Resrng < 0) + /* variable not declared */ + { + par_error(NOVBLE, WARN, $1, 0); + YYERROR; + } + else + ctlmod_decl(Resrng); + + checkupd(Resrng); + Tidnode = tree(NULL, NULL, VAR, sizeof(struct varnode), Resrng, &Faketid); + break; + default: + ; + } + } +; +tlclause: LPAREN tlist RPAREN = + { + $$ = $2; + + /* + ** replace must have tid node as left branch + ** (so does delete but it doesn't have a targ list) + */ + if (Opflag == mdREPL && !Err_current) + { + $$ = tlprepend(tree(NULL, Tidnode, RESDOM, sizeof(struct resdomnode), 0), $$); + } + } +; +tlist: tlelm + | tlist COMMA tlelm = + { + /* + ** attach bulk of targ list to leftmost node + ** of new element + */ + if (!Err_current) + $$ = tlprepend($1, $3); + } +; +tlelm: NAME is afcn = + { + Trname = $1; + /* make a new resdom entry for targ list */ + if (!Err_current) + $$ = addresdom(NULL, $3); + } + | attrib = + { + /* makes a new resdom entry for targ list */ + if (!Err_current) + $$ = addresdom(NULL, $1); + } + | var PERIOD ALL = + { + if (Opflag == mdREPL) + { + /* ALL not defined for REPLACE */ + par_error(REPALL, WARN, + trim_relname(Qt.qt_rangev[$1].rngvdesc->relvname), 0); + YYERROR; + } + /* makes set of new resdom entries for targ list */ + else if (!Err_current) + $$ = xdot($1); + } +; +is: IS + | BY +; +qualclause: where qual = + { + $$ = norml($2); + Qlflag--; + if (Opflag == mdREPL) + qualindex(); + } + | = + { + /* null qualification */ + if (Opflag == mdREPL) + qualindex(); + $$ = norml(NULL); + } +; +where: WHERE = + { + Qlflag++; + } +; +qual: LPAREN qual RPAREN = + { + $$ = $2; + } + | LUOP qual = + { + $$ = tree(NULL, $2, UOP, 2, $1); + } + | qual LBOP qual = + { + $$ = tree($1, $3, $2, sizeof (struct rootnode) -2, 0); + } + | clause +; +clause: afcn relop afcn = + { + $$ = tree($1, $3, BOP, 2, $2); + } +; +relop: EOP + | IS + | BDOP +; +afcn: aggrfcn + | attribfcn + | afcn BAOPH afcn = + { + $$ = tree($1, $3, BOP, 2, $2); + } + | afcn BAOP afcn = + { + $$ = tree($1, $3, BOP, 2, $2); + } + | afcn UAOP afcn = + { + $$ = tree($1, $3, BOP, 2, $2); + } + | LPAREN afcn RPAREN = + { + $$ = $2; + } + | uop afcn %prec unaryop = + { + $$ = tree(NULL, $2, UOP, 2, $1); + } + | FOP LPAREN afcn RPAREN = + { + $$ = tree($3, NULL, UOP, 2, $1); + } + | FBOP LPAREN afcn COMMA afcn RPAREN = + { + $$ = tree($3, $5, BOP, 2, $1); + } +; +aggrfcn: AGOP LPAREN afcn BY domseq qualclause RPAREN = + { +# ifdef xPTR2 + tTfp(39, 0, "agg func\n"); +# endif + windup($5); + $$ = tree(tree($5, tree(NULL, $3, AOP, 6, $1), BYHEAD, sizeof(struct resdomnode), 0), $6, AGHEAD, sizeof(struct rootnode), 0); + tlprepend(tree(NULL, NULL, TREE, 0), $$); + } + | AGOP LPAREN afcn qualclause RPAREN = + { + $$ = tree(tree(NULL, $3, AOP, 6, $1), $4, AGHEAD, sizeof(struct rootnode), 0); + } +; +domseq: targdom + | domseq COMMA targdom = + { + $$ = tlprepend($1, $3); + } +; +targdom: afcn = + { + $$ = tree(NULL, $1, RESDOM, sizeof(struct resdomnode), Rsdmno); + } +; +nameprt: NAME = + { + $$ = substring($1,1); + } + | SCONST = + { + $$ = substring($1,0); + } +; +subelm: DOLLAR = + { + $$ = substring(NULL,0); + } + | nameprt DOLLAR = + { + $1->flag[0] |= 2; + $$ = $1; + } + | nameprt = + { + $$ = $1; + } + | I2CONST subelm = + { + setnumber($2,$1); + $$ = $2; + } +; +grpelm: subelm COMMA subelm = + { + groupstrings($1,$3); + $$ = $1; + } +; +leftclose: PCT = + { + $$ = $1; + } + | LPAREN = + { + $$ = $1; + } +; +rightclose: PCT = + { + $$ = $1; + } + | RPAREN = + { + $$ = $1; + } +; +stringpart: leftclose subelm rightclose = + { + $$ = endvals($2,$1,$3); + } + | leftclose grpelm rightclose = + { + $$ = endvals($2,$1,$3); + } +; +attrib: var PERIOD NAME = + { +# ifdef xPTR2 + tTfp(39, 1, "attrib %12s.%12s found\n", + Qt.qt_rangev[$1].rngvdesc->relvname, $3); +# endif + + /* remember attribute name */ + Trname = $3; + + /* look up attribute */ + aptr = attlookup($1, Trname); + $$ = tree(NULL, NULL, VAR, sizeof(struct varnode), $1, aptr); + } + | attrib stringpart = + { + $1->sym.value.sym_var.varstr = $2; + $$ = $1; + } +; +var: NAME = + { + $$ = rnglook($1, LOOKVAR); + if ($$ < 0) + { + /* variable not declared */ + par_error(NOVBLE, WARN, $1, 0); + YYERROR; + } + else + ctlmod_decl($$); + } +; +attribfcn: I2CONST = + { + $$ = tree(NULL, NULL, INT, 2, $1); + } + | I4CONST = + { + $$ = tree(NULL, NULL, INT, 4, $1); + } + | F4CONST = + { + $$ = tree(NULL, NULL, FLOAT, 4, $1); + } + | F8CONST = + { + $$ = tree(NULL, NULL, FLOAT, 8, $1); + } + | SCONST = + { + patmat($1); + $$ = tree(NULL, NULL, CHAR, length($1), $1); + } + | NAME = + { + $$ = tree(NULL, NULL, COP, 2, $1); + } + | attrib +; +uop: UAOP %prec unaryop = + { + if ($1 == opADD) + $$ = opPLUS; + else + if ($1 == opSUB) + $$ = opMINUS; + } +; +copy: copstmnt alias LPAREN coparam RPAREN keywd SCONST = + { +# ifdef xPTR2 + tTfp(39, 3, "copy %12s,%12s\n", $2, $7); +# endif + + setp(PV_STR, $7); + } +; +copstmnt: COPY = + { + Opflag = mdCOPY; + } +; +coparam: cospecs + | ; +; +cospecs: alias is coent + | cospecs COMMA alias is coent +; +coent: alias + | SCONST = + { + setp(PV_STR, $1); + } +; +alias: NAME = + { + if (!Err_current) + { + setp(PV_STR, $1); + if (Opflag == mdDESTROY || Opflag == mdCREATE +# ifdef DISTRIB + || Opflag == mdDCREATE +# endif + ) + rngdel($1); + } + } +; +specs: alias is alias + | specs COMMA alias is alias +; +keywd: INTO = + { + setp(PV_STR, "\0"); + setp(PV_STR, "i"); + } + | FROM = + { + setp(PV_STR, "\0"); + setp(PV_STR, "f"); + } +; +create: crestmnt alias LPAREN specs RPAREN +; +crestmnt: CREATE = + { + Opflag = mdCREATE; + + /* set up parameters for regular create */ + setp(PV_STR, "0"); /* relstat = nil */ + } +/*DDD*/ | CREATE DISTRD = +/*DDD*/ { +/*DDD*/ Opflag = mdDCREATE; +/*DDD*/ +/*DDD*/ /* setup parameters for distributed create */ +/*DDD*/ setp(PV_STR, "U"); +/*DDD*/ setp(PV_STR, ""); +/*DDD*/ setp(PV_STR, "01000"); /* relstat = S_DISTRIBUTED */ +/*DDD*/ } +; +destroy: destmnt keys + | destqm destlist + | destmnt DELIM NAME = + { + Opflag = mdSTOP; + if ((i = openr(&Reldesc, OR_WRITE, "rdelim")) < 0) + syserr("relname: error in openr '%d'", i); + if (i > 0) + { + /* invalid relation name */ + par_error(RNGEXIST, WARN, "rdelim", 0); + YYERROR; + } + else + { + if ( i = destroy_delim(&Reldesc, $3) < 0) + { + closer(&Reldesc); + par_error(DELEXIST, WARN, "rdelim",0); + } + } + closer(&Reldesc); + } +; +destmnt: DESTROY = + { + Opflag = mdDESTROY; + } +; +destqm: destmnt INTEGRITY NAME = + { + Opflag = mdREMQM; + if (!Qrymod) + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + setp(PV_STR, "6"); + setp(PV_STR, $3); + } + | destmnt PERMIT NAME = + { + Opflag = mdREMQM; + if (!Qrymod) + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + setp(PV_STR, "5"); + setp(PV_STR, $3); + } +; +destlist: I2CONST = + { + i = iocv(*($1)); + setp(PV_STR, i); + } + | destlist COMMA I2CONST = + { + i = iocv(*($3)); + setp(PV_STR, i); + } + | ALL +; +help: helstmnt hlist + | helstmnt = + { + setp(PV_INT, RELIST); /* all relns */ + } + | helqmstmnt hqmlist + | heldelstmnt = + { + setp(PV_INT, ALLDELLIST); /* all delims */ + } + | heldelstmnt dlist +; +helstmnt: HELP = + { + Opflag = mdHELP; + } +; +heldelstmnt: HELP DELIM = + { + Opflag = mdHELP; + } +; +helqmstmnt: HELP VIEW = + { + Opflag = mdDISPLAY; + if (!Qrymod) + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + smove("4", hqmbuf); + } + | HELP PERMIT = + { + Opflag = mdDISPLAY; + if (!Qrymod) + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + smove("5", hqmbuf); + } + | HELP INTEGRITY = + { + Opflag = mdDISPLAY; + if (!Qrymod) + /* no qrymod in database */ + par_error(NOQRYMOD, WARN, 0); + smove("6", hqmbuf); + } + +; +hlist: hparam + | hlist COMMA hparam + | ALL = + { + setp(PV_INT, ALLRELINFO); + } +; +dlist: dparam + | dlist COMMA dparam +; +dparam: NAME = + { + /* relation */ + setp(PV_INT, DELLIST); + setp(PV_STR, $1); + } +; +hparam: NAME = + { + /* relation */ + setp(PV_INT, RELINFO); + setp(PV_STR, $1); + } + | SCONST = + { + /* manual page */ + setp(PV_INT, MANSEC); + setp(PV_STR, $1); + } +; +hqmlist: NAME = + { + setp(PV_STR, hqmbuf); + setp(PV_STR, $1); + } + | hqmlist COMMA NAME = + { + setp(PV_STR, hqmbuf); + setp(PV_STR, $3); + } +; +index: instmnt LPAREN keys RPAREN = + { + if (Rsdmno > MAXKEYS) + /* too many attributes in key */ + par_error(INDEXTRA, WARN, 0); + } +; +instmnt: indexq ON NAME IS NAME = + { + /* init INDEX command */ + Rsdmno = 0; + setp(PV_STR, $3); + setp(PV_STR, $5); + Indexname = $5; + } +; +indexq: INDEX = + { + Opflag = mdINDEX; + } +; +modify: modstmnt alias TO modstorage modkeys modqual +; +modstmnt: MODIFY = + { + Opflag = mdMODIFY; + Rsdmno = 0; + } +; +modstorage: NAME = + { + setp(PV_STR, $1); + } +modkeys: modstkey modrptkey + | ; +; +modstkey: ON = + { + setp(PV_STR, "name"); + } +; +modrptkey: modbasekey + | modrptkey COMMA modbasekey +; +modbasekey: NAME = + { + setp(PV_STR, $1); + } + | NAME COLON NAME = + { + concat($1, ztack(":", $3), modbuf); + setp(PV_STR, modbuf); + } +; +modqual: modcond modfill + | ; +; +modcond: WHERE = + { + setp(PV_STR, "\0"); + } +; +modfill: modfillnum + | modfill COMMA modfillnum +; +modfillnum: NAME IS I2CONST = + { + setp(PV_STR, $1); + i = iocv(*($3)); + setp(PV_STR, i); + } + | NAME IS NAME = + { + setp(PV_STR, $1); + setp(PV_STR, $3); + } +; +keys: alias = + { + Rsdmno++; + } + | keys COMMA alias = + { + Rsdmno++; + } +; +print: prinstmnt keys +; +prinstmnt: PRINT = + { + Opflag = mdPRINT; + } +; +save: savstmnt alias UNTIL date +; +savstmnt: SAVE = + { + Opflag = mdSAVE; + } +; +date: month day_year day_year +; +month: alias + | day_year +; +day_year: I2CONST = + { + i = iocv(*($1)); + +# ifdef xPTR3 + tTfp(39, 4, "day_year: %s\n", i); +# endif + + setp(PV_STR, i); + } +; +%% +# include "scanner.h" +# include "tables.y" +# include "yyerror.y"