* data/stack.hh (b4_stack_define): New.
* data/lalr1.cc: Use it when %defines is not passed.
* tests/output.at: Adjust expected output.
*** 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)
** 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'?
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])[
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:
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([#])
+])
])
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])