/[bison]/bison/data/glr.c
ViewVC logotype

Diff of /bison/data/glr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by eggert, Sat Oct 12 23:19:46 2002 UTC revision 1.11 by akim, Sun Oct 13 14:25:14 2002 UTC
# Line 169  typedef union b4_stype yystype; Line 169  typedef union b4_stype yystype;
169  typedef struct yyltype  typedef struct yyltype
170  {  {
171  ]b4_location_if([  ]b4_location_if([
172    int yyfirst_line;    int first_line;
173    int yyfirst_column;    int first_column;
174    int yylast_line;    int last_line;
175    int yylast_column;])[    int last_column;])[
176  } yyltype;  } yyltype;
177  # define YYLTYPE ]b4_ltype[  # define YYLTYPE ]b4_ltype[
178  # define YYLTYPE_IS_TRIVIAL 1  # define YYLTYPE_IS_TRIVIAL 1
# Line 333  static const ]b4_int_type_for([b4_pgoto] Line 333  static const ]b4_int_type_for([b4_pgoto]
333    
334  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
335     positive, shift that token.  If negative, reduce the rule which     positive, shift that token.  If negative, reduce the rule which
336     number is the opposite.  If zero, do what YYDEFACT says.  */     number is the opposite.  If zero, do what YYDEFACT says.
337       If YYTABLE_NINF, parse error.  */
338  #define YYTABLE_NINF ]b4_table_ninf[  #define YYTABLE_NINF ]b4_table_ninf[
339  static const ]b4_int_type_for([b4_table])[ yytable[] =  static const ]b4_int_type_for([b4_table])[ yytable[] =
340  {  {
# Line 396  int yyparse (void); Line 397  int yyparse (void);
397    
398  #ifndef YYLLOC_DEFAULT  #ifndef YYLLOC_DEFAULT
399  # define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN)                  \  # define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN)                  \
400    yyCurrent.yyfirst_line   = YYRHSLOC(yyRhs,1).yyfirst_line;    \    yyCurrent.first_line   = YYRHSLOC(yyRhs,1).first_line;        \
401    yyCurrent.yyfirst_column = YYRHSLOC(yyRhs,1).yyfirst_column;  \    yyCurrent.first_column = YYRHSLOC(yyRhs,1).first_column;      \
402    yyCurrent.yylast_line    = YYRHSLOC(yyRhs,YYN).yylast_line;   \    yyCurrent.last_line    = YYRHSLOC(yyRhs,YYN).last_line;       \
403    yyCurrent.yylast_column  = YYRHSLOC(yyRhs,YYN).yylast_column;    yyCurrent.last_column  = YYRHSLOC(yyRhs,YYN).last_column;
404  #endif  #endif
405    
406  /* YYLEX -- calling `yylex' with the right arguments.  */  /* YYLEX -- calling `yylex' with the right arguments.  */
# Line 705  yygetLRActions (yyStateNum yystate, int Line 706  yygetLRActions (yyStateNum yystate, int
706                  int* yyaction, const short** yyconflicts)                  int* yyaction, const short** yyconflicts)
707  {  {
708    int yyindex = yypact[yystate] + yytoken;    int yyindex = yypact[yystate] + yytoken;
709    if (yyindex < 0 || yyindex > YYLAST || yycheck[yyindex] != yytoken)    if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
710      {      {
711        *yyaction = -yydefact[yystate];        *yyaction = -yydefact[yystate];
712        *yyconflicts = yyconfl;        *yyconflicts = yyconfl;
713      }      }
714    else    else if (yytable[yyindex] != YYTABLE_NINF)
715      {      {
716        *yyaction = yytable[yyindex];        *yyaction = yytable[yyindex];
717        *yyconflicts = yyconfl + yyconflp[yyindex];        *yyconflicts = yyconfl + yyconflp[yyindex];
718      }      }
719      else
720        {
721          *yyaction = 0;
722          *yyconflicts = yyconfl + yyconflp[yyindex];
723        }
724  }  }
725    
726  static inline yyStateNum  static inline yyStateNum
# Line 722  yyLRgotoState (yyStateNum yystate, yySym Line 728  yyLRgotoState (yyStateNum yystate, yySym
728  {  {
729    int yyr;    int yyr;
730    yyr = yypgoto[yylhs - YYNTOKENS] + yystate;    yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
731    if (yyr >= 0 && yyr <= YYLAST && yycheck[yyr] == yystate)    if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
732      return yytable[yyr];      return yytable[yyr];
733    else    else
734      return yydefgoto[yylhs - YYNTOKENS];      return yydefgoto[yylhs - YYNTOKENS];
# Line 737  yyisShiftAction (int yyaction) Line 743  yyisShiftAction (int yyaction)
743  static inline bool  static inline bool
744  yyisErrorAction (int yyaction)  yyisErrorAction (int yyaction)
745  {  {
746    return yyaction == 0 || yyaction == YYPACT_NINF;    return yyaction == 0;
747  }  }
748    
749                                  /* GLRStates */                                  /* GLRStates */
# Line 1256  yyresolveAction (yySemanticOption* yyopt Line 1262  yyresolveAction (yySemanticOption* yyopt
1262  }  }
1263    
1264  #if YYDEBUG  #if YYDEBUG
1265  static yyGLRState YYLEFTMOST_STATE = { 0, NULL, -1, 0, { NULL } };  static yyGLRState YYLEFTMOST_STATE = { 0, 0, -1, NULL, 0, { NULL } };
1266    
1267  static void yyreportTree (yySemanticOption* yyx, int yyindent)  static void yyreportTree (yySemanticOption* yyx, int yyindent)
1268  {  {
# Line 1524  yyreportParseError (yyGLRStack* yystack, Line 1530  yyreportParseError (yyGLRStack* yystack,
1530              {              {
1531                yyprefix = ", expecting ";                yyprefix = ", expecting ";
1532                for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1)                for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1)
1533                  if (yycheck[yyx + yyn] == yyx)                  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1534                    {                    {
1535                      yyp += sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));                      yyp += sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));
1536                      yyprefix = " or ";                      yyprefix = " or ";
# Line 1540  yyreportParseError (yyGLRStack* yystack, Line 1546  yyreportParseError (yyGLRStack* yystack,
1546      }      }
1547  }  }
1548    
1549  /* Recover from a syntax error on STACK, assuming that TOKENP,  /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
1550     YYLVALP, and YYLLOCP point to the syntactic category, semantic     YYLVALP, and YYLLOCP point to the syntactic category, semantic
1551     value, and location of the lookahead.     value, and location of the lookahead.  */
    NOTE: This uses the panic-mode recovery algorithm described in the  
    Bison documentation, which differs from what is in bison.simple.  
    Specifically, this routine performs no reductions before shifting  
    the error token. */  
1552  static void  static void
1553  yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)  yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
1554  {  {
# Line 1855  b4_location_if( Line 1857  b4_location_if(
1857  [#ifndef YYLTYPE  [#ifndef YYLTYPE
1858  typedef struct yyltype  typedef struct yyltype
1859  {  {
1860    int yyfirst_line;    int first_line;
1861    int yyfirst_column;    int first_column;
1862    int yylast_line;    int last_line;
1863    int yylast_column;    int last_column;
1864  } yyltype;  } yyltype;
1865  # define YYLTYPE yyltype  # define YYLTYPE yyltype
1866  #endif  #endif

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26