home *** CD-ROM | disk | FTP | other *** search
- # define CHAR 257
- # define NUMBER 258
- # define SECTEND 259
- # define SCDECL 260
- # define XSCDECL 261
- # define WHITESPACE 262
- # define NAME 263
- # define PREVCCL 264
-
- # line 18 "parse.y"
- #include "flexdef.h"
-
- int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
- int trlcontxt, xcluflg, cclsorted, varlength;
- char clower();
-
- static int madeany = false; /* whether we've made the '.' character class */
-
- #define yyclearin yychar = -1
- #define yyerrok yyerrflag = 0
- extern int yychar;
- extern short yyerrflag;
- #ifndef YYMAXDEPTH
- #define YYMAXDEPTH 150
- #endif
- #ifndef YYSTYPE
- #define YYSTYPE int
- #endif
- YYSTYPE yylval, yyval;
- # define YYERRCODE 256
-
- # line 456 "parse.y"
-
-
- /* synerr - report a syntax error
- *
- * synopsis
- * char str[];
- * synerr( str );
- */
-
- synerr( str )
- char str[];
-
- {
- syntaxerror = true;
- fprintf( stderr, "Syntax error at line %d: %s\n", linenum, str );
- }
-
-
- /* yyerror - eat up an error message from the parser
- *
- * synopsis
- * char msg[];
- * yyerror( msg );
- */
-
- yyerror( msg )
- char msg[];
-
- {
- }
- short yyexca[] ={
- -1, 1,
- 0, -1,
- -2, 0,
- -1, 11,
- 0, 1,
- -2, 14,
- };
- # define YYNPROD 51
- # define YYLAST 268
- short yyact[]={
-
- 29, 29, 29, 45, 16, 71, 30, 30, 30, 56,
- 44, 15, 26, 26, 26, 33, 7, 8, 9, 77,
- 12, 75, 67, 64, 63, 78, 22, 4, 72, 42,
- 79, 66, 55, 39, 48, 49, 54, 41, 62, 25,
- 41, 74, 24, 20, 35, 10, 52, 27, 23, 43,
- 18, 17, 13, 14, 6, 50, 61, 32, 32, 32,
- 19, 36, 37, 38, 47, 11, 46, 5, 3, 2,
- 1, 58, 59, 0, 53, 0, 0, 0, 0, 0,
- 57, 0, 0, 60, 0, 0, 47, 0, 0, 0,
- 0, 70, 69, 0, 0, 0, 0, 0, 0, 0,
- 47, 0, 0, 0, 0, 0, 0, 0, 0, 73,
- 0, 0, 0, 0, 40, 51, 0, 40, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 76, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 68, 68, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 21, 31, 31, 31, 0, 0, 0, 0,
- 28, 28, 28, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 65, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 34 };
- short yypact[]={
-
- -1000,-1000,-229,-243, 35,-1000,-242,-1000,-1000,-1000,
- -1000,-1000,-252, -34, 5,-1000,-1000, 34, -33, -32,
- -7,-1000,-253, -32, -32, -8,-1000,-1000,-1000,-1000,
- -32,-1000, -62,-1000,-254,-1000, -32, -7, -7,-1000,
- -32,-1000,-1000, -6,-1000,-1000, -32, -8,-1000,-1000,
- -1000,-234, -11, -10, -71,-1000,-1000, -7,-1000,-1000,
- -32,-1000,-258, -16,-1000,-1000,-1000,-1000, -4, -72,
- -1000,-1000,-106,-1000,-232,-1000, -95,-1000,-1000,-1000 };
- short yypgo[]={
-
- 0, 70, 69, 68, 67, 65, 54, 53, 52, 51,
- 50, 43, 33, 49, 42, 48, 39, 47, 46, 36 };
- short yyr1[]={
-
- 0, 1, 2, 3, 3, 3, 4, 6, 6, 7,
- 7, 7, 5, 5, 8, 9, 9, 9, 9, 9,
- 10, 13, 13, 13, 12, 12, 11, 11, 11, 15,
- 14, 14, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 17, 17, 19, 19, 19, 18,
- 18 };
- short yyr2[]={
-
- 0, 4, 0, 5, 0, 2, 1, 1, 1, 3,
- 1, 1, 4, 0, 0, 4, 3, 3, 2, 1,
- 3, 3, 1, 1, 1, 0, 3, 2, 1, 2,
- 2, 1, 2, 2, 2, 6, 5, 4, 1, 1,
- 1, 3, 3, 1, 3, 4, 4, 2, 0, 2,
- 0 };
- short yychk[]={
-
- -1000, -1, -2, -3, 256, -4, -6, 259, 260, 261,
- 10, -5, 262, -8, -7, 263, 256, -9, -10, 94,
- -11, 256, 60, -15, -14, -16, 46, -17, 264, 34,
- 40, 257, 91, 10, 262, 10, 94, -11, -11, -12,
- 124, 47, 36, -13, 263, 256, -14, -16, 42, 43,
- 63, 123, -18, -11, -19, 94, 263, -11, -12, -12,
- -14, 62, 44, 258, 34, 257, 41, 93, 257, -19,
- -12, 263, 44, 125, 45, 93, 258, 125, 257, 125 };
- short yydef[]={
-
- 2, -2, 4, 0, 0, 13, 0, 6, 7, 8,
- 5, -2, 0, 0, 0, 10, 11, 0, 0, 0,
- 25, 19, 0, 0, 28, 31, 38, 39, 40, 50,
- 0, 43, 48, 3, 0, 12, 0, 25, 25, 18,
- 0, 29, 24, 0, 22, 23, 27, 30, 32, 33,
- 34, 0, 0, 0, 0, 48, 9, 25, 16, 17,
- 26, 20, 0, 0, 41, 49, 42, 44, 47, 0,
- 15, 21, 0, 37, 0, 45, 0, 36, 46, 35 };
- #ifndef lint
- static char yaccpar_sccsid[] = "@(#)yaccpar 4.1 (Berkeley) 2/11/83";
- #endif not lint
-
- #
- # define YYFLAG -1000
- # define YYERROR goto yyerrlab
- # define YYACCEPT return(0)
- # define YYABORT return(1)
-
- /* parser for yacc output */
-
- #ifdef YYDEBUG
- int yydebug = 0; /* 1 for debugging */
- #endif
- YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
- int yychar = -1; /* current input token number */
- int yynerrs = 0; /* number of errors */
- short yyerrflag = 0; /* error recovery flag */
-
- yyparse() {
-
- short yys[YYMAXDEPTH];
- short yyj, yym;
- register YYSTYPE *yypvt;
- register short yystate, *yyps, yyn;
- register YYSTYPE *yypv;
- register short *yyxi;
-
- yystate = 0;
- yychar = -1;
- yynerrs = 0;
- yyerrflag = 0;
- yyps= &yys[-1];
- yypv= &yyv[-1];
-
- yystack: /* put a state and value onto the stack */
-
- #ifdef YYDEBUG
- if( yydebug ) printf( "state %d, char 0%o\n", yystate, yychar );
- #endif
- if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
- *yyps = yystate;
- ++yypv;
- *yypv = yyval;
-
- yynewstate:
-
- yyn = yypact[yystate];
-
- if( yyn<= YYFLAG ) goto yydefault; /* simple state */
-
- if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
- if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
-
- if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
- yychar = -1;
- yyval = yylval;
- yystate = yyn;
- if( yyerrflag > 0 ) --yyerrflag;
- goto yystack;
- }
-
- yydefault:
- /* default state action */
-
- if( (yyn=yydef[yystate]) == -2 ) {
- if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
- /* look through exception table */
-
- for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
-
- while( *(yyxi+=2) >= 0 ){
- if( *yyxi == yychar ) break;
- }
- if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */
- }
-
- if( yyn == 0 ){ /* error */
- /* error ... attempt to resume parsing */
-
- switch( yyerrflag ){
-
- case 0: /* brand new error */
-
- yyerror( "syntax error" );
- yyerrlab:
- ++yynerrs;
-
- case 1:
- case 2: /* incompletely recovered error ... try again */
-
- yyerrflag = 3;
-
- /* find a state where "error" is a legal shift action */
-
- while ( yyps >= yys ) {
- yyn = yypact[*yyps] + YYERRCODE;
- if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
- yystate = yyact[yyn]; /* simulate a shift of "error" */
- goto yystack;
- }
- yyn = yypact[*yyps];
-
- /* the current yyps has no shift onn "error", pop stack */
-
- #ifdef YYDEBUG
- if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
- #endif
- --yyps;
- --yypv;
- }
-
- /* there is no state on the stack with an error shift ... abort */
-
- yyabort:
- return(1);
-
-
- case 3: /* no shift yet; clobber input char */
-
- #ifdef YYDEBUG
- if( yydebug ) printf( "error recovery discards char %d\n", yychar );
- #endif
-
- if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
- yychar = -1;
- goto yynewstate; /* try again in the same state */
-
- }
-
- }
-
- /* reduction by production yyn */
-
- #ifdef YYDEBUG
- if( yydebug ) printf("reduce %d\n",yyn);
- #endif
- yyps -= yyr2[yyn];
- yypvt = yypv;
- yypv -= yyr2[yyn];
- yyval = yypv[1];
- yym=yyn;
- /* consult goto table to find next state */
- yyn = yyr1[yyn];
- yyj = yypgo[yyn] + *yyps + 1;
- if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
- switch(yym){
-
- case 2:
- # line 33 "parse.y"
- {
- /* initialize for processing rules */
-
- /* create default DFA start condition */
- scinstal( "INITIAL", false );
- } break;
- case 5:
- # line 44 "parse.y"
- { synerr( "unknown error processing section 1" ); } break;
- case 7:
- # line 51 "parse.y"
- {
- /* these productions are separate from the s1object
- * rule because the semantics must be done before
- * we parse the remainder of an s1object
- */
-
- xcluflg = false;
- } break;
- case 8:
- # line 61 "parse.y"
- { xcluflg = true; } break;
- case 9:
- # line 65 "parse.y"
- { scinstal( nmstr, xcluflg ); } break;
- case 10:
- # line 68 "parse.y"
- { scinstal( nmstr, xcluflg ); } break;
- case 11:
- # line 71 "parse.y"
- { synerr( "bad start condition list" ); } break;
- case 14:
- # line 79 "parse.y"
- {
- /* initialize for a parse of one rule */
- trlcontxt = varlength = false;
- trailcnt = headcnt = rulelen = 0;
- } break;
- case 15:
- # line 87 "parse.y"
- {
- pat = link_machines( yypvt[-1], yypvt[-0] );
- add_accept( pat, headcnt, trailcnt );
-
- for ( i = 1; i <= actvp; ++i )
- scbol[actvsc[i]] = mkbranch( scbol[actvsc[i]], pat );
- } break;
- case 16:
- # line 96 "parse.y"
- {
- pat = link_machines( yypvt[-1], yypvt[-0] );
- add_accept( pat, headcnt, trailcnt );
-
- for ( i = 1; i <= actvp; ++i )
- scset[actvsc[i]] = mkbranch( scset[actvsc[i]], pat );
- } break;
- case 17:
- # line 105 "parse.y"
- {
- pat = link_machines( yypvt[-1], yypvt[-0] );
- add_accept( pat, headcnt, trailcnt );
-
- /* add to all non-exclusive start conditions,
- * including the default (0) start condition
- */
-
- for ( i = 1; i <= lastsc; ++i )
- if ( ! scxclu[i] )
- scbol[i] = mkbranch( scbol[i], pat );
- } break;
- case 18:
- # line 119 "parse.y"
- {
- pat = link_machines( yypvt[-1], yypvt[-0] );
- add_accept( pat, headcnt, trailcnt );
-
- for ( i = 1; i <= lastsc; ++i )
- if ( ! scxclu[i] )
- scset[i] = mkbranch( scset[i], pat );
- } break;
- case 19:
- # line 129 "parse.y"
- { synerr( "unrecognized rule" ); } break;
- case 21:
- # line 136 "parse.y"
- {
- if ( (scnum = sclookup( nmstr )) == 0 )
- synerr( "undeclared start condition" );
-
- else
- actvsc[++actvp] = scnum;
- } break;
- case 22:
- # line 145 "parse.y"
- {
- if ( (scnum = sclookup( nmstr )) == 0 )
- synerr( "undeclared start condition" );
- else
- actvsc[actvp = 1] = scnum;
- } break;
- case 23:
- # line 153 "parse.y"
- { synerr( "bad start condition list" ); } break;
- case 24:
- # line 157 "parse.y"
- {
- if ( trlcontxt )
- {
- synerr( "trailing context used twice" );
- yyval = mkstate( SYM_EPSILON );
- }
- else
- {
- trlcontxt = true;
-
- if ( ! varlength )
- headcnt = rulelen;
-
- ++rulelen;
- trailcnt = 1;
-
- eps = mkstate( SYM_EPSILON );
- yyval = link_machines( eps, mkstate( '\n' ) );
- }
- } break;
- case 25:
- # line 179 "parse.y"
- {
- yyval = mkstate( SYM_EPSILON );
-
- if ( trlcontxt )
- {
- if ( varlength && headcnt == 0 )
- /* both head and trail are variable-length */
- synerr( "illegal trailing context" );
-
- else
- trailcnt = rulelen;
- }
- } break;
- case 26:
- # line 195 "parse.y"
- {
- varlength = true;
-
- yyval = mkor( yypvt[-2], yypvt[-0] );
- } break;
- case 27:
- # line 202 "parse.y"
- { yyval = link_machines( yypvt[-1], yypvt[-0] ); } break;
- case 28:
- # line 205 "parse.y"
- { yyval = yypvt[-0]; } break;
- case 29:
- # line 210 "parse.y"
- {
- /* this rule is separate from the others for "re" so
- * that the reduction will occur before the trailing
- * series is parsed
- */
-
- if ( trlcontxt )
- synerr( "trailing context used twice" );
- else
- trlcontxt = true;
-
- if ( varlength )
- /* the trailing context had better be fixed-length */
- varlength = false;
- else
- headcnt = rulelen;
-
- rulelen = 0;
- yyval = yypvt[-1];
- } break;
- case 30:
- # line 233 "parse.y"
- {
- /* this is where concatenation of adjacent patterns
- * gets done
- */
- yyval = link_machines( yypvt[-1], yypvt[-0] );
- } break;
- case 31:
- # line 241 "parse.y"
- { yyval = yypvt[-0]; } break;
- case 32:
- # line 245 "parse.y"
- {
- varlength = true;
-
- yyval = mkclos( yypvt[-1] );
- } break;
- case 33:
- # line 252 "parse.y"
- {
- varlength = true;
-
- yyval = mkposcl( yypvt[-1] );
- } break;
- case 34:
- # line 259 "parse.y"
- {
- varlength = true;
-
- yyval = mkopt( yypvt[-1] );
- } break;
- case 35:
- # line 266 "parse.y"
- {
- varlength = true;
-
- if ( yypvt[-3] > yypvt[-1] || yypvt[-3] <= 0 )
- {
- synerr( "bad iteration values" );
- yyval = yypvt[-5];
- }
- else
- yyval = mkrep( yypvt[-5], yypvt[-3], yypvt[-1] );
- } break;
- case 36:
- # line 279 "parse.y"
- {
- varlength = true;
-
- if ( yypvt[-2] <= 0 )
- {
- synerr( "iteration value must be positive" );
- yyval = yypvt[-4];
- }
-
- else
- yyval = mkrep( yypvt[-4], yypvt[-2], INFINITY );
- } break;
- case 37:
- # line 293 "parse.y"
- {
- /* the singleton could be something like "(foo)",
- * in which case we have no idea what its length
- * is, so we punt here.
- */
- varlength = true;
-
- if ( yypvt[-1] <= 0 )
- {
- synerr( "iteration value must be positive" );
- yyval = yypvt[-3];
- }
-
- else
- yyval = link_machines( yypvt[-3], copysingl( yypvt[-3], yypvt[-1] - 1 ) );
- } break;
- case 38:
- # line 311 "parse.y"
- {
- if ( ! madeany )
- {
- /* create the '.' character class */
- anyccl = cclinit();
- ccladd( anyccl, '\n' );
- cclnegate( anyccl );
-
- if ( useecs )
- mkeccl( ccltbl + cclmap[anyccl],
- ccllen[anyccl], nextecm,
- ecgroup, CSIZE );
-
- madeany = true;
- }
-
- ++rulelen;
-
- yyval = mkstate( -anyccl );
- } break;
- case 39:
- # line 333 "parse.y"
- {
- if ( ! cclsorted )
- /* sort characters for fast searching. We use a
- * shell sort since this list could be large.
- */
- cshell( ccltbl + cclmap[yypvt[-0]], ccllen[yypvt[-0]] );
-
- if ( useecs )
- mkeccl( ccltbl + cclmap[yypvt[-0]], ccllen[yypvt[-0]],
- nextecm, ecgroup, CSIZE );
-
- ++rulelen;
-
- yyval = mkstate( -yypvt[-0] );
- } break;
- case 40:
- # line 350 "parse.y"
- {
- ++rulelen;
-
- yyval = mkstate( -yypvt[-0] );
- } break;
- case 41:
- # line 357 "parse.y"
- { yyval = yypvt[-1]; } break;
- case 42:
- # line 360 "parse.y"
- { yyval = yypvt[-1]; } break;
- case 43:
- # line 363 "parse.y"
- {
- ++rulelen;
-
- if ( yypvt[-0] == '\0' )
- synerr( "null in rule" );
-
- if ( caseins && yypvt[-0] >= 'A' && yypvt[-0] <= 'Z' )
- yypvt[-0] = clower( yypvt[-0] );
-
- yyval = mkstate( yypvt[-0] );
- } break;
- case 44:
- # line 377 "parse.y"
- { yyval = yypvt[-1]; } break;
- case 45:
- # line 380 "parse.y"
- {
- /* *Sigh* - to be compatible Unix lex, negated ccls
- * match newlines
- */
- #ifdef NOTDEF
- ccladd( yypvt[-1], '\n' ); /* negated ccls don't match '\n' */
- cclsorted = false; /* because we added the newline */
- #endif
- cclnegate( yypvt[-1] );
- yyval = yypvt[-1];
- } break;
- case 46:
- # line 394 "parse.y"
- {
- if ( yypvt[-2] > yypvt[-0] )
- synerr( "negative range in character class" );
-
- else
- {
- if ( caseins )
- {
- if ( yypvt[-2] >= 'A' && yypvt[-2] <= 'Z' )
- yypvt[-2] = clower( yypvt[-2] );
- if ( yypvt[-0] >= 'A' && yypvt[-0] <= 'Z' )
- yypvt[-0] = clower( yypvt[-0] );
- }
-
- for ( i = yypvt[-2]; i <= yypvt[-0]; ++i )
- ccladd( yypvt[-3], i );
-
- /* keep track if this ccl is staying in alphabetical
- * order
- */
- cclsorted = cclsorted && (yypvt[-2] > lastchar);
- lastchar = yypvt[-0];
- }
-
- yyval = yypvt[-3];
- } break;
- case 47:
- # line 422 "parse.y"
- {
- if ( caseins )
- if ( yypvt[-0] >= 'A' && yypvt[-0] <= 'Z' )
- yypvt[-0] = clower( yypvt[-0] );
-
- ccladd( yypvt[-1], yypvt[-0] );
- cclsorted = cclsorted && (yypvt[-0] > lastchar);
- lastchar = yypvt[-0];
- yyval = yypvt[-1];
- } break;
- case 48:
- # line 434 "parse.y"
- {
- cclsorted = true;
- lastchar = 0;
- yyval = cclinit();
- } break;
- case 49:
- # line 442 "parse.y"
- {
- if ( caseins )
- if ( yypvt[-0] >= 'A' && yypvt[-0] <= 'Z' )
- yypvt[-0] = clower( yypvt[-0] );
-
- ++rulelen;
-
- yyval = link_machines( yypvt[-1], mkstate( yypvt[-0] ) );
- } break;
- case 50:
- # line 453 "parse.y"
- { yyval = mkstate( SYM_EPSILON ); } break;
- }
- goto yystack; /* stack new state and value */
-
- }
-