|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57398 - in branches/release: . boost boost/algorithm/string boost/archive boost/config boost/filesystem boost/fusion boost/graph boost/interprocess boost/intrusive boost/iostreams boost/math boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/qi/nonterminal boost/spirit/home/qi/numeric/detail boost/spirit/home/support boost/spirit/repository/home/qi/nonterminal boost/system boost/thread boost/tr1 boost/type_traits boost/utility boost/wave boost/xpressive libs libs/config libs/filesystem libs/fusion libs/graph_parallel libs/interprocess libs/intrusive libs/iostreams libs/math libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/python libs/regex libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/doc/html/spirit/abstracts/customize libs/spirit/doc/html/spirit/abstracts/indepth libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/system libs/thread libs/thread/doc libs/timer libs/tr1 libs/type_traits libs/utility libs/wave libs/xpressive/doc status tools/boostbook tools/build/v2 tools/quickbook tools/regression tools/release tools/wave
From: eric_at_[hidden]
Date: 2009-11-04 20:48:24
Author: eric_niebler
Date: 2009-11-04 20:48:23 EST (Wed, 04 Nov 2009)
New Revision: 57398
URL: http://svn.boost.org/trac/boost/changeset/57398
Log:
xpressive documentation tweaks
Added:
branches/release/libs/xpressive/doc/named_captures.qbk
- copied unchanged from r57395, /trunk/libs/xpressive/doc/named_captures.qbk
Properties modified:
branches/release/ (props changed)
branches/release/boost/algorithm/string/ (props changed)
branches/release/boost/archive/ (props changed)
branches/release/boost/config/ (props changed)
branches/release/boost/filesystem/ (props changed)
branches/release/boost/fusion/ (props changed)
branches/release/boost/graph/ (props changed)
branches/release/boost/interprocess/ (props changed)
branches/release/boost/intrusive/ (props changed)
branches/release/boost/iostreams/ (props changed)
branches/release/boost/math/ (props changed)
branches/release/boost/numeric/ublas/ (props changed)
branches/release/boost/program_options/ (props changed)
branches/release/boost/property_tree/ (props changed)
branches/release/boost/python/ (props changed)
branches/release/boost/regex/ (props changed)
branches/release/boost/serialization/ (props changed)
branches/release/boost/signals/ (props changed)
branches/release/boost/signals2/ (props changed)
branches/release/boost/spirit/ (props changed)
branches/release/boost/spirit/home/ (props changed)
branches/release/boost/spirit/home/karma/ (props changed)
branches/release/boost/spirit/home/qi/nonterminal/rule.hpp (props changed)
branches/release/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp (props changed)
branches/release/boost/spirit/home/support/attributes.hpp (props changed)
branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp (props changed)
branches/release/boost/system/ (props changed)
branches/release/boost/thread/ (props changed)
branches/release/boost/thread.hpp (props changed)
branches/release/boost/tr1/ (props changed)
branches/release/boost/type_traits/ (props changed)
branches/release/boost/utility/value_init.hpp (props changed)
branches/release/boost/wave/ (props changed)
branches/release/index.html (props changed)
branches/release/libs/config/ (props changed)
branches/release/libs/filesystem/ (props changed)
branches/release/libs/fusion/ (props changed)
branches/release/libs/graph_parallel/ (props changed)
branches/release/libs/interprocess/ (props changed)
branches/release/libs/intrusive/ (props changed)
branches/release/libs/iostreams/ (props changed)
branches/release/libs/libraries.htm (props changed)
branches/release/libs/maintainers.txt (props changed)
branches/release/libs/math/ (props changed)
branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
branches/release/libs/numeric/ublas/ (props changed)
branches/release/libs/numeric/ublas/doc/ (props changed)
branches/release/libs/program_options/ (props changed)
branches/release/libs/property_tree/ (props changed)
branches/release/libs/python/ (props changed)
branches/release/libs/regex/ (props changed)
branches/release/libs/serialization/ (props changed)
branches/release/libs/signals/ (props changed)
branches/release/libs/signals2/ (props changed)
branches/release/libs/spirit/ (props changed)
branches/release/libs/spirit/classic/example/ (props changed)
branches/release/libs/spirit/doc/ (props changed)
branches/release/libs/spirit/doc/html/spirit/abstracts/customize/ (props changed)
branches/release/libs/spirit/doc/html/spirit/abstracts/indepth/ (props changed)
branches/release/libs/spirit/example/ (props changed)
branches/release/libs/spirit/phoenix/ (props changed)
branches/release/libs/spirit/test/ (props changed)
branches/release/libs/spirit/test/qi/optional.cpp (props changed)
branches/release/libs/system/ (props changed)
branches/release/libs/thread/ (props changed)
branches/release/libs/thread/doc/ (props changed)
branches/release/libs/timer/ (props changed)
branches/release/libs/tr1/ (props changed)
branches/release/libs/type_traits/ (props changed)
branches/release/libs/utility/swap.html (props changed)
branches/release/libs/utility/value_init.htm (props changed)
branches/release/libs/utility/value_init_test.cpp (props changed)
branches/release/libs/wave/ (props changed)
branches/release/status/ (props changed)
branches/release/tools/boostbook/ (props changed)
branches/release/tools/build/v2/ (props changed)
branches/release/tools/quickbook/ (props changed)
branches/release/tools/regression/ (props changed)
branches/release/tools/release/ (props changed)
branches/release/tools/wave/ (props changed)
Text files modified:
branches/release/boost/xpressive/regex_algorithms.hpp | 6 +-
branches/release/boost/xpressive/regex_primitives.hpp | 97 ++++++++++++++++++++++++++++-----------
branches/release/boost/xpressive/xpressive_fwd.hpp | 3
branches/release/libs/xpressive/doc/Jamfile.v2 | 1
branches/release/libs/xpressive/doc/static_regexes.qbk | 2
branches/release/libs/xpressive/doc/xpressive.qbk | 3 +
6 files changed, 78 insertions(+), 34 deletions(-)
Modified: branches/release/boost/xpressive/regex_algorithms.hpp
==============================================================================
--- branches/release/boost/xpressive/regex_algorithms.hpp (original)
+++ branches/release/boost/xpressive/regex_algorithms.hpp 2009-11-04 20:48:23 EST (Wed, 04 Nov 2009)
@@ -95,7 +95,7 @@
/// \param flags Optional match flags, used to control how the expression is matched
/// against the sequence. (See \c match_flag_type.)
/// \return \c true if a match is found, \c false otherwise
-/// \throw \c regex_error on stack exhaustion
+/// \throw regex_error on stack exhaustion
template<typename BidiIter>
inline bool regex_match
(
@@ -417,7 +417,7 @@
/// \param flags Optional match flags, used to control how the expression is matched against
/// the sequence. (See \c match_flag_type.)
/// \return \c true if a match is found, \c false otherwise
-/// \throw \c regex_error on stack exhaustion
+/// \throw regex_error on stack exhaustion
template<typename BidiIter>
inline bool regex_search
(
@@ -746,7 +746,7 @@
/// \param flags Optional match flags, used to control how the expression is matched against
/// the sequence. (See \c match_flag_type.)
/// \return The value of the output iterator after the output sequence has been written to it.
-/// \throw \c regex_error on stack exhaustion or invalid format string.
+/// \throw regex_error on stack exhaustion or invalid format string.
template<typename OutIter, typename BidiIter, typename Formatter>
inline OutIter regex_replace
(
Modified: branches/release/boost/xpressive/regex_primitives.hpp
==============================================================================
--- branches/release/boost/xpressive/regex_primitives.hpp (original)
+++ branches/release/boost/xpressive/regex_primitives.hpp 2009-11-04 20:48:23 EST (Wed, 04 Nov 2009)
@@ -39,25 +39,6 @@
typedef assert_word_placeholder<word_begin> assert_word_begin;
typedef assert_word_placeholder<word_end> assert_word_end;
- struct mark_tag
- : proto::extends<basic_mark_tag, mark_tag>
- {
- mark_tag(int mark_nbr)
- {
- // Marks numbers must be integers greater than 0.
- BOOST_ASSERT(mark_nbr > 0);
- mark_placeholder mark = {mark_nbr};
- proto::value(*this) = mark;
- }
-
- operator basic_mark_tag const &() const
- {
- return this->proto_base();
- }
-
- using proto::extends<basic_mark_tag, mark_tag>::operator =;
- };
-
// workaround msvc-7.1 bug with function pointer types
// within function types:
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
@@ -531,8 +512,66 @@
detail::set_initializer_type const set = {{}};
///////////////////////////////////////////////////////////////////////////////
+/// \brief Sub-match placeholder type, used to create named captures in
+/// static regexes.
+///
+/// \c mark_tag is the type of the global sub-match placeholders \c s0, \c s1, etc.. You
+/// can use the \c mark_tag type to create your own sub-match placeholders with
+/// more meaningful names. This is roughly equivalent to the "named capture"
+/// feature of dynamic regular expressions.
+///
+/// To create a named sub-match placeholder, initialize it with a unique integer.
+/// The integer must only be unique within the regex in which the placeholder
+/// is used. Then you can use it within static regexes to created sub-matches
+/// by assigning a sub-expression to it, or to refer back to already created
+/// sub-matches.
+///
+/// \code
+/// mark_tag number(1); // "number" is now equivalent to "s1"
+/// // Match a number, followed by a space and the same number again
+/// sregex rx = (number = +_d) >> ' ' >> number;
+/// \endcode
+///
+/// After a successful \c regex_match() or \c regex_search(), the sub-match placeholder
+/// can be used to index into the <tt>match_results\<\></tt> object to retrieve the
+/// corresponding sub-match.
+struct mark_tag
+ : proto::extends<detail::basic_mark_tag, mark_tag>
+{
+ /// \brief Initialize a mark_tag placeholder
+ /// \param mark_nbr An integer that uniquely identifies this \c mark_tag
+ /// within the static regexes in which this \c mark_tag will be used.
+ /// \pre <tt>mark_nbr \> 0</tt>
+ mark_tag(int mark_nbr)
+ : proto::extends<detail::basic_mark_tag, mark_tag>(
+ detail::basic_mark_tag::make(mark_nbr)
+ )
+ {
+ // Marks numbers must be integers greater than 0.
+ BOOST_ASSERT(mark_nbr > 0);
+ }
+
+ /// INTERNAL ONLY
+ operator detail::basic_mark_tag const &() const
+ {
+ return this->proto_base();
+ }
+
+ using proto::extends<detail::basic_mark_tag, mark_tag>::operator =;
+};
+
+// This macro is used when declaring mark_tags that are global because
+// it guarantees that they are statically initialized. That avoids
+// order-of-initialization bugs. In user code, the simpler: mark_tag s0(0);
+// would be preferable.
+/// INTERNAL ONLY
+#define BOOST_XPRESSIVE_GLOBAL_MARK_TAG(NAME, VALUE) \
+ boost::xpressive::mark_tag::proto_base_expr const NAME = {{VALUE}} \
+ /**/
+
+///////////////////////////////////////////////////////////////////////////////
/// \brief Sub-match placeholder, like $& in Perl
-mark_tag::proto_base_expr const s0 = {{0}};
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s0, 0);
///////////////////////////////////////////////////////////////////////////////
/// \brief Sub-match placeholder, like $1 in perl.
@@ -546,15 +585,15 @@
/// After a successful regex_match() or regex_search(), the sub-match placeholders
/// can be used to index into the match_results\<\> object to retrieve the Nth
/// sub-match.
-mark_tag::proto_base_expr const s1 = {{1}};
-mark_tag::proto_base_expr const s2 = {{2}};
-mark_tag::proto_base_expr const s3 = {{3}};
-mark_tag::proto_base_expr const s4 = {{4}};
-mark_tag::proto_base_expr const s5 = {{5}};
-mark_tag::proto_base_expr const s6 = {{6}};
-mark_tag::proto_base_expr const s7 = {{7}};
-mark_tag::proto_base_expr const s8 = {{8}};
-mark_tag::proto_base_expr const s9 = {{9}};
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s1, 1);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s2, 2);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s3, 3);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s4, 4);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s5, 5);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s6, 6);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s7, 7);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s8, 8);
+BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s9, 9);
// NOTE: For the purpose of xpressive's documentation, make icase() look like an
// ordinary function. In reality, it is a function object defined in detail/icase.hpp
Modified: branches/release/boost/xpressive/xpressive_fwd.hpp
==============================================================================
--- branches/release/boost/xpressive/xpressive_fwd.hpp (original)
+++ branches/release/boost/xpressive/xpressive_fwd.hpp 2009-11-04 20:48:23 EST (Wed, 04 Nov 2009)
@@ -79,11 +79,10 @@
struct mark_placeholder;
typedef proto::terminal<mark_placeholder>::type basic_mark_tag;
- struct mark_tag;
} // namespace detail
- using detail::mark_tag;
+ struct mark_tag;
typedef void const *regex_id_type;
Modified: branches/release/libs/xpressive/doc/Jamfile.v2
==============================================================================
--- branches/release/libs/xpressive/doc/Jamfile.v2 (original)
+++ branches/release/libs/xpressive/doc/Jamfile.v2 2009-11-04 20:48:23 EST (Wed, 04 Nov 2009)
@@ -13,6 +13,7 @@
<doxygen:param>EXTRACT_ALL=YES
<doxygen:param>"PREDEFINED=\"BOOST_XPRESSIVE_DOXYGEN_INVOKED\" \\
\"BOOST_DEDUCED_TYPENAME=typename\" \\
+ \"BOOST_XPRESSIVE_GLOBAL_MARK_TAG(x,y)=mark_tag const x(y)\" \\
\"BOOST_XPR_NONDEDUCED_TYPE_(X)=X\""
<doxygen:param>HIDE_UNDOC_MEMBERS=NO
<doxygen:param>EXTRACT_PRIVATE=NO
Modified: branches/release/libs/xpressive/doc/static_regexes.qbk
==============================================================================
--- branches/release/libs/xpressive/doc/static_regexes.qbk (original)
+++ branches/release/libs/xpressive/doc/static_regexes.qbk 2009-11-04 20:48:23 EST (Wed, 04 Nov 2009)
@@ -224,6 +224,8 @@
[[[^(?!['stuff])]] [`~_before_(`[^['stuff]]`)`] [negative look-ahead assertion, match if not before ['stuff].]]
[[[^(?<=['stuff])]] [`_after_(`[^['stuff]]`)`] [positive look-behind assertion, match if after ['stuff] but don't include ['stuff] in the match. (['stuff] must be constant-width.)]]
[[[^(?<!['stuff])]] [`~_after_(`[^['stuff]]`)`] [negative look-behind assertion, match if not after ['stuff]. (['stuff] must be constant-width.)]]
+ [[[^(?P<['name]>['stuff])]] [`_mark_tag_ `[^['name]]`(`['n]`);`\n ...\n `(`[^['name]]`= `[^['stuff]]`)`] [Create a named capture.]]
+ [[[^(?P=['name])]] [`_mark_tag_ `[^['name]]`(`['n]`);`\n ...\n [^['name]]] [Refer back to a previously created named capture.]]
]
\n
Modified: branches/release/libs/xpressive/doc/xpressive.qbk
==============================================================================
--- branches/release/libs/xpressive/doc/xpressive.qbk (original)
+++ branches/release/libs/xpressive/doc/xpressive.qbk 2009-11-04 20:48:23 EST (Wed, 04 Nov 2009)
@@ -49,6 +49,7 @@
[def _regex_compiler_ [^[classref boost::xpressive::regex_compiler regex_compiler<>]]]
[def _regex_iterator_ [^[classref boost::xpressive::regex_iterator regex_iterator<>]]]
[def _regex_token_iterator_ [^[classref boost::xpressive::regex_token_iterator regex_token_iterator<>]]]
+[def _mark_tag_ [^[classref boost::xpressive::mark_tag mark_tag]]]
[def _regex_match_ [^[funcref boost::xpressive::regex_match regex_match()]]]
[def _regex_search_ [^[funcref boost::xpressive::regex_search regex_search()]]]
[def _regex_replace_ [^[funcref boost::xpressive::regex_replace regex_replace()]]]
@@ -92,6 +93,8 @@
[include tokenization.qbk]
+[include named_captures.qbk]
+
[include grammars.qbk]
[include actions.qbk]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk