mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-12 04:05:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8adec9c125 | ||
|
|
cafa811a66 | ||
|
|
07a187c5ee | ||
|
|
a81bcbb245 | ||
|
|
96ef81cf07 | ||
|
|
fc54e6b9b3 |
+1
-1
@@ -1 +1 @@
|
|||||||
3.2.2
|
3.2.3
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
GNU Bison NEWS
|
GNU Bison NEWS
|
||||||
|
|
||||||
|
* Noteworthy changes in release 3.2.4 (2018-12-24) [stable]
|
||||||
|
|
||||||
|
** Bug fixes
|
||||||
|
|
||||||
|
Fix the move constructor of symbol_type.
|
||||||
|
|
||||||
|
Always provide a copy constructor for symbol_type, even in modern C++.
|
||||||
|
|
||||||
* Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
|
* Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
|
||||||
|
|
||||||
** Bug fixes
|
** Bug fixes
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ Wayne Green [email protected]
|
|||||||
Wei Song [email protected]
|
Wei Song [email protected]
|
||||||
Wojciech Polak [email protected]
|
Wojciech Polak [email protected]
|
||||||
Wolfgang S. Kechel [email protected]
|
Wolfgang S. Kechel [email protected]
|
||||||
|
Wolfgang Thaller [email protected]
|
||||||
Wolfram Wagner [email protected]
|
Wolfram Wagner [email protected]
|
||||||
Wwp [email protected]
|
Wwp [email protected]
|
||||||
xolodho [email protected]
|
xolodho [email protected]
|
||||||
|
|||||||
+42
-12
@@ -244,8 +244,13 @@ m4_define([b4_symbol_type_declare],
|
|||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
basic_symbol ();
|
basic_symbol ();
|
||||||
|
|
||||||
/// Move or copy constructor.
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
basic_symbol (YY_RVREF (basic_symbol) other);
|
/// Move constructor.
|
||||||
|
basic_symbol (basic_symbol&& that);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Copy constructor.
|
||||||
|
basic_symbol (const basic_symbol& that);
|
||||||
|
|
||||||
]b4_variant_if([[
|
]b4_variant_if([[
|
||||||
/// Constructor for valueless symbols, and symbols from each type.
|
/// Constructor for valueless symbols, and symbols from each type.
|
||||||
@@ -280,7 +285,7 @@ m4_define([b4_symbol_type_declare],
|
|||||||
private:
|
private:
|
||||||
#if YY_CPLUSPLUS < 201103L
|
#if YY_CPLUSPLUS < 201103L
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
basic_symbol& operator= (const basic_symbol& other);
|
basic_symbol& operator= (const basic_symbol& that);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -290,8 +295,13 @@ m4_define([b4_symbol_type_declare],
|
|||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
by_type ();
|
by_type ();
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Move constructor.
|
||||||
|
by_type (by_type&& that);
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
by_type (const by_type& other);
|
by_type (const by_type& that);
|
||||||
|
|
||||||
/// The symbol type as needed by the constructor.
|
/// The symbol type as needed by the constructor.
|
||||||
typedef token_type kind_type;
|
typedef token_type kind_type;
|
||||||
@@ -339,14 +349,26 @@ m4_define([b4_public_types_define],
|
|||||||
, location ()])[
|
, location ()])[
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (YY_RVREF (basic_symbol) other)
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
|
||||||
: Base (YY_MOVE (other))
|
: Base (std::move (that))
|
||||||
, value (]b4_variant_if([], [YY_MOVE (other.value)]))b4_locations_if([
|
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||||
, location (YY_MOVE (other.location))])[
|
, location (std::move (that.location))])[
|
||||||
{]b4_variant_if([
|
{]b4_variant_if([
|
||||||
b4_symbol_variant([other.type_get ()], [value], [YY_MOVE_OR_COPY],
|
b4_symbol_variant([this->type_get ()], [value], [move],
|
||||||
[YY_MOVE (other.value)])])[
|
[std::move (that.value)])])[
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename Base>
|
||||||
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||||
|
: Base (that)
|
||||||
|
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
||||||
|
, location (that.location)])[
|
||||||
|
{]b4_variant_if([
|
||||||
|
b4_symbol_variant([this->type_get ()], [value], [copy],
|
||||||
|
[that.value])])[
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_variant_if([[
|
]b4_variant_if([[
|
||||||
@@ -423,8 +445,16 @@ m4_define([b4_public_types_define],
|
|||||||
: type (empty_symbol)
|
: type (empty_symbol)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other)
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
: type (other.type)
|
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (by_type&& that)
|
||||||
|
: type (that.type)
|
||||||
|
{
|
||||||
|
that.clear ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& that)
|
||||||
|
: type (that.type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t)
|
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t)
|
||||||
|
|||||||
+39
-13
@@ -103,7 +103,7 @@ AT_KEYWORDS([variant])
|
|||||||
|
|
||||||
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %debug $1])
|
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %debug $1])
|
||||||
# Store strings and integers in a vector of strings.
|
# Store strings and integers in a vector of strings.
|
||||||
AT_DATA_GRAMMAR([list.y],
|
AT_DATA_GRAMMAR([list.yy],
|
||||||
[[%skeleton "lalr1.cc"
|
[[%skeleton "lalr1.cc"
|
||||||
%define api.value.type variant
|
%define api.value.type variant
|
||||||
%define parse.assert
|
%define parse.assert
|
||||||
@@ -142,24 +142,52 @@ exp: "int" { $$.push_back ($1); }
|
|||||||
]AT_YYERROR_DEFINE[
|
]AT_YYERROR_DEFINE[
|
||||||
]AT_YYLEX_DEFINE[
|
]AT_YYLEX_DEFINE[
|
||||||
|
|
||||||
|
template <typename Exp, typename Eff>
|
||||||
|
void assert_eq (const Exp& exp, const Eff& eff)
|
||||||
|
{
|
||||||
|
if (getenv ("DEBUG"))
|
||||||
|
std::cerr << "Assert: " << exp << " == " << eff << '\n';
|
||||||
|
if (exp != eff)
|
||||||
|
std::cerr << "Assertion failed: " << exp << " != " << eff << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
using yy::parser;
|
using yy::parser;
|
||||||
// symbol_type: construction, accessor.
|
// symbol_type: construction, accessor.
|
||||||
{
|
{
|
||||||
parser::symbol_type s = parser::make_INT(12);
|
parser::symbol_type s = parser::make_INT (12);
|
||||||
std::cerr << s.value.as<int>() << '\n';
|
assert_eq (s.value.as<int> (), 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
// symbol_type: move constructor.
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
{
|
||||||
|
auto s = parser::make_INT (42);
|
||||||
|
auto s2 = std::move (s);
|
||||||
|
assert_eq (s2.value.as<int> (), 42);
|
||||||
|
// Used to crash here, because s was improperly cleared, and
|
||||||
|
// its destructor tried to delete its (moved) value.
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// symbol_type: copy constructor.
|
||||||
|
{
|
||||||
|
parser::symbol_type s = parser::make_INT (51);
|
||||||
|
parser::symbol_type s2 = s;
|
||||||
|
assert_eq (s.value.as<int> (), 51);
|
||||||
|
assert_eq (s2.value.as<int> (), 51);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stack_symbol_type: construction, accessor.
|
// stack_symbol_type: construction, accessor.
|
||||||
{
|
{
|
||||||
#if defined __cplusplus && 201103L <= __cplusplus
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
auto ss = parser::stack_symbol_type(1, parser::make_INT(123));
|
auto ss = parser::stack_symbol_type(1, parser::make_INT(123));
|
||||||
#else
|
#else
|
||||||
parser::symbol_type s = parser::make_INT(123);
|
parser::symbol_type s = parser::make_INT (123);
|
||||||
parser::stack_symbol_type ss(1, s);
|
parser::stack_symbol_type ss(1, s);
|
||||||
#endif
|
#endif
|
||||||
std::cerr << ss.value.as<int>() << '\n';
|
assert_eq (ss.value.as<int> (), 123);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pushing on the stack.
|
// Pushing on the stack.
|
||||||
@@ -170,7 +198,7 @@ int main()
|
|||||||
const int mucho = 1700;
|
const int mucho = 1700;
|
||||||
for (int i = 0; i < mucho; ++i)
|
for (int i = 0; i < mucho; ++i)
|
||||||
{
|
{
|
||||||
#if defined __cplusplus && 201103L <= __cplusplus
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
st.push(parser::stack_symbol_type{1, parser::make_INT (i)});
|
st.push(parser::stack_symbol_type{1, parser::make_INT (i)});
|
||||||
#else
|
#else
|
||||||
parser::symbol_type s = parser::make_INT (i);
|
parser::symbol_type s = parser::make_INT (i);
|
||||||
@@ -180,19 +208,17 @@ int main()
|
|||||||
}
|
}
|
||||||
for (int i = mucho - 1; 0 <= i; --i)
|
for (int i = mucho - 1; 0 <= i; --i)
|
||||||
{
|
{
|
||||||
assert (st[0].value.as<int>() == i);
|
assert_eq (st[0].value.as<int>(), i);
|
||||||
st.pop ();
|
st.pop ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
AT_BISON_CHECK([[-o list.cc list.yy]])
|
||||||
AT_FOR_EACH_CXX([
|
AT_FOR_EACH_CXX([
|
||||||
AT_FULL_COMPILE([list])
|
AT_COMPILE_CXX([list])
|
||||||
AT_PARSER_CHECK([./list], 0, [],
|
AT_PARSER_CHECK([./list])
|
||||||
[12
|
|
||||||
123
|
|
||||||
])
|
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_BISON_OPTION_POPDEFS
|
AT_BISON_OPTION_POPDEFS
|
||||||
|
|||||||
Reference in New Issue
Block a user