Annotation of coherent/b/lib/yyparse.c,v, revision 1.1.1.1

1.1       root        1: head     1.1;
                      2: branch   ;
                      3: access   ;
                      4: symbols  ;
                      5: locks    bin:1.1;
                      6: comment  @ * @;
                      7: 
                      8: 
                      9: 1.1
                     10: date     93.07.09.08.32.45;  author bin;  state Exp;
                     11: branches ;
                     12: next     ;
                     13: 
                     14: 
                     15: desc
                     16: @new file from nigel for 4.2 alpha
                     17: @
                     18: 
                     19: 
                     20: 
                     21: 1.1
                     22: log
                     23: @Initial revision
                     24: @
                     25: text
                     26: @#define       YYACTSH         13
                     27: #define        YYAMASK         017777
                     28: #define        YYSHIFTACT      0
                     29: #define        YYREDACT        1
                     30: #define        YYACCEPTACT     2
                     31: #define        YYERRACT        3
                     32: #define        YYGOTO          4
                     33: #define        YYPACTION       5
                     34: #define        YYEOFVAL        (-1)
                     35: #define        YYERRVAL        (-2)
                     36: #define        YYOTHERS        (-1000)
                     37: 
                     38: $D
                     39: 
                     40: #define YYNOCHAR (-1000)
                     41: #define        yyerrok yyerrflag=0
                     42: #define        yyclearin       yylval=YYNOCHAR
                     43: int yystack[YYMAXDEPTH];
                     44: YYSTYPE yyvstack[YYMAXDEPTH], *yyv;
                     45: int yychar;
                     46: 
                     47: #ifdef YYDEBUG
                     48: int yydebug = 1;       /* No sir, not in the BSS */
                     49: #include <stdio.h>
                     50: #endif
                     51: 
                     52: short yyerrflag;
                     53: int *yys;
                     54: 
                     55: yyparse()
                     56: {
                     57:        register YYSTYPE *yypvt;
                     58:        int act;
                     59:        register unsigned *ip, yystate;
                     60:        int pno;
                     61:        yystate = 0;
                     62:        yychar = YYNOCHAR;
                     63:        yyv = &yyvstack[-1];
                     64:        yys = &yystack[-1];
                     65: 
                     66: stack:
                     67:        if( ++yys >= &yystack[YYMAXDEPTH] ) {
                     68:                write(2, "Stack overflow\n", 15);
                     69:                exit(1);
                     70:        }
                     71:        *yys = yystate;
                     72:        *++yyv = yyval;
                     73: #ifdef YYDEBUG
                     74:        if( yydebug )
                     75:                fprintf(stdout, "Stack state %d, char %d\n", yystate, yychar);
                     76: #endif
                     77: 
                     78: read:
                     79:        ip = &yyact[yypa[yystate]];
                     80:        if( ip[1] != YYNOCHAR ) {
                     81:                if( yychar == YYNOCHAR ) {
                     82:                        yychar = yylex();
                     83: #ifdef YYDEBUG
                     84:                        if( yydebug )
                     85:                                fprintf(stdout, "lex read char %d, val %d\n", yychar, yylval);
                     86: #endif
                     87:                }
                     88:                while (ip[1]!=YYNOCHAR) {
                     89:                        if (ip[1]==yychar)
                     90:                                break;
                     91:                        ip += 2;
                     92:                }
                     93:        }
                     94:        act = ip[0];
                     95:        switch( act>>YYACTSH ) {
                     96:        case YYSHIFTACT:
                     97:                if( ip[1]==YYNOCHAR )
                     98:                        goto YYerract;
                     99:                if( yychar != -1 )
                    100:                        yychar = YYNOCHAR; /* dont throw away EOF */
                    101:                yystate = act&YYAMASK;
                    102:                yyval = yylval;
                    103: #ifdef YYDEBUG
                    104:                if( yydebug )
                    105:                        fprintf(stdout, "shift %d\n", yystate);
                    106: #endif
                    107:                if( yyerrflag )
                    108:                        --yyerrflag;
                    109:                goto stack;
                    110: 
                    111:        case YYACCEPTACT:
                    112: #ifdef YYDEBUG
                    113:                if( yydebug )
                    114:                        fprintf(stdout, "accept\n");
                    115: #endif
                    116:                return(0);
                    117: 
                    118:        case YYERRACT:
                    119:        YYerract:
                    120:                switch (yyerrflag) {
                    121:                case 0:
                    122:                        yyerror("Syntax error");
                    123: 
                    124:                case 1:
                    125:                case 2:
                    126: 
                    127:                        yyerrflag = 3;
                    128:                        while( yys >= & yystack[0] ) {
                    129:                                ip = &yyact[yypa[*yys]];
                    130:                                while( ip[1]!=YYNOCHAR )
                    131:                                        ip += 2;
                    132:                                if( (*ip&~YYAMASK) == (YYSHIFTACT<<YYACTSH) ) {
                    133:                                        yystate = *ip&YYAMASK;
                    134:                                        goto stack;
                    135:                                }
                    136: #ifdef YYDEBUG
                    137:                                if( yydebug )
                    138:                                        fprintf(stderr, "error recovery leaves state %d, uncovers %d\n", *yys, yys[-1]);
                    139: #endif
                    140:                                yys--;
                    141:                                yyv--;
                    142:                        }
                    143: #ifdef YYDEBUG
                    144:                        if( yydebug )
                    145:                                fprintf(stderr, "no shift on error; abort\n");
                    146: #endif
                    147:                        return(1);
                    148: 
                    149:                case 3:
                    150: #ifdef YYDEBUG
                    151:                        if( yydebug )
                    152:                                fprintf(stderr, "Error recovery clobbers char %o\n", yychar);
                    153: #endif
                    154:                        if( yychar==YYEOFVAL )
                    155:                                return(1);
                    156:                        yychar = YYNOCHAR;
                    157:                        goto read;
                    158:                }
                    159: 
                    160:        case YYREDACT:
                    161:                pno = act&YYAMASK;
                    162: #ifdef YYDEBUG
                    163:                if( yydebug )
                    164:                        fprintf(stdout, "reduce %d\n", pno);
                    165: #endif
                    166:                yypvt = yyv;
                    167:                yyv -= yypn[pno];
                    168:                yys -= yypn[pno];
                    169:                yyval = yyv[1];
                    170:                switch(pno) {
                    171: $A
                    172:                }
                    173:                ip = &yygo[ yypgo[yypdnt[pno]] ];
                    174:                while( *ip!=*yys && *ip!=YYNOCHAR )
                    175:                        ip += 2;
                    176:                yystate = ip[1];
                    177:                goto stack;
                    178:        }
                    179: }
                    180: 
                    181: 
                    182: 
                    183: 
                    184: @

unix.superglobalmegacorp.com

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