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

Diff of /bison/data/yacc.c

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

revision 1.31 by eggert, Tue Nov 12 07:22:01 2002 UTC revision 1.32 by akim, Tue Nov 12 08:45:40 2002 UTC
# Line 133  m4_define([b4_rhs_location], Line 133  m4_define([b4_rhs_location],
133  ## Defining symbol actions, e.g., printers and destructors.  ##  ## Defining symbol actions, e.g., printers and destructors.  ##
134  ## --------------------------------------------------------- ##  ## --------------------------------------------------------- ##
135    
 # b4_symbol_actions(FILENAME, LINENO,  
 #                   SYMBOL-TAG, SYMBOL-NUM,  
 #                   SYMBOL-ACTION, SYMBOL-TYPENAME)  
 # -------------------------------------------------  
 m4_define([b4_symbol_actions],  
 [m4_pushdef([b4_dollar_dollar], [yyvalue.$6])dnl  
 m4_pushdef([b4_at_dollar], [yylocation])dnl  
       case $4: /* $3 */  
 b4_syncline([$2], [$1])  
         $5;  
 b4_syncline([@oline@], [@ofile@])  
         break;  
 m4_popdef([b4_at_dollar])dnl  
 m4_popdef([b4_dollar_dollar])dnl  
 ])  
   
   
136  # We do want M4 expansion after # for CPP macros.  # We do want M4 expansion after # for CPP macros.
137  m4_changecom()  m4_changecom()
138  m4_divert(0)dnl  m4_divert(0)dnl
# Line 348  b4_location_if( Line 331  b4_location_if(
331    
332  /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */  /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
333  #define YYUNDEFTOK  b4_undef_token_number  #define YYUNDEFTOK  b4_undef_token_number
334  #define YYMAXUTOK   b4_user_token_number_max  #define YYMAXUTOK   b4_user_token_number_max[
335    
336  #define YYTRANSLATE(X) \  #define YYTRANSLATE(YYX)                                                \
337    ((unsigned)(X) <= YYMAXUTOK ? yytranslate[[X]] : YYUNDEFTOK)    ((YYX <= 0) ? YYEOF :                                                 \
338       (unsigned)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
339    
340  /* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX.  */  /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
341  static const b4_int_type_for([b4_translate]) yytranslate[[]] =  static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
342  {  {
343    b4_translate    ]b4_translate
344  };  };
345    
346  #if YYDEBUG  #if YYDEBUG
# Line 477  static const b4_int_type_for([b4_stos]) Line 461  static const b4_int_type_for([b4_stos])
461  #endif  #endif
462    
463  #define yyerrok         (yyerrstatus = 0)  #define yyerrok         (yyerrstatus = 0)
464  #define yyclearin       (yychar = YYEMPTY)  #define yyclearin       (yytoken = YYEMPTY)
465  #define YYEMPTY         -2  #define YYEMPTY         -2
466  #define YYEOF           0  #define YYEOF           0
467    
# Line 495  static const b4_int_type_for([b4_stos]) Line 479  static const b4_int_type_for([b4_stos])
479    
480  #define YYBACKUP(Token, Value)                                  \  #define YYBACKUP(Token, Value)                                  \
481  do                                                              \  do                                                              \
482    if (yychar == YYEMPTY && yylen == 1)                          \    if (yytoken == YYEMPTY && yylen == 1)                         \
483      {                                                           \      {                                                           \
484        yychar = (Token);                                         \        yychar = (Token);                                         \
485        yylval = (Value);                                         \        yylval = (Value);                                         \
486        yychar1 = YYTRANSLATE (yychar);                           \        yytoken = YYTRANSLATE (yychar);                           \
487        YYPOPSTACK;                                               \        YYPOPSTACK;                                               \
488        goto yybackup;                                            \        goto yybackup;                                            \
489      }                                                           \      }                                                           \
# Line 672  m4_map([b4_symbol_actions], m4_defn([b4_ Line 656  m4_map([b4_symbol_actions], m4_defn([b4_
656  }  }
657  #endif /* YYDEBUG. */  #endif /* YYDEBUG. */
658    
659    b4_yydestruct_generate([b4_c_function_def])
 /*-----------------------------------------------.  
 | Release the memory associated to this symbol.  |  
 `-----------------------------------------------*/  
   
 b4_c_function_def([yydestruct],  
                   [static void],  
                   [[int yytype],         [yytype]],  
                   [[YYSTYPE yyvalue],    [yyvalue]]b4_location_if([,  
                   [[YYLTYPE yylocation], [yylocation]]]))  
 {  
   /* Pacify ``unused variable'' warnings.  */  
   (void) yyvalue;  
 b4_location_if([  (void) yylocation;  
 ])dnl  
   
   switch (yytype)  
     {  
 m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))dnl  
       default:  
         break;  
     }  
 }  
   
660    
661    
662  /* Prevent warnings from -Wmissing-prototypes.  */  /* Prevent warnings from -Wmissing-prototypes.  */
# Line 756  b4_c_function_def([yyparse], [int], b4_p Line 717  b4_c_function_def([yyparse], [int], b4_p
717    /* Number of tokens to shift before error messages enabled.  */    /* Number of tokens to shift before error messages enabled.  */
718    int yyerrstatus;    int yyerrstatus;
719    /* Lookahead token as an internal (translated) token number.  */    /* Lookahead token as an internal (translated) token number.  */
720    int yychar1 = 0;    int yytoken = 0;
721    
722    /* Three stacks and their tools:    /* Three stacks and their tools:
723       `yyss': related to states,       `yyss': related to states,
# Line 800  b4_c_function_def([yyparse], [int], b4_p Line 761  b4_c_function_def([yyparse], [int], b4_p
761    yystate = 0;    yystate = 0;
762    yyerrstatus = 0;    yyerrstatus = 0;
763    yynerrs = 0;    yynerrs = 0;
764    yychar = YYEMPTY;             /* Cause a token to be read.  */    yychar = yytoken = YYEMPTY;           /* Cause a token to be read.  */
765    
766    /* Initialize stack pointers.    /* Initialize stack pointers.
767       Waste one element of value and location stack       Waste one element of value and location stack
# Line 910  yybackup: Line 871  yybackup:
871    
872    /* Not known => get a lookahead token if don't already have one.  */    /* Not known => get a lookahead token if don't already have one.  */
873    
874    /* yychar is either YYEMPTY or YYEOF    /* YYTOKEN is either YYEMPTY or YYEOF or a valid token.  */
875       or a valid token in external form.  */    if (yytoken == YYEMPTY)
   
   if (yychar == YYEMPTY)  
876      {      {
877        YYDPRINTF ((stderr, "Reading a token: "));        YYDPRINTF ((stderr, "Reading a token: "));
878        yychar = YYLEX;        yychar = YYLEX;
879          yytoken = YYTRANSLATE (yychar);
880      }      }
881    
882    /* Convert token to internal form (in yychar1) for indexing tables with.  */    if (yytoken == YYEOF)
   
   if (yychar <= 0)              /* This means end of input.  */  
883      {      {
       yychar1 = 0;  
       yychar = YYEOF;           /* Don't call YYLEX any more.  */  
   
884        YYDPRINTF ((stderr, "Now at end of input.\n"));        YYDPRINTF ((stderr, "Now at end of input.\n"));
885      }      }
886    else    else
887      {      {
       yychar1 = YYTRANSLATE (yychar);  
   
888        /* We have to keep this `#if YYDEBUG', since we use variables        /* We have to keep this `#if YYDEBUG', since we use variables
889           which are defined only if `YYDEBUG' is set.  */           which are defined only if `YYDEBUG' is set.  */
890        YYDPRINTF ((stderr, "Next token is "));        YYDPRINTF ((stderr, "Next token is "));
891        YYDSYMPRINT ((stderr, yychar1, yylval]b4_location_if([, yyloc])[));        YYDSYMPRINT ((stderr, yytoken, yylval]b4_location_if([, yyloc])[));
892        YYDPRINTF ((stderr, "\n"));        YYDPRINTF ((stderr, "\n"));
893      }      }
894    
895    /* If the proper action on seeing token YYCHAR1 is to reduce or to    /* If the proper action on seeing token YYTOKEN is to reduce or to
896       detect an error, take that action.  */       detect an error, take that action.  */
897    yyn += yychar1;    yyn += yytoken;
898    if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)    if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
899      goto yydefault;      goto yydefault;
900    yyn = yytable[yyn];    yyn = yytable[yyn];
901    if (yyn <= 0)    if (yyn <= 0)
# Line 958  yybackup: Line 911  yybackup:
911    
912    /* Shift the lookahead token.  */    /* Shift the lookahead token.  */
913    YYDPRINTF ((stderr, "Shifting token %d (%s), ",    YYDPRINTF ((stderr, "Shifting token %d (%s), ",
914                yychar, yytname[yychar1]));                yytoken, yytname[yytoken]));
915    
916    /* Discard the token being shifted unless it is eof.  */    /* Discard the token being shifted unless it is eof.  */
917    if (yychar != YYEOF)    if (yytoken != YYEOF)
918      yychar = YYEMPTY;      yytoken = YYEMPTY;
919    
920    *++yyvsp = yylval;    *++yyvsp = yylval;
921  ]b4_location_if([  *++yylsp = yylloc;])[  ]b4_location_if([  *++yylsp = yylloc;])[
# Line 1134  yyerrlab1: Line 1087  yyerrlab1:
1087           error, discard it.  */           error, discard it.  */
1088    
1089        /* Return failure if at end of input.  */        /* Return failure if at end of input.  */
1090        if (yychar == YYEOF)        if (yytoken == YYEOF)
1091          {          {
1092            /* Pop the error token.  */            /* Pop the error token.  */
1093            YYPOPSTACK;            YYPOPSTACK;
# Line 1153  yyerrlab1: Line 1106  yyerrlab1:
1106          }          }
1107    
1108        YYDPRINTF ((stderr, "Discarding token %d (%s).\n",        YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1109                    yychar, yytname[yychar1]));                    yytoken, yytname[yytoken]));
1110        yydestruct (yychar1, yylval]b4_location_if([, yylloc])[);        yydestruct (yytoken, yylval]b4_location_if([, yylloc])[);
1111        yychar = YYEMPTY;        yytoken = YYEMPTY;
1112      }      }
1113    
1114    /* Else will try to reuse lookahead token after shifting the error    /* Else will try to reuse lookahead token after shifting the error

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

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