⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parse-gram.c

📁 GNU的词法/语法分析器bison源码
💻 C
📖 第 1 页 / 共 5 页
字号:
# ifndef YYSTACK_RELOCATE      goto yyexhaustedlab;# else      /* Extend the stack our own way.  */      if (YYMAXDEPTH <= yystacksize)	goto yyexhaustedlab;      yystacksize *= 2;      if (YYMAXDEPTH < yystacksize)	yystacksize = YYMAXDEPTH;      {	short int *yyss1 = yyss;	union yyalloc *yyptr =	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));	if (! yyptr)	  goto yyexhaustedlab;	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 203 "parse-gram.y"    { prologue_augment ((yyvsp[0].chars), (yylsp[0])); }    break;  case 7:#line 204 "parse-gram.y"    { debug_flag = true; }    break;  case 8:#line 205 "parse-gram.y"    { muscle_insert ((yyvsp[-1].chars), (yyvsp[0].chars)); }    break;  case 9:#line 206 "parse-gram.y"    { defines_flag = true; }    break;  case 10:#line 207 "parse-gram.y"    { error_verbose = true; }    break;  case 11:#line 208 "parse-gram.y"    { expected_sr_conflicts = (yyvsp[0].integer); }    break;  case 12:#line 209 "parse-gram.y"    { expected_rr_conflicts = (yyvsp[0].integer); }    break;  case 13:#line 210 "parse-gram.y"    { spec_file_prefix = (yyvsp[0].chars); }    break;  case 14:#line 212 "parse-gram.y"    {    nondeterministic_parser = true;    glr_parser = true;  }    break;  case 15:#line 217 "parse-gram.y"    {    muscle_code_grow ("initial_action", (yyvsp[0].chars), (yylsp[0]));  }    break;  case 16:#line 220 "parse-gram.y"    { add_param ("lex_param", (yyvsp[0].chars), (yylsp[0])); }    break;  case 17:#line 221 "parse-gram.y"    { locations_flag = true; }    break;  case 18:#line 222 "parse-gram.y"    { spec_name_prefix = (yyvsp[0].chars); }    break;  case 19:#line 223 "parse-gram.y"    { no_lines_flag = true; }    break;  case 20:#line 224 "parse-gram.y"    { nondeterministic_parser = true; }    break;  case 21:#line 225 "parse-gram.y"    { spec_outfile = (yyvsp[0].chars); }    break;  case 22:#line 226 "parse-gram.y"    { add_param ("parse_param", (yyvsp[0].chars), (yylsp[0])); }    break;  case 23:#line 227 "parse-gram.y"    { pure_parser = true; }    break;  case 24:#line 228 "parse-gram.y"    { skeleton = (yyvsp[0].chars); }    break;  case 25:#line 229 "parse-gram.y"    { token_table_flag = true; }    break;  case 26:#line 230 "parse-gram.y"    { report_flag = report_states; }    break;  case 27:#line 231 "parse-gram.y"    { yacc_flag = true; }    break;  case 31:#line 239 "parse-gram.y"    {      grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0]));    }    break;  case 32:#line 243 "parse-gram.y"    {      typed = true;      MUSCLE_INSERT_INT ("stype_line", (yylsp[0]).start.line);      muscle_insert ("stype", (yyvsp[0].chars));    }    break;  case 33:#line 249 "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 256 "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 263 "parse-gram.y"    {      default_prec = true;    }    break;  case 36:#line 267 "parse-gram.y"    {      default_prec = false;    }    break;  case 37:#line 273 "parse-gram.y"    { current_class = nterm_sym; }    break;  case 38:#line 274 "parse-gram.y"    {      current_class = unknown_sym;      current_type = NULL;    }    break;  case 39:#line 278 "parse-gram.y"    { current_class = token_sym; }    break;  case 40:#line 279 "parse-gram.y"    {      current_class = unknown_sym;      current_type = NULL;    }    break;  case 41:#line 284 "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 294 "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 308 "parse-gram.y"    { (yyval.assoc) = left_assoc; }    break;  case 44:#line 309 "parse-gram.y"    { (yyval.assoc) = right_assoc; }    break;  case 45:#line 310 "parse-gram.y"    { (yyval.assoc) = non_assoc; }    break;  case 46:#line 314 "parse-gram.y"    { current_type = NULL; }    break;  case 47:#line 315 "parse-gram.y"    { current_type = (yyvsp[0].uniqstr); }    break;  case 48:#line 321 "parse-gram.y"    { (yyval.list) = symbol_list_new ((yyvsp[0].symbol), (yylsp[0])); }    break;  case 49:#line 322 "parse-gram.y"    { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), (yyvsp[0].symbol), (yylsp[0])); }    break;  case 50:#line 328 "parse-gram.y"    {       current_type = (yyvsp[0].uniqstr);     }    break;  case 51:#line 332 "parse-gram.y"    {       symbol_class_set ((yyvsp[0].symbol), current_class, (yylsp[0]));       symbol_type_set ((yyvsp[0].symbol), current_type, (yylsp[0]));     }    break;  case 52:#line 337 "parse-gram.y"    {      symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]));      symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1]));      symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0]));    }    break;  case 53:#line 343 "parse-gram.y"    {      symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]));      symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1]));      symbol_make_alias ((yyvsp[-1].symbol), (yyvsp[0].symbol), (yyloc));    }    break;  case 54:#line 349 "parse-gram.y"    {      symbol_class_set ((yyvsp[-2].symbol), current_class, (yylsp[-2]));      symbol_type_set ((yyvsp[-2].symbol), current_type, (yylsp[-2]));      symbol_user_token_number_set ((yyvsp[-2].symbol), (yyvsp[-1].integer), (yylsp[-1]));      symbol_make_alias ((yyvsp[-2].symbol), (yyvsp[0].symbol), (yyloc));    }    break;  case 60:#line 378 "parse-gram.y"    {      if (yacc_flag)	complain_at ((yyloc), _("POSIX forbids declarations in the grammar"));    }    break;  case 61:#line 383 "parse-gram.y"    {      yyerrok;    }    break;  case 62:#line 389 "parse-gram.y"    { current_lhs = (yyvsp[0].symbol); current_lhs_location = (yylsp[0]); }    break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -