* TODO (assert): Remove.
* data/bison.m4 (b4_assert_if): Replace with...
(b4_parse_assert_if): this.
* data/lalr1.cc, data/variant.hh, tests/c++.at: Adjust.
* doc/bison.texinfo (Decl Summary): Document parse.assert.
+2009-04-14 Akim Demaille <demaille@gostai.com>
+
+ variables: use `parse.assert' instead of `assert'.
+ * TODO (assert): Remove.
+ * data/bison.m4 (b4_assert_if): Replace with...
+ (b4_parse_assert_if): this.
+ * data/lalr1.cc, data/variant.hh, tests/c++.at: Adjust.
+ * doc/bison.texinfo (Decl Summary): Document parse.assert.
+
2009-04-14 Akim Demaille <demaille@gostai.com>
variables: use `parse.assert' instead of `debug'.
2009-04-14 Akim Demaille <demaille@gostai.com>
variables: use `parse.assert' instead of `debug'.
** %printer
Wow, %printer is not documented. Clearly mark YYPRINT as obsolete.
** %printer
Wow, %printer is not documented. Clearly mark YYPRINT as obsolete.
b4_percent_define_if_define_([$1], $[1], $[2])])
b4_percent_define_if_define_([$1], $[1], $[2])])
-# b4_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
+# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
# b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
# ----------------------------------------------
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
# b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
# ----------------------------------------------
-b4_percent_define_if_define([assert])
-b4_percent_define_if_define([parse.trace])
b4_percent_define_if_define([error_verbose])
b4_percent_define_if_define([lex_symbol])
b4_percent_define_if_define([locations]) # Whether locations are tracked.
b4_percent_define_if_define([error_verbose])
b4_percent_define_if_define([lex_symbol])
b4_percent_define_if_define([locations]) # Whether locations are tracked.
+b4_percent_define_if_define([parse.assert])
+b4_percent_define_if_define([parse.trace])
b4_percent_define_if_define([variant])
b4_percent_define_if_define([variant])
]b4_percent_code_get([[requires]])[
]b4_percent_code_get([[requires]])[
-]b4_assert_if([#include <cassert>])[
+]b4_parse_assert_if([#include <cassert>])[
#include <string>
#include <iostream>
#include "stack.hh"
#include <string>
#include <iostream>
#include "stack.hh"
/// via the current state.
template <size_t S>
struct variant
/// via the current state.
template <size_t S>
struct variant
/// Whether something is contained.
bool built;
])[
/// Empty construction.
inline
/// Whether something is contained.
bool built;
])[
/// Empty construction.
inline
- variant ()]b4_assert_if([
+ variant ()]b4_parse_assert_if([
template <typename T>
inline T&
build ()
template <typename T>
inline T&
build ()
assert (!built);
built = true;])[
return *new (buffer.raw) T;
assert (!built);
built = true;])[
return *new (buffer.raw) T;
template <typename T>
inline T&
build (const T& t)
template <typename T>
inline T&
build (const T& t)
assert(!built);
built = true;])[
return *new (buffer.raw) T(t);
assert(!built);
built = true;])[
return *new (buffer.raw) T(t);
/// Construct and fill.
template <typename T>
inline
/// Construct and fill.
template <typename T>
inline
- variant (const T& t)]b4_assert_if([
+ variant (const T& t)]b4_parse_assert_if([
: built (true)])[
{
new (buffer.raw) T(t);
: built (true)])[
{
new (buffer.raw) T(t);
template <typename T>
inline T&
as ()
template <typename T>
inline T&
as ()
assert (built);])[
return reinterpret_cast<T&>(buffer.raw);
}
assert (built);])[
return reinterpret_cast<T&>(buffer.raw);
}
template <typename T>
inline const T&
as () const
template <typename T>
inline const T&
as () const
assert(built);])[
return reinterpret_cast<const T&>(buffer.raw);
}
assert(built);])[
return reinterpret_cast<const T&>(buffer.raw);
}
- as<T>().~T();]b4_assert_if([
+ as<T>().~T();]b4_parse_assert_if([
@end itemize
@c namespace
@end itemize
@c namespace
+@item parse.assert
+@findex %define parse.assert
+
+@itemize
+@item Languages(s): C++
+
+@item Purpose: Issue runtime assertions to catch invalid uses.
+In C++, when variants are used, symbols must be constructed and
+destroyed properly. This option checks these constraints.
+
+@item Accepted Values: Boolean
+
+@item Default Value: @code{false}
+@end itemize
+@c parse.assert
+
@item parse.trace
@findex %define parse.trace
@item parse.trace
@findex %define parse.trace
# Checking the output filenames. -*- Autotest -*-
# Checking the output filenames. -*- Autotest -*-
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-AT_CHECK_VARIANTS([%define assert])
-AT_CHECK_VARIANTS([[%define assert %code {\n#define ONE_STAGE_BUILD\n}]])
-AT_CHECK_VARIANTS([[%define assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n}]])
-AT_CHECK_VARIANTS([[%define assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define token.prefix "TOK_"]])
+AT_CHECK_VARIANTS([%define parse.assert])
+AT_CHECK_VARIANTS([[%define parse.assert %code {\n#define ONE_STAGE_BUILD\n}]])
+AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n}]])
+AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define token.prefix "TOK_"]])
## ----------------------- ##
## ----------------------- ##