]> git.saurik.com Git - bison.git/commitdiff
lalr1.cc: do not create stack.hh without %defines
authorAkim Demaille <akim@lrde.epita.fr>
Mon, 30 Jul 2012 14:51:29 +0000 (16:51 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Tue, 31 Jul 2012 09:33:46 +0000 (11:33 +0200)
* data/stack.hh (b4_stack_define): New.
* data/lalr1.cc: Use it when %defines is not passed.
* tests/output.at: Adjust expected output.

NEWS
TODO
data/lalr1.cc
data/stack.hh
tests/output.at

diff --git a/NEWS b/NEWS
index ef01a6a27eeed2d4468f49c418ead444bc8e37f8..fa1b948f57e090eef5e955ffc0a13cac480ff89f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -87,7 +87,8 @@ GNU Bison NEWS
 *** parser header (%defines) is no longer mandatory (lalr1.cc)
 
   In which case, if needed, the support classes are defined in the generated
-  parser, instead of additional files such as position.hh and location.hh.
+  parser, instead of additional files (location.hh, position.hh and
+  stack.hh).
 
 *** locations are no longer mandatory (lalr1.cc, glr.cc)
 
diff --git a/TODO b/TODO
index 9eb109200cddcdbc54f0f9bf534021e2a852532a..1c5d3585fa0410788a3ac5f2dba0caf17b6c0081 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,6 +10,11 @@ b4_parser_declaration for instance.
 ** glr.cc: %defines
 it should not be mandatory.
 
+** stack.hh
+Get rid of it.  The original idea is nice, but actually it makes
+the code harder to follow, and uselessly different from the other
+skeletons.
+
 ** Variable names.
 What should we name `variant' and `lex_symbol'?
 
index 6e299d5d09bb7fcadfbf3259fe17f492b928a2e2..8cf20430ea30ea5f185c5e42762eb5d3db261a8b 100644 (file)
@@ -134,20 +134,22 @@ b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
 m4_define([b4_shared_declarations],
 [b4_percent_code_get([[requires]])[
 ]b4_parse_assert_if([# include <cassert>])[
-# include <stdexcept>
-# include <string>
+# include <deque>
 # include <iostream>
-
-]b4_YYDEBUG_define[
-
+# include <stdexcept>
+# include <string>]b4_defines_if([[
 # include "stack.hh"
 ]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
-    [b4_defines_if([[# include "location.hh"]])])])[
+                                          [[# include "location.hh"]])])])[
+
+]b4_YYDEBUG_define[
 
 ]b4_namespace_open[
 
-]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
-  [b4_defines_if([], [b4_position_define
+]b4_defines_if([],
+[b4_stack_define
+b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
+                                         [b4_position_define
 b4_location_define])])])[
 
 ]b4_variant_if([b4_variant_define])[
index cea7b41a80100f3b2486c0deec1a0af19dab8ce6..bd94eb2da5dded1256f7ed840257ae72d4adebf3 100644 (file)
 m4_pushdef([b4_copyright_years],
            [2002-2012])
 
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
-@output(b4_dir_prefix[]stack.hh@)@
-b4_copyright([Stack handling for Bison parsers in C++])[
-
-/**
- ** \file ]b4_dir_prefix[stack.hh
- ** Define the ]b4_namespace_ref[::stack class.
- */
-
-]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
-
-# include <deque>
-
-]b4_namespace_open[
-  template <class T, class S = std::deque<T> >
+# b4_stack_define
+# ---------------
+m4_define([b4_stack_define],
+[[  template <class T, class S = std::deque<T> >
   class stack
   {
   public:
@@ -129,9 +116,30 @@ b4_copyright([Stack handling for Bison parsers in C++])[
     const S& stack_;
     unsigned int range_;
   };
+]])
+
+b4_defines_if(
+[# We do want M4 expansion after # for CPP macros.
+m4_changecom()
+m4_divert_push(0)dnl
+@output(b4_dir_prefix[]stack.hh@)@
+b4_copyright([Stack handling for Bison parsers in C++])[
+
+/**
+ ** \file ]b4_dir_prefix[stack.hh
+ ** Define the ]b4_namespace_ref[::stack class.
+ */
+
+]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
+
+# include <deque>
+
+]b4_namespace_open[
+]b4_stack_define[
 ]b4_namespace_close[
 
 ]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
 m4_divert_pop(0)
 m4_popdef([b4_copyright_years])dnl
 m4_changecom([#])
+])
index e8019c2a50dac4c9ba801a9857d3d52287ee459a..400f5c20df3b61b9e2bb49e6a2d4dab5176f0da4 100644 (file)
@@ -114,13 +114,13 @@ AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
 ])
 
 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [],
-                [foo.tab.cc foo.output stack.hh])
+                [foo.tab.cc foo.output])
 
 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
-                [foo.tab.cc foo.tab.hh foo.output stack.hh])
+                [foo.tab.cc foo.tab.hh foo.output])
 
 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose %locations], [],
-                [foo.tab.cc foo.output stack.hh])
+                [foo.tab.cc foo.output])
 
 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [],
                 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])