mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
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.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
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'.
|
||||
|
||||
2
TODO
2
TODO
@@ -293,8 +293,6 @@ Are there any Texinfo standards for bibliography?
|
||||
** %printer
|
||||
Wow, %printer is not documented. Clearly mark YYPRINT as obsolete.
|
||||
|
||||
** %define assert
|
||||
|
||||
* Java, Fortran, etc.
|
||||
|
||||
|
||||
|
||||
@@ -677,17 +677,17 @@ m4_define([b4_percent_define_if_define],
|
||||
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_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([parse.assert])
|
||||
b4_percent_define_if_define([parse.trace])
|
||||
b4_percent_define_if_define([variant])
|
||||
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
||||
|
||||
]b4_percent_code_get([[requires]])[
|
||||
|
||||
]b4_assert_if([#include <cassert>])[
|
||||
]b4_parse_assert_if([#include <cassert>])[
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "stack.hh"
|
||||
|
||||
@@ -87,13 +87,13 @@ m4_define([b4_variant_define],
|
||||
/// via the current state.
|
||||
template <size_t S>
|
||||
struct variant
|
||||
{]b4_assert_if([
|
||||
{]b4_parse_assert_if([
|
||||
/// Whether something is contained.
|
||||
bool built;
|
||||
])[
|
||||
/// Empty construction.
|
||||
inline
|
||||
variant ()]b4_assert_if([
|
||||
variant ()]b4_parse_assert_if([
|
||||
: built (false)])[
|
||||
{}
|
||||
|
||||
@@ -101,7 +101,7 @@ m4_define([b4_variant_define],
|
||||
template <typename T>
|
||||
inline T&
|
||||
build ()
|
||||
{]b4_assert_if([
|
||||
{]b4_parse_assert_if([
|
||||
assert (!built);
|
||||
built = true;])[
|
||||
return *new (buffer.raw) T;
|
||||
@@ -111,7 +111,7 @@ m4_define([b4_variant_define],
|
||||
template <typename T>
|
||||
inline T&
|
||||
build (const T& t)
|
||||
{]b4_assert_if([
|
||||
{]b4_parse_assert_if([
|
||||
assert(!built);
|
||||
built = true;])[
|
||||
return *new (buffer.raw) T(t);
|
||||
@@ -120,7 +120,7 @@ m4_define([b4_variant_define],
|
||||
/// 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);
|
||||
@@ -130,7 +130,7 @@ m4_define([b4_variant_define],
|
||||
template <typename T>
|
||||
inline T&
|
||||
as ()
|
||||
{]b4_assert_if([
|
||||
{]b4_parse_assert_if([
|
||||
assert (built);])[
|
||||
return reinterpret_cast<T&>(buffer.raw);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ m4_define([b4_variant_define],
|
||||
template <typename T>
|
||||
inline const T&
|
||||
as () const
|
||||
{]b4_assert_if([
|
||||
{]b4_parse_assert_if([
|
||||
assert(built);])[
|
||||
return reinterpret_cast<const T&>(buffer.raw);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ m4_define([b4_variant_define],
|
||||
inline void
|
||||
destroy ()
|
||||
{
|
||||
as<T>().~T();]b4_assert_if([
|
||||
as<T>().~T();]b4_parse_assert_if([
|
||||
built = false;])[
|
||||
}
|
||||
|
||||
|
||||
@@ -5003,6 +5003,22 @@ The parser namespace is @code{foo} and @code{yylex} is referenced as
|
||||
@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
|
||||
|
||||
|
||||
10
tests/c++.at
10
tests/c++.at
@@ -1,5 +1,5 @@
|
||||
# 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
|
||||
@@ -196,10 +196,10 @@ AT_CLEANUP
|
||||
])
|
||||
|
||||
AT_CHECK_VARIANTS([])
|
||||
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_"]])
|
||||
|
||||
|
||||
## ----------------------- ##
|
||||
|
||||
Reference in New Issue
Block a user