mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Improve C++ namespace support. Discussed starting at
<http://lists.gnu.org/archive/html/help-bison/2007-09/msg00016.html>. * data/c++.m4: (b4_namespace_ref, b4_namespace_open, b4_namespace_close): New macros that interpret the %define variable "namespace" so its value can contain "::" to indicate nested namespaces. * data/glr.cc (b4_namespace): Don't define, and replace all uses with the above macros. * data/lalr1.cc (b4_namespace): Likewise. * data/location.cc (b4_namespace): Likewise. * doc/bison.texinfo (Decl Summary): Move `%define push_pull' entry inside a new table in the general %define entry. Document `%define namespace' there as well. Point the %name-prefix entry to it since it explains it more completely in the case of C++. (C++ Bison Interface): Mention `%define namespace' instead of %name-prefix. (Table of Symbols): Remove the `%define push_pull' entry. The %define entry suffices. * tests/c++.at (Relative namespace references): New test case. (Absolute namespace references): New test case. (Syntactically invalid namespace references): New test case. * tests/input.at (C++ namespace reference errors): New test case.
This commit is contained in:
@@ -25,7 +25,7 @@ b4_copyright([Positions for Bison parsers in C++],
|
||||
|
||||
/**
|
||||
** \file position.hh
|
||||
** Define the ]b4_percent_define_get([[namespace]])[::position class.
|
||||
** Define the ]b4_namespace_ref[::position class.
|
||||
*/
|
||||
|
||||
#ifndef BISON_POSITION_HH
|
||||
@@ -35,8 +35,7 @@ b4_copyright([Positions for Bison parsers in C++],
|
||||
# include <string>
|
||||
# include <algorithm>
|
||||
|
||||
namespace ]b4_percent_define_get([[namespace]])[
|
||||
{
|
||||
]b4_namespace_open[
|
||||
/// Abstract a position.
|
||||
class position
|
||||
{
|
||||
@@ -142,7 +141,7 @@ namespace ]b4_percent_define_get([[namespace]])[
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
|
||||
}
|
||||
]b4_namespace_close[
|
||||
#endif // not BISON_POSITION_HH]
|
||||
@output(b4_dir_prefix[]location.hh@)
|
||||
b4_copyright([Locations for Bison parsers in C++],
|
||||
@@ -150,7 +149,7 @@ b4_copyright([Locations for Bison parsers in C++],
|
||||
|
||||
/**
|
||||
** \file location.hh
|
||||
** Define the ]b4_percent_define_get([[namespace]])[::location class.
|
||||
** Define the ]b4_namespace_ref[::location class.
|
||||
*/
|
||||
|
||||
#ifndef BISON_LOCATION_HH
|
||||
@@ -160,8 +159,7 @@ b4_copyright([Locations for Bison parsers in C++],
|
||||
# include <string>
|
||||
# include "position.hh"
|
||||
|
||||
namespace ]b4_percent_define_get([[namespace]])[
|
||||
{
|
||||
]b4_namespace_open[
|
||||
|
||||
/// Abstract a location.
|
||||
class location
|
||||
@@ -270,7 +268,7 @@ namespace ]b4_percent_define_get([[namespace]])[
|
||||
return ostr;
|
||||
}
|
||||
|
||||
}
|
||||
]b4_namespace_close[
|
||||
|
||||
#endif // not BISON_LOCATION_HH]
|
||||
m4_divert_pop(0)
|
||||
|
||||
Reference in New Issue
Block a user