home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char yysccsid[] = "@(#)yaccpar 1.6 (Berkeley) 07/15/90";
- #endif
- #line 7 "parse.y"
- /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Vern Paxson.
- *
- * The United States Government has rights in this work pursuant
- * to contract no. DE-AC03-76SF00098 between the United States
- * Department of Energy and the University of California.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement: ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
- #ifndef lint
- static char rcsid[] =
- "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/parse.y,v 2.7 90/06/27 23:48:31 vern Exp $ (LBL)";
- #endif
-
- #include "flexdef.h"
-
- int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
- int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
- Char clower();
-
- static int madeany = false; /* whether we've made the '.' character class */
- int previous_continued_action; /* whether the previous rule's action was '|' */
-
- #line 46 "y_tab.c"
- #define CHAR 257
- #define NUMBER 258
- #define SECTEND 259
- #define SCDECL 260
- #define XSCDECL 261
- #define WHITESPACE 262
- #define NAME 263
- #define PREVCCL 264
- #define EOF_OP 265
- #define YYERRCODE 256
- short yylhs[] = { -1,
- 0, 1, 2, 2, 2, 3, 6, 6, 7, 7,
- 7, 4, 4, 5, 8, 8, 8, 8, 8, 8,
- 8, 9, 11, 11, 11, 10, 10, 10, 10, 13,
- 13, 12, 14, 14, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 16, 16, 18, 18,
- 18, 17, 17,
- };
- short yylen[] = { 2,
- 5, 0, 5, 0, 2, 1, 1, 1, 3, 1,
- 1, 4, 0, 0, 3, 2, 2, 1, 2, 1,
- 1, 3, 3, 1, 1, 2, 3, 2, 1, 3,
- 1, 2, 2, 1, 2, 2, 2, 6, 5, 4,
- 1, 1, 1, 3, 3, 1, 3, 4, 4, 2,
- 0, 2, 0,
- };
- short yydefred[] = { 2,
- 0, 0, 0, 0, 5, 6, 7, 8, 13, 0,
- 14, 0, 0, 11, 10, 0, 21, 46, 43, 20,
- 0, 0, 41, 53, 0, 0, 0, 0, 18, 0,
- 0, 0, 0, 42, 0, 3, 17, 25, 24, 0,
- 0, 0, 51, 0, 12, 19, 0, 16, 0, 28,
- 0, 32, 0, 35, 36, 37, 0, 9, 22, 0,
- 52, 44, 45, 0, 0, 47, 15, 27, 0, 0,
- 23, 48, 0, 0, 40, 49, 0, 39, 38,
- };
- short yydgoto[] = { 1,
- 2, 4, 9, 11, 13, 10, 16, 27, 28, 29,
- 40, 30, 31, 32, 33, 34, 41, 44,
- };
- short yysindex[] = { 0,
- 0, -231, 28, -186, 0, 0, 0, 0, 0, -221,
- 0, -212, -32, 0, 0, -9, 0, 0, 0, 0,
- -28, -203, 0, 0, -28, -39, 47, -30, 0, -28,
- -15, -28, 4, 0, -205, 0, 0, 0, 0, 8,
- -29, -19, 0, -86, 0, 0, -28, 0, -16, 0,
- -28, 0, 4, 0, 0, 0, -193, 0, 0, -194,
- 0, 0, 0, -84, 34, 0, 0, 0, -28, -21,
- 0, 0, -177, -110, 0, 0, -43, 0, 0,
- };
- short yyrindex[] = { 0,
- 0, -183, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 83, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, -82, 0, 0, 0, 0,
- 75, 7, -10, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 0,
- 0, 0, -7, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, -80, 0, 0, 0, 9, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- };
- short yygindex[] = { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
- 0, 0, 41, 36, 3, 0, 0, 45,
- };
- #define YYTABLESIZE 257
- short yytable[] = { 34,
- 36, 24, 33, 24, 62, 24, 66, 25, 72, 25,
- 51, 25, 50, 23, 78, 23, 31, 23, 30, 68,
- 50, 63, 74, 34, 3, 34, 33, 22, 33, 34,
- 34, 52, 33, 33, 53, 34, 34, 5, 33, 33,
- 12, 37, 31, 14, 30, 54, 55, 31, 48, 30,
- 15, 60, 38, 31, 43, 30, 45, 58, 26, 39,
- 26, 21, 26, 47, 70, 42, 56, 67, 71, 59,
- 49, 53, 6, 7, 8, 4, 4, 4, 73, 76,
- 34, 79, 1, 33, 29, 26, 69, 64, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 75, 51, 0, 0, 51, 51, 0,
- 0, 0, 0, 34, 0, 0, 33, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 57, 0, 0, 0,
- 31, 0, 30, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 77, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 65, 0, 65, 0, 51, 0, 50, 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, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 17, 18, 0, 18, 61, 18, 0,
- 0, 19, 20, 19, 46, 19, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 34, 0, 0, 33,
- 0, 0, 35, 34, 0, 0, 33,
- };
- short yycheck[] = { 10,
- 10, 34, 10, 34, 34, 34, 93, 40, 93, 40,
- 93, 40, 93, 46, 125, 46, 10, 46, 10, 36,
- 36, 41, 44, 34, 256, 36, 34, 60, 36, 40,
- 41, 47, 40, 41, 32, 46, 47, 10, 46, 47,
- 262, 21, 36, 256, 36, 42, 43, 41, 28, 41,
- 263, 44, 256, 47, 94, 47, 10, 263, 91, 263,
- 91, 94, 91, 94, 258, 25, 63, 47, 263, 62,
- 30, 69, 259, 260, 261, 259, 260, 261, 45, 257,
- 91, 125, 0, 91, 10, 10, 51, 43, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 125, 124, -1, -1, 124, 124, -1,
- -1, -1, -1, 124, -1, -1, 124, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 123, -1, -1, -1,
- 124, -1, 124, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 258, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 257, -1, 257, -1, 257, -1, 257, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 256, 257, -1, 257, 257, 257, -1,
- -1, 264, 265, 264, 265, 264, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 257, -1, -1, 257,
- -1, -1, 262, 264, -1, -1, 264,
- };
- #define YYFINAL 1
- #ifndef YYDEBUG
- #define YYDEBUG 0
- #endif
- #define YYMAXTOKEN 265
- #if YYDEBUG
- char *yyname[] = {
- "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CHAR","NUMBER","SECTEND",
- "SCDECL","XSCDECL","WHITESPACE","NAME","PREVCCL","EOF_OP",
- };
- char *yyrule[] = {
- "$accept : goal",
- "goal : initlex sect1 sect1end sect2 initforrule",
- "initlex :",
- "sect1 : sect1 startconddecl WHITESPACE namelist1 '\\n'",
- "sect1 :",
- "sect1 : error '\\n'",
- "sect1end : SECTEND",
- "startconddecl : SCDECL",
- "startconddecl : XSCDECL",
- "namelist1 : namelist1 WHITESPACE NAME",
- "namelist1 : NAME",
- "namelist1 : error",
- "sect2 : sect2 initforrule flexrule '\\n'",
- "sect2 :",
- "initforrule :",
- "flexrule : scon '^' rule",
- "flexrule : scon rule",
- "flexrule : '^' rule",
- "flexrule : rule",
- "flexrule : scon EOF_OP",
- "flexrule : EOF_OP",
- "flexrule : error",
- "scon : '<' namelist2 '>'",
- "namelist2 : namelist2 ',' NAME",
- "namelist2 : NAME",
- "namelist2 : error",
- "rule : re2 re",
- "rule : re2 re '$'",
- "rule : re '$'",
- "rule : re",
- "re : re '|' series",
- "re : series",
- "re2 : re '/'",
- "series : series singleton",
- "series : singleton",
- "singleton : singleton '*'",
- "singleton : singleton '+'",
- "singleton : singleton '?'",
- "singleton : singleton '{' NUMBER ',' NUMBER '}'",
- "singleton : singleton '{' NUMBER ',' '}'",
- "singleton : singleton '{' NUMBER '}'",
- "singleton : '.'",
- "singleton : fullccl",
- "singleton : PREVCCL",
- "singleton : '\"' string '\"'",
- "singleton : '(' re ')'",
- "singleton : CHAR",
- "fullccl : '[' ccl ']'",
- "fullccl : '[' '^' ccl ']'",
- "ccl : ccl CHAR '-' CHAR",
- "ccl : ccl CHAR",
- "ccl :",
- "string : string CHAR",
- "string :",
- };
- #endif
- #ifndef YYSTYPE
- typedef int YYSTYPE;
- #endif
- #define yyclearin (yychar=(-1))
- #define yyerrok (yyerrflag=0)
- #ifndef YYSTACKSIZE
- #ifdef YYMAXDEPTH
- #define YYSTACKSIZE YYMAXDEPTH
- #else
- #define YYSTACKSIZE 600
- #endif
- #endif
- int yydebug;
- int yynerrs;
- int yyerrflag;
- int yychar;
- short *yyssp;
- YYSTYPE *yyvsp;
- YYSTYPE yyval;
- YYSTYPE yylval;
- #define yystacksize YYSTACKSIZE
- short yyss[YYSTACKSIZE];
- YYSTYPE yyvs[YYSTACKSIZE];
- #line 628 "parse.y"
-
-
- /* build_eof_action - build the "<<EOF>>" action for the active start
- * conditions
- */
-
- void build_eof_action()
-
- {
- register int i;
-
- for ( i = 1; i <= actvp; ++i )
- {
- if ( sceof[actvsc[i]] )
- format_pinpoint_message(
- "multiple <<EOF>> rules for start condition %s",
- scname[actvsc[i]] );
-
- else
- {
- sceof[actvsc[i]] = true;
- fprintf( temp_action_file, "case YY_STATE_EOF(%s):\n",
- scname[actvsc[i]] );
- }
- }
-
- line_directive_out( temp_action_file );
- }
-
-
- /* synerr - report a syntax error */
-
- void synerr( str )
- char str[];
-
- {
- syntaxerror = true;
- pinpoint_message( str );
- }
-
-
- /* format_pinpoint_message - write out a message formatted with one string,
- * pinpointing its location
- */
-
- void format_pinpoint_message( msg, arg )
- char msg[], arg[];
-
- {
- char errmsg[MAXLINE];
-
- (void) sprintf( errmsg, msg, arg );
- pinpoint_message( errmsg );
- }
-
-
- /* pinpoint_message - write out a message, pinpointing its location */
-
- void pinpoint_message( str )
- char str[];
-
- {
- fprintf( stderr, "\"%s\", line %d: %s\n", infilename, linenum, str );
- }
-
-
- /* yyerror - eat up an error message from the parser;
- * currently, messages are ignore
- */
-
- void yyerror( msg )
- char msg[];
-
- {
- }
- #line 341 "y_tab.c"
- #define YYABORT goto yyabort
- #define YYACCEPT goto yyaccept
- #define YYERROR goto yyerrlab
- int
- yyparse()
- {
- register int yym, yyn, yystate;
- #if YYDEBUG
- register char *yys;
- extern char *getenv();
-
- if (yys = getenv("YYDEBUG"))
- {
- yyn = *yys;
- if (yyn >= '0' && yyn <= '9')
- yydebug = yyn - '0';
- }
- #endif
-
- yynerrs = 0;
- yyerrflag = 0;
- yychar = (-1);
-
- yyssp = yyss;
- yyvsp = yyvs;
- *yyssp = yystate = 0;
-
- yyloop:
- if (yyn = yydefred[yystate]) goto yyreduce;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
- #if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("yydebug: state %d, reading %d (%s)\n", yystate,
- yychar, yys);
- }
- #endif
- }
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, shifting to state %d\n",
- yystate, yytable[yyn]);
- #endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- yychar = (-1);
- if (yyerrflag > 0) --yyerrflag;
- goto yyloop;
- }
- if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- yyn = yytable[yyn];
- goto yyreduce;
- }
- if (yyerrflag) goto yyinrecovery;
- #ifdef lint
- goto yynewerror;
- #endif
- yynewerror:
- yyerror("syntax error");
- #ifdef lint
- goto yyerrlab;
- #endif
- yyerrlab:
- ++yynerrs;
- yyinrecovery:
- if (yyerrflag < 3)
- {
- yyerrflag = 3;
- for (;;)
- {
- if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
- {
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, error recovery shifting\
- to state %d\n", *yyssp, yytable[yyn]);
- #endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- goto yyloop;
- }
- else
- {
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: error recovery discarding state %d\n",
- *yyssp);
- #endif
- if (yyssp <= yyss) goto yyabort;
- --yyssp;
- --yyvsp;
- }
- }
- }
- else
- {
- if (yychar == 0) goto yyabort;
- #if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("yydebug: state %d, error recovery discards token %d (%s)\n",
- yystate, yychar, yys);
- }
- #endif
- yychar = (-1);
- goto yyloop;
- }
- yyreduce:
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, reducing by rule %d (%s)\n",
- yystate, yyn, yyrule[yyn]);
- #endif
- yym = yylen[yyn];
- yyval = yyvsp[1-yym];
- switch (yyn)
- {
- case 1:
- #line 51 "parse.y"
- { /* add default rule */
- int def_rule;
-
- pat = cclinit();
- cclnegate( pat );
-
- def_rule = mkstate( -pat );
-
- finish_rule( def_rule, false, 0, 0 );
-
- for ( i = 1; i <= lastsc; ++i )
- scset[i] = mkbranch( scset[i], def_rule );
-
- if ( spprdflt )
- fputs( "YY_FATAL_ERROR( \"flex scanner jammed\" )",
- temp_action_file );
- else
- fputs( "ECHO", temp_action_file );
-
- fputs( ";\n\tYY_BREAK\n", temp_action_file );
- }
- break;
- case 2:
- #line 75 "parse.y"
- {
- /* initialize for processing rules */
-
- /* create default DFA start condition */
- scinstal( "INITIAL", false );
- }
- break;
- case 5:
- #line 86 "parse.y"
- { synerr( "unknown error processing section 1" ); }
- break;
- case 7:
- #line 93 "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 103 "parse.y"
- { xcluflg = true; }
- break;
- case 9:
- #line 107 "parse.y"
- { scinstal( nmstr, xcluflg ); }
- break;
- case 10:
- #line 110 "parse.y"
- { scinstal( nmstr, xcluflg ); }
- break;
- case 11:
- #line 113 "parse.y"
- { synerr( "bad start condition list" ); }
- break;
- case 14:
- #line 121 "parse.y"
- {
- /* initialize for a parse of one rule */
- trlcontxt = variable_trail_rule = varlength = false;
- trailcnt = headcnt = rulelen = 0;
- current_state_type = STATE_NORMAL;
- previous_continued_action = continued_action;
- new_rule();
- }
- break;
- case 15:
- #line 132 "parse.y"
- {
- pat = yyvsp[0];
- finish_rule( pat, variable_trail_rule,
- headcnt, trailcnt );
-
- for ( i = 1; i <= actvp; ++i )
- scbol[actvsc[i]] =
- mkbranch( scbol[actvsc[i]], pat );
-
- if ( ! bol_needed )
- {
- bol_needed = true;
-
- if ( performance_report )
- pinpoint_message(
- "'^' operator results in sub-optimal performance" );
- }
- }
- break;
- case 16:
- #line 152 "parse.y"
- {
- pat = yyvsp[0];
- finish_rule( pat, variable_trail_rule,
- headcnt, trailcnt );
-
- for ( i = 1; i <= actvp; ++i )
- scset[actvsc[i]] =
- mkbranch( scset[actvsc[i]], pat );
- }
- break;
- case 17:
- #line 163 "parse.y"
- {
- pat = yyvsp[0];
- finish_rule( pat, variable_trail_rule,
- 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 );
-
- if ( ! bol_needed )
- {
- bol_needed = true;
-
- if ( performance_report )
- pinpoint_message(
- "'^' operator results in sub-optimal performance" );
- }
- }
- break;
- case 18:
- #line 187 "parse.y"
- {
- pat = yyvsp[0];
- finish_rule( pat, variable_trail_rule,
- headcnt, trailcnt );
-
- for ( i = 1; i <= lastsc; ++i )
- if ( ! scxclu[i] )
- scset[i] = mkbranch( scset[i], pat );
- }
- break;
- case 19:
- #line 198 "parse.y"
- { build_eof_action(); }
- break;
- case 20:
- #line 201 "parse.y"
- {
- /* this EOF applies to all start conditions
- * which don't already have EOF actions
- */
- actvp = 0;
-
- for ( i = 1; i <= lastsc; ++i )
- if ( ! sceof[i] )
- actvsc[++actvp] = i;
-
- if ( actvp == 0 )
- pinpoint_message(
- "warning - all start conditions already have <<EOF>> rules" );
-
- else
- build_eof_action();
- }
- break;
- case 21:
- #line 220 "parse.y"
- { synerr( "unrecognized rule" ); }
- break;
- case 23:
- #line 227 "parse.y"
- {
- if ( (scnum = sclookup( nmstr )) == 0 )
- format_pinpoint_message(
- "undeclared start condition %s", nmstr );
-
- else
- actvsc[++actvp] = scnum;
- }
- break;
- case 24:
- #line 237 "parse.y"
- {
- if ( (scnum = sclookup( nmstr )) == 0 )
- format_pinpoint_message(
- "undeclared start condition %s", nmstr );
- else
- actvsc[actvp = 1] = scnum;
- }
- break;
- case 25:
- #line 246 "parse.y"
- { synerr( "bad start condition list" ); }
- break;
- case 26:
- #line 250 "parse.y"
- {
- if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON )
- /* provide final transition \now/ so it
- * will be marked as a trailing context
- * state
- */
- yyvsp[0] = link_machines( yyvsp[0], mkstate( SYM_EPSILON ) );
-
- mark_beginning_as_normal( yyvsp[0] );
- current_state_type = STATE_NORMAL;
-
- if ( previous_continued_action )
- {
- /* we need to treat this as variable trailing
- * context so that the backup does not happen
- * in the action but before the action switch
- * statement. If the backup happens in the
- * action, then the rules "falling into" this
- * one's action will *also* do the backup,
- * erroneously.
- */
- if ( ! varlength || headcnt != 0 )
- {
- fprintf( stderr,
- "%s: warning - trailing context rule at line %d made variable because\n",
- program_name, linenum );
- fprintf( stderr,
- " of preceding '|' action\n" );
- }
-
- /* mark as variable */
- varlength = true;
- headcnt = 0;
- }
-
- if ( varlength && headcnt == 0 )
- { /* variable trailing context rule */
- /* mark the first part of the rule as the accepting
- * "head" part of a trailing context rule
- */
- /* by the way, we didn't do this at the beginning
- * of this production because back then
- * current_state_type was set up for a trail
- * rule, and add_accept() can create a new
- * state ...
- */
- add_accept( yyvsp[-1], num_rules | YY_TRAILING_HEAD_MASK );
- variable_trail_rule = true;
- }
-
- else
- trailcnt = rulelen;
-
- yyval = link_machines( yyvsp[-1], yyvsp[0] );
- }
- break;
- case 27:
- #line 307 "parse.y"
- { synerr( "trailing context used twice" ); }
- break;
- case 28:
- #line 310 "parse.y"
- {
- if ( trlcontxt )
- {
- synerr( "trailing context used twice" );
- yyval = mkstate( SYM_EPSILON );
- }
-
- else if ( previous_continued_action )
- {
- /* see the comment in the rule for "re2 re"
- * above
- */
- if ( ! varlength || headcnt != 0 )
- {
- fprintf( stderr,
- "%s: warning - trailing context rule at line %d made variable because\n",
- program_name, linenum );
- fprintf( stderr,
- " of preceding '|' action\n" );
- }
-
- /* mark as variable */
- varlength = true;
- headcnt = 0;
- }
-
- trlcontxt = true;
-
- if ( ! varlength )
- headcnt = rulelen;
-
- ++rulelen;
- trailcnt = 1;
-
- eps = mkstate( SYM_EPSILON );
- yyval = link_machines( yyvsp[-1],
- link_machines( eps, mkstate( '\n' ) ) );
- }
- break;
- case 29:
- #line 350 "parse.y"
- {
- yyval = yyvsp[0];
-
- if ( trlcontxt )
- {
- if ( varlength && headcnt == 0 )
- /* both head and trail are variable-length */
- variable_trail_rule = true;
- else
- trailcnt = rulelen;
- }
- }
- break;
- case 30:
- #line 366 "parse.y"
- {
- varlength = true;
- yyval = mkor( yyvsp[-2], yyvsp[0] );
- }
- break;
- case 31:
- #line 372 "parse.y"
- { yyval = yyvsp[0]; }
- break;
- case 32:
- #line 377 "parse.y"
- {
- /* this rule is written separately so
- * the reduction will occur before the trailing
- * series is parsed
- */
-
- if ( trlcontxt )
- synerr( "trailing context used twice" );
- else
- trlcontxt = true;
-
- if ( varlength )
- /* we hope the trailing context is fixed-length */
- varlength = false;
- else
- headcnt = rulelen;
-
- rulelen = 0;
-
- current_state_type = STATE_TRAILING_CONTEXT;
- yyval = yyvsp[-1];
- }
- break;
- case 33:
- #line 402 "parse.y"
- {
- /* this is where concatenation of adjacent patterns
- * gets done
- */
- yyval = link_machines( yyvsp[-1], yyvsp[0] );
- }
- break;
- case 34:
- #line 410 "parse.y"
- { yyval = yyvsp[0]; }
- break;
- case 35:
- #line 414 "parse.y"
- {
- varlength = true;
-
- yyval = mkclos( yyvsp[-1] );
- }
- break;
- case 36:
- #line 421 "parse.y"
- {
- varlength = true;
-
- yyval = mkposcl( yyvsp[-1] );
- }
- break;
- case 37:
- #line 428 "parse.y"
- {
- varlength = true;
-
- yyval = mkopt( yyvsp[-1] );
- }
- break;
- case 38:
- #line 435 "parse.y"
- {
- varlength = true;
-
- if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 )
- {
- synerr( "bad iteration values" );
- yyval = yyvsp[-5];
- }
- else
- {
- if ( yyvsp[-3] == 0 )
- yyval = mkopt( mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ) );
- else
- yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] );
- }
- }
- break;
- case 39:
- #line 453 "parse.y"
- {
- varlength = true;
-
- if ( yyvsp[-2] <= 0 )
- {
- synerr( "iteration value must be positive" );
- yyval = yyvsp[-4];
- }
-
- else
- yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY );
- }
- break;
- case 40:
- #line 467 "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 ( yyvsp[-1] <= 0 )
- {
- synerr( "iteration value must be positive" );
- yyval = yyvsp[-3];
- }
-
- else
- yyval = link_machines( yyvsp[-3], copysingl( yyvsp[-3], yyvsp[-1] - 1 ) );
- }
- break;
- case 41:
- #line 485 "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, csize );
-
- madeany = true;
- }
-
- ++rulelen;
-
- yyval = mkstate( -anyccl );
- }
- break;
- case 42:
- #line 507 "parse.y"
- {
- if ( ! cclsorted )
- /* sort characters for fast searching. We use a
- * shell sort since this list could be large.
- */
- cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], true );
-
- if ( useecs )
- mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]],
- nextecm, ecgroup, csize, csize );
-
- ++rulelen;
-
- yyval = mkstate( -yyvsp[0] );
- }
- break;
- case 43:
- #line 524 "parse.y"
- {
- ++rulelen;
-
- yyval = mkstate( -yyvsp[0] );
- }
- break;
- case 44:
- #line 531 "parse.y"
- { yyval = yyvsp[-1]; }
- break;
- case 45:
- #line 534 "parse.y"
- { yyval = yyvsp[-1]; }
- break;
- case 46:
- #line 537 "parse.y"
- {
- ++rulelen;
-
- if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
-
- yyval = mkstate( yyvsp[0] );
- }
- break;
- case 47:
- #line 548 "parse.y"
- { yyval = yyvsp[-1]; }
- break;
- case 48:
- #line 551 "parse.y"
- {
- /* *Sigh* - to be compatible Unix lex, negated ccls
- * match newlines
- */
- #ifdef NOTDEF
- ccladd( yyvsp[-1], '\n' ); /* negated ccls don't match '\n' */
- cclsorted = false; /* because we added the newline */
- #endif
- cclnegate( yyvsp[-1] );
- yyval = yyvsp[-1];
- }
- break;
- case 49:
- #line 565 "parse.y"
- {
- if ( yyvsp[-2] > yyvsp[0] )
- synerr( "negative range in character class" );
-
- else
- {
- if ( caseins )
- {
- if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' )
- yyvsp[-2] = clower( yyvsp[-2] );
- if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
- }
-
- for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i )
- ccladd( yyvsp[-3], i );
-
- /* keep track if this ccl is staying in alphabetical
- * order
- */
- cclsorted = cclsorted && (yyvsp[-2] > lastchar);
- lastchar = yyvsp[0];
- }
-
- yyval = yyvsp[-3];
- }
- break;
- case 50:
- #line 593 "parse.y"
- {
- if ( caseins )
- if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
-
- ccladd( yyvsp[-1], yyvsp[0] );
- cclsorted = cclsorted && (yyvsp[0] > lastchar);
- lastchar = yyvsp[0];
- yyval = yyvsp[-1];
- }
- break;
- case 51:
- #line 605 "parse.y"
- {
- cclsorted = true;
- lastchar = 0;
- yyval = cclinit();
- }
- break;
- case 52:
- #line 613 "parse.y"
- {
- if ( caseins )
- if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
-
- ++rulelen;
-
- yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) );
- }
- break;
- case 53:
- #line 624 "parse.y"
- { yyval = mkstate( SYM_EPSILON ); }
- break;
- #line 1075 "y_tab.c"
- }
- yyssp -= yym;
- yystate = *yyssp;
- yyvsp -= yym;
- yym = yylhs[yyn];
- if (yystate == 0 && yym == 0)
- {
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: after reduction, shifting from state 0 to\
- state %d\n", YYFINAL);
- #endif
- yystate = YYFINAL;
- *++yyssp = YYFINAL;
- *++yyvsp = yyval;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
- #if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("yydebug: state %d, reading %d (%s)\n",
- YYFINAL, yychar, yys);
- }
- #endif
- }
- if (yychar == 0) goto yyaccept;
- goto yyloop;
- }
- if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
- yystate = yytable[yyn];
- else
- yystate = yydgoto[yym];
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: after reduction, shifting from state %d \
- to state %d\n", *yyssp, yystate);
- #endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate;
- *++yyvsp = yyval;
- goto yyloop;
- yyoverflow:
- yyerror("yacc stack overflow");
- yyabort:
- return (1);
- yyaccept:
- return (0);
- }
-