📄 parse.c
字号:
else { yychar1 = YYTRANSLATE(YY_parse_CHAR);#if YY_parse_DEBUG != 0 if (YY_parse_DEBUG_FLAG) { fprintf (stderr, "Next token is %d (%s", YY_parse_CHAR, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */#ifdef YYPRINT YYPRINT (stderr, YY_parse_CHAR, YY_parse_LVAL);#endif fprintf (stderr, ")\n"); }#endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) YYGOTO(yydefault); yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) YYGOTO(yyerrlab); yyn = -yyn; YYGOTO(yyreduce); } else if (yyn == 0) YYGOTO(yyerrlab); if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */#if YY_parse_DEBUG != 0 if (YY_parse_DEBUG_FLAG) fprintf(stderr, "Shifting token %d (%s), ", YY_parse_CHAR, yytname[yychar1]);#endif /* Discard the token being shifted unless it is eof. */ if (YY_parse_CHAR != YYEOF) YY_parse_CHAR = YYEMPTY; *++yyvsp = YY_parse_LVAL;#ifdef YY_parse_LSP_NEEDED *++yylsp = YY_parse_LLOC;#endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; YYGOTO(yynewstate);/* Do the default action for the current state. */YYLABEL(yydefault) yyn = yydefact[yystate]; if (yyn == 0) YYGOTO(yyerrlab);/* Do a reduction. yyn is the number of a rule to reduce with. */YYLABEL(yyreduce) yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */#if YY_parse_DEBUG != 0 if (YY_parse_DEBUG_FLAG) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); }#endif/* #line 783 "/u/icdc/rdt/tools/lib/bison.cc" */#line 1096 "y.tab.c" switch (yyn) {case 1:#line 53 "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 77 "parse.y"{ /* initialize for processing rules */ /* create default DFA start condition */ scinstal( "INITIAL", false ); ; break;}case 5:#line 88 "parse.y"{ synerr( "unknown error processing section 1" ); ; break;}case 7:#line 95 "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 105 "parse.y"{ xcluflg = true; ; break;}case 9:#line 109 "parse.y"{ scinstal( nmstr, xcluflg ); ; break;}case 10:#line 112 "parse.y"{ scinstal( nmstr, xcluflg ); ; break;}case 11:#line 115 "parse.y"{ synerr( "bad start condition list" ); ; break;}case 14:#line 123 "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 134 "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 154 "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 165 "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 189 "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 200 "parse.y"{ build_eof_action(); ; break;}case 20:#line 203 "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 222 "parse.y"{ synerr( "unrecognized rule" ); ; break;}case 23:#line 229 "parse.y"{ if ( (scnum = sclookup( nmstr )) == 0 ) format_pinpoint_message( "undeclared start condition %s", nmstr ); else actvsc[++actvp] = scnum; ; break;}case 24:#line 239 "parse.y"{ if ( (scnum = sclookup( nmstr )) == 0 ) format_pinpoint_message( "undeclared start condition %s", nmstr ); else actvsc[actvp = 1] = scnum; ; break;}case 25:#line 248 "parse.y"{ synerr( "bad start condition list" ); ; break;}case 26:#line 252 "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 309 "parse.y"{ synerr( "trailing context used twice" ); ; break;}case 28:#line 312 "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; } if ( varlength && headcnt == 0 ) { /* again, see the comment in the rule for "re2 re" * above */ add_accept( yyvsp[-1], num_rules | YY_TRAILING_HEAD_MASK ); variable_trail_rule = true; } else { if ( ! varlength ) headcnt = rulelen; ++rulelen; trailcnt = 1; } trlcontxt = true; eps = mkstate( SYM_EPSILON ); yyval = link_machines( yyvsp[-1], link_machines( eps, mkstate( '\n' ) ) ); ; break;}case 29:#line 364 "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 380 "parse.y"{ varlength = true; yyval = mkor( yyvsp[-2], yyvsp[0] ); ; break;}case 31:#line 386 "parse.y"{ yyval = yyvsp[0]; ; break;}case 32:#line 391 "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 416 "parse.y"{ /* this is where concatenation of adjacent patterns * gets done */ yyval = link_machines( yyvsp[-1], yyvsp[0] ); ; break;}case 34:#line 424 "parse.y"{ yyval = yyvsp[0]; ; break;}case 35:#line 428 "parse.y"{ varlength = true; yyval = mkclos( yyvsp[-1] ); ; break;}case 36:#line 435 "parse.y"{ varlength = true; yyval = mkposcl( yyvsp[-1] ); ; break;}case 37:#line 442 "parse.y"{ varlength = true; yyval = mkopt( yyvsp[-1] );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -