|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69501 - in trunk/boost/spirit/home/qi: . nonterminal
From: joel_at_[hidden]
Date: 2011-03-02 19:26:03
Author: djowel
Date: 2011-03-02 19:26:00 EST (Wed, 02 Mar 2011)
New Revision: 69501
URL: http://svn.boost.org/trac/boost/changeset/69501
Log:
Added DEBUG_NODES and sucess_handler.
Added:
trunk/boost/spirit/home/qi/nonterminal/success_handler.hpp (contents, props changed)
Text files modified:
trunk/boost/spirit/home/qi/nonterminal.hpp | 1 +
trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp | 14 +++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
Modified: trunk/boost/spirit/home/qi/nonterminal.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/nonterminal.hpp (original)
+++ trunk/boost/spirit/home/qi/nonterminal.hpp 2011-03-02 19:26:00 EST (Wed, 02 Mar 2011)
@@ -16,5 +16,6 @@
#include <boost/spirit/home/qi/nonterminal/error_handler.hpp>
#include <boost/spirit/home/qi/nonterminal/debug_handler.hpp>
#include <boost/spirit/home/qi/nonterminal/simple_trace.hpp>
+#include <boost/spirit/home/qi/nonterminal/success_handler.hpp>
#endif
Modified: trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp (original)
+++ trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp 2011-03-02 19:26:00 EST (Wed, 02 Mar 2011)
@@ -90,7 +90,7 @@
struct simple_trace;
- namespace detail
+ namespace detail
{
// This class provides an extra level of indirection through a
// template to produce the simple_trace type. This way, the use
@@ -98,7 +98,7 @@
// that compilers eagerly type-checking template definitions
// won't complain that simple_trace is incomplete.
template<typename T>
- struct get_simple_trace
+ struct get_simple_trace
{
typedef simple_trace type;
};
@@ -130,8 +130,16 @@
#if defined(BOOST_SPIRIT_DEBUG) || defined(BOOST_SPIRIT_QI_DEBUG)
#define BOOST_SPIRIT_DEBUG_NODE(r) r.name(#r); debug(r)
#else
- #define BOOST_SPIRIT_DEBUG_NODE(r) r.name(#r);
+ #define BOOST_SPIRIT_DEBUG_NODE(r) r.name(#r)
#endif
#endif
+#define BOOST_SPIRIT_DEBUG_NODE_A(r, _, name) \
+ BOOST_SPIRIT_DEBUG_NODE(name); \
+ /***/
+
+#define BOOST_SPIRIT_DEBUG_NODES(seq) \
+ BOOST_PP_SEQ_FOR_EACH(BOOST_SPIRIT_DEBUG_NODE_A, _, seq) \
+ /***/
+
#endif
Added: trunk/boost/spirit/home/qi/nonterminal/success_handler.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/nonterminal/success_handler.hpp 2011-03-02 19:26:00 EST (Wed, 02 Mar 2011)
@@ -0,0 +1,83 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 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)
+==============================================================================*/
+#if !defined(BOOST_SPIRIT_SUCCESS_HANDLER_FEBRUARY_25_2011_1051AM)
+#define BOOST_SPIRIT_SUCCESS_HANDLER_FEBRUARY_25_2011_1051AM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/qi/nonterminal/rule.hpp>
+#include <boost/function.hpp>
+
+namespace boost { namespace spirit { namespace qi
+{
+ template <
+ typename Iterator, typename Context
+ , typename Skipper, typename F
+ >
+ struct success_handler
+ {
+ typedef function<
+ bool(Iterator& first, Iterator const& last
+ , Context& context
+ , Skipper const& skipper
+ )>
+ function_type;
+
+ success_handler(function_type subject, F f)
+ : subject(subject)
+ , f(f)
+ {
+ }
+
+ bool operator()(
+ Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper) const
+ {
+ Iterator i = first;
+ bool r = subject(i, last, context, skipper);
+ if (r)
+ {
+ typedef
+ fusion::vector<
+ Iterator&
+ , Iterator const&
+ , Iterator const&>
+ params;
+ skip_over(first, last, skipper);
+ params args(first, last, i);
+ f(args, context);
+
+ first = i;
+ }
+ return r;
+ }
+
+ function_type subject;
+ F f;
+ };
+
+ template <
+ typename Iterator, typename T0, typename T1, typename T2
+ , typename F>
+ void on_success(rule<Iterator, T0, T1, T2>& r, F f)
+ {
+ typedef rule<Iterator, T0, T1, T2> rule_type;
+
+ typedef
+ success_handler<
+ Iterator
+ , typename rule_type::context_type
+ , typename rule_type::skipper_type
+ , F>
+ success_handler;
+ r.f = success_handler(r.f, f);
+ }
+}}}
+
+#endif
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