Annotation of 42BSD/ingres/source/equel/grammar.y, revision 1.1

1.1     ! root        1: /*
        !             2: **  GRAMMAR.Y -- Equel 6.2 grammar
        !             3: **
        !             4: **     Yacc grammar and semantic rules for Quel
        !             5: **     embedded in C.
        !             6: **
        !             7: **     The grammar is organized in the following manner:
        !             8: **             a) control structure
        !             9: **             b) quel statments
        !            10: **             c) equel statements
        !            11: **             d) declaration and use of C vars
        !            12: **             e) special objects
        !            13: **             f) expressions
        !            14: **             g) keywords
        !            15: **             h) noise words and punctuation
        !            16: **     Within a single classification, major objects are ordered
        !            17: **     alphabetically, and minor objects under the major ones they
        !            18: **     are in.
        !            19: **
        !            20: **     Side Effects:
        !            21: **             performs the translation of an Equel program into
        !            22: **             a C program with calls on the Equel run-time
        !            23: **             support
        !            24: **
        !            25: **     NOTE:
        !            26: **             There are two shift/reduce conflicts associated
        !            27: **             with the non-terminals "[o_]gen_while". It is resolved
        !            28: **             correctly by yacc.
        !            29: */
        !            30: 
        !            31: 
        !            32: 
        !            33: %{
        !            34:        /* STANDARD SCANNER & PARSER GLOBALS */
        !            35: 
        !            36: # include      "constants.h"
        !            37: # include      <stdio.h>
        !            38: # include      "globals.h"
        !            39: # include      <sccs.h>
        !            40: 
        !            41: SCCSID(@(#)grammar.y   7.1     2/5/81)
        !            42: 
        !            43: 
        !            44: %}
        !            45: %union
        !            46: {
        !            47:        struct disp_node        *u_dn;
        !            48: };
        !            49: 
        !            50: 
        !            51:        /* QUEL keywords */
        !            52: %token <u_dn>  APPEND          COPY            CREATE          DEFINE          
        !            53: %token <u_dn>  DELETE          DESTROY         HELP            INDEX
        !            54: %token <u_dn>  MODIFY          PRINT           INTEGRITY       RANGE
        !            55: %token <u_dn>  REPLACE         RETRIEVE        SAVE            UNIQUE
        !            56: %token <u_dn>  PERMIT          VIEW
        !            57: 
        !            58:        /* special embedded QUEL commands */
        !            59: %token <u_dn>  INGRES          EXIT            PARAM
        !            60: 
        !            61:        /* C variable usages */
        !            62: %token <u_dn>  TYPE            ALLOC           STRUCT          STRUCT_VAR
        !            63: 
        !            64:        /* QUEL noise words */
        !            65: %token <u_dn>  ALL             BY              FROM            IN
        !            66: %token <u_dn>  INTO            IS              OF              ON
        !            67: %token <u_dn>  ONTO            TO              WHERE           UNTIL
        !            68: %token <u_dn>  AT
        !            69: 
        !            70:        /* constants */
        !            71: 
        !            72: %token <u_dn>  NAME            SCONST          I2CONST         I4CONST
        !            73: %token <u_dn>  F8CONST         C_CODE
        !            74: 
        !            75:        /* punctuation */
        !            76: %token <u_dn>  COMMA           LPAREN          RPAREN          PERIOD
        !            77: %token <u_dn>  QUOTE           BGNCMNT         ENDCMNT         LBRACE
        !            78: %token <u_dn>  RBRACE          LBRKT           RBRKT           NONREF
        !            79: %token <u_dn>  SEMICOL         POINTER         COLON
        !            80: 
        !            81:        /* operator classes */
        !            82: %token <u_dn>  UOP
        !            83: %token <u_dn>  BOP
        !            84: %token <u_dn>  BDOP
        !            85: %token <u_dn>  EOP
        !            86: %token <u_dn>  LBOP            LUOP
        !            87: %token <u_dn>  FOP             FBOP
        !            88: %token <u_dn>  AOP
        !            89: 
        !            90:        /* define ascending precedence for operators */
        !            91: 
        !            92: %left  LBOP
        !            93: %left  LUOP
        !            94: %left  BOP             LBRKT
        !            95: %left  UOP
        !            96: %nonassoc              unaryop
        !            97: 
        !            98:        /* non-teriminal type info */
        !            99: %type <u_dn>           endblock
        !           100: %type <u_dn>           c_variable
        !           101: %type <u_dn>           cvarx
        !           102: %type <u_dn>           struct_var
        !           103: %type <u_dn>           ptr
        !           104: %type <u_dn>           selector_part
        !           105: %type <u_dn>           str_var_key
        !           106: %type <u_dn>           id
        !           107: 
        !           108: 
        !           109: 
        !           110: %%
        !           111: %{
        !           112:        struct cvar     *cvarp;
        !           113: %}
        !           114: 
        !           115: /*
        !           116:  * Program Control Structure
        !           117:  */
        !           118: 
        !           119: program:       program statement = 
        !           120:                {
        !           121:                        /* for each "statement", free the symbol space
        !           122:                         * used by that query (lookahed space must not
        !           123:                         * be freed), and catch up on output lines
        !           124:                         */
        !           125:                        symspfree();
        !           126:                        equate_lines();
        !           127:                }
        !           128:        |       ;
        !           129: ;
        !           130: statement:     startquel quel_statement = 
        !           131:                {
        !           132:                        w_sync();
        !           133:                        /* the purpose of the actions for startquel
        !           134:                         * and this action is to make each query
        !           135:                         * a single compound C statement (if (x) "{query}")
        !           136:                         */
        !           137:                        w_op("}");
        !           138:                }
        !           139:        |       startquel equel_statement =
        !           140:                {
        !           141:                        end_quote();
        !           142:                        w_op("}");
        !           143:                }
        !           144:        |       c_code  
        !           145:        |       declaration      
        !           146:        |       error
        !           147: ;
        !           148: startquel:     =
        !           149:                        w_op("{");
        !           150: ;
        !           151: /*
        !           152:  * C_CODE is a token returned by the lexical analyzer
        !           153:  * when it recognizes that the following line is not
        !           154:  * equel code. On the NEXT call to the lexical analyzer,
        !           155:  * the code will be copied from the source to the output file.
        !           156:  */
        !           157: c_code:        C_CODE  
        !           158:        |       beginblock =
        !           159:                        Block_level += 1;
        !           160:        |       endblock =
        !           161:                {
        !           162:                        if (Block_level == 0)
        !           163:                                yyserror("extra '}'", $1);
        !           164:                        else if ((Block_level -= 1) == 0)
        !           165:                        {
        !           166:                                freecvar(&C_locals);
        !           167:                                freecvar(&F_locals);
        !           168:                        }
        !           169:                }
        !           170: ;
        !           171: 
        !           172:        /* the %prec is to resolve conflicts with the { after a
        !           173:         * "tupret".
        !           174:         */
        !           175: beginblock:    LBRACE  %prec LBOP =
        !           176:                        w_op($1->d_elm);
        !           177: ;
        !           178: endblock:      RBRACE =
        !           179:                        w_op($1->d_elm);
        !           180: ;
        !           181: quel_statement: append  
        !           182:        |       copy 
        !           183:        |       create   
        !           184:        |       delete 
        !           185:        |       destroy  
        !           186:        |       help 
        !           187:        |       index    
        !           188:        |       integrity        
        !           189:        |       modify 
        !           190:        |       permit
        !           191:        |       print 
        !           192:        |       range 
        !           193:        |       replace 
        !           194:        |       retrieve 
        !           195:        |       save 
        !           196:        |       view
        !           197: ;
        !           198: 
        !           199:        /* commands particular to Equel */
        !           200: 
        !           201: equel_statement:append_p
        !           202:        |       copy_p
        !           203:        |       create_p
        !           204:        |       exit     
        !           205:        |       ingres   
        !           206:        |       replace_p
        !           207:        |       retrieve_p
        !           208:        |       tupret
        !           209:        |       view_p
        !           210: ;
        !           211: /*
        !           212:  * QUEL statements 
        !           213:  */
        !           214: 
        !           215: append:                append_key apclause tlclause qualclause 
        !           216: ;
        !           217: apclause:      apkword id      
        !           218: ;
        !           219: 
        !           220: copy:          copy_key id lparen ctl rparen cp_kword filename 
        !           221:        |       copy_key id lparen rparen cp_kword filename
        !           222: ;
        !           223: filename:      sconst
        !           224:        |       id 
        !           225: ;
        !           226: 
        !           227: create:                create_key id lparen ctl rparen
        !           228: ;
        !           229: 
        !           230: delete:                delete_key delclause qualclause 
        !           231: ;
        !           232: delclause:     delnoise id             
        !           233: ;
        !           234: 
        !           235: destroy:       destroy_key idlist
        !           236:        |       destroy_key integ_permit id int_list_all
        !           237: ;
        !           238: integ_permit:  integ_key
        !           239:        |       permit_key
        !           240: ;
        !           241: int_list_all:  int_list
        !           242:        |       all
        !           243: ;
        !           244: 
        !           245: help:          help_key        
        !           246:        |       help_key all
        !           247:        |       help_key hlist
        !           248:        |       help_key int_perm_view idlist
        !           249: ;
        !           250: hlist:         hparam
        !           251:        |       hlist comma hparam
        !           252: ;
        !           253: hparam:                id 
        !           254:        |       sconst
        !           255: ;
        !           256: int_perm_view: integ_permit
        !           257:        |       view_key
        !           258: ;
        !           259: 
        !           260: index:         index_key id is id lparen idlist rparen
        !           261: ;
        !           262: 
        !           263: integrity:     define_key integ_key integnoise id isnoise qual
        !           264: ;
        !           265: 
        !           266: modify:                modify_key id to id on modkeylist density
        !           267:        |       modify_key id to id
        !           268: ;
        !           269: modkeylist:    modkey
        !           270:        |       modkeylist comma modkey
        !           271: ;
        !           272: modkey:                id
        !           273:        |       id colon id
        !           274: ;
        !           275: density:       where modfill
        !           276:        |       ;
        !           277: ;
        !           278: modfill:       id is mod_var
        !           279:        |       modfill comma id is mod_var
        !           280: ;
        !           281:        /* mod_var can be an integer constant or var, or a string var
        !           282:         * or a quel name
        !           283:         */
        !           284: mod_var:       I2CONST =
        !           285:                        w_con(I2CONST, $1->d_elm);
        !           286:        |       c_variable =
        !           287:                {
        !           288:                        if ($1)
        !           289:                        {
        !           290:                                if (!Cvarp)
        !           291:                                        w_key($1->d_elm);
        !           292:                                else if (Fieldp && Fieldp->c_type == opINT
        !           293:                                        || Cvarp->c_type == opINT)
        !           294:                                                w_var(Cv_display, opINT);
        !           295:                                else if (Fieldp && Fieldp->c_type == opSTRING 
        !           296:                                        || Cvarp->c_type == opSTRING)
        !           297:                                                w_var(Cv_display, opIDSTRING);
        !           298:                                else
        !           299:                                        yyserror("in MODIFY, qual var must be in or string",
        !           300:                                        $1);
        !           301:                        }
        !           302:                        else
        !           303:                                yyserror("bad modify qualification", 0);
        !           304:                        free_display(Cv_display);
        !           305:                        Cvarp = Fieldp = 0;
        !           306:                }
        !           307: ;
        !           308: 
        !           309: permit:                def_perm permit_list on_of_to id perm_tl
        !           310:                        perm_who perm_term perm_time perm_day qualclause
        !           311: ;
        !           312: def_perm:      define_key permit_key 
        !           313: ;
        !           314: permit_list:   permlistelm
        !           315:        |       permit_list comma permlistelm
        !           316: ;
        !           317: permlistelm:   RETRIEVE =
        !           318:                        w_key($1->d_elm);
        !           319:        |       APPEND =
        !           320:                        w_key($1->d_elm);
        !           321:        |       DELETE =
        !           322:                        w_key($1->d_elm);
        !           323:        |       REPLACE = 
        !           324:                        w_key($1->d_elm);
        !           325:        |       all
        !           326: ;
        !           327: on_of_to:      on
        !           328:        |       of
        !           329:        |       to
        !           330: ;
        !           331: perm_tl:       lparen idlist rparen
        !           332:        |       ;
        !           333: ;
        !           334: perm_who:      to id
        !           335:        |       all
        !           336:        |       ;
        !           337: ;
        !           338: perm_term:     at id
        !           339:        |       at all
        !           340:        |       ;
        !           341: ;
        !           342: perm_time:     from integer colon integer to
        !           343:                        integer colon integer
        !           344:        |       ;
        !           345: ;
        !           346: perm_day:      on id to id
        !           347:        |       ;
        !           348: ;
        !           349: 
        !           350: print:         print_key idlist 
        !           351: ;
        !           352: 
        !           353: range:         range_of id is id       
        !           354: ;
        !           355: 
        !           356: replace:       replace_key repclause tlclause qualclause       
        !           357: ;
        !           358: repclause:     repkword id     
        !           359: ;
        !           360: 
        !           361: retrieve:      retrieve_key resclause tlclause qualclause      
        !           362: ;
        !           363: resclause:     retkword id     
        !           364: ;
        !           365: 
        !           366: save:          save_key id until date
        !           367: ;
        !           368: date:          id integer integer
        !           369: ;
        !           370: 
        !           371: view:          define_key view_key id tlclause qualclause
        !           372: ;
        !           373: 
        !           374: /*
        !           375:  * Statements Particular to Equel
        !           376:  */
        !           377: 
        !           378: append_p:      append_p_key apclause param_tl qualclause
        !           379: ;
        !           380: 
        !           381: copy_p:                copy_p_key id param_tl fr_in_id filename
        !           382: ;
        !           383: fr_in_id:      cp_kword
        !           384:        |       c_variable =
        !           385:                {
        !           386:                        if ($1 && Cvarp)
        !           387:                        {
        !           388:                                if (Fieldp && Fieldp->c_type != opSTRING
        !           389:                                   || !Fieldp && Cvarp->c_type != opSTRING)
        !           390:                                        yyserror("string var expected for from/into in COPY",
        !           391:                                        $1);
        !           392:                                else
        !           393:                                        w_var(Cv_display, opIDSTRING);
        !           394:                        }
        !           395:                        else
        !           396:                                yyserror("into/from expected in COPY", $1);
        !           397:                        free_display(Cv_display);
        !           398:                        Fieldp = Cvarp = 0;
        !           399:                }
        !           400: ;
        !           401: 
        !           402: create_p:      create_p_key id param_tl
        !           403: ;
        !           404: 
        !           405: exit:          EXIT = 
        !           406:                { 
        !           407:                        Opflag = mdEXIT;
        !           408:                        w_new("IIexit();"); 
        !           409:                }
        !           410: ;
        !           411: 
        !           412: ingres:                ingres_key param_list = 
        !           413:                        w_op(");"); 
        !           414: ;
        !           415: param_list:    param =
        !           416:                        w_op("0");
        !           417:        |       param param_list
        !           418: ;
        !           419: param:         id  =
        !           420:                        w_op(",");
        !           421:        |       SCONST =
        !           422:                {
        !           423:                        w_string($1->d_elm, 0);
        !           424:                        w_op(",");
        !           425:                }
        !           426: ;
        !           427: 
        !           428: replace_p:     replace_p_key repclause param_tl qualclause
        !           429: ;
        !           430: 
        !           431: retrieve_p:    retrieve_p_key resclause param_tl qualclause
        !           432: ;
        !           433: 
        !           434: tupret:                tupret_keyw xc_code =
        !           435:                        w_flush();
        !           436:        |       tupret_p o_xc_code =
        !           437:                        w_flush();
        !           438: ;
        !           439: tupret_keyw:   retrieve_key unique c_tlclause qualclause       =
        !           440:                {
        !           441:                        w_new("IIsetup();");
        !           442:                }
        !           443: ;
        !           444: unique:        UNIQUE =
        !           445:                {
        !           446:                        Opflag = mdTUPRET;
        !           447:                        w_key($1->d_elm);
        !           448:                }
        !           449:        |       =
        !           450:                        Opflag = mdTUPRET;
        !           451: ;
        !           452: c_tlclause:    lparen  c_tlist rparen   
        !           453: ;
        !           454: c_tlist:       c_tlelm 
        !           455:        |       c_tlelm comma c_tlist  
        !           456: ;
        !           457: c_tlelm:       reduc cvar is_key afcn   
        !           458: ;
        !           459: reduc:         =
        !           460:                        Opflag = mdCTLELM;
        !           461: ;
        !           462: xc_code:       LBRACE gen_while c_code RBRACE %prec LBRACE =
        !           463:                        w_op("}");
        !           464:        |       gen_while %prec LBOP =
        !           465:                        w_op("}");
        !           466: ;
        !           467: gen_while:     =
        !           468:                {
        !           469:                        w_new("while(IIn_get(");
        !           470:                        w_file();
        !           471:                        w_op(")){");
        !           472:                        w_ret();
        !           473:                        free_ret();
        !           474:                        w_op("if(IIerrtest())continue;");
        !           475:                        equate_lines();
        !           476:                }
        !           477: ;
        !           478: o_xc_code:     LBRACE  o_gen_while c_code RBRACE %prec LBRACE =
        !           479:                        w_op("}");
        !           480:        |       o_gen_while %prec LBOP =
        !           481:                        w_op("}");
        !           482: ;
        !           483: o_gen_while:   =
        !           484:                {
        !           485:                        w_new("while(IIgettup(");
        !           486:                        w_file();
        !           487:                        w_op(")){");
        !           488:                        equate_lines();
        !           489:                }
        !           490: ;
        !           491: tupret_p:      tupret_p_key unique param_tl qualclause =
        !           492:                {
        !           493:                        w_new("IIsetup();");
        !           494:                }
        !           495: ;
        !           496: 
        !           497: view_p:                PARAM define_key view_key id param_tl qualclause
        !           498: ;
        !           499: 
        !           500: /*
        !           501:  * Declarations and use of C variables
        !           502:  */
        !           503: 
        !           504: declaration:   decl_specifer declarator_list SEMICOL   =
        !           505:                {
        !           506:                        w_op($3->d_elm);
        !           507:                        Type_spec = 0;
        !           508:                }
        !           509:        |       decl_specifer SEMICOL = 
        !           510:                { 
        !           511:                        w_op($2->d_elm);
        !           512:                        Type_spec = 0;
        !           513:                }
        !           514: ;
        !           515: decl_specifer: type_specifier  
        !           516:        |       sc_specifier    
        !           517:        |       type_specifier sc_specifier     
        !           518:        |       sc_specifier type_specifier     
        !           519:        |       struct_dec =
        !           520:                {
        !           521:                        Struct_flag = 0;
        !           522:                        Type_spec = opSTRUCT;
        !           523:                }
        !           524:        |       sc_specifier struct_dec =
        !           525:                {
        !           526:                        Struct_flag = 0;
        !           527:                        Type_spec = opSTRUCT;
        !           528:                }
        !           529: ;
        !           530: sc_specifier:  ALLOC   =
        !           531:                {
        !           532:                        Opflag = mdDECL;
        !           533:                        w_key($1->d_elm);
        !           534:                        /* in case the default "int" should be assumed,
        !           535:                         * the Type_spec is set up for it, if a previous
        !           536:                         * type hasn't been given
        !           537:                         */
        !           538:                        if (!Type_spec)
        !           539:                                Type_spec = opINT;
        !           540:                }
        !           541: ;
        !           542: type_specifier:        TYPE    =
        !           543:                {
        !           544:                        Opflag = mdDECL;
        !           545:                        w_key($1->d_elm);
        !           546:                        Type_spec = Opcode;
        !           547:                }
        !           548: ;
        !           549: struct_dec:    struct_name field_declaration 
        !           550:        |       struct_name
        !           551:        |       struct_key field_declaration
        !           552: ;
        !           553: struct_name:   struct_key NAME =
        !           554:                        w_key($2->d_elm);
        !           555: ;
        !           556: field_declaration:     lbrace field_seq RBRACE =
        !           557:                {
        !           558:                        w_op($3->d_elm);
        !           559:                        Type_spec = 0;
        !           560:                }
        !           561: ;
        !           562: field_seq:     field_seq field
        !           563:        |       ;
        !           564: ;
        !           565: field:         type_specifier declarator_list SEMICOL =
        !           566:                {
        !           567:                        w_op($3->d_elm);
        !           568:                        Type_spec = 0;
        !           569:                }
        !           570:        |       C_CODE
        !           571: ;
        !           572: declarator_list:       cvar_dec
        !           573:        |       declarator_list comma cvar_dec
        !           574: ;
        !           575: cvar_dec:      cvarx =
        !           576:                {
        !           577:                        if (Type_spec == opSTRING)
        !           578:                                Indir_level -= 1;
        !           579:                        if (Struct_flag)
        !           580:                                decl_field($1->d_elm, Type_spec,
        !           581:                                        Indir_level, Block_level);
        !           582:                        else
        !           583:                                decl_cvar($1->d_elm, Type_spec,
        !           584:                                        Indir_level, Block_level);
        !           585:                        free_display(Cv_display);
        !           586:                        Indir_level = Field_indir = 0;
        !           587:                        Fieldp = Cvarp = 0;
        !           588:                }
        !           589: ;
        !           590: c_variable:    cvarx =
        !           591:                {
        !           592:                        $$ = $1;
        !           593:                        if (Cvarp && Cvarp->c_indir != Indir_level)
        !           594:                        {
        !           595:                                yyserror("bad indirection on a C variable", $1);
        !           596:                                $$ = 0;
        !           597:                        }
        !           598:                        Indir_level = Field_indir = 0;
        !           599:                }
        !           600:        |       NONREF NAME =
        !           601:                {
        !           602:                        enter_display(Cv_display, salloc($1->d_elm));
        !           603:                        Cvarp = Fieldp = 0;
        !           604:                        $$ = $2;
        !           605:                }
        !           606:        |       NONREF STRUCT_VAR =
        !           607:                {
        !           608:                        enter_display(Cv_display, salloc($1->d_elm));
        !           609:                        Cvarp = Fieldp = 0;
        !           610:                        $$ = $2;
        !           611:                }
        !           612:        |       struct_var =
        !           613:                {
        !           614:                        if (!Fieldp)
        !           615:                        {
        !           616:                                yyserror("undeclared field", $1);
        !           617:                                $$ = $<u_dn>0;
        !           618:                        }
        !           619:                        else if (Fieldp->c_indir != Field_indir)
        !           620:                        {
        !           621:                                yyserror("bad indirection on a structure's field",
        !           622:                                $1);
        !           623:                                $$ = 0;
        !           624:                        }
        !           625:                        if (Cvarp->c_indir != Indir_level)
        !           626:                        {
        !           627:                                yysemerr("bad indirection a structure variable",
        !           628:                                Cvarp->c_indir);
        !           629:                                $$ = 0;
        !           630:                        }
        !           631:                        Indir_level = Field_indir = 0;
        !           632:                }
        !           633: ;
        !           634: struct_var:    ptr struct_var  %prec unaryop =
        !           635:                {
        !           636:                        if ($1->d_elm[1] == '*')
        !           637:                                Field_indir += 1;
        !           638:                        Field_indir += 1;
        !           639:                        $$ = $2;
        !           640:                }
        !           641:        |       struct_var arraysub     %prec LBRKT =
        !           642:                        Field_indir += 1;
        !           643:        |       str_var_key selector_part
        !           644: ;
        !           645: str_var_key:   STRUCT_VAR =
        !           646:                {
        !           647:                        Cvarp = getcvar($1->d_elm);
        !           648:                        enter_display(Cv_display, $1->d_elm);
        !           649:                }
        !           650: ;
        !           651: selector_part: arraysub selector_part =
        !           652:                {
        !           653:                        Indir_level += 1;
        !           654:                        $$ = $2;
        !           655:                }
        !           656:        |       select_op NAME =
        !           657:                {
        !           658:                        enter_display(Cv_display, $2->d_elm);
        !           659:                        Fieldp = getfield($2->d_elm);
        !           660:                        $$ = $2;
        !           661:                }
        !           662: ;
        !           663: select_op:     PERIOD =
        !           664:                        enter_display(Cv_display, $1->d_elm);
        !           665:        |       POINTER =
        !           666:                {
        !           667:                        enter_display(Cv_display, $1->d_elm);
        !           668:                        Indir_level += 1;
        !           669:                }
        !           670: ;
        !           671: 
        !           672: /* use of a C variable */
        !           673: cvar:          c_variable =    
        !           674:                {
        !           675:                        if ($1)
        !           676:                        {
        !           677:                                if (!Fieldp && ! Cvarp)
        !           678:                                {
        !           679:                                        if (!Field_indir && !Indir_level
        !           680:                                          && (sequal($1->d_elm, "dba")
        !           681:                                            || sequal($1->d_elm, "usercode")))
        !           682:                                                /* constant operator COP */
        !           683:                                                w_key($1->d_elm);
        !           684:                                        else
        !           685:                                                yyserror("C var expected", $1);
        !           686:                                }
        !           687:                                else if (Opflag == mdCTLELM)
        !           688:                                {
        !           689:                                        w_con(NAME,
        !           690:                                          Fieldp ? Fieldp->c_id: Cvarp->c_id);
        !           691:                                        enter_ret(Cv_display,
        !           692:                                          Fieldp ? Fieldp->c_type: Cvarp->c_type);
        !           693:                                }
        !           694:                                else
        !           695:                                        w_var(Cv_display,
        !           696:                                          Fieldp ? Fieldp->c_type: Cvarp->c_type);
        !           697:                        }
        !           698:                        free_display(Cv_display);
        !           699:                        Fieldp = Cvarp = 0;
        !           700:                        Indir_level = Field_indir = 0;
        !           701:                }
        !           702: cvarx:                 NAME =
        !           703:                {
        !           704:                        if (Opflag == mdDECL)
        !           705:                                w_con(NAME, $1->d_elm);
        !           706:                        else
        !           707:                        {
        !           708:                                Cvarp = getcvar($1->d_elm);
        !           709:                                enter_display(Cv_display, salloc($1->d_elm));
        !           710:                        }
        !           711:                }
        !           712:        |       ptr cvarx %prec unaryop =
        !           713:                {
        !           714:                        if ($1->d_elm [1] == '*')
        !           715:                                Indir_level += 1;
        !           716:                        Indir_level += 1;
        !           717:                        $$ = $2;
        !           718:                }
        !           719:        |       cvarx arraysub  %prec LBRKT =
        !           720:                {
        !           721:                        Indir_level += 1;
        !           722:                }
        !           723: ;
        !           724: ptr:           BOP =
        !           725:                {
        !           726:                        if (!sequal($1->d_elm, "*") && !sequal((struct disp_node *)($1)->d_elm, "**"))
        !           727:                                yyserror(Opflag == mdDECL ?
        !           728:                                "invalid operator in declaration":
        !           729:                                "invalid operator in C variable",
        !           730:                                $1);
        !           731:                        if (Opflag == mdDECL)
        !           732:                                w_op($1->d_elm);
        !           733:                        else
        !           734:                                enter_display(Cv_display, salloc($1->d_elm));
        !           735:                }
        !           736: ;
        !           737: arraysub:      LBRKT =
        !           738:                {
        !           739:                        if (Opflag == mdDECL)
        !           740:                                eat_display(0, '[', ']');
        !           741:                        else
        !           742:                                eat_display(Cv_display, '[', ']');
        !           743:                }
        !           744: ;
        !           745: 
        !           746: /*
        !           747:  * Special Objects used throughout grammar
        !           748:  */
        !           749: 
        !           750: id:            c_variable =
        !           751:                {
        !           752:                        if ($1)
        !           753:                        {
        !           754:                                if (Cvarp)
        !           755:                                {
        !           756:                                        if (Fieldp && Fieldp->c_type != opSTRING
        !           757:                                           || !Fieldp && Cvarp->c_type != opSTRING)
        !           758:                                                yyserror("string var expected", $1);
        !           759:                                        else if (Opflag == mdFILENAME)
        !           760:                                                w_var(Cv_display, opSTRING);
        !           761:                                        else if (Opflag == mdINGRES)
        !           762:                                                w_display(Cv_display);
        !           763:                                        else
        !           764:                                                w_var(Cv_display, opIDSTRING);
        !           765:                                }
        !           766:                                else if (Opflag == mdINGRES)
        !           767:                                        w_string($1->d_elm, 0);
        !           768:                                else if (Opflag == mdFILENAME)
        !           769:                                        yyserror("file for a COPY must be a string or string variable",
        !           770:                                        $1);
        !           771:                                else
        !           772:                                        w_key($1->d_elm);
        !           773:                        }
        !           774:                        free_display(Cv_display);
        !           775:                        Fieldp = Cvarp = 0;
        !           776:                }
        !           777: ;
        !           778: 
        !           779: idlist:                id
        !           780:        |       idlist comma id
        !           781: ;
        !           782: 
        !           783: integer:       I2CONST =
        !           784:                        w_con(I2CONST, $1->d_elm);
        !           785:        |       c_variable =
        !           786:                {
        !           787:                        if ($1)
        !           788:                        {
        !           789:                                if (Cvarp)
        !           790:                                        if (Fieldp && Fieldp->c_type == opINT
        !           791:                                           || Cvarp->c_type == opINT)
        !           792:                                                w_var(Cv_display, opINT);
        !           793:                                        else
        !           794:                                                yyserror("integer variable required",
        !           795:                                                $1);
        !           796:                                else
        !           797:                                        yyserror("integer variable required", $1);
        !           798:                        }
        !           799:                        free_display(Cv_display);
        !           800:                }
        !           801: ;
        !           802: 
        !           803: int_list:      integer
        !           804:        |       int_list comma integer
        !           805: ;
        !           806: 
        !           807: param_tl:      LPAREN =
        !           808:                {
        !           809:                        w_op("(");
        !           810:                        end_quote();
        !           811:                        if (Opflag == mdTUPRET)
        !           812:                                w_key("IIw_left");
        !           813:                        else
        !           814:                                w_key("IIw_right");
        !           815:                        eat_display(0, '(', ')');
        !           816:                        w_op(";");
        !           817:                        begin_quote();
        !           818:                        w_op(")");
        !           819: 
        !           820:                }
        !           821: ;
        !           822: 
        !           823: qualclause:    where qual      
        !           824:        |       where c_variable =
        !           825:                {
        !           826:                        if (!$2 || !Cvarp)
        !           827:                                yyserror("C var (string) expected", $2);
        !           828:                        else if (Fieldp && Fieldp->c_type == opSTRING
        !           829:                                || Cvarp->c_type == opSTRING)
        !           830:                        {
        !           831:                                end_quote();
        !           832:                                w_op("IIwrite(");
        !           833:                                w_display(Cv_display);
        !           834:                                w_op(");");
        !           835:                        }
        !           836:                        else
        !           837:                                yyserror("var must be string valued for qualification",
        !           838:                                $2);
        !           839:                        free_display(Cv_display);
        !           840:                        Cvarp = Fieldp = 0;
        !           841:                }
        !           842:        |       ;
        !           843: ;
        !           844: qual:          lparen qual rparen      
        !           845:        |       luop qual               %prec LUOP      
        !           846:        |       qual lbop qual          %prec LBOP      
        !           847:        |       clause  
        !           848:        |       ;
        !           849: ;
        !           850: clause:        afcn rop afcn   
        !           851:        |       afcn rop afcn bdop afcn 
        !           852: ;
        !           853: ctl:           id is id 
        !           854:        |       ctl comma id is id 
        !           855: ;
        !           856: 
        !           857: sconst:                SCONST = 
        !           858:                        w_con(SCONST, $1->d_elm);
        !           859: ;
        !           860: 
        !           861: tlclause:      lparen tlist rparen     
        !           862: ;
        !           863: tlist:         tlelm   
        !           864:        |       tlelm comma tlist       
        !           865: ;
        !           866: tlelm:         id is_key afcn  
        !           867:        |       attrib  
        !           868: ;
        !           869: 
        !           870: /*
        !           871:  * Expressions
        !           872:  */
        !           873: 
        !           874: afcn:          aggrfcn  
        !           875:        |       aggr     
        !           876:        |       attribfcn  
        !           877:        |       afcn bop afcn   %prec BOP  
        !           878:        |       lparen afcn rparen  
        !           879:        |       uop afcn        %prec unaryop   
        !           880:        |       fop lparen afcn rparen  
        !           881:        |       fbop lparen afcn comma afcn rparen      
        !           882: ;
        !           883: aggr:          aop lparen afcn qualclause rparen       
        !           884: ;
        !           885: aggrfcn:       aop lparen afcn by aseq qualclause rparen
        !           886: ;
        !           887: attribfcn:     I2CONST = 
        !           888:                        w_con(I2CONST, $1->d_elm);
        !           889:        |       I4CONST = 
        !           890:                        w_con(I4CONST, $1->d_elm);
        !           891:        |       F8CONST = 
        !           892:                        w_con(F8CONST, $1->d_elm);
        !           893:        |       SCONST  = 
        !           894:                        w_con(SCONST, $1->d_elm);
        !           895:        |       cvar
        !           896:        |       attrib  
        !           897: ;
        !           898: aseq:          aseq comma afcn  
        !           899:        |       afcn    
        !           900: ;
        !           901: attrib:                id period id    
        !           902:        |       id period all=
        !           903:                {
        !           904:                        if (Opflag != mdVIEW && Opflag != mdRETRIEVE
        !           905:                           && Opflag != mdAPPEND)
        !           906:                                yyserror(
        !           907:                                "'all' applied to this range variable illegal in this kind of statement",
        !           908:                                $1);
        !           909:                }
        !           910: ;
        !           911: lbop:          LBOP    = 
        !           912:                        w_key($1->d_elm);
        !           913: ;
        !           914: luop:          LUOP    = 
        !           915:                        w_key($1->d_elm);
        !           916: ;
        !           917: bdop:          BDOP    = 
        !           918:                        w_op($1->d_elm);
        !           919: ;
        !           920: rop:           EOP     = 
        !           921:                        w_op($1->d_elm);
        !           922:        |       BDOP    = 
        !           923:                        w_op($1->d_elm);
        !           924:        |       IS      = 
        !           925:                        w_op("=");
        !           926: ;
        !           927: uop:           UOP = 
        !           928:                        w_op($1->d_elm);
        !           929: ;
        !           930: fop:           FOP = 
        !           931:                        w_key($1->d_elm);
        !           932: ;
        !           933: fbop:          FBOP = 
        !           934:                        w_key($1->d_elm);
        !           935: ;
        !           936: bop:           BOP = 
        !           937:                        w_op($1->d_elm);
        !           938:        |       UOP = 
        !           939:                        w_op($1->d_elm);
        !           940: ;
        !           941: by:            BY =
        !           942:                        w_key($1->d_elm);
        !           943: ;
        !           944: aop:           AOP = 
        !           945:                        w_key($1->d_elm);
        !           946: ;
        !           947:        
        !           948: /*
        !           949:  * Keywords
        !           950:  */
        !           951: 
        !           952: append_p_key:  PARAM APPEND =
        !           953:                {
        !           954:                        begin_quote();
        !           955:                        w_key($2->d_elm);
        !           956:                        Opflag = mdAPPEND;
        !           957:                }
        !           958: ;
        !           959: append_key:    APPEND  =
        !           960:                {
        !           961:                        Opflag = mdAPPEND;
        !           962:                        begin_quote();
        !           963:                        w_key($1->d_elm);
        !           964:                }
        !           965: ;
        !           966: copy_key:      COPY    =
        !           967:                {
        !           968:                        Opflag = mdCOPY;
        !           969:                        begin_quote();
        !           970:                        w_key($1->d_elm);
        !           971:                }
        !           972: ;
        !           973: copy_p_key:    PARAM COPY =
        !           974:                {
        !           975:                        Opflag = mdCOPY;
        !           976:                        begin_quote();
        !           977:                        w_key($2->d_elm);
        !           978:                }
        !           979: ;
        !           980: cp_kword:      INTO    = 
        !           981:                {
        !           982:                        w_key($1->d_elm);
        !           983:                        Opflag = mdFILENAME;
        !           984:                }
        !           985:        |       FROM    = 
        !           986:                {
        !           987:                        w_key($1->d_elm);
        !           988:                        Opflag = mdFILENAME;
        !           989:                }
        !           990: ;
        !           991: create_key:    CREATE  =
        !           992:                {
        !           993:                        Opflag = mdCREATE;
        !           994:                        begin_quote();
        !           995:                        w_key($1->d_elm);
        !           996:                }
        !           997: ;
        !           998: create_p_key:  PARAM CREATE =
        !           999:                {
        !          1000:                        Opflag = mdCREATE;
        !          1001:                        begin_quote();
        !          1002:                        w_key($2->d_elm);
        !          1003:                }
        !          1004: ;
        !          1005: define_key:    DEFINE =
        !          1006:                {
        !          1007:                        Opflag = mdDEFINE;
        !          1008:                        begin_quote();
        !          1009:                        w_key($1->d_elm);
        !          1010:                }
        !          1011: ;
        !          1012: delete_key:    DELETE  =
        !          1013:                {
        !          1014:                        Opflag = mdDELETE;
        !          1015:                        begin_quote();
        !          1016:                        w_key($1->d_elm);
        !          1017:                }
        !          1018: ;
        !          1019: destroy_key:   DESTROY =
        !          1020:                {
        !          1021:                        Opflag = mdDESTROY;
        !          1022:                        begin_quote();
        !          1023:                        w_key($1->d_elm);
        !          1024:                }
        !          1025: ;
        !          1026: help_key:      HELP =
        !          1027:                {
        !          1028:                        Opflag = mdHELP;
        !          1029:                        begin_quote();
        !          1030:                        w_key($1->d_elm);
        !          1031:                }
        !          1032: ;
        !          1033: index_key:     INDEX ON =
        !          1034:                {
        !          1035:                        Opflag = mdINDEX;
        !          1036:                        begin_quote();
        !          1037:                        w_key($1->d_elm);
        !          1038:                        w_key($2->d_elm);
        !          1039:                }
        !          1040: ;
        !          1041: ingres_key:    INGRES  =
        !          1042:                {
        !          1043:                        Opflag = mdINGRES;
        !          1044:                        w_new("IIingres(");
        !          1045:                }
        !          1046: ;
        !          1047: integ_key:     INTEGRITY=
        !          1048:                {
        !          1049:                        if (Opflag == mdDEFINE)
        !          1050:                                Opflag = mdINTEGRITY;
        !          1051:                        w_key($1->d_elm);
        !          1052:                }
        !          1053: ;
        !          1054: is_key:                IS =
        !          1055:                { 
        !          1056:                        if (Opflag == mdCTLELM)
        !          1057:                                Opflag = mdTUPRET;
        !          1058:                        w_op("=");
        !          1059:                }
        !          1060:        |       BY = 
        !          1061:                        w_key($1->d_elm);
        !          1062: ;
        !          1063: modify_key:    MODIFY  =
        !          1064:                {
        !          1065:                        Opflag = mdMODIFY;
        !          1066:                        begin_quote();
        !          1067:                        w_key($1->d_elm);
        !          1068:                }
        !          1069: ;
        !          1070: permit_key:    PERMIT=
        !          1071:                {
        !          1072:                        if (Opflag == mdDEFINE)
        !          1073:                                Opflag = mdINTEGRITY;
        !          1074:                        w_key($1->d_elm);
        !          1075:                }
        !          1076: ;
        !          1077: print_key:     PRINT   =  
        !          1078:                { 
        !          1079:                        Opflag = mdPRINT;
        !          1080:                        begin_quote();
        !          1081:                        w_key($1->d_elm);
        !          1082:                }
        !          1083: ;
        !          1084: range_of:      RANGE OF = 
        !          1085:                {
        !          1086:                        Opflag = mdRANGE;
        !          1087:                        begin_quote();
        !          1088:                        w_key($1->d_elm);
        !          1089:                        w_key($2->d_elm);
        !          1090:                }
        !          1091: ;
        !          1092: replace_key:   REPLACE =
        !          1093:                {
        !          1094:                        Opflag = mdREPLACE;
        !          1095:                        begin_quote();
        !          1096:                        w_key($1->d_elm);
        !          1097:                }
        !          1098: ;
        !          1099: replace_p_key: PARAM REPLACE =
        !          1100:                {
        !          1101:                        begin_quote();
        !          1102:                        Opflag = mdREPLACE;
        !          1103:                        w_key($2->d_elm);
        !          1104:                }
        !          1105: ;
        !          1106: retrieve_key:  RETRIEVE        =
        !          1107:                {
        !          1108:                        Opflag = mdRETRIEVE;
        !          1109:                        begin_quote();
        !          1110:                        w_key($1->d_elm);
        !          1111:                }
        !          1112: ;
        !          1113: retrieve_p_key: PARAM RETRIEVE =
        !          1114:                {
        !          1115:                        Opflag = mdRETRIEVE;
        !          1116:                        begin_quote();
        !          1117:                        w_key($2->d_elm);
        !          1118:                }
        !          1119: ;
        !          1120: save_key:      SAVE    =
        !          1121:                {
        !          1122:                        Opflag = mdSAVE;
        !          1123:                        begin_quote();
        !          1124:                        w_key($1->d_elm);
        !          1125:                }
        !          1126: ;
        !          1127: struct_key:    STRUCT =
        !          1128:                {
        !          1129:                        Opflag = mdDECL;
        !          1130:                        Struct_flag = 1;
        !          1131:                        w_key($1->d_elm);
        !          1132:                }
        !          1133: ;
        !          1134: tupret_p_key:  PARAM RETRIEVE =
        !          1135:                {
        !          1136:                        begin_quote();
        !          1137:                        w_key($2->d_elm);
        !          1138:                        Opflag = mdTUPRET;
        !          1139:                }
        !          1140: ;
        !          1141: view_key:      VIEW =
        !          1142:                {
        !          1143:                        if (Opflag == mdDEFINE)
        !          1144:                                Opflag = mdVIEW;
        !          1145:                        w_key($1->d_elm);
        !          1146:                }
        !          1147: ;
        !          1148: 
        !          1149: /*
        !          1150:  * Noise words and punctuation
        !          1151:  */
        !          1152: 
        !          1153: all:           ALL=
        !          1154:                        w_key($1->d_elm);
        !          1155: ;
        !          1156: apkword:       INTO    
        !          1157:        |       ONTO    
        !          1158:        |       TO      
        !          1159:        |       ON      
        !          1160:        |       ;
        !          1161: ;
        !          1162: at:            AT =
        !          1163:                        w_key($1->d_elm);
        !          1164: ;
        !          1165: colon:         COLON =
        !          1166:                        w_op($1->d_elm);
        !          1167: ;
        !          1168: comma:         COMMA   = 
        !          1169:                        w_op($1->d_elm);
        !          1170: ;
        !          1171: delnoise:      IN      
        !          1172:        |       ON      
        !          1173:        |       FROM    
        !          1174:        |       ;
        !          1175: ;
        !          1176: from:          FROM =
        !          1177:                        w_key($1->d_elm);
        !          1178: ;
        !          1179: integnoise:    ON
        !          1180:        |       ONTO
        !          1181:        |       IN
        !          1182:        |       OF
        !          1183: ;
        !          1184: is:            IS      = 
        !          1185:                        w_op("=");
        !          1186: ;
        !          1187: isnoise:       IS
        !          1188:        |       ;
        !          1189: ;
        !          1190: lbrace:                LBRACE =
        !          1191:                        w_op($1->d_elm);
        !          1192: ;
        !          1193: lparen:                LPAREN  = 
        !          1194:                        w_op($1->d_elm);
        !          1195: ;
        !          1196: of:            OF=
        !          1197:                        w_key($1->d_elm);
        !          1198: ;
        !          1199: on:            ON =
        !          1200:                        w_key($1->d_elm);
        !          1201: ;
        !          1202: period:                PERIOD =
        !          1203:                        w_op($1->d_elm);
        !          1204: ;
        !          1205: repkword:      INTO    
        !          1206:        |       IN      
        !          1207:        |       ON      
        !          1208:        |       ;
        !          1209: ;
        !          1210: rparen:                RPAREN  =
        !          1211:                        w_op($1->d_elm);
        !          1212: ;
        !          1213: to:            TO = 
        !          1214:                        w_key($1->d_elm);
        !          1215: ;
        !          1216: retkword:      INTO    
        !          1217:        |       TO      
        !          1218:        |       ;
        !          1219: ;
        !          1220: until:         UNTIL   = 
        !          1221:                        w_key($1->d_elm);
        !          1222: ;
        !          1223: where:         WHERE   = 
        !          1224:                        w_key($1->d_elm);
        !          1225: ;
        !          1226: %%
        !          1227: 
        !          1228: # include      "tokens.y"

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.