Update of /cvsroot/boost/boost/libs/xpressive/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26821/libs/xpressive/test
Modified Files:
test_actions.cpp
Log Message:
add value<>, reference<> and local<> for semantic actions, rename
match_result::bind() to match_results::let()
Index: test_actions.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/test/test_actions.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_actions.cpp 29 Mar 2007 22:19:39 -0000 1.6
+++ test_actions.cpp 30 Mar 2007 05:44:26 -0000 1.7
@@ -122,7 +122,7 @@
std::string str("aaa=>1 bbb=>23 ccc=>456");
smatch what;
std::map<std::string, int> result;
- what.bind( map = result ); // bind the argument!
+ what.let(map = result); // bind the argument!
if(!regex_match(str, what, rx))
{
@@ -144,44 +144,49 @@
{
using namespace boost::xpressive;
- int left = 0, right = 0;
- std::stack<int> stack;
+ // test for "local" variables.
+ local<int> left = 0, right = 0;
+
+ // test for reference<> to an existing variable
+ std::stack<int> stack_;
+ reference<std::stack<int> > stack(stack_);
+
std::string str("4+5*(3-1)");
sregex group, factor, term, expression;
group = '(' >> by_ref(expression) >> ')';
- factor = (+_d)[ push(ref(stack), as<int>(_)) ] | group;
+ factor = (+_d)[ push(stack, as<int>(_)) ] | group;
term = factor >> *(
('*' >> factor)
- [ ref(right) = top(ref(stack))
- , pop(ref(stack))
- , ref(left) = top(ref(stack))
- , pop(ref(stack))
- , push(ref(stack), ref(left) * ref(right))
+ [ right = top(stack)
+ , pop(stack)
+ , left = top(stack)
+ , pop(stack)
+ , push(stack, left * right)
]
| ('/' >> factor)
- [ ref(right) = top(ref(stack))
- , pop(ref(stack))
- , ref(left) = top(ref(stack))
- , pop(ref(stack))
- , push(ref(stack), ref(left) / ref(right))
+ [ right = top(stack)
+ , pop(stack)
+ , left = top(stack)
+ , pop(stack)
+ , push(stack, left / right)
]
);
expression = term >> *(
('+' >> term)
- [ ref(right) = top(ref(stack))
- , pop(ref(stack))
- , ref(left) = top(ref(stack))
- , pop(ref(stack))
- , push(ref(stack), ref(left) + ref(right))
+ [ right = top(stack)
+ , pop(stack)
+ , left = top(stack)
+ , pop(stack)
+ , push(stack, left + right)
]
| ('-' >> term)
- [ ref(right) = top(ref(stack))
- , pop(ref(stack))
- , ref(left) = top(ref(stack))
- , pop(ref(stack))
- , push(ref(stack), ref(left) - ref(right))
+ [ right = top(stack)
+ , pop(stack)
+ , left = top(stack)
+ , pop(stack)
+ , push(stack, left - right)
]
);
@@ -191,8 +196,11 @@
}
else
{
- BOOST_REQUIRE_EQUAL(stack.size(), 1u);
- BOOST_CHECK_EQUAL(stack.top(), 14);
+ BOOST_REQUIRE_EQUAL(stack_.size(), 1u);
+ BOOST_CHECK_EQUAL(stack_.top(), 14);
+
+ BOOST_REQUIRE_EQUAL(stack.get().size(), 1u);
+ BOOST_CHECK_EQUAL(stack.get().top(), 14);
}
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs