summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2011-01-13 22:08:30 +0100
committerAkim Demaille <demaille@gostai.com>2011-06-30 10:53:09 +0200
commitf8de42c04640d4fe9eecef2c881471347bd5b744 (patch)
tree7b51740ce7540f125ed4637ec0d5c08bc70f9e62
parent262c0ad4c3986a8d11a17198d3b37ace38e014b3 (diff)
downloadbison-candidates/make-symbol-glr.tar.gz
WIP: fix test suite failures.candidates/make-symbol-glr
* data/c++.m4 (move): New. * data/glr.c (swap): New overload for symbol_type. * data/lalr1.cc: Use move, not swap. Here, we actually need a move-assignment.
-rw-r--r--data/c++.m413
-rw-r--r--data/glr.c8
-rw-r--r--data/lalr1.cc16
3 files changed, 32 insertions, 5 deletions
diff --git a/data/c++.m4 b/data/c++.m4
index 45b4322c..613e921b 100644
--- a/data/c++.m4
+++ b/data/c++.m4
@@ -183,6 +183,9 @@ m4_define([b4_public_types_declare],
/// Default constructor.
inline symbol_type ();
+ /// Destructive move, \a s is emptied.
+ inline void move (symbol_type& s);
+
/// Constructor for tokens with semantic value.
inline symbol_type (]b4_args([token_type t],
[const semantic_type& v],
@@ -293,6 +296,16 @@ m4_define([b4_public_types_define],
}
inline
+ void
+ ]b4_parser_class_name[::symbol_type::move (symbol_type& s)
+ {
+ ]b4_variant_if([b4_symbol_variant([[s.type]], [value], [build], [s.value])],
+ [value = s.value;])[
+ type = s.type;]b4_locations_if([
+ location = s.location;])[
+ }
+
+ inline
int
]b4_parser_class_name[::symbol_type::type_get_ () const
{
diff --git a/data/glr.c b/data/glr.c
index 113ba2fa..05fb2489 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -1407,7 +1407,7 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
yynewState->yyposn = yyposn;
yynewState->yyresolved = yytrue;
yynewState->yypred = yystackp->yytops.yystates[yyk];]b4_variant_if([[
- // new (&yynewState->yysemantics.yysval) YYSTYPE;
+ // new (&yynewState->yysemantics.yysval) YYSTYPE;
]b4_symbol_variant([[yystos[yylrState]]], [[yynewState->yysemantics.yysval]],
[copy], [*yyvalp])], [[
yynewState->yysemantics.yysval = *yyvalp;]])[
@@ -1623,7 +1623,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
}
if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
{
- YYASSERT (0);// FIXME: Beware of realloc in C++.
+ ]b4_variant_if([YYASSERT (!"Not implemented");])[
yyGLRState** yynewStates;
yybool* yynewLookaheadNeeds;
@@ -1808,8 +1808,8 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
if (yynrhs == 0)
/* Set default location. */
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
- // YY_SYMBOL_PRINT("yyresolveAction: BEFORE",
- // YYTRANSLATE(yychar), &yylval, &yylloc);
+ // YY_SYMBOL_PRINT("yyresolveAction: BEFORE",
+ // YYTRANSLATE(yychar), &yylval, &yylloc);
YY_SYMBOL_SWAP (yychar_current, yylval_current, yylloc_current,
yychar, yylval, yylloc);
diff --git a/data/lalr1.cc b/data/lalr1.cc
index b74a979e..0ace5482 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -346,6 +346,20 @@ b4_namespace_close])[
b4_public_types_define])[
]b4_namespace_close[
+]b4_variant_if([[namespace std
+{
+ // FIXME: this is useless.
+ inline
+ void
+ swap(]b4_namespace_ref::b4_parser_class_name[::symbol_type& s1, ]b4_namespace_ref::b4_parser_class_name[::symbol_type& s2)
+ {
+ ]b4_symbol_variant([[s1.type]], [[s1.value]],
+ [swap], [s2.value])[
+ std::swap (s1.type, s2.type);]b4_locations_if([
+ std::swap (s1.location, s2.location);])[
+ }
+}]])[
+
]b4_percent_define_flag_if([[global_tokens_and_yystype]],
[b4_token_defines(b4_tokens)
@@ -738,7 +752,7 @@ m4_popdef([b4_at_dollar])])dnl
]b4_lex_symbol_if(
[ symbol_type yylookahead = b4_c_function_call([yylex], [symbol_type],
m4_ifdef([b4_lex_param], b4_lex_param));
- std::swap(yylookahead, yyla);],
+ yyla.move(yylookahead);],
[ yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
[[YYSTYPE*], [&yyla.value]][]dnl
b4_locations_if([, [[location*], [&yyla.location]]])dnl