📄 parse-gram.c
字号:
#endif#endif{ /* The look-ahead symbol. */int yychar;/* The semantic value of the look-ahead symbol. */YYSTYPE yylval;/* Number of syntax errors so far. */int yynerrs;/* Location data for the look-ahead symbol. */YYLTYPE yylloc; register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short int yyssa[YYINITDEPTH]; short int *yyss = yyssa; register short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2];#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; yylsp = yyls;#if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 0;#endif /* User initialization code. */ #line 71 "parse-gram.y"{ /* Bison's grammar can initial empty locations, hence a default location is needed. */ yylloc.start.file = yylloc.end.file = current_file; yylloc.start.line = yylloc.end.line = 1; yylloc.start.column = yylloc.end.column = 0;}/* Line 842 of yacc.c. */#line 1152 "parse-gram.c" yyvsp[0] = yylval; yylsp[0] = yylloc; goto yysetstate;/*------------------------------------------------------------.| yynewstate -- Push a new state, which is found in yystate. |`------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1;#ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short int *yyss1 = yyss; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; yyss = yyss1; yyvs = yyvs1; }#else /* no yyoverflow */# ifndef YYSTACK_RELOCATE goto yyoverflowlab;# else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { short int *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); YYSTACK_RELOCATE (yyls);# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); }# endif#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup;/*-----------.| yybackup. |`-----------*/yybackup:/* Do appropriate processing given the current state. *//* Read a look-ahead token if we need one and don't already have one. *//* yyresume: */ /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a look-ahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; *++yylsp = yylloc; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate;/*-----------------------------------------------------------.| yydefault -- do the default action for the current state. |`-----------------------------------------------------------*/yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce;/*-----------------------------.| yyreduce -- Do a reduction. |`-----------------------------*/yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; /* Default location. */ YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen); YY_REDUCE_PRINT (yyn); switch (yyn) { case 6:#line 189 "parse-gram.y" { prologue_augment ((yyvsp[0].chars), (yylsp[0])); } break; case 7:#line 190 "parse-gram.y" { debug_flag = true; } break; case 8:#line 191 "parse-gram.y" { muscle_insert ((yyvsp[-1].chars), (yyvsp[0].chars)); } break; case 9:#line 192 "parse-gram.y" { defines_flag = true; } break; case 10:#line 193 "parse-gram.y" { error_verbose = true; } break; case 11:#line 194 "parse-gram.y" { expected_sr_conflicts = (yyvsp[0].integer); } break; case 12:#line 195 "parse-gram.y" { expected_rr_conflicts = (yyvsp[0].integer); } break; case 13:#line 196 "parse-gram.y" { spec_file_prefix = (yyvsp[0].chars); } break; case 14:#line 198 "parse-gram.y" { nondeterministic_parser = true; glr_parser = true; } break; case 15:#line 203 "parse-gram.y" { muscle_code_grow ("initial_action", (yyvsp[0].chars), (yylsp[0])); } break; case 16:#line 206 "parse-gram.y" { add_param ("lex_param", (yyvsp[0].chars), (yylsp[0])); } break; case 17:#line 207 "parse-gram.y" { locations_flag = true; } break; case 18:#line 208 "parse-gram.y" { spec_name_prefix = (yyvsp[0].chars); } break; case 19:#line 209 "parse-gram.y" { no_lines_flag = true; } break; case 20:#line 210 "parse-gram.y" { nondeterministic_parser = true; } break; case 21:#line 211 "parse-gram.y" { spec_outfile = (yyvsp[0].chars); } break; case 22:#line 212 "parse-gram.y" { add_param ("parse_param", (yyvsp[0].chars), (yylsp[0])); } break; case 23:#line 213 "parse-gram.y" { pure_parser = true; } break; case 24:#line 214 "parse-gram.y" { skeleton = (yyvsp[0].chars); } break; case 25:#line 215 "parse-gram.y" { token_table_flag = true; } break; case 26:#line 216 "parse-gram.y" { report_flag = report_states; } break; case 27:#line 217 "parse-gram.y" { yacc_flag = true; } break; case 31:#line 225 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0])); } break; case 32:#line 229 "parse-gram.y" { typed = true; MUSCLE_INSERT_INT ("stype_line", (yylsp[0]).start.line); muscle_insert ("stype", (yyvsp[0].chars)); } break; case 33:#line 235 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[0].list); list; list = list->next) symbol_destructor_set (list->sym, (yyvsp[-1].chars), (yylsp[-1])); symbol_list_free ((yyvsp[0].list)); } break; case 34:#line 242 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[0].list); list; list = list->next) symbol_printer_set (list->sym, (yyvsp[-1].chars), list->location); symbol_list_free ((yyvsp[0].list)); } break; case 35:#line 249 "parse-gram.y" { default_prec = true; } break; case 36:#line 253 "parse-gram.y" { default_prec = false; } break; case 37:#line 259 "parse-gram.y" { current_class = nterm_sym; } break; case 38:#line 260 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; } break; case 39:#line 264 "parse-gram.y" { current_class = token_sym; } break; case 40:#line 265 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; } break; case 41:#line 270 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[0].list); list; list = list->next) symbol_type_set (list->sym, (yyvsp[-1].uniqstr), (yylsp[-1])); symbol_list_free ((yyvsp[0].list)); } break; case 42:#line 280 "parse-gram.y" { symbol_list *list; ++current_prec; for (list = (yyvsp[0].list); list; list = list->next) { symbol_type_set (list->sym, current_type, (yylsp[-1])); symbol_precedence_set (list->sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2])); } symbol_list_free ((yyvsp[0].list)); current_type = NULL; } break; case 43:#line 294 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 44:#line 295 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 45:#line 296 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 46:#line 300 "parse-gram.y" { current_type = NULL; } break; case 47:#line 301 "parse-gram.y" { current_type = (yyvsp[0].uniqstr); } break; case 48:#line 307 "parse-gram.y" { (yyval.list) = symbol_list_new ((yyvsp[0].symbol), (yylsp[0])); } break; case 49:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -