Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-10-24 11:04:41


Author: eric_niebler
Date: 2007-10-24 11:04:41 EDT (Wed, 24 Oct 2007)
New Revision: 40420
URL: http://svn.boost.org/trac/boost/changeset/40420

Log:
more typeof registrations from Dave Jankins
Added:
   trunk/libs/xpressive/test/test_typeof2.cpp (contents, props changed)
Text files modified:
   trunk/boost/xpressive/xpressive_typeof.hpp | 7 +
   trunk/libs/xpressive/test/Jamfile.v2 | 1
   trunk/libs/xpressive/test/test_typeof.cpp | 277 ++++++++++++++++++++++++++++++---------
   3 files changed, 220 insertions(+), 65 deletions(-)

Modified: trunk/boost/xpressive/xpressive_typeof.hpp
==============================================================================
--- trunk/boost/xpressive/xpressive_typeof.hpp (original)
+++ trunk/boost/xpressive/xpressive_typeof.hpp 2007-10-24 11:04:41 EDT (Wed, 24 Oct 2007)
@@ -32,6 +32,10 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::modifier_tag)
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::lookahead_tag)
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::lookbehind_tag)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::check_tag)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::mark_tag)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::word_begin)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::word_end)
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::generic_quant_tag, (unsigned int)(unsigned int))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::basic_regex, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::word_boundary, (bool))
@@ -43,6 +47,9 @@
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::regex_impl, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::let_, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::action_arg, (typename)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::named_mark, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::sub_match, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::nested_results, (typename))
 
 ///////////////////////////////////////////////////////////////////////////////
 // Placeholders

Modified: trunk/libs/xpressive/test/Jamfile.v2
==============================================================================
--- trunk/libs/xpressive/test/Jamfile.v2 (original)
+++ trunk/libs/xpressive/test/Jamfile.v2 2007-10-24 11:04:41 EDT (Wed, 24 Oct 2007)
@@ -68,5 +68,6 @@
          [ compile test_regex_traits.cpp ]
          [ compile test_sub_match.cpp ]
 # [ compile test_typeof.cpp : <define>BOOST_TYPEOF_EMULATION=1 <define>BOOST_TYPEOF_LIMIT_SIZE=200 ]
+# [ compile test_typeof2.cpp : <define>BOOST_TYPEOF_EMULATION=1 <define>BOOST_TYPEOF_LIMIT_SIZE=200 ]
     ;
 

Modified: trunk/libs/xpressive/test/test_typeof.cpp
==============================================================================
--- trunk/libs/xpressive/test/test_typeof.cpp (original)
+++ trunk/libs/xpressive/test/test_typeof.cpp 2007-10-24 11:04:41 EDT (Wed, 24 Oct 2007)
@@ -5,84 +5,231 @@
 // Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
+#define BOOST_TYPEOF_LIMIT_SIZE 200
+#define BOOST_TYPEOF_COMPILANT
+
 #include <string>
-#include <map>
 #include <boost/version.hpp>
 #include <boost/xpressive/xpressive_static.hpp>
-#include <boost/xpressive/regex_actions.hpp>
 #include <boost/xpressive/xpressive_typeof.hpp>
-#include <boost/typeof/std/stack.hpp>
-#include <boost/typeof/std/list.hpp>
-#include <boost/typeof/std/map.hpp>
+#include <boost/test/unit_test.hpp>
 
-// DJ: I couldn't find these registrations anywhere else, so I put them here
+// I couldn't find these registrations anywhere else, so I put them here
 // They are necessary for this program to compile
 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::mpl::int_, (int))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::reference_wrapper, (typename))
 
+// Here's the test for typeof registration, to be used on static regular expressions
+#define TYPEOF_TEST(Expr) { BOOST_PROTO_AUTO(Dummy, Expr); }
+
 namespace xp = boost::xpressive;
 
-int main()
+///////////////////////////////////////////////////////////////////////////////
+// test_misc1
+// miscelaneous regular expressions
+static void test_misc1()
+{
+ using namespace boost::xpressive;
+
+ TYPEOF_TEST(epsilon);
+ TYPEOF_TEST(nil);
+ TYPEOF_TEST(alnum);
+ TYPEOF_TEST(bos);
+ TYPEOF_TEST(eos);
+ TYPEOF_TEST(bol);
+ TYPEOF_TEST(eol);
+ TYPEOF_TEST(bow);
+ TYPEOF_TEST(eow);
+ TYPEOF_TEST(_b);
+ TYPEOF_TEST(_w);
+ TYPEOF_TEST(_d);
+ TYPEOF_TEST(_s);
+ TYPEOF_TEST(_n);
+ TYPEOF_TEST(_ln);
+ TYPEOF_TEST(_);
+ TYPEOF_TEST(self);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// test_misc2
+// miscelaneous regular expressions
+static void test_misc2()
+{
+ using namespace boost::xpressive;
+
+ TYPEOF_TEST(+set[_d | '-' | 'g']);
+ TYPEOF_TEST(+set['g' | as_xpr('-') | _d]);
+ TYPEOF_TEST(icase(+range('a','g')));
+ TYPEOF_TEST(+range('-','/'));
+ TYPEOF_TEST(+range('+','-'));
+ TYPEOF_TEST(+range('b','b'));
+ TYPEOF_TEST(icase((s1= "foo") >> *_ >> '\15'));
+ TYPEOF_TEST(repeat<2>(repeat<3>(_d) >> '-') >> repeat<4>(_d));
+ TYPEOF_TEST('f' >> +as_xpr('o'));
+ TYPEOF_TEST(icase(+(s1= "foo") >> "foobar"));
+ cregex parens = '(' >> *( keep( +~(set='(',')') ) | by_ref(parens) ) >> ')';
+ TYPEOF_TEST(_b >> "sublist" >> parens);
+ TYPEOF_TEST(bos >> "baz" | "bar");
+ TYPEOF_TEST(icase(*_ >> "foo"));
+ TYPEOF_TEST(icase(*_ >> "boo" | "bar"));
+ TYPEOF_TEST(icase("bar"));
+
+ TYPEOF_TEST(('f' >> repeat<1,repeat_max>('o')));
+ TYPEOF_TEST("This " >> (s1= "(has)") >> ' ' >> (s2= "parens"));
+ TYPEOF_TEST(as_xpr("This (has parens"));
+ TYPEOF_TEST(+_d);
+ TYPEOF_TEST(+~_d);
+ TYPEOF_TEST(+set[_d]);
+ TYPEOF_TEST(+set[~_d]);
+ TYPEOF_TEST(+~set[~_d]);
+ TYPEOF_TEST(+~set[_d]);
+ TYPEOF_TEST(+set[~_w | ~_d]);
+ TYPEOF_TEST(+~set[_w | _d]);
+ TYPEOF_TEST((s1= '(' >> (s2= nil) | '[' >> (s3= nil)) >> -*_ >> (s4= ')') >> s2 | ']' >> s3);
+ TYPEOF_TEST(after("foo") >> "bar");
+ TYPEOF_TEST(after(s1= 'f' >> _ >> 'o') >> "bar");
+ TYPEOF_TEST(icase(after(s1= "fo") >> 'o'));
+ TYPEOF_TEST(icase(~after(s1= "fo") >> 'o'));
+ TYPEOF_TEST(+alpha);
+ TYPEOF_TEST(+set[alpha | digit]);
+ TYPEOF_TEST(after(s1= nil) >> 'a');
+ TYPEOF_TEST(after(s1= "abc" >> repeat<3>(_d)) >> "foo");
+ TYPEOF_TEST(~before(bol) >> 'x');
+ TYPEOF_TEST(~before(bos) >> 'x');
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// test_misc3
+// miscelaneous regular expressions
+
+static void test_misc3()
+{
+ using namespace boost::xpressive;
+
+ TYPEOF_TEST(as_xpr("foo"));
+ TYPEOF_TEST('b' >> *_ >> "ar");
+ TYPEOF_TEST('b' >> *_ >> 'r');
+ TYPEOF_TEST('b' >> +_ >> "ar");
+ TYPEOF_TEST('b' >> +_ >> 'r');
+ TYPEOF_TEST('b' >> +_ >> "oo");
+ TYPEOF_TEST(bos >> "foo");
+ TYPEOF_TEST(bos >> 'b' >> *_ >> "ar");
+ TYPEOF_TEST('b' >> +_ >> "ar" >> eos);
+ TYPEOF_TEST('b' >> +_ >> 'o' >> eos);
+ TYPEOF_TEST(bos >> (s1= !(set='-','+') >> +range('0','9')
+ >> !(s2= '.' >> *range('0','9')))
+ >> (s3= (set='C','F')) >> eos);
+ TYPEOF_TEST( !(s1= as_xpr('+')|'-') >> (s2= +range('0','9') >> !as_xpr('.') >> *range('0','9') |
+ '.' >> +range('0','9')) >> !(s3= (set='e','E') >> !(s4= as_xpr('+')|'-') >> +range('0','9')));
+ TYPEOF_TEST('f' | icase('g'));
+ TYPEOF_TEST(icase(+lower));
+ TYPEOF_TEST(icase(+as_xpr('\x61')));
+ TYPEOF_TEST(icase(+set['\x61']));
+ TYPEOF_TEST(icase(+as_xpr('\x0061')));
+ TYPEOF_TEST(icase(+set['\x0061']));
+ TYPEOF_TEST('a' >> +(s1= 'b' | (s2= *(s3= 'c'))) >> 'd');
+ TYPEOF_TEST('a' >> +(s1= 'b' | (s2= !(s3= 'c'))) >> 'd');
+ TYPEOF_TEST(*as_xpr('a') >> *as_xpr('a') >> *as_xpr('a') >> *as_xpr('a') >> *as_xpr('a') >> 'b');
+ TYPEOF_TEST(*set[range('a','z') | range('A','Z')]);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// test_misc4
+// miscelaneous regular expressions
+static void test_misc4()
+{
+ using namespace boost::xpressive;
+ TYPEOF_TEST('a' >> bos >> 'b');
+ TYPEOF_TEST(as_xpr("a^b"));
+ TYPEOF_TEST('a' >> ~set[' '] >> 'b');
+ TYPEOF_TEST('a' >> ~set['^'] >> 'b');
+ TYPEOF_TEST('a' >> ~set['^'] >> 'b');
+ TYPEOF_TEST('a' >> set['^'] >> 'b');
+ TYPEOF_TEST(icase("foo" >> before("bar")));
+ TYPEOF_TEST(icase("foo" >> ~before("bar")));
+ TYPEOF_TEST(icase("foo" >> ~before("bar")));
+ TYPEOF_TEST(icase(+(s1= keep(s2= "foo") >> "bar")));
+ TYPEOF_TEST(+(s1= "bar" | (s2= "foo")));
+ TYPEOF_TEST(+(s1= (s2= "bar") | "foo"));
+ TYPEOF_TEST(+(s1= "foo" | (s2= "bar")));
+ TYPEOF_TEST(+(s1= (s2= "foo") | "bar"));
+ TYPEOF_TEST((s1= icase("FOO")) >> (s2= -*_) >> s1);
+ TYPEOF_TEST((s1= icase("FOO")) >> (s2= -*_) >> icase(s1));
+ TYPEOF_TEST(+(s1= "foo" | icase(s1 >> 'O')));
+ TYPEOF_TEST((bos >> set[range('A','Z') | range('a','m')]));
+ TYPEOF_TEST(('f' >> repeat<2,5>('o')));
+ TYPEOF_TEST(('f' >> -repeat<2,5>('o')));
+ TYPEOF_TEST(('f' >> repeat<2,5>('o') >> 'o'));
+ TYPEOF_TEST(('f' >> -repeat<2,5>('o') >> 'o'));
+ TYPEOF_TEST(bos >> '{' >> *_ >> '}' >> eos);
+ TYPEOF_TEST(+(set='+','-'));
+ TYPEOF_TEST(+(set='-','+'));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// test_misc5
+// miscelaneous regular expressions
+static void test_misc5()
 {
     using namespace boost::xpressive;
- // regexes from test_actions.cpp
- std::string result;
- BOOST_PROTO_AUTO(dummy1, (+_w)[ xp::ref(result) += _ ] >> *(' ' >> (+_w)[ xp::ref(result) += ',' + _ ]));
- BOOST_PROTO_AUTO(dummy2, (+_w)[ xp::ref(result) += _ ] >> *(' ' >> (+_w)[ xp::ref(result) += ',' + _ ]) >> repeat<4>(_));
- std::list<int> result2;
- BOOST_PROTO_AUTO(dummy3, (+_d)[ xp::ref(result2)->*push_back( as<int>(_) ) ]
- >> *(' ' >> (+_d)[ xp::ref(result2)->*push_back( as<int>(_) ) ]));
- std::map<std::string, int> result3;
- BOOST_PROTO_AUTO(dummy4, ( (s1= +_w) >> "=>" >> (s2= +_d) )[ xp::ref(result3)[s1] = as<int>(s2) ]);
- placeholder< std::map<std::string, int> > const _map = {{}};
- BOOST_PROTO_AUTO(dummy5,( (s1= +_w) >> "=>" >> (s2= +_d) )[ _map[s1] = as<int>(s2) ]);
-
- local<int> left, right;
- std::stack<int> stack_;
- reference<std::stack<int> > stack(stack_);
- cregex expression2;
- BOOST_PROTO_AUTO(group, '(' >> by_ref(expression2) >> ')');
- BOOST_PROTO_AUTO(factor, (+_d)[ push(stack, as<int>(_)) ] | group);
- //BOOST_PROTO_AUTO(term, factor >> *(
- // ('*' >> factor)
- // [ right = top(stack)
- // , pop(stack)
- // , left = top(stack)
- // , pop(stack)
- // , push(stack, left * right)
- // ]
- // | ('/' >> factor)
- // [ right = top(stack)
- // , pop(stack)
- // , left = top(stack)
- // , pop(stack)
- // , push(stack, left / right)
- // ]
- // ));
- //BOOST_PROTO_AUTO(expression, term >> *(
- // ('+' >> term)
- // [ right = top(stack)
- // , pop(stack)
- // , left = top(stack)
- // , pop(stack)
- // , push(stack, left + right)
- // ]
- // | ('-' >> term)
- // [ right = top(stack)
- // , pop(stack)
- // , left = top(stack)
- // , pop(stack)
- // , push(stack, left - right)
- // ]
- // ));
-
- // regexes from test_symbols.cpp
- std::string result10;
- std::map<std::string,std::string> map10;
- BOOST_PROTO_AUTO(dummy10, (a1=map10)[ xp::ref(result10) = a1 ] >> *(' ' >> (a1=map10)[ xp::ref(result10) += ',' + a1 ]));
- BOOST_PROTO_AUTO(dummy11, (a1=map10)[ xp::ref(result10) = a1 ]
- >> *((a1=map10)[ xp::ref(result10) += ',', xp::ref(result10) += a1 ]));
+ TYPEOF_TEST(bos >> ('(' >> (s1= nil) | (s2= nil)) >> +_w >> (')' >> s1 | s2) >> eos);
+ TYPEOF_TEST(+~alpha);
+ TYPEOF_TEST(+set[alpha | ~alpha]);
+ TYPEOF_TEST(+~set[~alpha]);
+ TYPEOF_TEST(as_xpr("[[:alpha:]\\y]+"));
+ TYPEOF_TEST(+~set[~alnum | ~digit]);
+ TYPEOF_TEST(icase(bos >> repeat<4>(s1= 'a' >> !s1) >> eos));
+ TYPEOF_TEST(as_xpr("foo") >> /*This is a comment[*/ "bar");
+ TYPEOF_TEST(bos >> "foobar" >> eos);
+ TYPEOF_TEST(bos >> 'f' >> *as_xpr('o'));
+ TYPEOF_TEST(bos >> 'f' >> *as_xpr('\157'));
+ TYPEOF_TEST(bos >> ("foo" >> set[' '] >> "bar") >> eos /*This is a comment*/);
+}
 
- return 0;
+///////////////////////////////////////////////////////////////////////////////
+// test_misc6
+// miscelaneous regular expressions
+static void test_misc6()
+{
+ using namespace boost::xpressive;
+ TYPEOF_TEST(bos >> *(s1= optional('a')) >> eos);
+ TYPEOF_TEST(bos >> -*(s1= optional('a')) >> eos);
+ TYPEOF_TEST(bos >> repeat<2>(s1= optional('b')) >> "bc" >> eos);
+ TYPEOF_TEST(bos >> *(s1= optional('b')) >> 'd' >> eos);
+ TYPEOF_TEST(bos >> -repeat<2>(s1= optional('b')) >> "bc" >> eos);
+ TYPEOF_TEST(bos >> -*(s1= optional('b')) >> 'd' >> eos);
+ TYPEOF_TEST(bos >> repeat<2>(s1= -optional('b')) >> "bc" >> eos);
+ TYPEOF_TEST(bos >> *(s1= -optional('b')) >> 'd' >> eos);
+ TYPEOF_TEST(bos >> -repeat<2>(s1= -optional('b')) >> "bc" >> eos);
+ TYPEOF_TEST(bos >> -*(s1= -optional('b')) >> 'd' >> eos);
+ TYPEOF_TEST(bos >> *(s1= nil | nil | nil | 'b') >> "bc" >> eos);
+ TYPEOF_TEST(bos >> -*(s1= nil | nil | nil | 'b') >> "bc" >> eos);
+ TYPEOF_TEST(icase(+range('Z','a')));
+ TYPEOF_TEST(+range('Z','a'));
+}
+
+// These functions are defined in test_typeof2.cpp
+void test_actions();
+void test_symbols();
+void test_assert();
+
+using namespace boost::unit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+// init_unit_test_suite
+//
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("test_typeof");
+ test->add(BOOST_TEST_CASE(&test_misc1));
+ test->add(BOOST_TEST_CASE(&test_misc2));
+ test->add(BOOST_TEST_CASE(&test_misc3));
+ test->add(BOOST_TEST_CASE(&test_misc4));
+ test->add(BOOST_TEST_CASE(&test_misc5));
+ test->add(BOOST_TEST_CASE(&test_misc6));
+ test->add(BOOST_TEST_CASE(&test_actions));
+ test->add(BOOST_TEST_CASE(&test_symbols));
+ test->add(BOOST_TEST_CASE(&test_assert));
+ return test;
 }

Added: trunk/libs/xpressive/test/test_typeof2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/xpressive/test/test_typeof2.cpp 2007-10-24 11:04:41 EDT (Wed, 24 Oct 2007)
@@ -0,0 +1,178 @@
+///////////////////////////////////////////////////////////////////////////////
+// test_typeof2.cpp
+//
+// Copyright 2007 David Jenkins. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TYPEOF_LIMIT_SIZE 200
+#define BOOST_TYPEOF_COMPILANT
+
+#include <string>
+#include <map>
+#include <list>
+#include <stack>
+#include <boost/version.hpp>
+#include <boost/xpressive/xpressive_static.hpp>
+#include <boost/xpressive/regex_actions.hpp>
+#include <boost/xpressive/xpressive_typeof.hpp>
+#include <boost/typeof/std/stack.hpp>
+#include <boost/typeof/std/list.hpp>
+#include <boost/test/unit_test.hpp>
+
+
+// I couldn't find these registrations anywhere else, so I put them here
+// They are necessary for this program to compile
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::mpl::int_, (int))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::reference_wrapper, (typename))
+
+// Here's the test for typeof registration, to be used on static regular expressions
+#define TYPEOF_TEST(Expr) { BOOST_PROTO_AUTO(Dummy, Expr); }
+
+namespace xp = boost::xpressive;
+
+///////////////////////////////////////////////////////////////////////////////
+// test_actions
+// regular expressions from test_actions.cpp
+void test_actions()
+{
+ using namespace boost::xpressive;
+ // regexes from test_actions.cpp
+ std::string result;
+ TYPEOF_TEST((+_w)[ xp::ref(result) += _ ] >> *(' ' >> (+_w)[ xp::ref(result) += ',' + _ ]));
+ TYPEOF_TEST((+_w)[ xp::ref(result) += _ ] >> *(' ' >> (+_w)[ xp::ref(result) += ',' + _ ]) >> repeat<4>(_));
+ std::list<int> result2;
+ TYPEOF_TEST((+_d)[ xp::ref(result2)->*push_back( as<int>(_) ) ]
+ >> *(' ' >> (+_d)[ xp::ref(result2)->*push_back( as<int>(_) ) ]));
+ std::map<std::string, int> result3;
+ TYPEOF_TEST(( (s1= +_w) >> "=>" >> (s2= +_d) )[ xp::ref(result3)[s1] = as<int>(s2) ]);
+ placeholder< std::map<std::string, int> > const _map5 = {{}};
+ TYPEOF_TEST(( (s1= +_w) >> "=>" >> (s2= +_d) )[ _map5[s1] = as<int>(s2) ]);
+
+ smatch what;
+ placeholder< std::map<std::string, int> > const _map6 = {{}};
+ std::map<std::string, int> result6;
+ what.let(_map6 = result6); // bind the argument!
+
+ local<int> left, right;
+ std::stack<int> stack_;
+ reference<std::stack<int> > stack(stack_);
+ cregex expression2, factor2, term2, group2;
+ TYPEOF_TEST( '(' >> by_ref(expression2) >> ')');
+ TYPEOF_TEST( (+_d)[ push(stack, as<int>(_)) ] | group2);
+ TYPEOF_TEST(factor2 >> *(
+ ('*' >> factor2)
+ [ right = top(stack)
+ , pop(stack)
+ , left = top(stack)
+ , pop(stack)
+ , push(stack, left * right)
+ ]
+ ));
+ TYPEOF_TEST(term2 >> *(
+ ('+' >> term2)
+ [ right = top(stack)
+ , pop(stack)
+ , left = top(stack)
+ , pop(stack)
+ , push(stack, left + right)
+ ]
+ ));
+}
+
+
+#ifndef BOOST_XPRESSIVE_NO_WREGEX
+ struct City
+ {
+ std::wstring name;
+ char const* nickname;
+ int population;
+ };
+ BOOST_TYPEOF_REGISTER_TYPE(City)
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// test_symbols
+// regular expressions from test_symbols.cpp
+void test_symbols()
+{
+ using namespace boost::xpressive;
+ std::string result;
+ std::map<std::string,std::string> map10;
+ TYPEOF_TEST((a1=map10)[ xp::ref(result) = a1 ] >> *(' ' >> (a1=map10)[ xp::ref(result) += ',' + a1 ]));
+ TYPEOF_TEST((a1=map10)[ xp::ref(result) = a1 ]
+ >> *((a1=map10)[ xp::ref(result) += ',', xp::ref(result) += a1 ]));
+ std::list<int> result12;
+ std::map<std::string,int> map12;
+ TYPEOF_TEST((a1=map12)[ xp::ref(result12)->*push_back( a1 ) ]
+ >> *(' ' >> (a1=map12)[ xp::ref(result12)->*push_back( a1 ) ]));
+
+ placeholder< std::map<std::string, int> > const _map13 = {};
+ BOOST_PROTO_AUTO(pair13, ( (a1=map10) >> "=>" >> (a2= map12) )[ _map13[a1] = a2 ]);
+ smatch what;
+ std::map<std::string, int> result13;
+ what.let(_map13 = result13);
+ TYPEOF_TEST(pair13 >> *(+_s >> pair13));
+
+ int result14 = 0;
+ std::map<std::string,int> map1a;
+ std::map<std::string,int> map2a;
+ std::map<std::string,int> map3a;
+ TYPEOF_TEST((a1=map1a)[ xp::ref(result14) += a1 ]
+ >> (a2=map2a)[ xp::ref(result) += a2 ]
+ >> (a3=map3a)[ xp::ref(result) += a3 ]
+ );
+ {
+ TYPEOF_TEST(icase(a1= map10) [ xp::ref(result) = a1 ]
+ >> repeat<3>( (' ' >> icase(a1= map10) [ xp::ref(result) += ',', xp::ref(result) += a1 ]) )
+ );
+ TYPEOF_TEST(*((a1= map1a) | (a1= map2a) | 'e') [ xp::ref(result) += (a1 | "9") ]);
+ }
+#ifndef BOOST_XPRESSIVE_NO_WREGEX
+ City result17a, result17b;
+ std::map<std::wstring, City> map17;
+ TYPEOF_TEST((a1= map17)[ xp::ref(result17a) = a1 ] >> +_s
+ >> (a1= map17)[ xp::ref(result17b) = a1 ]);
+#else
+ // This test is empty
+#endif
+
+}
+
+bool three_or_six(xp::csub_match const &sub)
+{
+ return sub.length() == 3 || sub.length() == 6;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// test_assert
+// regular expressions from test_assert.cpp
+void test_assert()
+{
+ using namespace boost::xpressive;
+ std::string result;
+ TYPEOF_TEST((bow >> +_w >> eow)[ check(&three_or_six) ]);
+ TYPEOF_TEST((bow >> +_w >> eow)[ check(length(_)==3 || length(_)==6) ]);
+ int const days_per_month[] =
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 31, 31};
+ mark_tag month(1), day(2);
+ // Note: if you uncomment the lines below,
+ // the BOOST_TYPEOF_LIMIT_SIZE is exceeded
+ TYPEOF_TEST((
+ // Month must be between 1 and 12 inclusive
+ (month= _d >> !_d) [ check(as<int>(_) >= 1
+ && as<int>(_) <= 12) ]
+ //>> '/'
+ // // Day must be between 1 and 31 inclusive
+ //>> (day= _d >> !_d) [ check(as<int>(_) >= 1
+ // && as<int>(_) <= 31) ]
+ //>> '/'
+ // // Only consider years between 1970 and 2038
+ //>> (_d >> _d >> _d >> _d) [ check(as<int>(_) >= 1970
+ // && as<int>(_) <= 2038) ]
+ )
+ // Ensure the month actually has that many days.
+ [ check( ref(days_per_month)[as<int>(month)-1] >= as<int>(day) ) ]);
+}
+


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