mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
lalr1.cc: do not create stack.hh without %defines
* data/stack.hh (b4_stack_define): New. * data/lalr1.cc: Use it when %defines is not passed. * tests/output.at: Adjust expected output.
This commit is contained in:
3
NEWS
3
NEWS
@@ -87,7 +87,8 @@ GNU Bison NEWS
|
|||||||
*** parser header (%defines) is no longer mandatory (lalr1.cc)
|
*** parser header (%defines) is no longer mandatory (lalr1.cc)
|
||||||
|
|
||||||
In which case, if needed, the support classes are defined in the generated
|
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)
|
*** locations are no longer mandatory (lalr1.cc, glr.cc)
|
||||||
|
|
||||||
|
|||||||
5
TODO
5
TODO
@@ -10,6 +10,11 @@ b4_parser_declaration for instance.
|
|||||||
** glr.cc: %defines
|
** glr.cc: %defines
|
||||||
it should not be mandatory.
|
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.
|
** Variable names.
|
||||||
What should we name `variant' and `lex_symbol'?
|
What should we name `variant' and `lex_symbol'?
|
||||||
|
|
||||||
|
|||||||
@@ -134,20 +134,22 @@ b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
|
|||||||
m4_define([b4_shared_declarations],
|
m4_define([b4_shared_declarations],
|
||||||
[b4_percent_code_get([[requires]])[
|
[b4_percent_code_get([[requires]])[
|
||||||
]b4_parse_assert_if([# include <cassert>])[
|
]b4_parse_assert_if([# include <cassert>])[
|
||||||
# include <stdexcept>
|
# include <deque>
|
||||||
# include <string>
|
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
|
# include <stdexcept>
|
||||||
|
# include <string>]b4_defines_if([[
|
||||||
|
# include "stack.hh"
|
||||||
|
]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
|
||||||
|
[[# include "location.hh"]])])])[
|
||||||
|
|
||||||
]b4_YYDEBUG_define[
|
]b4_YYDEBUG_define[
|
||||||
|
|
||||||
# include "stack.hh"
|
|
||||||
]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
|
|
||||||
[b4_defines_if([[# include "location.hh"]])])])[
|
|
||||||
|
|
||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
|
|
||||||
]b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
|
]b4_defines_if([],
|
||||||
[b4_defines_if([], [b4_position_define
|
[b4_stack_define
|
||||||
|
b4_locations_if([b4_percent_define_ifdef([[location_type]], [],
|
||||||
|
[b4_position_define
|
||||||
b4_location_define])])])[
|
b4_location_define])])])[
|
||||||
|
|
||||||
]b4_variant_if([b4_variant_define])[
|
]b4_variant_if([b4_variant_define])[
|
||||||
|
|||||||
@@ -18,23 +18,10 @@
|
|||||||
m4_pushdef([b4_copyright_years],
|
m4_pushdef([b4_copyright_years],
|
||||||
[2002-2012])
|
[2002-2012])
|
||||||
|
|
||||||
# We do want M4 expansion after # for CPP macros.
|
# b4_stack_define
|
||||||
m4_changecom()
|
# ---------------
|
||||||
m4_divert_push(0)dnl
|
m4_define([b4_stack_define],
|
||||||
@output(b4_dir_prefix[]stack.hh@)@
|
[[ template <class T, class S = std::deque<T> >
|
||||||
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> >
|
|
||||||
class stack
|
class stack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -129,9 +116,30 @@ b4_copyright([Stack handling for Bison parsers in C++])[
|
|||||||
const S& stack_;
|
const S& stack_;
|
||||||
unsigned int range_;
|
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_namespace_close[
|
||||||
|
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
|
||||||
m4_divert_pop(0)
|
m4_divert_pop(0)
|
||||||
m4_popdef([b4_copyright_years])dnl
|
m4_popdef([b4_copyright_years])dnl
|
||||||
m4_changecom([#])
|
m4_changecom([#])
|
||||||
|
])
|
||||||
|
|||||||
@@ -114,13 +114,13 @@ AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
|
|||||||
])
|
])
|
||||||
|
|
||||||
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [],
|
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], [],
|
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], [],
|
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], [],
|
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])
|
[foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
|
||||||
|
|||||||
Reference in New Issue
Block a user