Commit e07b233d by Benjamin Kosnik Committed by Benjamin Kosnik

c++config: Remove __regex nested namespace.

2012-06-27  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/c++config: Remove __regex nested namespace.
	* include/bits/regex_compiler.h: Change __regex to
	__detail. Adjust doxygen markup, add regex-details group.
	* include/bits/regex_constants.h: Same.
	* include/bits/regex_cursor.h: Same.
	* include/bits/regex_error.h: Same.
	* include/bits/regex_grep_matcher.h: Same.
	* include/bits/regex_grep_matcher.tcc: Same.
	* include/bits/regex_nfa.h: Same.
	* include/bits/regex_nfa.tcc: Same.
	* include/bits/regex.h: Same. Remove static from global constants.

	* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust line numbers.

	* include/bits/locale_classes.tcc: Add use_facet, has_facet to
	locales group.

From-SVN: r189039
parent 7fefe030
2012-06-27 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/c++config: Remove __regex nested namespace.
* include/bits/regex_compiler.h: Change __regex to
__detail. Adjust doxygen markup, add regex-details group.
* include/bits/regex_constants.h: Same.
* include/bits/regex_cursor.h: Same.
* include/bits/regex_error.h: Same.
* include/bits/regex_grep_matcher.h: Same.
* include/bits/regex_grep_matcher.tcc: Same.
* include/bits/regex_nfa.h: Same.
* include/bits/regex_nfa.tcc: Same.
* include/bits/regex.h: Same. Remove static from global constants.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust line numbers.
* include/bits/locale_classes.tcc: Add use_facet, has_facet to
locales group.
2012-06-25 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/tr2/bool_set (count, size, num_blocks, empty, max_size):
......
// Predefined symbols and macros -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -210,7 +210,6 @@ namespace std
namespace this_thread { inline namespace __7 { } }
namespace __detail { inline namespace __7 { } }
namespace __regex { inline namespace __7 { } }
}
namespace __gnu_cxx
......
// Locale support -*- C++ -*-
// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -89,6 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Test for the presence of a facet.
* @ingroup locales
*
* has_facet tests the locale argument for the presence of the facet type
* provided as the template parameter. Facets derived from the facet
......@@ -114,6 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Return a facet.
* @ingroup locales
*
* use_facet looks for and returns a reference to a facet of type Facet
* where Facet is the template parameter. If has_facet(locale) is true,
......
// class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -30,10 +30,16 @@
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __regex
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup regex-detail
* @{
*/
/// Base class for scanner.
struct _Scanner_base
{
typedef unsigned int _StateT;
......@@ -45,16 +51,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
virtual ~_Scanner_base() { };
};
//
// @brief Scans an input range for regex tokens.
//
// The %_Scanner class interprets the regular expression pattern in the input
// range passed to its constructor as a sequence of parse tokens passed to
// the regular expression compiler. The sequence of tokens provided depends
// on the flag settings passed to the constructor: different regular
// expression grammars will interpret the same input pattern in
// syntactically different ways.
//
/**
* @brief struct _Scanner. Scans an input range for regex tokens.
*
* The %_Scanner class interprets the regular expression pattern in
* the input range passed to its constructor as a sequence of parse
* tokens passed to the regular expression compiler. The sequence
* of tokens provided depends on the flag settings passed to the
* constructor: different regular expression grammars will interpret
* the same input pattern in syntactically different ways.
*/
template<typename _InputIterator>
class _Scanner: public _Scanner_base
{
......@@ -65,7 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef regex_constants::syntax_option_type _FlagT;
typedef const std::ctype<_CharT> _CtypeT;
// Token types returned from the scanner.
/// Token types returned from the scanner.
enum _TokenT
{
_S_token_anychar,
......@@ -99,7 +105,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_S_token_unknown
};
public:
_Scanner(_IteratorT __begin, _IteratorT __end, _FlagT __flags,
std::locale __loc)
: _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
......@@ -141,7 +146,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_M_eat_collsymbol();
private:
_IteratorT _M_current;
_IteratorT _M_end;
_FlagT _M_flags;
......@@ -625,7 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#endif
// Builds an NFA from an input iterator interval.
/// Builds an NFA from an input iterator interval.
template<typename _InIter, typename _TraitsT>
class _Compiler
{
......@@ -635,7 +639,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef std::basic_string<_CharT> _StringT;
typedef regex_constants::syntax_option_type _FlagT;
public:
_Compiler(const _InIter& __b, const _InIter& __e,
_TraitsT& __traits, _FlagT __flags);
......@@ -704,7 +707,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int
_M_cur_int_value(int __radix);
private:
_TraitsT& _M_traits;
_ScannerT _M_scanner;
_StringT _M_cur_value;
......@@ -1102,8 +1104,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _AutomatonPtr(new _Nfa(_Compiler<_InIter, _TraitsT>(__b, __e, __t,
__f)._M_nfa())); }
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex
} // namespace __detail
} // namespace std
/* vim: set ts=8 sw=2 sts=2: */
// class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -33,6 +33,13 @@
namespace std _GLIBCXX_VISIBILITY(default)
{
/**
* @defgroup regex Regular Expressions
*
* A facility for performing regular expression pattern matching.
* @{
*/
/**
* @namespace std::regex_constants
* @brief ISO C++-0x entities sub namespace for regex.
*/
......@@ -76,14 +83,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Specifies that the matching of regular expressions against a character
* sequence shall be performed without regard to case.
*/
static constexpr syntax_option_type icase = 1 << _S_icase;
constexpr syntax_option_type icase = 1 << _S_icase;
/**
* Specifies that when a regular expression is matched against a character
* container sequence, no sub-expression matches are to be stored in the
* supplied match_results structure.
*/
static constexpr syntax_option_type nosubs = 1 << _S_nosubs;
constexpr syntax_option_type nosubs = 1 << _S_nosubs;
/**
* Specifies that the regular expression engine should pay more attention to
......@@ -91,13 +98,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* speed with which regular expression objects are constructed. Otherwise
* it has no detectable effect on the program output.
*/
static constexpr syntax_option_type optimize = 1 << _S_optimize;
constexpr syntax_option_type optimize = 1 << _S_optimize;
/**
* Specifies that character ranges of the form [a-b] should be locale
* sensitive.
*/
static constexpr syntax_option_type collate = 1 << _S_collate;
constexpr syntax_option_type collate = 1 << _S_collate;
/**
* Specifies that the grammar recognized by the regular expression engine is
......@@ -107,7 +114,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* in the PERL scripting language but extended with elements found in the
* POSIX regular expression grammar.
*/
static constexpr syntax_option_type ECMAScript = 1 << _S_ECMAScript;
constexpr syntax_option_type ECMAScript = 1 << _S_ECMAScript;
/**
* Specifies that the grammar recognized by the regular expression engine is
......@@ -116,7 +123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Headers, Section 9, Regular Expressions [IEEE, Information Technology --
* Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
*/
static constexpr syntax_option_type basic = 1 << _S_basic;
constexpr syntax_option_type basic = 1 << _S_basic;
/**
* Specifies that the grammar recognized by the regular expression engine is
......@@ -124,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Portable Operating System Interface (POSIX), Base Definitions and Headers,
* Section 9, Regular Expressions.
*/
static constexpr syntax_option_type extended = 1 << _S_extended;
constexpr syntax_option_type extended = 1 << _S_extended;
/**
* Specifies that the grammar recognized by the regular expression engine is
......@@ -134,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos;, &apos;,
* and \\ddd (where ddd is one, two, or three octal digits).
*/
static constexpr syntax_option_type awk = 1 << _S_awk;
constexpr syntax_option_type awk = 1 << _S_awk;
/**
* Specifies that the grammar recognized by the regular expression engine is
......@@ -142,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* identical to syntax_option_type basic, except that newlines are treated
* as whitespace.
*/
static constexpr syntax_option_type grep = 1 << _S_grep;
constexpr syntax_option_type grep = 1 << _S_grep;
/**
* Specifies that the grammar recognized by the regular expression engine is
......@@ -150,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* IEEE Std 1003.1-2001. This option is identical to syntax_option_type
* extended, except that newlines are treated as whitespace.
*/
static constexpr syntax_option_type egrep = 1 << _S_egrep;
constexpr syntax_option_type egrep = 1 << _S_egrep;
//@}
......@@ -193,56 +200,56 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* The default matching rules.
*/
static constexpr match_flag_type match_default = 0;
constexpr match_flag_type match_default = 0;
/**
* The first character in the sequence [first, last) is treated as though it
* is not at the beginning of a line, so the character (^) in the regular
* expression shall not match [first, first).
*/
static constexpr match_flag_type match_not_bol = 1 << _S_not_bol;
constexpr match_flag_type match_not_bol = 1 << _S_not_bol;
/**
* The last character in the sequence [first, last) is treated as though it
* is not at the end of a line, so the character ($) in the regular
* expression shall not match [last, last).
*/
static constexpr match_flag_type match_not_eol = 1 << _S_not_eol;
constexpr match_flag_type match_not_eol = 1 << _S_not_eol;
/**
* The expression \\b is not matched against the sub-sequence
* [first,first).
*/
static constexpr match_flag_type match_not_bow = 1 << _S_not_bow;
constexpr match_flag_type match_not_bow = 1 << _S_not_bow;
/**
* The expression \\b should not be matched against the sub-sequence
* [last,last).
*/
static constexpr match_flag_type match_not_eow = 1 << _S_not_eow;
constexpr match_flag_type match_not_eow = 1 << _S_not_eow;
/**
* If more than one match is possible then any match is an acceptable
* result.
*/
static constexpr match_flag_type match_any = 1 << _S_any;
constexpr match_flag_type match_any = 1 << _S_any;
/**
* The expression does not match an empty sequence.
*/
static constexpr match_flag_type match_not_null = 1 << _S_not_null;
constexpr match_flag_type match_not_null = 1 << _S_not_null;
/**
* The expression only matches a sub-sequence that begins at first .
*/
static constexpr match_flag_type match_continuous = 1 << _S_continuous;
constexpr match_flag_type match_continuous = 1 << _S_continuous;
/**
* --first is a valid iterator position. When this flag is set then the
* flags match_not_bol and match_not_bow are ignored by the regular
* expression algorithms 28.11 and iterators 28.12.
*/
static constexpr match_flag_type match_prev_avail = 1 << _S_prev_avail;
constexpr match_flag_type match_prev_avail = 1 << _S_prev_avail;
/**
* When a regular expression match is to be replaced by a new string, the
......@@ -270,7 +277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* undefined, use the empty string instead. If
* nn > match_results::size(), the result is implementation-defined.
*/
static constexpr match_flag_type format_default = 0;
constexpr match_flag_type format_default = 0;
/**
* When a regular expression match is to be replaced by a new string, the
......@@ -278,24 +285,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
* Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
*/
static constexpr match_flag_type format_sed = 1 << _S_sed;
constexpr match_flag_type format_sed = 1 << _S_sed;
/**
* During a search and replace operation, sections of the character
* container sequence being searched that do not match the regular
* expression shall not be copied to the output string.
*/
static constexpr match_flag_type format_no_copy = 1 << _S_no_copy;
constexpr match_flag_type format_no_copy = 1 << _S_no_copy;
/**
* When specified during a search and replace operation, only the first
* occurrence of the regular expression shall be replaced.
*/
static constexpr match_flag_type format_first_only = 1 << _S_first_only;
constexpr match_flag_type format_first_only = 1 << _S_first_only;
//@}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace regex_constants
} // namespace
/* @} */ // group regex
} // namespace std
// class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -30,11 +30,17 @@
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __regex
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// ABC for pattern matching
/**
* @defgroup regex-detail Base and Implementation Classes
* @ingroup regex
* @{
*/
/// ABC for pattern matching
struct _PatternCursor
{
virtual ~_PatternCursor() { };
......@@ -42,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
virtual bool _M_at_end() const = 0;
};
// Provides a cursor into the specific target string.
/// Provides a cursor into the specific target string.
template<typename _FwdIterT>
class _SpecializedCursor
: public _PatternCursor
......@@ -88,6 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__cursor(const _FwdIterT& __b, const _FwdIterT __e)
{ return _SpecializedCursor<_FwdIterT>(__b, __e); }
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex
} // namespace __detail
} // namespace
// class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -32,6 +32,11 @@
namespace std _GLIBCXX_VISIBILITY(default)
{
/**
* @addtogroup regex
* @{
*/
namespace regex_constants
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
......@@ -60,60 +65,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
/** The expression contained an invalid collating element name. */
static constexpr error_type error_collate(_S_error_collate);
constexpr error_type error_collate(_S_error_collate);
/** The expression contained an invalid character class name. */
static constexpr error_type error_ctype(_S_error_ctype);
constexpr error_type error_ctype(_S_error_ctype);
/**
* The expression contained an invalid escaped character, or a trailing
* escape.
*/
static constexpr error_type error_escape(_S_error_escape);
constexpr error_type error_escape(_S_error_escape);
/** The expression contained an invalid back reference. */
static constexpr error_type error_backref(_S_error_backref);
constexpr error_type error_backref(_S_error_backref);
/** The expression contained mismatched [ and ]. */
static constexpr error_type error_brack(_S_error_brack);
constexpr error_type error_brack(_S_error_brack);
/** The expression contained mismatched ( and ). */
static constexpr error_type error_paren(_S_error_paren);
constexpr error_type error_paren(_S_error_paren);
/** The expression contained mismatched { and } */
static constexpr error_type error_brace(_S_error_brace);
constexpr error_type error_brace(_S_error_brace);
/** The expression contained an invalid range in a {} expression. */
static constexpr error_type error_badbrace(_S_error_badbrace);
constexpr error_type error_badbrace(_S_error_badbrace);
/**
* The expression contained an invalid character range,
* such as [b-a] in most encodings.
*/
static constexpr error_type error_range(_S_error_range);
constexpr error_type error_range(_S_error_range);
/**
* There was insufficient memory to convert the expression into a
* finite state machine.
*/
static constexpr error_type error_space(_S_error_space);
constexpr error_type error_space(_S_error_space);
/**
* One of <em>*?+{</em> was not preceded by a valid regular expression.
*/
static constexpr error_type error_badrepeat(_S_error_badrepeat);
constexpr error_type error_badrepeat(_S_error_badrepeat);
/**
* The complexity of an attempted match against a regular expression
* exceeded a pre-set level.
*/
static constexpr error_type error_complexity(_S_error_complexity);
constexpr error_type error_complexity(_S_error_complexity);
/**
* There was insufficient memory to determine whether the
* regular expression could match the specified character sequence.
*/
static constexpr error_type error_stack(_S_error_stack);
constexpr error_type error_stack(_S_error_stack);
//@}
_GLIBCXX_END_NAMESPACE_VERSION
......@@ -153,6 +158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_code; }
};
//@} // group regex
void
__throw_regex_error(regex_constants::error_type __ecode);
......
// class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -40,11 +40,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
namespace __regex
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// A _Results facade specialized for wrapping a templated match_results.
/**
* @defgroup regex-detail Base and Implementation Classes
* @ingroup regex
* @{
*/
/// A _Results facade specialized for wrapping a templated match_results.
template<typename _FwdIterT, typename _Alloc>
class _SpecializedResults
: public _Results
......@@ -95,12 +101,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_results.at(__i).second = __c._M_pos()+1;
}
// A stack of states used in evaluating the NFA.
/// A stack of states used in evaluating the NFA.
typedef std::stack<_StateIdT, std::vector<_StateIdT> > _StateStack;
// Executes a regular expression NFA/DFA over a range using a variant of
// the parallel execution algorithm featured in the grep utility, modified
// to use Laurikari tags.
/// Executes a regular expression NFA/DFA over a range using a
/// variant of the parallel execution algorithm featured in the grep
/// utility, modified to use Laurikari tags.
class _Grep_matcher
{
public:
......@@ -119,14 +125,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StateSet
_M_e_closure(_StateStack& __stack, const _StateSet& __s);
private:
const std::shared_ptr<_Nfa> _M_nfa;
_PatternCursor& _M_pattern;
_Results& _M_results;
};
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex
} // namespace
} // namespace __detail
} // namespace std
#include <bits/regex_grep_matcher.tcc>
// class template regex -*- C++ -*-
// Copyright (C) 2010 Free Software Foundation, Inc.
// Copyright (C) 2010, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -35,26 +35,26 @@ namespace std _GLIBCXX_VISIBILITY(default)
namespace
{
// A stack of states used in evaluating the NFA.
typedef std::stack<std::__regex::_StateIdT,
std::vector<std::__regex::_StateIdT>
typedef std::stack<std::__detail::_StateIdT,
std::vector<std::__detail::_StateIdT>
> _StateStack;
// Obtains the next state set given the current state set __s and the current
// input character.
inline std::__regex::_StateSet
__move(const std::__regex::_PatternCursor& __p,
const std::__regex::_Nfa& __nfa,
const std::__regex::_StateSet& __s)
inline std::__detail::_StateSet
__move(const std::__detail::_PatternCursor& __p,
const std::__detail::_Nfa& __nfa,
const std::__detail::_StateSet& __s)
{
std::__regex::_StateSet __m;
for (std::__regex::_StateSet::const_iterator __i = __s.begin();
std::__detail::_StateSet __m;
for (std::__detail::_StateSet::const_iterator __i = __s.begin();
__i != __s.end(); ++__i)
{
if (*__i == std::__regex::_S_invalid_state_id)
if (*__i == std::__detail::_S_invalid_state_id)
continue;
const std::__regex::_State& __state = __nfa[*__i];
if (__state._M_opcode == std::__regex::_S_opcode_match
const std::__detail::_State& __state = __nfa[*__i];
if (__state._M_opcode == std::__detail::_S_opcode_match
&& __state._M_matches(__p))
__m.insert(__state._M_next);
}
......@@ -63,13 +63,13 @@ namespace
// returns true if (__s intersect __t) is not empty
inline bool
__includes_some(const std::__regex::_StateSet& __s,
const std::__regex::_StateSet& __t)
__includes_some(const std::__detail::_StateSet& __s,
const std::__detail::_StateSet& __t)
{
if (__s.size() > 0 && __t.size() > 0)
{
std::__regex::_StateSet::const_iterator __first = __s.begin();
std::__regex::_StateSet::const_iterator __second = __t.begin();
std::__detail::_StateSet::const_iterator __first = __s.begin();
std::__detail::_StateSet::const_iterator __second = __t.begin();
while (__first != __s.end() && __second != __t.end())
{
if (*__first < *__second)
......@@ -86,9 +86,9 @@ namespace
// If an identified state __u is not already in the current state set __e,
// insert it and push it on the current state stack __s.
inline void
__add_visited_state(const std::__regex::_StateIdT __u,
__add_visited_state(const std::__detail::_StateIdT __u,
_StateStack& __s,
std::__regex::_StateSet& __e)
std::__detail::_StateSet& __e)
{
if (__e.count(__u) == 0)
{
......@@ -99,7 +99,7 @@ namespace
} // anonymous namespace
namespace __regex
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
......@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_constants::match_flag_type __flags)
: _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
{
__regex::_StateSet __t = this->_M_e_closure(_M_nfa->_M_start());
__detail::_StateSet __t = this->_M_e_closure(_M_nfa->_M_start());
for (; !_M_pattern._M_at_end(); _M_pattern._M_next())
__t = this->_M_e_closure(__move(_M_pattern, *_M_nfa, __t));
......@@ -175,5 +175,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex
} // namespace __detail
} // namespace
// class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -30,11 +30,16 @@
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __regex
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Base class for, um, automata. Could be an NFA or a DFA. Your choice.
/**
* @addtogroup regex-detail
* @{
*/
/// Base class for, um, automata. Could be an NFA or a DFA. Your choice.
class _Automaton
{
public:
......@@ -53,11 +58,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
};
// Generic shared pointer to an automaton.
/// Generic shared pointer to an automaton.
typedef std::shared_ptr<_Automaton> _AutomatonPtr;
// Operation codes that define the type of transitions within the base NFA
// that represents the regular expression.
/// Operation codes that define the type of transitions within the base NFA
/// that represents the regular expression.
enum _Opcode
{
_S_opcode_unknown = 0,
......@@ -68,16 +73,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_S_opcode_accept = 255
};
// Provides a generic facade for a templated match_results.
/// Provides a generic facade for a templated match_results.
struct _Results
{
virtual void _M_set_pos(int __i, int __j, const _PatternCursor& __p) = 0;
virtual void _M_set_matched(int __i, bool __is_matched) = 0;
};
// Tags current state (for subexpr begin/end).
/// Tags current state (for subexpr begin/end).
typedef std::function<void (const _PatternCursor&, _Results&)> _Tagger;
/// Start state tag.
template<typename _FwdIterT, typename _TraitsT>
struct _StartTagger
{
......@@ -93,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int _M_index;
};
/// End state tag.
template<typename _FwdIterT, typename _TraitsT>
struct _EndTagger
{
......@@ -108,15 +115,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int _M_index;
_FwdIterT _M_pos;
};
// Indicates if current state matches cursor current.
/// Indicates if current state matches cursor current.
typedef std::function<bool (const _PatternCursor&)> _Matcher;
// Matches any character
/// Matches any character
inline bool
_AnyMatcher(const _PatternCursor&)
{ return true; }
// Matches a single character
/// Matches a single character
template<typename _InIterT, typename _TraitsT>
struct _CharMatcher
{
......@@ -139,7 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
char_type _M_c;
};
// Matches a character range (bracket expression)
/// Matches a character range (bracket expression)
template<typename _InIterT, typename _TraitsT>
struct _RangeMatcher
{
......@@ -183,20 +191,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool _M_is_non_matching;
};
// Identifies a state in the NFA.
/// Identifies a state in the NFA.
typedef int _StateIdT;
// The special case in which a state identifier is not an index.
/// The special case in which a state identifier is not an index.
static const _StateIdT _S_invalid_state_id = -1;
// An individual state in an NFA
//
// In this case a "state" is an entry in the NFA definition coupled with its
// outgoing transition(s). All states have a single outgoing transition,
// except for accepting states (which have no outgoing transitions) and alt
// states, which have two outgoing transitions.
//
/**
* @brief struct _State
*
* An individual state in an NFA
*
* In this case a "state" is an entry in the NFA definition coupled
* with its outgoing transition(s). All states have a single outgoing
* transition, except for accepting states (which have no outgoing
* transitions) and alt states, which have two outgoing transitions.
*/
struct _State
{
typedef int _OpcodeT;
......@@ -236,22 +247,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
// The Grep Matcher works on sets of states. Here are sets of states.
/// The Grep Matcher works on sets of states. Here are sets of states.
typedef std::set<_StateIdT> _StateSet;
// A collection of all states making up an NFA
//
// An NFA is a 4-tuple M = (K, S, s, F), where
// K is a finite set of states,
// S is the alphabet of the NFA,
// s is the initial state,
// F is a set of final (accepting) states.
//
// This NFA class is templated on S, a type that will hold values of the
// underlying alphabet (without regard to semantics of that alphabet). The
// other elements of the tuple are generated during construction of the NFA
// and are available through accessor member functions.
//
/**
* @brief struct _Nfa
*
* A collection of all states making up an NFA.
*
* An NFA is a 4-tuple M = (K, S, s, F), where
* K is a finite set of states,
* S is the alphabet of the NFA,
* s is the initial state,
* F is a set of final (accepting) states.
*
* This NFA class is templated on S, a type that will hold values of the
* underlying alphabet (without regard to semantics of that alphabet). The
* other elements of the tuple are generated during construction of the NFA
* and are available through accessor member functions.
*/
class _Nfa
: public _Automaton, public std::vector<_State>
{
......@@ -260,7 +274,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef unsigned int _SizeT;
typedef regex_constants::syntax_option_type _FlagT;
public:
_Nfa(_FlagT __f)
: _M_flags(__f), _M_start_state(0), _M_subexpr_count(0)
{ }
......@@ -309,7 +322,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StateIdT
_M_insert_subexpr_begin(const _Tagger& __t)
{
this->push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++, __t));
this->push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++,
__t));
return this->size()-1;
}
......@@ -332,9 +346,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_SizeT _M_subexpr_count;
};
// Describes a sequence of one or more %_State, its current start and end(s).
//
// This structure contains fragments of an NFA during construction.
/// Describes a sequence of one or more %_State, its current start
/// and end(s). This structure contains fragments of an NFA during
/// construction.
class _StateSeq
{
public:
......@@ -392,8 +406,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex
} // namespace __detail
} // namespace std
#include <bits/regex_nfa.tcc>
......
// class template regex -*- C++ -*-
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -31,7 +31,7 @@
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __regex
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
......@@ -170,5 +170,5 @@ _M_clone()
{ return 0; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __regex
} // namespace __detail
} // namespace
......@@ -25,4 +25,4 @@
#include <vector>
// { dg-error "multiple inlined namespaces" "" { target *-*-* } 263 }
// { dg-error "multiple inlined namespaces" "" { target *-*-* } 262 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment