Annotation of cci/usr/src/bin/expr.c, revision 1.1

1.1     ! root        1: # define OR 257
        !             2: # define AND 258
        !             3: # define ADD 259
        !             4: # define SUBT 260
        !             5: # define MULT 261
        !             6: # define DIV 262
        !             7: # define REM 263
        !             8: # define EQ 264
        !             9: # define GT 265
        !            10: # define GEQ 266
        !            11: # define LT 267
        !            12: # define LEQ 268
        !            13: # define NEQ 269
        !            14: # define A_STRING 270
        !            15: # define SUBSTR 271
        !            16: # define LENGTH 272
        !            17: # define INDEX 273
        !            18: # define NOARG 274
        !            19: # define MATCH 275
        !            20: # define MCH 276
        !            21: #define yyclearin yychar = -1
        !            22: #define yyerrok yyerrflag = 0
        !            23: extern int yychar;
        !            24: extern short yyerrflag;
        !            25: #ifndef YYMAXDEPTH
        !            26: #define YYMAXDEPTH 150
        !            27: #endif
        !            28: #ifndef YYSTYPE
        !            29: #define YYSTYPE int
        !            30: #endif
        !            31: YYSTYPE yylval, yyval;
        !            32: # define YYERRCODE 256
        !            33: 
        !            34: # line 48 "expr.y"
        !            35: 
        !            36: /*     expression command */
        !            37: #include <stdio.h>
        !            38: #define ESIZE  256
        !            39: #define error(c)       errxx(c)
        !            40: #define EQL(x,y) !strcmp(x,y)
        !            41: long atol();
        !            42: char   **Av;
        !            43: int    Ac;
        !            44: int    Argi;
        !            45: 
        !            46: char Mstring[1][128];
        !            47: char *malloc();
        !            48: extern int nbra;
        !            49: 
        !            50: main(argc, argv) char **argv; {
        !            51:        Ac = argc;
        !            52:        Argi = 1;
        !            53:        Av = argv;
        !            54:        yyparse();
        !            55: }
        !            56: 
        !            57: char *operators[] = { "|", "&", "+", "-", "*", "/", "%", ":",
        !            58:        "=", "==", "<", "<=", ">", ">=", "!=",
        !            59:        "match", "substr", "length", "index", "\0" };
        !            60: int op[] = { OR, AND, ADD,  SUBT, MULT, DIV, REM, MCH,
        !            61:        EQ, EQ, LT, LEQ, GT, GEQ, NEQ,
        !            62:        MATCH, SUBSTR, LENGTH, INDEX };
        !            63: yylex() {
        !            64:        register char *p;
        !            65:        register i;
        !            66: 
        !            67:        if(Argi >= Ac) return NOARG;
        !            68: 
        !            69:        p = Av[Argi++];
        !            70: 
        !            71:        if(*p == '(' || *p == ')')
        !            72:                return (int)*p;
        !            73:        for(i = 0; *operators[i]; ++i)
        !            74:                if(EQL(operators[i], p))
        !            75:                        return op[i];
        !            76: 
        !            77:        yylval = p;
        !            78:        return A_STRING;
        !            79: }
        !            80: 
        !            81: char *rel(op, r1, r2) register char *r1, *r2; {
        !            82:        register long i;
        !            83: 
        !            84:        if(ematch(r1, "-*[0-9]*$") && ematch(r2, "[0-9]*$"))
        !            85:                i = atol(r1) - atol(r2);
        !            86:        else
        !            87:                i = strcmp(r1, r2);
        !            88:        switch(op) {
        !            89:        case EQ: i = i==0; break;
        !            90:        case GT: i = i>0; break;
        !            91:        case GEQ: i = i>=0; break;
        !            92:        case LT: i = i<0; break;
        !            93:        case LEQ: i = i<=0; break;
        !            94:        case NEQ: i = i!=0; break;
        !            95:        }
        !            96:        return i? "1": "0";
        !            97: }
        !            98: 
        !            99: char *arith(op, r1, r2) char *r1, *r2; {
        !           100:        long i1, i2;
        !           101:        register char *rv;
        !           102: 
        !           103:        if(!(ematch(r1, "[0-9]*$") && ematch(r2, "[0-9]*$")))
        !           104:                yyerror("non-numeric argument");
        !           105:        i1 = atol(r1);
        !           106:        i2 = atol(r2);
        !           107: 
        !           108:        switch(op) {
        !           109:        case ADD: i1 = i1 + i2; break;
        !           110:        case SUBT: i1 = i1 - i2; break;
        !           111:        case MULT: i1 = i1 * i2; break;
        !           112:        case DIV: i1 = i1 / i2; break;
        !           113:        case REM: i1 = i1 % i2; break;
        !           114:        }
        !           115:        rv = malloc(16);
        !           116:        sprintf(rv, "%D", i1);
        !           117:        return rv;
        !           118: }
        !           119: char *conj(op, r1, r2) char *r1, *r2; {
        !           120:        register char *rv;
        !           121: 
        !           122:        switch(op) {
        !           123: 
        !           124:        case OR:
        !           125:                if(EQL(r1, "0")
        !           126:                || EQL(r1, ""))
        !           127:                        if(EQL(r2, "0")
        !           128:                        || EQL(r2, ""))
        !           129:                                rv = "0";
        !           130:                        else
        !           131:                                rv = r2;
        !           132:                else
        !           133:                        rv = r1;
        !           134:                break;
        !           135:        case AND:
        !           136:                if(EQL(r1, "0")
        !           137:                || EQL(r1, ""))
        !           138:                        rv = "0";
        !           139:                else if(EQL(r2, "0")
        !           140:                || EQL(r2, ""))
        !           141:                        rv = "0";
        !           142:                else
        !           143:                        rv = r1;
        !           144:                break;
        !           145:        }
        !           146:        return rv;
        !           147: }
        !           148: 
        !           149: char *substr(v, s, w) char *v, *s, *w; {
        !           150: register si, wi;
        !           151: register char *res;
        !           152: 
        !           153:        si = atol(s);
        !           154:        wi = atol(w);
        !           155:        while(--si) if(*v) ++v;
        !           156: 
        !           157:        res = v;
        !           158: 
        !           159:        while(wi--) if(*v) ++v;
        !           160: 
        !           161:        *v = '\0';
        !           162:        return res;
        !           163: }
        !           164: 
        !           165: char *length(s) register char *s; {
        !           166:        register i = 0;
        !           167:        register char *rv;
        !           168: 
        !           169:        while(*s++) ++i;
        !           170: 
        !           171:        rv = malloc(8);
        !           172:        sprintf(rv, "%d", i);
        !           173:        return rv;
        !           174: }
        !           175: 
        !           176: char *index(s, t) char *s, *t; {
        !           177:        register i, j;
        !           178:        register char *rv;
        !           179: 
        !           180:        for(i = 0; s[i] ; ++i)
        !           181:                for(j = 0; t[j] ; ++j)
        !           182:                        if(s[i]==t[j]) {
        !           183:                                sprintf(rv = malloc(8), "%d", ++i);
        !           184:                                return rv;
        !           185:                        }
        !           186:        return "0";
        !           187: }
        !           188: 
        !           189: char *match(s, p)
        !           190: {
        !           191:        register char *rv;
        !           192: 
        !           193:        sprintf(rv = malloc(8), "%d", ematch(s, p));
        !           194:        if(nbra) {
        !           195:                rv = malloc(strlen(Mstring[0])+1);
        !           196:                strcpy(rv, Mstring[0]);
        !           197:        }
        !           198:        return rv;
        !           199: }
        !           200: 
        !           201: #define INIT   register char *sp = instring;
        !           202: #define GETC()         (*sp++)
        !           203: #define PEEKC()                (*sp)
        !           204: #define UNGETC(c)      (--sp)
        !           205: #define RETURN(c)      return
        !           206: #define ERROR(c)       errxx(c)
        !           207: 
        !           208: 
        !           209: ematch(s, p)
        !           210: char *s;
        !           211: register char *p;
        !           212: {
        !           213:        static char expbuf[ESIZE];
        !           214:        char *compile();
        !           215:        register num;
        !           216:        extern char *braslist[], *braelist[], *loc2;
        !           217: 
        !           218:        compile(p, expbuf, &expbuf[ESIZE], 0);
        !           219:        if(nbra > 1)
        !           220:                yyerror("Too many '\\('s");
        !           221:        if(advance(s, expbuf)) {
        !           222:                if(nbra == 1) {
        !           223:                        p = braslist[0];
        !           224:                        num = braelist[0] - p;
        !           225:                        strncpy(Mstring[0], p, num);
        !           226:                        Mstring[0][num] = '\0';
        !           227:                }
        !           228:                return(loc2-s);
        !           229:        }
        !           230:        return(0);
        !           231: }
        !           232: 
        !           233: errxx(c)
        !           234: {
        !           235:        yyerror("RE error");
        !           236: }
        !           237: 
        !           238: #define        CBRA    2
        !           239: #define        CCHR    4
        !           240: #define        CDOT    8
        !           241: #define        CCL     12
        !           242: #define        CDOL    20
        !           243: #define        CEOF    22
        !           244: #define        CKET    24
        !           245: #define        CBACK   36
        !           246: 
        !           247: #define        STAR    01
        !           248: #define RNGE   03
        !           249: 
        !           250: #define        NBRA    9
        !           251: 
        !           252: #define PLACE(c)       ep[c >> 3] |= bittab[c & 07]
        !           253: #define ISTHERE(c)     (ep[c >> 3] & bittab[c & 07])
        !           254: 
        !           255: char   *braslist[NBRA];
        !           256: char   *braelist[NBRA];
        !           257: int    nbra;
        !           258: char *loc1, *loc2, *locs;
        !           259: int    sed;
        !           260: 
        !           261: int    circf;
        !           262: int    low;
        !           263: int    size;
        !           264: 
        !           265: char   bittab[] = {
        !           266:        1,
        !           267:        2,
        !           268:        4,
        !           269:        8,
        !           270:        16,
        !           271:        32,
        !           272:        64,
        !           273:        128
        !           274: };
        !           275: 
        !           276: char *
        !           277: compile(instring, ep, endbuf, seof)
        !           278: register char *ep;
        !           279: char *instring, *endbuf;
        !           280: {
        !           281:        INIT    /* Dependent declarations and initializations */
        !           282:        register c;
        !           283:        register eof = seof;
        !           284:        char *lastep = instring;
        !           285:        int cclcnt;
        !           286:        char bracket[NBRA], *bracketp;
        !           287:        int closed;
        !           288:        char neg;
        !           289:        int lc;
        !           290:        int i, cflg;
        !           291: 
        !           292:        lastep = 0;
        !           293:        if((c = GETC()) == eof) {
        !           294:                if(*ep == 0 && !sed)
        !           295:                        ERROR(41);
        !           296:                RETURN(ep);
        !           297:        }
        !           298:        bracketp = bracket;
        !           299:        circf = closed = nbra = 0;
        !           300:        if (c == '^')
        !           301:                circf++;
        !           302:        else
        !           303:                UNGETC(c);
        !           304:        for (;;) {
        !           305:                if (ep >= endbuf)
        !           306:                        ERROR(50);
        !           307:                if((c = GETC()) != '*' && ((c != '\\') || (PEEKC() != '{')))
        !           308:                        lastep = ep;
        !           309:                if (c == eof) {
        !           310:                        *ep++ = CEOF;
        !           311:                        RETURN(ep);
        !           312:                }
        !           313:                switch (c) {
        !           314: 
        !           315:                case '.':
        !           316:                        *ep++ = CDOT;
        !           317:                        continue;
        !           318: 
        !           319:                case '\n':
        !           320:                        ERROR(36);
        !           321:                case '*':
        !           322:                        if (lastep==0 || *lastep==CBRA || *lastep==CKET)
        !           323:                                goto defchar;
        !           324:                        *lastep |= STAR;
        !           325:                        continue;
        !           326: 
        !           327:                case '$':
        !           328:                        if(PEEKC() != eof)
        !           329:                                goto defchar;
        !           330:                        *ep++ = CDOL;
        !           331:                        continue;
        !           332: 
        !           333:                case '[':
        !           334:                        if(&ep[17] >= endbuf)
        !           335:                                ERROR(50);
        !           336: 
        !           337:                        *ep++ = CCL;
        !           338:                        lc = 0;
        !           339:                        for(i = 0; i < 16; i++)
        !           340:                                ep[i] = 0;
        !           341: 
        !           342:                        neg = 0;
        !           343:                        if((c = GETC()) == '^') {
        !           344:                                neg = 1;
        !           345:                                c = GETC();
        !           346:                        }
        !           347: 
        !           348:                        do {
        !           349:                                if(c == '\0' || c == '\n')
        !           350:                                        ERROR(49);
        !           351:                                if(c == '-' && lc != 0) {
        !           352:                                        if ((c = GETC()) == ']') {
        !           353:                                                PLACE('-');
        !           354:                                                break;
        !           355:                                        }
        !           356:                                        while(lc < c) {
        !           357:                                                PLACE(lc);
        !           358:                                                lc++;
        !           359:                                        }
        !           360:                                }
        !           361:                                lc = c;
        !           362:                                PLACE(c);
        !           363:                        } while((c = GETC()) != ']');
        !           364:                        if(neg) {
        !           365:                                for(cclcnt = 0; cclcnt < 16; cclcnt++)
        !           366:                                        ep[cclcnt] ^= -1;
        !           367:                                ep[0] &= 0376;
        !           368:                        }
        !           369: 
        !           370:                        ep += 16;
        !           371: 
        !           372:                        continue;
        !           373: 
        !           374:                case '\\':
        !           375:                        switch(c = GETC()) {
        !           376: 
        !           377:                        case '(':
        !           378:                                if(nbra >= NBRA)
        !           379:                                        ERROR(43);
        !           380:                                *bracketp++ = nbra;
        !           381:                                *ep++ = CBRA;
        !           382:                                *ep++ = nbra++;
        !           383:                                continue;
        !           384: 
        !           385:                        case ')':
        !           386:                                if(bracketp <= bracket)
        !           387:                                        ERROR(42);
        !           388:                                *ep++ = CKET;
        !           389:                                *ep++ = *--bracketp;
        !           390:                                closed++;
        !           391:                                continue;
        !           392: 
        !           393:                        case '{':
        !           394:                                if(lastep == (char *) (0))
        !           395:                                        goto defchar;
        !           396:                                *lastep |= RNGE;
        !           397:                                cflg = 0;
        !           398:                        nlim:
        !           399:                                c = GETC();
        !           400:                                i = 0;
        !           401:                                do {
        !           402:                                        if ('0' <= c && c <= '9')
        !           403:                                                i = 10 * i + c - '0';
        !           404:                                        else
        !           405:                                                ERROR(16);
        !           406:                                } while(((c = GETC()) != '\\') && (c != ','));
        !           407:                                if (i > 255)
        !           408:                                        ERROR(11);
        !           409:                                *ep++ = i;
        !           410:                                if (c == ',') {
        !           411:                                        if(cflg++)
        !           412:                                                ERROR(44);
        !           413:                                        if((c = GETC()) == '\\')
        !           414:                                                *ep++ = 255;
        !           415:                                        else {
        !           416:                                                UNGETC(c);
        !           417:                                                goto nlim; /* get 2'nd number */
        !           418:                                        }
        !           419:                                }
        !           420:                                if(GETC() != '}')
        !           421:                                        ERROR(45);
        !           422:                                if(!cflg)       /* one number */
        !           423:                                        *ep++ = i;
        !           424:                                else if((ep[-1] & 0377) < (ep[-2] & 0377))
        !           425:                                        ERROR(46);
        !           426:                                continue;
        !           427: 
        !           428:                        case '\n':
        !           429:                                ERROR(36);
        !           430: 
        !           431:                        case 'n':
        !           432:                                c = '\n';
        !           433:                                goto defchar;
        !           434: 
        !           435:                        default:
        !           436:                                if(c >= '1' && c <= '9') {
        !           437:                                        if((c -= '1') >= closed)
        !           438:                                                ERROR(25);
        !           439:                                        *ep++ = CBACK;
        !           440:                                        *ep++ = c;
        !           441:                                        continue;
        !           442:                                }
        !           443:                        }
        !           444:                        /* Drop through to default to use \ to turn off special chars */
        !           445: 
        !           446:                defchar:
        !           447:                default:
        !           448:                        lastep = ep;
        !           449:                        *ep++ = CCHR;
        !           450:                        *ep++ = c;
        !           451:                }
        !           452:        }
        !           453: }
        !           454: 
        !           455: step(p1, p2)
        !           456: register char *p1, *p2;
        !           457: {
        !           458:        register c;
        !           459: 
        !           460:        if (circf) {
        !           461:                loc1 = p1;
        !           462:                return(advance(p1, p2));
        !           463:        }
        !           464:        /* fast check for first character */
        !           465:        if (*p2==CCHR) {
        !           466:                c = p2[1];
        !           467:                do {
        !           468:                        if (*p1 != c)
        !           469:                                continue;
        !           470:                        if (advance(p1, p2)) {
        !           471:                                loc1 = p1;
        !           472:                                return(1);
        !           473:                        }
        !           474:                } while (*p1++);
        !           475:                return(0);
        !           476:        }
        !           477:                /* regular algorithm */
        !           478:        do {
        !           479:                if (advance(p1, p2)) {
        !           480:                        loc1 = p1;
        !           481:                        return(1);
        !           482:                }
        !           483:        } while (*p1++);
        !           484:        return(0);
        !           485: }
        !           486: 
        !           487: advance(lp, ep)
        !           488: register char *lp, *ep;
        !           489: {
        !           490:        register char *curlp;
        !           491:        char c;
        !           492:        char *bbeg;
        !           493:        int ct;
        !           494: 
        !           495:        for (;;) switch (*ep++) {
        !           496: 
        !           497:        case CCHR:
        !           498:                if (*ep++ == *lp++)
        !           499:                        continue;
        !           500:                return(0);
        !           501: 
        !           502:        case CDOT:
        !           503:                if (*lp++)
        !           504:                        continue;
        !           505:                return(0);
        !           506: 
        !           507:        case CDOL:
        !           508:                if (*lp==0)
        !           509:                        continue;
        !           510:                return(0);
        !           511: 
        !           512:        case CEOF:
        !           513:                loc2 = lp;
        !           514:                return(1);
        !           515: 
        !           516:        case CCL:
        !           517:                c = *lp++ & 0177;
        !           518:                if(ISTHERE(c)) {
        !           519:                        ep += 16;
        !           520:                        continue;
        !           521:                }
        !           522:                return(0);
        !           523:        case CBRA:
        !           524:                braslist[*ep++] = lp;
        !           525:                continue;
        !           526: 
        !           527:        case CKET:
        !           528:                braelist[*ep++] = lp;
        !           529:                continue;
        !           530: 
        !           531:        case CCHR|RNGE:
        !           532:                c = *ep++;
        !           533:                getrnge(ep);
        !           534:                while(low--)
        !           535:                        if(*lp++ != c)
        !           536:                                return(0);
        !           537:                curlp = lp;
        !           538:                while(size--) 
        !           539:                        if(*lp++ != c)
        !           540:                                break;
        !           541:                if(size < 0)
        !           542:                        lp++;
        !           543:                ep += 2;
        !           544:                goto star;
        !           545: 
        !           546:        case CDOT|RNGE:
        !           547:                getrnge(ep);
        !           548:                while(low--)
        !           549:                        if(*lp++ == '\0')
        !           550:                                return(0);
        !           551:                curlp = lp;
        !           552:                while(size--)
        !           553:                        if(*lp++ == '\0')
        !           554:                                break;
        !           555:                if(size < 0)
        !           556:                        lp++;
        !           557:                ep += 2;
        !           558:                goto star;
        !           559: 
        !           560:        case CCL|RNGE:
        !           561:                getrnge(ep + 16);
        !           562:                while(low--) {
        !           563:                        c = *lp++ & 0177;
        !           564:                        if(!ISTHERE(c))
        !           565:                                return(0);
        !           566:                }
        !           567:                curlp = lp;
        !           568:                while(size--) {
        !           569:                        c = *lp++ & 0177;
        !           570:                        if(!ISTHERE(c))
        !           571:                                break;
        !           572:                }
        !           573:                if(size < 0)
        !           574:                        lp++;
        !           575:                ep += 18;               /* 16 + 2 */
        !           576:                goto star;
        !           577: 
        !           578:        case CBACK:
        !           579:                bbeg = braslist[*ep];
        !           580:                ct = braelist[*ep++] - bbeg;
        !           581: 
        !           582:                if(ecmp(bbeg, lp, ct)) {
        !           583:                        lp += ct;
        !           584:                        continue;
        !           585:                }
        !           586:                return(0);
        !           587: 
        !           588:        case CBACK|STAR:
        !           589:                bbeg = braslist[*ep];
        !           590:                ct = braelist[*ep++] - bbeg;
        !           591:                curlp = lp;
        !           592:                while(ecmp(bbeg, lp, ct))
        !           593:                        lp += ct;
        !           594: 
        !           595:                while(lp >= curlp) {
        !           596:                        if(advance(lp, ep))     return(1);
        !           597:                        lp -= ct;
        !           598:                }
        !           599:                return(0);
        !           600: 
        !           601: 
        !           602:        case CDOT|STAR:
        !           603:                curlp = lp;
        !           604:                while (*lp++);
        !           605:                goto star;
        !           606: 
        !           607:        case CCHR|STAR:
        !           608:                curlp = lp;
        !           609:                while (*lp++ == *ep);
        !           610:                ep++;
        !           611:                goto star;
        !           612: 
        !           613:        case CCL|STAR:
        !           614:                curlp = lp;
        !           615:                do {
        !           616:                        c = *lp++ & 0177;
        !           617:                } while(ISTHERE(c));
        !           618:                ep += 16;
        !           619:                goto star;
        !           620: 
        !           621:        star:
        !           622:                do {
        !           623:                        if(--lp == locs)
        !           624:                                break;
        !           625:                        if (advance(lp, ep))
        !           626:                                return(1);
        !           627:                } while (lp > curlp);
        !           628:                return(0);
        !           629: 
        !           630:        }
        !           631: }
        !           632: 
        !           633: getrnge(str)
        !           634: register char *str;
        !           635: {
        !           636:        low = *str++ & 0377;
        !           637:        size = *str == 255 ? 20000 : (*str &0377) - low;
        !           638: }
        !           639: 
        !           640: ecmp(a, b, count)
        !           641: register char  *a, *b;
        !           642: register       count;
        !           643: {
        !           644:        if(a == b) /* should have been caught in compile() */
        !           645:                error(51);
        !           646:        while(count--)
        !           647:                if(*a++ != *b++)        return(0);
        !           648:        return(1);
        !           649: }
        !           650: 
        !           651: static char *sccsid = "@(#)expr.y      4.3 (Berkeley) 6/30/83";
        !           652: yyerror(s)
        !           653: 
        !           654: {
        !           655:        fprintf(stderr, "%s\n", s);
        !           656:        exit(2);
        !           657: }
        !           658: short yyexca[] ={
        !           659: -1, 1,
        !           660:        0, -1,
        !           661:        -2, 0,
        !           662:        };
        !           663: # define YYNPROD 22
        !           664: # define YYLAST 270
        !           665: short yyact[]={
        !           666: 
        !           667:    3,  10,  11,  18,  19,  20,  21,  22,  12,  13,
        !           668:   14,  15,  16,  17,  23,   1,   0,   0,   9,   0,
        !           669:   23,  43,  11,  18,  19,  20,  21,  22,  12,  13,
        !           670:   14,  15,  16,  17,   3,  18,  19,  20,  21,  22,
        !           671:   23,  18,  19,  20,  21,  22,  12,  13,  14,  15,
        !           672:   16,  17,  23,  20,  21,  22,   0,   0,  23,   2,
        !           673:    0,   0,   0,  24,  25,  26,  27,  28,  23,   0,
        !           674:   29,  30,  31,  32,  33,  34,  35,  36,  37,  38,
        !           675:   39,  40,  41,  42,   0,  44,  45,   0,  46,   0,
        !           676:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           677:    0,   0,   0,   0,   0,  47,   0,   0,   0,   0,
        !           678:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           679:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           680:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           681:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           682:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           683:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           684:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           685:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           686:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           687:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           688:    0,   0,   0,   0,   0,   0,   0,  10,  11,  18,
        !           689:   19,  20,  21,  22,  12,  13,  14,  15,  16,  17,
        !           690:    8,   5,   6,   7,   0,   4,  23,  10,  11,  18,
        !           691:   19,  20,  21,  22,  12,  13,  14,  15,  16,  17,
        !           692:    0,   0,   0,   0,   0,   0,  23,   0,   0,   0,
        !           693:    0,   0,   0,   0,   8,   5,   6,   7,   0,   4 };
        !           694: short yypact[]={
        !           695: 
        !           696:   -6,-1000,-256,  -6,  -6,  -6,  -6,  -6,-1000,-1000,
        !           697:   -6,  -6,  -6,  -6,  -6,  -6,  -6,  -6,  -6,  -6,
        !           698:   -6,  -6,  -6,  -6, -20, -40, -40,-1000, -40,-236,
        !           699: -218,-224,-224,-224,-224,-224,-224,-208,-208,-262,
        !           700: -262,-262,-1000,-1000,-1000, -40,-1000,-1000 };
        !           701: short yypgo[]={
        !           702: 
        !           703:    0,  15,  59 };
        !           704: short yyr1[]={
        !           705: 
        !           706:    0,   1,   2,   2,   2,   2,   2,   2,   2,   2,
        !           707:    2,   2,   2,   2,   2,   2,   2,   2,   2,   2,
        !           708:    2,   2 };
        !           709: short yyr2[]={
        !           710: 
        !           711:    0,   2,   3,   3,   3,   3,   3,   3,   3,   3,
        !           712:    3,   3,   3,   3,   3,   3,   3,   3,   4,   2,
        !           713:    3,   1 };
        !           714: short yychk[]={
        !           715: 
        !           716: -1000,  -1,  -2,  40, 275, 271, 272, 273, 270, 274,
        !           717:  257, 258, 264, 265, 266, 267, 268, 269, 259, 260,
        !           718:  261, 262, 263, 276,  -2,  -2,  -2,  -2,  -2,  -2,
        !           719:   -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,
        !           720:   -2,  -2,  -2,  41,  -2,  -2,  -2,  -2 };
        !           721: short yydef[]={
        !           722: 
        !           723:    0,  -2,   0,   0,   0,   0,   0,   0,  21,   1,
        !           724:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        !           725:    0,   0,   0,   0,   0,   0,   0,  19,   0,   3,
        !           726:    4,   5,   6,   7,   8,   9,  10,  11,  12,  13,
        !           727:   14,  15,  16,   2,  17,   0,  20,  18 };
        !           728: #ifndef lint
        !           729: static char yaccpar_sccsid[] = "@(#)yaccpar    4.1     (Berkeley)      2/11/83";
        !           730: #endif not lint
        !           731: 
        !           732: #
        !           733: # define YYFLAG -1000
        !           734: # define YYERROR goto yyerrlab
        !           735: # define YYACCEPT return(0)
        !           736: # define YYABORT return(1)
        !           737: 
        !           738: /*     parser for yacc output  */
        !           739: 
        !           740: #ifdef YYDEBUG
        !           741: int yydebug = 0; /* 1 for debugging */
        !           742: #endif
        !           743: YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
        !           744: int yychar = -1; /* current input token number */
        !           745: int yynerrs = 0;  /* number of errors */
        !           746: short yyerrflag = 0;  /* error recovery flag */
        !           747: 
        !           748: yyparse() {
        !           749: 
        !           750:        short yys[YYMAXDEPTH];
        !           751:        short yyj, yym;
        !           752:        register YYSTYPE *yypvt;
        !           753:        register short yystate, *yyps, yyn;
        !           754:        register YYSTYPE *yypv;
        !           755:        register short *yyxi;
        !           756: 
        !           757:        yystate = 0;
        !           758:        yychar = -1;
        !           759:        yynerrs = 0;
        !           760:        yyerrflag = 0;
        !           761:        yyps= &yys[-1];
        !           762:        yypv= &yyv[-1];
        !           763: 
        !           764:  yystack:    /* put a state and value onto the stack */
        !           765: 
        !           766: #ifdef YYDEBUG
        !           767:        if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
        !           768: #endif
        !           769:                if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
        !           770:                *yyps = yystate;
        !           771:                ++yypv;
        !           772:                *yypv = yyval;
        !           773: 
        !           774:  yynewstate:
        !           775: 
        !           776:        yyn = yypact[yystate];
        !           777: 
        !           778:        if( yyn<= YYFLAG ) goto yydefault; /* simple state */
        !           779: 
        !           780:        if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
        !           781:        if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
        !           782: 
        !           783:        if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
        !           784:                yychar = -1;
        !           785:                yyval = yylval;
        !           786:                yystate = yyn;
        !           787:                if( yyerrflag > 0 ) --yyerrflag;
        !           788:                goto yystack;
        !           789:                }
        !           790: 
        !           791:  yydefault:
        !           792:        /* default state action */
        !           793: 
        !           794:        if( (yyn=yydef[yystate]) == -2 ) {
        !           795:                if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
        !           796:                /* look through exception table */
        !           797: 
        !           798:                for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
        !           799: 
        !           800:                while( *(yyxi+=2) >= 0 ){
        !           801:                        if( *yyxi == yychar ) break;
        !           802:                        }
        !           803:                if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
        !           804:                }
        !           805: 
        !           806:        if( yyn == 0 ){ /* error */
        !           807:                /* error ... attempt to resume parsing */
        !           808: 
        !           809:                switch( yyerrflag ){
        !           810: 
        !           811:                case 0:   /* brand new error */
        !           812: 
        !           813:                        yyerror( "syntax error" );
        !           814:                yyerrlab:
        !           815:                        ++yynerrs;
        !           816: 
        !           817:                case 1:
        !           818:                case 2: /* incompletely recovered error ... try again */
        !           819: 
        !           820:                        yyerrflag = 3;
        !           821: 
        !           822:                        /* find a state where "error" is a legal shift action */
        !           823: 
        !           824:                        while ( yyps >= yys ) {
        !           825:                           yyn = yypact[*yyps] + YYERRCODE;
        !           826:                           if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
        !           827:                              yystate = yyact[yyn];  /* simulate a shift of "error" */
        !           828:                              goto yystack;
        !           829:                              }
        !           830:                           yyn = yypact[*yyps];
        !           831: 
        !           832:                           /* the current yyps has no shift onn "error", pop stack */
        !           833: 
        !           834: #ifdef YYDEBUG
        !           835:                           if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
        !           836: #endif
        !           837:                           --yyps;
        !           838:                           --yypv;
        !           839:                           }
        !           840: 
        !           841:                        /* there is no state on the stack with an error shift ... abort */
        !           842: 
        !           843:        yyabort:
        !           844:                        return(1);
        !           845: 
        !           846: 
        !           847:                case 3:  /* no shift yet; clobber input char */
        !           848: 
        !           849: #ifdef YYDEBUG
        !           850:                        if( yydebug ) printf( "error recovery discards char %d\n", yychar );
        !           851: #endif
        !           852: 
        !           853:                        if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
        !           854:                        yychar = -1;
        !           855:                        goto yynewstate;   /* try again in the same state */
        !           856: 
        !           857:                        }
        !           858: 
        !           859:                }
        !           860: 
        !           861:        /* reduction by production yyn */
        !           862: 
        !           863: #ifdef YYDEBUG
        !           864:                if( yydebug ) printf("reduce %d\n",yyn);
        !           865: #endif
        !           866:                yyps -= yyr2[yyn];
        !           867:                yypvt = yypv;
        !           868:                yypv -= yyr2[yyn];
        !           869:                yyval = yypv[1];
        !           870:                yym=yyn;
        !           871:                        /* consult goto table to find next state */
        !           872:                yyn = yyr1[yyn];
        !           873:                yyj = yypgo[yyn] + *yyps + 1;
        !           874:                if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
        !           875:                switch(yym){
        !           876:                        
        !           877: case 1:
        !           878: # line 20 "expr.y"
        !           879:  {
        !           880:                        printf("%s\n", yypvt[-1]);
        !           881:                        exit((!strcmp(yypvt[-1],"0")||!strcmp(yypvt[-1],"\0"))? 1: 0);
        !           882:                        } break;
        !           883: case 2:
        !           884: # line 27 "expr.y"
        !           885:  { yyval = yypvt[-1]; } break;
        !           886: case 3:
        !           887: # line 28 "expr.y"
        !           888:  { yyval = conj(OR, yypvt[-2], yypvt[-0]); } break;
        !           889: case 4:
        !           890: # line 29 "expr.y"
        !           891:  { yyval = conj(AND, yypvt[-2], yypvt[-0]); } break;
        !           892: case 5:
        !           893: # line 30 "expr.y"
        !           894:  { yyval = rel(EQ, yypvt[-2], yypvt[-0]); } break;
        !           895: case 6:
        !           896: # line 31 "expr.y"
        !           897:  { yyval = rel(GT, yypvt[-2], yypvt[-0]); } break;
        !           898: case 7:
        !           899: # line 32 "expr.y"
        !           900:  { yyval = rel(GEQ, yypvt[-2], yypvt[-0]); } break;
        !           901: case 8:
        !           902: # line 33 "expr.y"
        !           903:  { yyval = rel(LT, yypvt[-2], yypvt[-0]); } break;
        !           904: case 9:
        !           905: # line 34 "expr.y"
        !           906:  { yyval = rel(LEQ, yypvt[-2], yypvt[-0]); } break;
        !           907: case 10:
        !           908: # line 35 "expr.y"
        !           909:  { yyval = rel(NEQ, yypvt[-2], yypvt[-0]); } break;
        !           910: case 11:
        !           911: # line 36 "expr.y"
        !           912:  { yyval = arith(ADD, yypvt[-2], yypvt[-0]); } break;
        !           913: case 12:
        !           914: # line 37 "expr.y"
        !           915:  { yyval = arith(SUBT, yypvt[-2], yypvt[-0]); } break;
        !           916: case 13:
        !           917: # line 38 "expr.y"
        !           918:  { yyval = arith(MULT, yypvt[-2], yypvt[-0]); } break;
        !           919: case 14:
        !           920: # line 39 "expr.y"
        !           921:  { yyval = arith(DIV, yypvt[-2], yypvt[-0]); } break;
        !           922: case 15:
        !           923: # line 40 "expr.y"
        !           924:  { yyval = arith(REM, yypvt[-2], yypvt[-0]); } break;
        !           925: case 16:
        !           926: # line 41 "expr.y"
        !           927:  { yyval = match(yypvt[-2], yypvt[-0]); } break;
        !           928: case 17:
        !           929: # line 42 "expr.y"
        !           930:  { yyval = match(yypvt[-1], yypvt[-0]); } break;
        !           931: case 18:
        !           932: # line 43 "expr.y"
        !           933:  { yyval = substr(yypvt[-2], yypvt[-1], yypvt[-0]); } break;
        !           934: case 19:
        !           935: # line 44 "expr.y"
        !           936:  { yyval = length(yypvt[-0]); } break;
        !           937: case 20:
        !           938: # line 45 "expr.y"
        !           939:  { yyval = index(yypvt[-1], yypvt[-0]); } break;
        !           940:                }
        !           941:                goto yystack;  /* stack new state and value */
        !           942: 
        !           943:        }

unix.superglobalmegacorp.com

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