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

1.1     ! root        1: /*
        !             2: **  GRAMMAR.Y
        !             3: **
        !             4: **     This file contains a grammar for ingres parsing.  It is setup
        !             5: **     for the (7-31-78) version of yacc.
        !             6: **
        !             7: **     Use:
        !             8: **             to use for non-distributed ingres:
        !             9: **                     grep -v "DDD" > grammar.y
        !            10: **
        !            11: **     Trace Flags:
        !            12: **             Grammar.y ~~ 38, 39
        !            13: */
        !            14: 
        !            15: %{
        !            16: /* SCANNER/PARSER GLOBALS & TABLES */
        !            17: # include      <ingres.h>
        !            18: # include      <aux.h>
        !            19: # include      <tree.h>
        !            20: # include      <symbol.h>
        !            21: # include      <pv.h>
        !            22: # include      "parser.h"
        !            23: # include      <sccs.h>
        !            24: 
        !            25: SCCSID(@(#)grammar.y   7.2     4/7/82)
        !            26: 
        !            27: # ifdef                xPTR1
        !            28: # define       YYDEBUG
        !            29: # endif
        !            30: 
        !            31: int                            i;
        !            32: struct atstash                 *aptr;
        !            33: char                           permbuf[3];
        !            34: /* space for two names, their null bytes and the seperator */
        !            35: char                           modbuf[(2 * (MAXNAME + 1)) + 1];
        !            36: static char                    hqmbuf[2];
        !            37: 
        !            38: extern DESC                    Reldesc;
        !            39: extern int                     Opflag;
        !            40: extern QTREE                   *Lastree;
        !            41: extern QTREE                   *Tidnode;
        !            42: extern int                     Rsdmno;
        !            43: extern int                     Resrng;
        !            44: extern int                     Qrymod;
        !            45: extern int                     Permcomd;
        !            46: extern char                    *Trname;
        !            47: extern int                     Qlflag;
        !            48: extern struct atstash          Faketid;
        !            49: 
        !            50: # ifdef        DISTRIB
        !            51: extern struct atstash          Fakesid;
        !            52: # endif
        !            53: 
        !            54: extern int                     Patflag;
        !            55: extern char                    *Indexname;
        !            56: 
        !            57: extern QTREE                   *tree();
        !            58: extern QTREE                   *tlprepend();
        !            59: extern QTREE                   *addresdom();
        !            60: extern QTREE                   *xdot();
        !            61: extern QTREE                   *norml();
        !            62: extern struct atstash          *attlookup();
        !            63: extern int                     rngent();
        !            64: extern int                     rnglook();
        !            65: extern PARRNG                  Parrng[];
        !            66: %}
        !            67: 
        !            68: /* NEW BEGIN-END THINGS */
        !            69: %start         program
        !            70: 
        !            71: /* UNION YYSTYPE DEFINED */
        !            72: %union
        !            73: {
        !            74:        int                             type_type;      /* OPERATOR TYPES ETC. */
        !            75:        QTREE                           *tree_type;
        !            76:        int                             rng_type;
        !            77:        char                            char_type;
        !            78:        int                             int_type;
        !            79:        short                           *I2_type;
        !            80:        long                            *I4_type;
        !            81:        float                           *F4_type;
        !            82:        double                          *F8_type;
        !            83:        char                            *string_type;
        !            84: }
        !            85: 
        !            86: /* COMMANDS */
        !            87: %token         APPEND  COPY    CREATE  DELETE  DESTROY HELP    INDEX   MODIFY
        !            88: %token         PRINT   RANGE   REPLACE RETRIEVE        SAVE            
        !            89: %token         DEFINE  PERMIT  VIEW    INTEGRITY
        !            90: /*DDD*/%token  DISTRIBUTE
        !            91: 
        !            92: /* 'NOISE' WORDS */
        !            93: %token         ALL     BY      FROM    IN      INTO    UNIQUE  AT
        !            94: %token         IS      OF      ON      ONTO    TO      UNTIL   WHERE
        !            95: /*DDD*/%token  DISTRD
        !            96: 
        !            97: /* CONSTANTS */
        !            98: %token         NAME    SCONST  I2CONST I4CONST F4CONST F8CONST
        !            99: 
        !           100: /* PUNCTUATION */
        !           101: %token         COMMA   LPAREN  PERIOD  RPAREN  COLON   BGNCMNT ENDCMNT
        !           102: 
        !           103: /* UNARY ARITHMETIC OPERATORS */
        !           104: %token         UAOP
        !           105: 
        !           106: /* BINARY ARITHMETIC OPERATORS */
        !           107: %token         BAOP    BAOPH
        !           108: 
        !           109: /* BOUNDS OPERATORS */
        !           110: %token         BDOP
        !           111: 
        !           112: /* EQUALITY OPERATORS */
        !           113: %token         EOP
        !           114: 
        !           115: /* LOGICAL OPERATORS */
        !           116: %token         LBOP    LUOP
        !           117: 
        !           118: /* FUNCTIONAL OPERATORS */
        !           119: %token         FOP     FBOP
        !           120: 
        !           121: /* AGGREGATE OPERATORS */
        !           122: %token         AGOP
        !           123: 
        !           124: /* TYPES FOR INGRES TOKENS */
        !           125: %type  <type_type>     IS
        !           126: %type  <string_type>   NAME    SCONST
        !           127: %type  <I2_type>       I2CONST
        !           128: %type  <I4_type>       I4CONST
        !           129: %type  <F4_type>       F4CONST
        !           130: %type  <F8_type>       F8CONST
        !           131: %type  <type_type>     UAOP
        !           132: %type  <type_type>     BAOP    BAOPH
        !           133: %type  <type_type>     BDOP
        !           134: %type  <type_type>     EOP
        !           135: %type  <type_type>     LBOP    LUOP
        !           136: %type  <type_type>     FOP     FBOP
        !           137: %type  <type_type>     AGOP
        !           138: 
        !           139: /* TYPES FOR INGRES NON-TERMINALS */
        !           140: %type  <tree_type>     permtarg        permtlist       permtlelm
        !           141: /*DDD*/%type   <tree_type>     distribute      distcrits       dcriterion
        !           142: %type  <tree_type>     tlclause        tlist   tlelm
        !           143: %type  <tree_type>     qualclause      qual    clause  afcn    aggrfcn
        !           144: %type  <type_type>     relop
        !           145: %type  <tree_type>     domseq  targdom attrib
        !           146: %type  <rng_type>      var
        !           147: %type  <tree_type>     attribfcn
        !           148: %type  <type_type>     uop
        !           149: %type  <string_type>   alias
        !           150: 
        !           151: /* DEFINE ASCENDING PRECEDENCE FOR OPERATORS */
        !           152: %left          LBOP
        !           153: %left          LUOP
        !           154: %left          UAOP
        !           155: %left          BAOP
        !           156: %left          BAOPH
        !           157: %nonassoc      unaryop
        !           158: 
        !           159: %%
        !           160: program:       program stmnt =
        !           161:                {
        !           162: #                      ifdef   xPTR1
        !           163:                        tTfp(38, 0, "*** [program stmnt] parsed.\n");
        !           164: #                      endif
        !           165: 
        !           166:                        if (endquelst(Opflag) < 0)
        !           167:                                return (-1);
        !           168:                }
        !           169:        |       stmnt =
        !           170:                {
        !           171: #                      ifdef   xPTR1
        !           172:                        tTfp(38, 1, "*** [stmnt] parsed.\n");
        !           173: #                      endif
        !           174: 
        !           175:                        if (endquelst(Opflag) < 0)
        !           176:                                return (-1);
        !           177:                }
        !           178:        |
        !           179:                {
        !           180: #                      ifdef   xPTR1
        !           181:                        tTfp(38, 2, "*** [(NULL)] parsed.\n");
        !           182: #                      endif
        !           183:                }
        !           184: ;
        !           185: stmnt:         append
        !           186:        |       copy
        !           187:        |       create
        !           188:        |       delete  
        !           189:        |       destroy
        !           190: /*DDD*/        |       distribute
        !           191:        |       help
        !           192:        |       index   
        !           193:        |       integrity
        !           194:        |       modify
        !           195:        |       permit
        !           196:        |       print
        !           197:        |       range
        !           198:        |       replace 
        !           199:        |       retrieve 
        !           200:        |       save
        !           201:        |       view
        !           202:        |       error
        !           203:                {
        !           204: #                      ifdef   xPTR1
        !           205:                        tTfp(38, 0, "*** [error] parsed.\n");
        !           206: #                      endif
        !           207:                }
        !           208: 
        !           209: ;
        !           210: range:         rngstmnt OF NAME IS NAME =
        !           211:                {
        !           212:                        if ((i = openr(&Reldesc, -1, $5)) < 0)
        !           213:                                syserr("relname: error in openr '%d'", i);
        !           214:                        if (i > 0)
        !           215:                        {
        !           216:                                /* invalid relation name */
        !           217:                                par_error(RNGEXIST, WARN, $5, 0);
        !           218:                                YYERROR;
        !           219:                        }
        !           220:                        else
        !           221:                                rngent(R_EXTERNAL, $3, &Reldesc);
        !           222:                }
        !           223: ;
        !           224: rngstmnt:      RANGE =
        !           225:                {
        !           226:                        Opflag = mdRANGE;
        !           227:                }
        !           228: ;
        !           229: append:                apstmnt apto relation tlclause qualclause =
        !           230:                {
        !           231:                        /* make root node */
        !           232:                        Lastree = tree($4, $5, ROOT, sizeof(struct rootnode), 1);
        !           233:                }
        !           234: ;
        !           235: apstmnt:       APPEND =
        !           236:                {
        !           237:                        Opflag = mdAPP;
        !           238:                }
        !           239: ;
        !           240: apto:          INTO
        !           241:        |       ONTO
        !           242:        |       TO
        !           243:        |       ON
        !           244:        |       ;
        !           245: ;
        !           246: delete:                delstmnt delwd relation qualclause =
        !           247:                {
        !           248:                        /* make root node for delete, with a TIDNODE at leftmost */
        !           249:                        Lastree = tree(tree(NULL, Tidnode, RESDOM, sizeof(struct resdomnode), NULL), $4, ROOT, sizeof(struct rootnode), 1);
        !           250:                }
        !           251: ;
        !           252: delstmnt:      DELETE =
        !           253:                {
        !           254:                        Opflag = mdDEL;
        !           255:                }
        !           256: ;
        !           257: delwd:         IN
        !           258:        |       ON
        !           259:        |       FROM
        !           260:        |       ;
        !           261: ;
        !           262: replace:       repstmnt repkwd relation tlclause qualclause =
        !           263:                {
        !           264:                        /* make root node for replace */
        !           265:                        Lastree = tree($4, $5, ROOT, sizeof(struct rootnode), 1);
        !           266:                }
        !           267: ;
        !           268: repstmnt:      REPLACE =
        !           269:                {
        !           270:                        Opflag = mdREPL;
        !           271:                }
        !           272: ;
        !           273: repkwd:                INTO
        !           274:        |       IN
        !           275:        |       ON
        !           276:        |       ;
        !           277: ;
        !           278: retrieve:      retstmnt retclause tlclause qualclause =
        !           279:                {
        !           280:                        /* make root node for retrieve */
        !           281:                        Lastree = tree($3, $4, ROOT, sizeof(struct rootnode), 1);
        !           282:                }
        !           283: ;
        !           284: retstmnt:      RETRIEVE =
        !           285:                {
        !           286:                        Opflag = mdRETR;
        !           287:                }
        !           288: ;
        !           289: retclause:     retkwd relation =
        !           290:                {
        !           291:                        /* set up pipe block and save relname for create */
        !           292: #                      ifdef   xPTR2
        !           293:                        tTfp(38, 4, "retclause: Rsdmno %d", Rsdmno);
        !           294: #                      endif
        !           295:                        Rsdmno = 0;
        !           296:                        setp(PV_STR, "0");      /* relstat = nil */
        !           297:                        setp(PV_STR, trim_relname(Parrng[Resrng].vardesc.reldum.relid));
        !           298:                }
        !           299:        |       =
        !           300:                {
        !           301:                        /* no result relation, output to terminal */
        !           302:                        Rsdmno = 0;
        !           303:                        Resrng = -1;
        !           304:                }
        !           305:        |       UNIQUE =
        !           306:                {
        !           307:                        Opflag = mdRET_UNI;
        !           308:                        Rsdmno = 0;
        !           309:                        Resrng = -1;
        !           310:                }
        !           311: ;
        !           312: retkwd:                INTO
        !           313:        |       TO
        !           314:        |       ;
        !           315: ;
        !           316: view:          viewclause tlclause qualclause =
        !           317:                {
        !           318:                        Lastree = tree($2, $3, ROOT, sizeof(struct rootnode), 1);
        !           319:                }
        !           320: ;
        !           321: viewclause:    viewstmnt relation =
        !           322:                {
        !           323:                        Rsdmno = 0;
        !           324:                        setp(PV_STR, "0040");   /* relstat = S_VIEW */
        !           325:                        setp(PV_STR, trim_relname(Parrng[Resrng].vardesc.reldum.relid));
        !           326:                }
        !           327: ;
        !           328: viewstmnt:     DEFINE VIEW =
        !           329:                {
        !           330:                        Opflag = mdVIEW;
        !           331:                        if (!Qrymod)
        !           332:                        {
        !           333:                                /* no qrymod in database */
        !           334:                                par_error(NOQRYMOD, WARN, 0);
        !           335:                        }
        !           336:                }
        !           337: ;
        !           338: permit:                permstmnt permlist permrel permtarg permwho permplace permtd qualclause =
        !           339:                {
        !           340:                        Lastree = tree($4, $8, ROOT, sizeof(struct rootnode), 1);
        !           341:                }
        !           342: ;
        !           343: permstmnt:     DEFINE PERMIT =
        !           344:                {
        !           345:                        Opflag = mdPROT;
        !           346:                        if (!Qrymod)
        !           347:                        {
        !           348:                                /* no qrymod in database */
        !           349:                                par_error(NOQRYMOD, WARN, 0);
        !           350:                        }
        !           351:                }
        !           352: ;
        !           353: permlist:      permxlist
        !           354:        |       permlist COMMA permxlist
        !           355: ;
        !           356: permxlist:     ALL =
        !           357:                {
        !           358:                        permcom(-1);    /* means 'all' commands */
        !           359:                }
        !           360:        |       RETRIEVE =
        !           361:                {
        !           362:                        permcom(mdRETR);
        !           363:                }
        !           364:        |       DELETE =
        !           365:                {
        !           366:                        permcom(mdDEL);
        !           367:                }
        !           368:        |       APPEND =
        !           369:                {
        !           370:                        permcom(mdAPP);
        !           371:                }
        !           372:        |       REPLACE =
        !           373:                {
        !           374:                        permcom(mdREPL);
        !           375:                }
        !           376: ;
        !           377: permrel:       permword relation =
        !           378:                {
        !           379:                        /* put command vector into list now since this always happens */
        !           380:                        setp(PV_INT, Permcomd);
        !           381:                        Permcomd = 0;           /* reset command map */
        !           382:                        setp(PV_STR, trim_relname(Parrng[Resrng].vardesc.reldum.relid));
        !           383:                        bmove(Parrng[Resrng].vardesc.reldum.relowner, permbuf, 2);
        !           384:                        permbuf[2] = 0;
        !           385:                        setp(PV_STR, permbuf);
        !           386:                }
        !           387: ;
        !           388: permword:      ON
        !           389:        |       OF
        !           390:        |       TO
        !           391: ;
        !           392: permtarg:      LPAREN permtlist RPAREN =
        !           393:                {
        !           394:                        $$ = $2;
        !           395:                }
        !           396:        |       =
        !           397:                {
        !           398:                        $$ = NULL;
        !           399:                }
        !           400: ;
        !           401: permtlist:     permtlelm
        !           402:        |       permtlist COMMA permtlelm =
        !           403:                {
        !           404:                        /*
        !           405:                        ** attach bulk of permit tl to leftmost node of new elem
        !           406:                        */
        !           407:                        if (!Err_current)
        !           408:                                $$ = tlprepend($1, $3);
        !           409:                }
        !           410: ;
        !           411: permtlelm:     NAME =
        !           412:                {
        !           413:                        /* Resrng is set by the "relation" production */
        !           414:                        if (!Err_current)
        !           415:                        {
        !           416:                                Trname = $1;
        !           417:                                aptr = attlookup(Resrng, Trname);
        !           418:                                $$ = tree(NULL, NULL, VAR, sizeof(struct varnode), Resrng, aptr);
        !           419:                                $$ = addresdom(NULL, $$);
        !           420:                        }
        !           421:                }
        !           422: ;
        !           423: permwho:       TO NAME =
        !           424:                {
        !           425:                        setp(PV_STR, $2);
        !           426:                }
        !           427:        |       TO ALL =
        !           428:                {
        !           429:                        setp(PV_STR, "all");
        !           430:                }
        !           431: ;
        !           432: permplace:     AT NAME =
        !           433:                {
        !           434:                        setp(PV_STR, $2);
        !           435:                }
        !           436:        |       AT ALL =
        !           437:                {
        !           438:                        setp(PV_STR, "all");
        !           439:                }
        !           440:        |       =
        !           441:                {
        !           442:                        setp(PV_STR, "all");            /* default is all */
        !           443:                }
        !           444: ;
        !           445: permtd:                permtime permday
        !           446:        |       permdeftime permday
        !           447:        |       permtime permdefday
        !           448:        |       permdeftime permdefday
        !           449: ;
        !           450: permdeftime:   =
        !           451:                {
        !           452:                        setp(PV_INT, 0);
        !           453:                        setp(PV_INT, 1440);
        !           454:                }
        !           455: ;
        !           456: permdefday:    =
        !           457:                {
        !           458:                        setp(PV_STR, "sun");
        !           459:                        setp(PV_STR, "sat");
        !           460:                }
        !           461: ;
        !           462: permtime:      FROM I2CONST COLON I2CONST TO I2CONST COLON I2CONST =
        !           463:                {
        !           464:                        setp(PV_INT, timeofday($2, $4));
        !           465:                        setp(PV_INT, timeofday($6, $8));
        !           466:                }
        !           467: ;
        !           468: permday:       ON NAME TO NAME =
        !           469:                {
        !           470:                        setp(PV_STR, $2);
        !           471:                        setp(PV_STR, $4);
        !           472:                }
        !           473: ;
        !           474: integrity:     integstmnt integnoise relation integis qual =
        !           475:                {
        !           476:                        Lastree = tree(NULL, norml($5), ROOT, sizeof(struct rootnode), 1);
        !           477:                        Qlflag--;       /* turn off here */
        !           478:                }
        !           479: ;
        !           480: integstmnt:    DEFINE INTEGRITY =
        !           481:                {
        !           482:                        Opflag = mdINTEG;
        !           483:                        Qlflag++;       /* OK to turn on here because integrity doesn't have a targ list */
        !           484:                        if (!Qrymod)
        !           485:                        {
        !           486:                                /* no qrymod in database */
        !           487:                                par_error(NOQRYMOD, WARN, 0);
        !           488:                        }
        !           489:                }
        !           490: ;
        !           491: integnoise:    ON
        !           492:        |       ONTO
        !           493:        |       IN
        !           494:        |       OF
        !           495:        |       /* null */
        !           496: ;
        !           497: integis:       IS
        !           498:        |       /* null*/
        !           499: ;
        !           500: /*DDD*/distribute:     diststmnt relation AT distcrits =
        !           501: /*DDD*/                {
        !           502: /*DDD*/                        if (!Err_current)
        !           503: /*DDD*/                        {
        !           504: /*DDD*/                                $$ = tree(NULL, NULL, QLEND, 0);
        !           505: /*DDD*/                                Lastree = tree($4, $$, ROOT, sizeof(struct rootnode), 1);
        !           506: /*DDD*/                        }
        !           507: /*DDD*/                }
        !           508: /*DDD*/;
        !           509: /*DDD*/diststmnt:      DISTRIBUTE =
        !           510: /*DDD*/                                Opflag = mdDISTRIB;
        !           511: /*DDD*/;
        !           512: /*DDD*/distcrits:      dcriterion =
        !           513: /*DDD*/                {
        !           514: /*DDD*/                        $$ = $1;
        !           515: /*DDD*/                }
        !           516: /*DDD*/        |       distcrits dcriterion =
        !           517: /*DDD*/                {
        !           518: /*DDD*/                        $$ = tlprepend($1, $2);
        !           519: /*DDD*/                }
        !           520: /*DDD*/;
        !           521: /*DDD*/dcriterion:     NAME where qual =
        !           522: /*DDD*/                {
        !           523: /*DDD*/                        Qlflag--;
        !           524: /*DDD*/                        syserr("Warning this node may be the wrong size\n");
        !           525: /*DDD*/                        if (!Err_current)
        !           526: /*DDD*/                                $$ = tree(NULL, norml($3), SITE, 2, $1);
        !           527: /*DDD*/                }
        !           528: /*DDD*/;
        !           529: relation:      NAME =
        !           530:                {
        !           531: #                      ifdef   xPTR2
        !           532:                        tTfp(38, 3, "res rel name/var: '%s'\n", $1);
        !           533: #                      endif
        !           534:                        switch (Opflag)
        !           535:                        {
        !           536:                          case mdRETR:
        !           537:                          case mdVIEW:
        !           538:                                /* result better not be a rel name */
        !           539:                                if ((i = openr(&Reldesc, -1, $1)) < 0)
        !           540:                                        syserr("relation: err openr '%d'", i);
        !           541:                                if (i == 0)
        !           542:                                {
        !           543:                                        /* reln exists */
        !           544:                                        if (bequal(Reldesc.reldum.relowner, Usercode, 2))
        !           545:                                        {
        !           546:                                                /* same owner, can't duplicate name */
        !           547:                                                par_error(RESEXIST, WARN, $1, 0);
        !           548:                                                YYERROR;
        !           549:                                        }
        !           550:                                        else if (!Err_current)
        !           551:                                        {
        !           552:                                                /* owned by dba -- purge range table */
        !           553:                                                rngdel($1);
        !           554:                                        }
        !           555:                                }
        !           556:                                if (!Err_current)
        !           557:                                {
        !           558:                                        bmove(Usercode, Reldesc.reldum.relowner, 2);
        !           559:                                        pmove($1, Reldesc.reldum.relid, MAXNAME, ' ');
        !           560:                                        Resrng = rngent(R_INTERNAL, "", &Reldesc);
        !           561:                                }
        !           562:                                break;
        !           563: 
        !           564:                          case mdAPP:
        !           565:                                /* result is a rel name */
        !           566:                                if (!Err_current)
        !           567:                                {
        !           568:                                        Resrng = rnglook($1, LOOKREL);
        !           569:                                        if (Resrng < 0)
        !           570:                                        {
        !           571:                                                if ((i = openr(&Reldesc, -1, $1)) < 0)
        !           572:                                                        syserr("relation: err openr '%d'", i);
        !           573:                                                if (i)
        !           574:                                                {
        !           575:                                                        /* invalid relation name */
        !           576:                                                        par_error(RESAPPEX, WARN, $1, 0);
        !           577:                                                        YYERROR;
        !           578:                                                }
        !           579:                                                Resrng = rngent(R_INTERNAL, "", &Reldesc);
        !           580:                                        }
        !           581:                                        else
        !           582:                                                ctlmod_decl(Resrng);
        !           583:                                        checkupd(Resrng);
        !           584:                                }
        !           585:                                break;
        !           586: 
        !           587:                          case mdPROT:
        !           588:                          case mdINTEG:
        !           589: #                        ifdef DISTRIB
        !           590:                          case mdDISTRIB:
        !           591: #                        endif
        !           592:                                /* the result is a tuple variable */
        !           593:                                Resrng = rnglook($1, LOOKVAR);
        !           594:                                if (Resrng < 0)
        !           595:                                {
        !           596:                                        /* variable not declared */
        !           597:                                        par_error(NOVBLE, WARN, $1, 0);
        !           598:                                        YYERROR;
        !           599:                                }
        !           600:                                else
        !           601:                                        ctlmod_decl(Resrng);
        !           602:                                break;
        !           603: 
        !           604:                          case mdREPL:
        !           605:                          case mdDEL:
        !           606:                                /* the result is a tuple variable */
        !           607:                                Resrng = rnglook($1, LOOKVAR);
        !           608:                                if (Resrng < 0)
        !           609:                                        /* variable not declared */
        !           610:                                {
        !           611:                                        par_error(NOVBLE, WARN, $1, 0);
        !           612:                                        YYERROR;
        !           613:                                }
        !           614:                                else
        !           615:                                        ctlmod_decl(Resrng);
        !           616: 
        !           617:                                checkupd(Resrng);
        !           618:                                Tidnode = tree(NULL, NULL, VAR, sizeof(struct varnode), Resrng, &Faketid);
        !           619:                                break;
        !           620:                        }
        !           621:                }
        !           622: ;
        !           623: tlclause:      LPAREN tlist RPAREN =
        !           624:                {
        !           625:                        if (Patflag)
        !           626:                        {
        !           627:                                /* no patt match in targ list */
        !           628:                                par_error(NOPATMAT, WARN, 0);
        !           629:                        }
        !           630:                        $$ = $2;
        !           631: 
        !           632:                        /*
        !           633:                        ** replace must have tid node as left branch
        !           634:                        **      (so does delete but it doesn't have a targ list)
        !           635:                        */
        !           636:                        if (Opflag == mdREPL && !Err_current)
        !           637:                        {
        !           638:                                $$ = tlprepend(tree(NULL, Tidnode, RESDOM, sizeof(struct resdomnode), 0), $$);
        !           639:                        }
        !           640:                }
        !           641: ;
        !           642: tlist:         tlelm
        !           643:        |       tlist COMMA tlelm =
        !           644:                {
        !           645:                        /*
        !           646:                        ** attach bulk of targ list to leftmost node
        !           647:                        ** of new element
        !           648:                        */
        !           649:                        if (!Err_current)
        !           650:                                $$ = tlprepend($1, $3);
        !           651:                }
        !           652: ;
        !           653: tlelm:         NAME is afcn =
        !           654:                {
        !           655:                        Trname = $1;
        !           656:                        /* make a new resdom entry for targ list */
        !           657:                        if (!Err_current)
        !           658:                                $$ = addresdom(NULL, $3);
        !           659:                }
        !           660:        |       attrib =
        !           661:                {
        !           662:                        /* makes a new resdom entry for targ list */
        !           663:                        if (!Err_current)
        !           664:                                $$ = addresdom(NULL, $1);
        !           665:                }
        !           666:        |       var PERIOD ALL =
        !           667:                {
        !           668:                        if (Opflag == mdREPL)
        !           669:                        {
        !           670:                                /* ALL not defined for REPLACE */
        !           671:                                par_error(REPALL, WARN,
        !           672:                                    trim_relname(Qt.qt_rangev[$1].rngvdesc->relvname), 0);
        !           673:                                YYERROR;
        !           674:                        }
        !           675:                        /* makes set of new resdom entries for targ list */
        !           676:                        else if (!Err_current)
        !           677:                                $$ = xdot($1);
        !           678:                }
        !           679: ;
        !           680: is:            IS
        !           681:        |       BY
        !           682: ;
        !           683: qualclause:    where qual =
        !           684:                {
        !           685:                        $$ = norml($2);
        !           686:                        Qlflag--;
        !           687:                }
        !           688:        |       =
        !           689:                {
        !           690:                        /* null qualification */
        !           691:                        $$ = norml(NULL);
        !           692:                }
        !           693: ;
        !           694: where:         WHERE =
        !           695:                {
        !           696:                        Qlflag++;
        !           697:                }
        !           698: ;
        !           699: qual:          LPAREN qual RPAREN =
        !           700:                {
        !           701:                        $$ = $2;
        !           702:                }
        !           703:        |       LUOP qual =
        !           704:                {
        !           705:                        $$ = tree(NULL, $2, UOP, 2, $1);
        !           706:                }
        !           707:        |       qual LBOP qual =
        !           708:                {
        !           709:                        $$ = tree($1, $3, $2, sizeof (struct rootnode) -2, 0);
        !           710:                }
        !           711:        |       clause
        !           712: ;
        !           713: clause:                afcn relop afcn =
        !           714:                {
        !           715:                        $$ = tree($1, $3, BOP, 2, $2);
        !           716:                }
        !           717: ;
        !           718: relop:         EOP
        !           719:        |       IS
        !           720:        |       BDOP
        !           721: ;
        !           722: afcn:          aggrfcn
        !           723:        |       attribfcn
        !           724:        |       afcn BAOPH afcn =
        !           725:                {
        !           726:                        $$ = tree($1, $3, BOP, 2, $2);
        !           727:                }
        !           728:        |       afcn BAOP afcn =
        !           729:                {
        !           730:                        $$ = tree($1, $3, BOP, 2, $2);
        !           731:                }
        !           732:        |       afcn UAOP afcn =
        !           733:                {
        !           734:                        $$ = tree($1, $3, BOP, 2, $2);
        !           735:                }
        !           736:        |       LPAREN afcn RPAREN =
        !           737:                {
        !           738:                        $$ = $2;
        !           739:                }
        !           740:        |       uop afcn        %prec unaryop   =
        !           741:                {
        !           742:                        $$ = tree(NULL, $2, UOP, 2, $1);
        !           743:                }
        !           744:        |       FOP LPAREN afcn RPAREN =
        !           745:                {
        !           746:                        $$ = tree($3, NULL, UOP, 2, $1);
        !           747:                }
        !           748:        |       FBOP LPAREN afcn COMMA afcn RPAREN =
        !           749:                {
        !           750:                        $$ = tree($3, $5, BOP, 2, $1);
        !           751:                }
        !           752: ;
        !           753: aggrfcn:       AGOP LPAREN afcn BY domseq qualclause RPAREN =
        !           754:                {
        !           755: #                      ifdef   xPTR2
        !           756:                        tTfp(39, 0, "agg func\n");
        !           757: #                      endif
        !           758:                        windup($5);
        !           759:                        $$ = tree(tree($5, tree(NULL, $3, AOP, 6, $1), BYHEAD, sizeof(struct resdomnode), 0), $6, AGHEAD, sizeof(struct rootnode), 0);
        !           760:                        tlprepend(tree(NULL, NULL, TREE, 0), $$);
        !           761:                }
        !           762:        |       AGOP LPAREN afcn qualclause RPAREN =
        !           763:                {
        !           764:                        $$ = tree(tree(NULL, $3, AOP, 6, $1), $4,  AGHEAD, sizeof(struct rootnode), 0);
        !           765:                }
        !           766: ;
        !           767: domseq:                targdom
        !           768:        |       domseq COMMA targdom =
        !           769:                {
        !           770:                        $$ = tlprepend($1, $3);
        !           771:                }
        !           772: ;
        !           773: targdom:       afcn =
        !           774:                {
        !           775:                        $$ = tree(NULL, $1, RESDOM, sizeof(struct resdomnode), Rsdmno);
        !           776:                }
        !           777: ;
        !           778: attrib:                var PERIOD NAME =
        !           779:                {
        !           780: #                      ifdef   xPTR2
        !           781:                        tTfp(39, 1, "attrib %12s.%12s found\n",
        !           782:                        Qt.qt_rangev[$1].rngvdesc->relvname, $3);
        !           783: #                      endif
        !           784: 
        !           785:                        /* remember attribute name */
        !           786:                        Trname = $3;
        !           787: 
        !           788:                        /* look up attribute */
        !           789:                        aptr = attlookup($1, Trname);
        !           790:                        $$ = tree(NULL, NULL, VAR, sizeof(struct varnode), $1, aptr);
        !           791:                }
        !           792: ;
        !           793: var:           NAME =
        !           794:                {
        !           795:                        $$ = rnglook($1, LOOKVAR);
        !           796:                        if ($$ < 0)
        !           797:                        {
        !           798:                                /* variable not declared */
        !           799:                                par_error(NOVBLE, WARN, $1, 0);
        !           800:                                YYERROR;
        !           801:                        }
        !           802:                        else
        !           803:                                ctlmod_decl($$);
        !           804:                }
        !           805: ;
        !           806: attribfcn:     I2CONST =
        !           807:                {
        !           808:                        $$ = tree(NULL, NULL, INT, 2, $1);
        !           809:                }
        !           810:        |       I4CONST =
        !           811:                {
        !           812:                        $$ = tree(NULL, NULL, INT, 4, $1);
        !           813:                }
        !           814:        |       F4CONST =
        !           815:                {
        !           816:                        $$ = tree(NULL, NULL, FLOAT, 4, $1);
        !           817:                }
        !           818:        |       F8CONST =
        !           819:                {
        !           820:                        $$ = tree(NULL, NULL, FLOAT, 8, $1);
        !           821:                }
        !           822:        |       SCONST =
        !           823:                {
        !           824:                        if (patmat($1) && !Qlflag)
        !           825:                                Patflag = 1;
        !           826:                        $$ = tree(NULL, NULL, CHAR, length($1), $1);
        !           827:                }
        !           828:        |       NAME =
        !           829:                {
        !           830:                        $$ = tree(NULL, NULL, COP, 2, $1);
        !           831:                }
        !           832:        |       attrib
        !           833: ;
        !           834: uop:           UAOP    %prec unaryop   =
        !           835:                {
        !           836:                        if ($1 == opADD)
        !           837:                                $$ = opPLUS;
        !           838:                        else
        !           839:                                if ($1 == opSUB)
        !           840:                                        $$ = opMINUS;
        !           841:                }
        !           842: ;
        !           843: copy:          copstmnt alias LPAREN coparam RPAREN keywd SCONST =
        !           844:                {
        !           845: #                      ifdef   xPTR2
        !           846:                        tTfp(39, 3, "copy %12s,%12s\n", $2, $7);
        !           847: #                      endif
        !           848: 
        !           849:                        setp(PV_STR, $7);
        !           850:                }
        !           851: ;
        !           852: copstmnt:      COPY =
        !           853:                {
        !           854:                        Opflag = mdCOPY;
        !           855:                }
        !           856: ;
        !           857: coparam:       cospecs
        !           858:        |       ;
        !           859: ;
        !           860: cospecs:       alias is coent
        !           861:        |       cospecs COMMA alias is coent
        !           862: ;
        !           863: coent:         alias
        !           864:        |       SCONST =
        !           865:                {
        !           866:                        setp(PV_STR, $1);
        !           867:                }
        !           868: ;
        !           869: alias:         NAME =
        !           870:                {
        !           871:                        if (!Err_current)
        !           872:                        {
        !           873:                                setp(PV_STR, $1);
        !           874:                                if (Opflag == mdDESTROY || Opflag == mdCREATE
        !           875: #                                      ifdef   DISTRIB
        !           876:                                        || Opflag == mdDCREATE
        !           877: #                                      endif
        !           878:                                                                )
        !           879:                                        rngdel($1);
        !           880:                        }
        !           881:                }
        !           882: ;
        !           883: specs:         alias is alias
        !           884:        |       specs COMMA alias is alias
        !           885: ;
        !           886: keywd:         INTO =
        !           887:                {
        !           888:                        setp(PV_STR, "\0");
        !           889:                        setp(PV_STR, "i");
        !           890:                }
        !           891:        |       FROM =
        !           892:                {
        !           893:                        setp(PV_STR, "\0");
        !           894:                        setp(PV_STR, "f");
        !           895:                }
        !           896: ;
        !           897: create:                crestmnt alias LPAREN specs RPAREN
        !           898: ;
        !           899: crestmnt:      CREATE =
        !           900:                {
        !           901:                        Opflag = mdCREATE;
        !           902: 
        !           903:                        /* set up parameters for regular create */
        !           904:                        setp(PV_STR, "0");              /* relstat = nil */
        !           905:                }
        !           906: /*DDD*/        |       CREATE DISTRD =
        !           907: /*DDD*/                {
        !           908: /*DDD*/                        Opflag = mdDCREATE;
        !           909: /*DDD*/
        !           910: /*DDD*/                        /* setup parameters for distributed create */
        !           911: /*DDD*/                        setp(PV_STR, "U");
        !           912: /*DDD*/                        setp(PV_STR, "");
        !           913: /*DDD*/                        setp(PV_STR, "01000");  /* relstat = S_DISTRIBUTED */
        !           914: /*DDD*/                }
        !           915: ;
        !           916: destroy:       destmnt keys
        !           917:        |       destqm destlist
        !           918: ;
        !           919: destmnt:       DESTROY =
        !           920:                {
        !           921:                        Opflag = mdDESTROY;
        !           922:                }
        !           923: ;
        !           924: destqm:                destmnt INTEGRITY NAME =
        !           925:                {
        !           926:                        Opflag = mdREMQM;
        !           927:                        if (!Qrymod)
        !           928:                                /* no qrymod in database */
        !           929:                                par_error(NOQRYMOD, WARN, 0);
        !           930:                        setp(PV_STR, "6");
        !           931:                        setp(PV_STR, $3);
        !           932:                }
        !           933:        |       destmnt PERMIT NAME =
        !           934:                {
        !           935:                        Opflag = mdREMQM;
        !           936:                        if (!Qrymod)
        !           937:                                /* no qrymod in database */
        !           938:                                par_error(NOQRYMOD, WARN, 0);
        !           939:                        setp(PV_STR, "5");
        !           940:                        setp(PV_STR, $3);
        !           941:                }
        !           942: ;
        !           943: destlist:      I2CONST =
        !           944:                {
        !           945:                        i = iocv(*($1));
        !           946:                        setp(PV_STR, i);
        !           947:                }
        !           948:        |       destlist COMMA I2CONST =
        !           949:                {
        !           950:                        i = iocv(*($3));
        !           951:                        setp(PV_STR, i);
        !           952:                }
        !           953:        |       ALL
        !           954: ;
        !           955: help:          helstmnt hlist
        !           956:        |       helstmnt =
        !           957:                {
        !           958:                        setp(PV_STR, "2");      /* all relns */
        !           959:                }
        !           960:        |       helqmstmnt hqmlist
        !           961: ;
        !           962: helstmnt:      HELP =
        !           963:                {
        !           964:                        Opflag = mdHELP;
        !           965:                }
        !           966: ;
        !           967: helqmstmnt:    HELP VIEW =
        !           968:                {
        !           969:                        Opflag = mdDISPLAY;
        !           970:                        if (!Qrymod)
        !           971:                                /* no qrymod in database */
        !           972:                                par_error(NOQRYMOD, WARN, 0);
        !           973:                        smove("4", hqmbuf);
        !           974:                }
        !           975:        |       HELP PERMIT =
        !           976:                {
        !           977:                        Opflag = mdDISPLAY;
        !           978:                        if (!Qrymod)
        !           979:                                /* no qrymod in database */
        !           980:                                par_error(NOQRYMOD, WARN, 0);
        !           981:                        smove("5", hqmbuf);
        !           982:                }
        !           983:        |       HELP INTEGRITY =
        !           984:                {
        !           985:                        Opflag = mdDISPLAY;
        !           986:                        if (!Qrymod)
        !           987:                                /* no qrymod in database */
        !           988:                                par_error(NOQRYMOD, WARN, 0);
        !           989:                        smove("6", hqmbuf);
        !           990:                }
        !           991: ;
        !           992: hlist:         hparam
        !           993:        |       hlist COMMA hparam
        !           994:        |       ALL =
        !           995:                {
        !           996:                        setp(PV_STR, "3");
        !           997:                }
        !           998: ;
        !           999: hparam:                NAME =
        !          1000:                {
        !          1001:                        /* relation */
        !          1002:                        setp(PV_STR, "0");
        !          1003:                        setp(PV_STR, $1);
        !          1004:                }
        !          1005:        |       SCONST =
        !          1006:                {
        !          1007:                        /* manual page */
        !          1008:                        setp(PV_STR, "1");
        !          1009:                        setp(PV_STR, $1);
        !          1010:                }
        !          1011: ;
        !          1012: hqmlist:       NAME =
        !          1013:                {
        !          1014:                        setp(PV_STR, hqmbuf);
        !          1015:                        setp(PV_STR, $1);
        !          1016:                }
        !          1017:        |       hqmlist COMMA NAME =
        !          1018:                {
        !          1019:                        setp(PV_STR, hqmbuf);
        !          1020:                        setp(PV_STR, $3);
        !          1021:                }
        !          1022: ;
        !          1023: index:         instmnt LPAREN keys RPAREN =
        !          1024:                {
        !          1025:                        if (Rsdmno > MAXKEYS)
        !          1026:                                /* too many attributes in key */
        !          1027:                                par_error(INDEXTRA, WARN, 0);
        !          1028:                }
        !          1029: ;
        !          1030: instmnt:       indexq ON NAME IS NAME =
        !          1031:                {
        !          1032:                        /* init INDEX command */
        !          1033:                        Rsdmno = 0;
        !          1034:                        setp(PV_STR, $3);
        !          1035:                        setp(PV_STR, $5);
        !          1036:                        Indexname = $5;
        !          1037:                }
        !          1038: ;
        !          1039: indexq:                INDEX =
        !          1040:                {
        !          1041:                        Opflag = mdINDEX;
        !          1042:                }
        !          1043: ;
        !          1044: modify:                modstmnt alias TO modstorage modkeys modqual
        !          1045: ;
        !          1046: modstmnt:      MODIFY =
        !          1047:                {
        !          1048:                        Opflag = mdMODIFY;
        !          1049:                        Rsdmno = 0;
        !          1050:                }
        !          1051: ;
        !          1052: modstorage:    NAME =
        !          1053:                {
        !          1054:                        setp(PV_STR, $1);
        !          1055:                }
        !          1056: modkeys:       modstkey modrptkey
        !          1057:        |       ;
        !          1058: ;
        !          1059: modstkey:      ON =
        !          1060:                {
        !          1061:                        setp(PV_STR, "name");
        !          1062:                }
        !          1063: ;
        !          1064: modrptkey:     modbasekey
        !          1065:        |       modrptkey COMMA modbasekey
        !          1066: ;
        !          1067: modbasekey:    NAME =
        !          1068:                {
        !          1069:                        setp(PV_STR, $1);
        !          1070:                }
        !          1071:        |       NAME COLON NAME =
        !          1072:                {
        !          1073:                        concat($1, ztack(":", $3), modbuf);
        !          1074:                        setp(PV_STR, modbuf);
        !          1075:                }
        !          1076: ;
        !          1077: modqual:       modcond modfill
        !          1078:        |       ;
        !          1079: ;
        !          1080: modcond:       WHERE =
        !          1081:                {
        !          1082:                        setp(PV_STR, "\0");
        !          1083:                }
        !          1084: ;
        !          1085: modfill:       modfillnum
        !          1086:        |       modfill COMMA modfillnum
        !          1087: ;
        !          1088: modfillnum:    NAME IS I2CONST =
        !          1089:                {
        !          1090:                        setp(PV_STR, $1);
        !          1091:                        i = iocv(*($3));
        !          1092:                        setp(PV_STR, i);
        !          1093:                }
        !          1094: ;
        !          1095: keys:          alias =
        !          1096:                {
        !          1097:                        Rsdmno++;
        !          1098:                }
        !          1099:        |       keys COMMA alias =
        !          1100:                {
        !          1101:                        Rsdmno++;
        !          1102:                }
        !          1103: ;
        !          1104: print:         prinstmnt keys
        !          1105: ;
        !          1106: prinstmnt:     PRINT =
        !          1107:                {
        !          1108:                        Opflag = mdPRINT;
        !          1109:                }
        !          1110: ;
        !          1111: save:          savstmnt alias UNTIL date
        !          1112: ;
        !          1113: savstmnt:      SAVE =
        !          1114:                {
        !          1115:                        Opflag = mdSAVE;
        !          1116:                }
        !          1117: ;
        !          1118: date:          month day_year day_year
        !          1119: ;
        !          1120: month:         alias
        !          1121:        |       day_year
        !          1122: ;
        !          1123: day_year:      I2CONST =
        !          1124:                {
        !          1125:                        i = iocv(*($1));
        !          1126: 
        !          1127: #                      ifdef   xPTR3
        !          1128:                        tTfp(39, 4, "day_year: %s\n", i);
        !          1129: #                      endif
        !          1130: 
        !          1131:                        setp(PV_STR, i);
        !          1132:                }
        !          1133: ;
        !          1134: %%
        !          1135: # include      "scanner.h"
        !          1136: # include      "tables.y"
        !          1137: # include      "yyerror.y"

unix.superglobalmegacorp.com

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