mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 10:13:03 +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>
|
2009-04-14 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
variables: use `parse.assert' instead of `debug'.
|
variables: use `parse.assert' instead of `debug'.
|
||||||
|
|||||||
2
TODO
2
TODO
@@ -293,8 +293,6 @@ Are there any Texinfo standards for bibliography?
|
|||||||
** %printer
|
** %printer
|
||||||
Wow, %printer is not documented. Clearly mark YYPRINT as obsolete.
|
Wow, %printer is not documented. Clearly mark YYPRINT as obsolete.
|
||||||
|
|
||||||
** %define assert
|
|
||||||
|
|
||||||
* Java, Fortran, etc.
|
* Java, Fortran, etc.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -677,17 +677,17 @@ m4_define([b4_percent_define_if_define],
|
|||||||
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_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
||||||
# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [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_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
|
||||||
# b4_variant_if([IF-VARIANT-ARE-USED], [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([error_verbose])
|
||||||
b4_percent_define_if_define([lex_symbol])
|
b4_percent_define_if_define([lex_symbol])
|
||||||
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
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])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
|
|
||||||
]b4_percent_code_get([[requires]])[
|
]b4_percent_code_get([[requires]])[
|
||||||
|
|
||||||
]b4_assert_if([#include <cassert>])[
|
]b4_parse_assert_if([#include <cassert>])[
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "stack.hh"
|
#include "stack.hh"
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ m4_define([b4_variant_define],
|
|||||||
/// via the current state.
|
/// via the current state.
|
||||||
template <size_t S>
|
template <size_t S>
|
||||||
struct variant
|
struct variant
|
||||||
{]b4_assert_if([
|
{]b4_parse_assert_if([
|
||||||
/// Whether something is contained.
|
/// Whether something is contained.
|
||||||
bool built;
|
bool built;
|
||||||
])[
|
])[
|
||||||
/// Empty construction.
|
/// Empty construction.
|
||||||
inline
|
inline
|
||||||
variant ()]b4_assert_if([
|
variant ()]b4_parse_assert_if([
|
||||||
: built (false)])[
|
: built (false)])[
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ m4_define([b4_variant_define],
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline T&
|
inline T&
|
||||||
build ()
|
build ()
|
||||||
{]b4_assert_if([
|
{]b4_parse_assert_if([
|
||||||
assert (!built);
|
assert (!built);
|
||||||
built = true;])[
|
built = true;])[
|
||||||
return *new (buffer.raw) T;
|
return *new (buffer.raw) T;
|
||||||
@@ -111,7 +111,7 @@ m4_define([b4_variant_define],
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline T&
|
inline T&
|
||||||
build (const T& t)
|
build (const T& t)
|
||||||
{]b4_assert_if([
|
{]b4_parse_assert_if([
|
||||||
assert(!built);
|
assert(!built);
|
||||||
built = true;])[
|
built = true;])[
|
||||||
return *new (buffer.raw) T(t);
|
return *new (buffer.raw) T(t);
|
||||||
@@ -120,7 +120,7 @@ m4_define([b4_variant_define],
|
|||||||
/// Construct and fill.
|
/// Construct and fill.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline
|
inline
|
||||||
variant (const T& t)]b4_assert_if([
|
variant (const T& t)]b4_parse_assert_if([
|
||||||
: built (true)])[
|
: built (true)])[
|
||||||
{
|
{
|
||||||
new (buffer.raw) T(t);
|
new (buffer.raw) T(t);
|
||||||
@@ -130,7 +130,7 @@ m4_define([b4_variant_define],
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline T&
|
inline T&
|
||||||
as ()
|
as ()
|
||||||
{]b4_assert_if([
|
{]b4_parse_assert_if([
|
||||||
assert (built);])[
|
assert (built);])[
|
||||||
return reinterpret_cast<T&>(buffer.raw);
|
return reinterpret_cast<T&>(buffer.raw);
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ m4_define([b4_variant_define],
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline const T&
|
inline const T&
|
||||||
as () const
|
as () const
|
||||||
{]b4_assert_if([
|
{]b4_parse_assert_if([
|
||||||
assert(built);])[
|
assert(built);])[
|
||||||
return reinterpret_cast<const T&>(buffer.raw);
|
return reinterpret_cast<const T&>(buffer.raw);
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ m4_define([b4_variant_define],
|
|||||||
inline void
|
inline void
|
||||||
destroy ()
|
destroy ()
|
||||||
{
|
{
|
||||||
as<T>().~T();]b4_assert_if([
|
as<T>().~T();]b4_parse_assert_if([
|
||||||
built = false;])[
|
built = false;])[
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5003,6 +5003,22 @@ The parser namespace is @code{foo} and @code{yylex} is referenced as
|
|||||||
@end itemize
|
@end itemize
|
||||||
@c namespace
|
@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
|
@item parse.trace
|
||||||
@findex %define parse.trace
|
@findex %define parse.trace
|
||||||
|
|
||||||
|
|||||||
10
tests/c++.at
10
tests/c++.at
@@ -1,5 +1,5 @@
|
|||||||
# 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
|
# 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
|
# 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([])
|
||||||
AT_CHECK_VARIANTS([%define assert])
|
AT_CHECK_VARIANTS([%define parse.assert])
|
||||||
AT_CHECK_VARIANTS([[%define assert %code {\n#define ONE_STAGE_BUILD\n}]])
|
AT_CHECK_VARIANTS([[%define parse.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 parse.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 %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define token.prefix "TOK_"]])
|
||||||
|
|
||||||
|
|
||||||
## ----------------------- ##
|
## ----------------------- ##
|
||||||
|
|||||||
Reference in New Issue
Block a user