]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
Clean up handling of %destructor for the end token (token 0).
[bison.git] / data / lalr1.cc
index e6c622c71b5a8ea3c0a6c9ce9bd9aae9915f163a..377659e54100c6e56174310dad31b4742b317933 100644 (file)
@@ -53,12 +53,9 @@ namespace ]b4_namespace[
   class location;
 }
 
-]m4_ifdef([b4_before_definitions],
-[[/* Copy the %before-definitions blocks.  */
-]b4_before_definitions])[]dnl
-
-[/* Line __line__ of lalr1.cc.  */
-]b4_syncline([@oline@], [@ofile@])[
+]m4_ifdef([b4_start_header],
+[[/* Copy the %start-header blocks.  */
+]b4_user_start_header])[
 
 ]dnl Include location.hh here: it might depend on headers included above.
 [#include "location.hh"
@@ -111,11 +108,11 @@ namespace ]b4_namespace[
 #ifndef YYSTYPE
 ]m4_ifdef([b4_stype],
 [    union semantic_type
-b4_stype
-/* Line __line__ of lalr1.cc.  */
-b4_syncline([@oline@], [@ofile@])
+b4_user_stype
        ;],
-[    typedef int semantic_type;])[
+[m4_if(b4_tag_seen_flag, 0,
+[[    typedef int semantic_type;]],
+[[    typedef YYSTYPE semantic_type;]])])[
 #else
     typedef YYSTYPE semantic_type;
 #endif
@@ -300,9 +297,9 @@ b4_error_verbose_if([, int tok])[);
 # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
 #endif
 ])
-m4_ifdef([b4_after_definitions],
-[[/* Copy the %after-definitions blocks.  */
-]b4_after_definitions])[]dnl
+m4_ifdef([b4_end_header],
+[[/* Copy the %end-header blocks.  */
+]b4_end_header])[]dnl
 
 [#endif /* ! defined PARSER_HEADER_H */]
 ])dnl
@@ -321,10 +318,7 @@ b4_defines_if([
 #include @output_header_name@])[
 
 /* User implementation prologue.  */
-]b4_post_prologue[
-
-]/* Line __line__ of lalr1.cc.  */
-b4_syncline([@oline@], [@ofile@])[
+]b4_user_post_prologue[
 
 #ifndef YY_
 # if YYENABLE_NLS
@@ -342,9 +336,7 @@ b4_syncline([@oline@], [@ofile@])[
 #define YYUSE(e) ((void) (e))
 
 /* A pseudo ostream that takes yydebug_ into account.  */
-# define YYCDEBUG                                                      \
-  for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false)       \
-    (*yycdebug_)
+# define YYCDEBUG if (yydebug_) (*yycdebug_)
 
 /* Enable debugging if requested.  */
 #if YYDEBUG
@@ -557,11 +549,9 @@ namespace ]b4_namespace[
 m4_pushdef([b4_at_dollar],     [yylloc])dnl
 m4_pushdef([b4_dollar_dollar], [yylval])dnl
     /* User initialization code.  */
-    b4_initial_action
+    b4_user_initial_action
 m4_popdef([b4_dollar_dollar])dnl
-m4_popdef([b4_at_dollar])dnl
-  /* Line __line__ of yacc.c.  */
-b4_syncline([@oline@], [@ofile@])])dnl
+m4_popdef([b4_at_dollar])])dnl
 
   [  /* Initialize the stacks.  The initial state will be pushed in
        yynewstate, since the latter expects the semantical and the
@@ -577,6 +567,11 @@ b4_syncline([@oline@], [@ofile@])])dnl
   yynewstate:
     yystate_stack_.push (yystate);
     YYCDEBUG << "Entering state " << yystate << std::endl;
+
+    /* Accept?  */
+    if (yystate == yyfinal_)
+      goto yyacceptlab;
+
     goto yybackup;
 
     /* Backup.  */
@@ -626,16 +621,11 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
        goto yyreduce;
       }
 
-    /* Accept?  */
-    if (yyn == yyfinal_)
-      goto yyacceptlab;
-
     /* Shift the lookahead token.  */
     YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
-    /* Discard the token being shifted unless it is eof.  */
-    if (yychar != yyeof_)
-      yychar = yyempty_;
+    /* Discard the token being shifted.  */
+    yychar = yyempty_;
 
     yysemantic_stack_.push (yylval);
     yylocation_stack_.push (yylloc);
@@ -680,9 +670,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
     YY_REDUCE_PRINT (yyn);
     switch (yyn)
       {
-       ]b4_actions
-    /* Line __line__ of lalr1.cc.  */
-b4_syncline([@oline@], [@ofile@])[
+       ]b4_user_actions[
        default: break;
       }
     YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
@@ -792,9 +780,6 @@ b4_error_verbose_if([, yytoken])[));
        YY_STACK_PRINT ();
       }
 
-    if (yyn == yyfinal_)
-      goto yyacceptlab;
-
     yyerror_range[1] = yylloc;
     // Using YYLLOC is tempting, but would change the location of
     // the lookahead.  YYLOC is available though.
@@ -820,7 +805,7 @@ b4_error_verbose_if([, yytoken])[));
     goto yyreturn;
 
   yyreturn:
-    if (yychar != yyeof_ && yychar != yyempty_)
+    if (yychar != yyempty_)
       yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
 
     /* Do not reclaim the symbols of the rule which action triggered