|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54016 - trunk/libs/spirit/test/qi
From: joel_at_[hidden]
Date: 2009-06-17 12:24:08
Author: djowel
Date: 2009-06-17 12:24:08 EDT (Wed, 17 Jun 2009)
New Revision: 54016
URL: http://svn.boost.org/trac/boost/changeset/54016
Log:
fixed.
Text files modified:
trunk/libs/spirit/test/qi/debug.cpp | 51 ++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 22 deletions(-)
Modified: trunk/libs/spirit/test/qi/debug.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/debug.cpp (original)
+++ trunk/libs/spirit/test/qi/debug.cpp 2009-06-17 12:24:08 EDT (Wed, 17 Jun 2009)
@@ -1,10 +1,9 @@
/*=============================================================================
- Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2001-2009 Joel de Guzman
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_SPIRIT_DEBUG
#include <boost/detail/lightweight_test.hpp>
@@ -12,27 +11,40 @@
#include <boost/spirit/include/qi_char.hpp>
#include <boost/spirit/include/qi_string.hpp>
#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
#include <boost/spirit/include/qi_nonterminal.hpp>
#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/qi_debug.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_bind.hpp>
+#include <boost/fusion/include/std_pair.hpp>
#include <string>
+#include <cstring>
#include <iostream>
#include "test.hpp"
-using namespace spirit_test;
-
int
main()
{
- using namespace boost::spirit;
- using namespace boost::spirit::qi;
+ using spirit_test::test_attr;
+ using spirit_test::test;
+
using namespace boost::spirit::ascii;
+ using namespace boost::spirit::qi::labels;
+ using boost::spirit::qi::locals;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::fail;
+ using boost::spirit::qi::on_error;
+ using boost::spirit::qi::debug;
+
+ namespace phx = boost::phoenix;
+
{ // basic tests
+
rule<char const*> a, b, c, start;
a = 'a';
@@ -50,6 +62,9 @@
BOOST_SPIRIT_DEBUG_NODE(start);
BOOST_TEST(test("aaaabababaaabbb", start));
BOOST_TEST(test("aaaabababaaabba", start, false));
+
+ // ignore the skipper!
+ BOOST_TEST(test("aaaabababaaabba", start, space, false));
}
{ // basic tests w/ skipper
@@ -64,11 +79,8 @@
BOOST_SPIRIT_DEBUG_NODE(c);
start = *(a | b | c);
- BOOST_TEST(test(" a b c a b c a c b", start, space));
-
- // allow no skipping too:
BOOST_SPIRIT_DEBUG_NODE(start);
- BOOST_TEST(test("abcabcacb", start));
+ BOOST_TEST(test(" a b c a b c a c b ", start, space));
start = (a | b) >> (start | b);
BOOST_SPIRIT_DEBUG_NODE(start);
@@ -78,26 +90,21 @@
{ // error handling
- using namespace boost::phoenix;
using namespace boost::spirit::ascii;
- using boost::phoenix::val;
- using boost::spirit::int_;
- using boost::spirit::arg_names::_4; // what
- using boost::spirit::arg_names::_3; // error pos
- using boost::spirit::arg_names::_2; // end
- using boost::spirit::qi::fail;
+ using boost::phoenix::construct;
+ using boost::phoenix::bind;
rule<char const*> r;
- r = char_('(') > int_ > ',' > int_ > ')';
+ r = '(' > int_ > ',' > int_ > ')';
on_error<fail>
(
r, std::cout
- << val("Error! Expecting: ")
+ << phx::val("Error! Expecting: ")
<< _4
- << val(" Here: \"")
+ << phx::val(", got: \"")
<< construct<std::string>(_3, _2)
- << val("\"")
+ << phx::val("\"")
<< std::endl
);
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