|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55165 - in trunk/boost/spirit: home/support repository/home repository/home/qi repository/home/support repository/include
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-30 14:42:10
Author: hkaiser
Date: 2009-07-25 21:10:49 EDT (Sat, 25 Jul 2009)
New Revision: 55165
URL: http://svn.boost.org/trac/boost/changeset/55165
Log:
Spirit: added qi::distinct to repository
Added:
trunk/boost/spirit/repository/home/qi/distinct.hpp (contents, props changed)
trunk/boost/spirit/repository/home/support/distinct.hpp (contents, props changed)
trunk/boost/spirit/repository/include/qi_distinct.hpp (contents, props changed)
Text files modified:
trunk/boost/spirit/home/support/common_terminals.hpp | 17 ++++++++++++-----
trunk/boost/spirit/repository/home/qi.hpp | 2 +-
2 files changed, 13 insertions(+), 6 deletions(-)
Modified: trunk/boost/spirit/home/support/common_terminals.hpp
==============================================================================
--- trunk/boost/spirit/home/support/common_terminals.hpp (original)
+++ trunk/boost/spirit/home/support/common_terminals.hpp 2009-07-25 21:10:49 EDT (Sat, 25 Jul 2009)
@@ -85,15 +85,18 @@
// are placed in its char-set namespace. For example, there exist a placeholder
// spirit::ascii::alnum for ascii versions of alnum.
+#define BOOST_SPIRIT_TAG_CHAR_SPEC(charset) \
+ typedef tag::char_code<tag::char_, charset> char_; \
+ typedef tag::char_code<tag::string, charset> string; \
+ /***/
+
#define BOOST_SPIRIT_CHAR_SPEC(charset) \
- typedef spirit::terminal< \
- tag::char_code<tag::char_, charset> > char__type; \
+ typedef spirit::terminal<tag::charset::char_> char__type; \
char__type const char_ = char__type(); \
\
inline void silence_unused_warnings__##char_() { (void) char_; } \
\
- typedef spirit::terminal< \
- tag::char_code<tag::string, charset> > string_type; \
+ typedef spirit::terminal<tag::charset::string> string_type; \
string_type const string = string_type(); \
\
inline void silence_unused_warnings__##string() { (void) string; } \
@@ -108,9 +111,13 @@
/***/
#define BOOST_SPIRIT_DEFINE_CHAR_CODES(charset) \
+ namespace boost { namespace spirit { namespace tag { namespace charset \
+ { \
+ BOOST_SPIRIT_TAG_CHAR_SPEC(spirit::char_encoding::charset) \
+ }}}} \
namespace boost { namespace spirit { namespace charset \
{ \
- BOOST_SPIRIT_CHAR_SPEC(spirit::char_encoding::charset) \
+ BOOST_SPIRIT_CHAR_SPEC(charset) \
\
BOOST_SPIRIT_CHAR_CODE(alnum, spirit::char_encoding::charset) \
BOOST_SPIRIT_CHAR_CODE(alpha, spirit::char_encoding::charset) \
Modified: trunk/boost/spirit/repository/home/qi.hpp
==============================================================================
--- trunk/boost/spirit/repository/home/qi.hpp (original)
+++ trunk/boost/spirit/repository/home/qi.hpp 2009-07-25 21:10:49 EDT (Sat, 25 Jul 2009)
@@ -12,8 +12,8 @@
#endif
#include <boost/spirit/repository/home/qi/flush_multi_pass.hpp>
+#include <boost/spirit/repository/home/qi/distinct.hpp>
//#include <boost/spirit/repository/qi/confix.hpp>
-//#include <boost/spirit/repository/qi/distinct.hpp>
#endif
Added: trunk/boost/spirit/repository/home/qi/distinct.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/repository/home/qi/distinct.hpp 2009-07-25 21:10:49 EDT (Sat, 25 Jul 2009)
@@ -0,0 +1,136 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+// Copyright (c) 2001-2009 Joel de Guzman
+// Copyright (c) 2003 Vaclav Vesely
+//
+// 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(SPIRIT_REPOSITORY_QI_DISTINCT_MAY_20_2009_0825M)
+#define SPIRIT_REPOSITORY_QI_DISTINCT_MAY_20_2009_0825M
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/qi/skip_over.hpp>
+#include <boost/spirit/home/qi/domain.hpp>
+#include <boost/spirit/home/qi/parser.hpp>
+#include <boost/spirit/home/qi/meta_compiler.hpp>
+#include <boost/spirit/home/qi/detail/unused_skipper.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/make_component.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/qi/auxiliary/eps.hpp>
+#include <boost/spirit/home/qi/auxiliary/lazy.hpp>
+#include <boost/spirit/home/qi/directive/lexeme.hpp>
+#include <boost/spirit/home/qi/operator/not_predicate.hpp>
+
+#include <boost/spirit/repository/home/support/distinct.hpp>
+
+#include <boost/fusion/include/at.hpp>
+#include <boost/fusion/include/vector.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+
+ // enables distinct(...)[...]
+ template <typename Tail>
+ struct use_directive<qi::domain
+ , terminal_ex<repository::tag::distinct, fusion::vector1<Tail> > >
+ : mpl::true_ {};
+
+ // enables *lazy* distinct(...)[...]
+ template <>
+ struct use_lazy_directive<qi::domain, repository::tag::distinct, 1>
+ : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace repository {namespace qi
+{
+ using repository::distinct_type;
+ using repository::distinct;
+
+ template <typename Subject, typename Tail, typename Modifier>
+ struct distinct_parser
+ : spirit::qi::unary_parser<distinct_parser<Subject, Tail, Modifier> >
+ {
+ template <typename Context, typename Iterator>
+ struct attribute
+ {
+ typedef typename traits::attribute_of<Subject>::type type;
+ };
+
+ distinct_parser(Subject const& subject, Tail const& tail)
+ : subject(subject), tail(tail) {}
+
+ template <typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper, Attribute& attr) const
+ {
+ Iterator iter = first;
+
+ spirit::qi::skip_over(iter, last, skipper);
+ if (!subject.parse(iter, last, context
+ , spirit::qi::detail::unused_skipper<Skipper>(skipper), attr))
+ return false;
+
+ Iterator i = iter;
+ if (tail.parse(i, last, context, unused, unused))
+ return false;
+
+ first = iter;
+ return true;
+ }
+
+ template <typename Context>
+ info what(Context& /*ctx*/) const
+ {
+ return info("distinct");
+ }
+
+ Subject subject;
+ Tail tail;
+ };
+
+}}}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace qi
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Parser generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Tail, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<repository::tag::distinct, fusion::vector1<Tail> >
+ , Subject, Modifiers>
+ {
+ typedef typename result_of::compile<qi::domain, Tail, Modifiers>::type
+ tail_type;
+
+ typedef repository::qi::distinct_parser<
+ Subject, tail_type, Modifiers> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , Modifiers const& modifiers) const
+ {
+ return result_type(subject
+ , compile<qi::domain>(fusion::at_c<0>(term.args), modifiers));
+ }
+ };
+
+}}}
+
+#endif
+
Added: trunk/boost/spirit/repository/home/support/distinct.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/repository/home/support/distinct.hpp 2009-07-25 21:10:49 EDT (Sat, 25 Jul 2009)
@@ -0,0 +1,22 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// 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_REPOSITORY_SUPPORT_DISTINCT_APR_28_2009_0110PM)
+#define BOOST_SPIRIT_REPOSITORY_SUPPORT_DISTINCT_APR_28_2009_0110PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/support/terminal.hpp>
+
+namespace boost { namespace spirit { namespace repository
+{
+ // The distinct extended terminal
+ BOOST_SPIRIT_DEFINE_TERMINALS_EX(( distinct ))
+
+}}}
+
+#endif
Added: trunk/boost/spirit/repository/include/qi_distinct.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/repository/include/qi_distinct.hpp 2009-07-25 21:10:49 EDT (Sat, 25 Jul 2009)
@@ -0,0 +1,18 @@
+/*=============================================================================
+ Copyright (c) 2001-2009 Joel de Guzman
+ Copyright (c) 2001-2009 Hartmut Kaiser
+ http://spirit.sourceforge.net/
+
+ 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)
+=============================================================================*/
+#ifndef BOOST_SPIRIT_INCLUDE_QI_REPOSITORY_DISTINCT
+#define BOOST_SPIRIT_INCLUDE_QI_REPOSITORY_DISTINCT
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/repository/home/qi/distinct.hpp>
+
+#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