PageRenderTime 25ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/boost/spirit/home/qi/directive/no_skip.hpp

http://pythonocc.googlecode.com/
C++ Header | 96 lines | 69 code | 13 blank | 14 comment | 0 complexity | a10bdaf05936c0a60291d4a65112226d MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2010 Joel de Guzman
 3    Copyright (c) 2001-2010 Hartmut Kaiser
 4
 5    Distributed under the Boost Software License, Version 1.0. (See accompanying
 6    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 7=============================================================================*/
 8#if !defined(SPIRIT_NO_SKIP_JAN_16_2010_0802PM)
 9#define SPIRIT_NO_SKIP_JAN_16_2010_0802PM
10
11#if defined(_MSC_VER)
12#pragma once
13#endif
14
15#include <boost/spirit/home/qi/meta_compiler.hpp>
16#include <boost/spirit/home/qi/skip_over.hpp>
17#include <boost/spirit/home/qi/parser.hpp>
18#include <boost/spirit/home/qi/detail/unused_skipper.hpp>
19#include <boost/spirit/home/support/unused.hpp>
20#include <boost/spirit/home/support/common_terminals.hpp>
21#include <boost/spirit/home/support/attributes.hpp>
22#include <boost/spirit/home/support/info.hpp>
23
24namespace boost { namespace spirit
25{
26    ///////////////////////////////////////////////////////////////////////////
27    // Enablers
28    ///////////////////////////////////////////////////////////////////////////
29    template <>
30    struct use_directive<qi::domain, tag::no_skip> // enables no_skip
31      : mpl::true_ {};
32}}
33
34namespace boost { namespace spirit { namespace qi
35{
36    using spirit::no_skip;
37    using spirit::no_skip_type;
38
39    // same as lexeme[], but does not pre-skip
40    template <typename Subject>
41    struct no_skip_directive : unary_parser<no_skip_directive<Subject> >
42    {
43        typedef Subject subject_type;
44        no_skip_directive(Subject const& subject)
45          : subject(subject) {}
46
47        template <typename Context, typename Iterator>
48        struct attribute
49        {
50            typedef typename
51                traits::attribute_of<subject_type, Context, Iterator>::type
52            type;
53        };
54
55        template <typename Iterator, typename Context
56          , typename Skipper, typename Attribute>
57        bool parse(Iterator& first, Iterator const& last
58          , Context& context, Skipper const& skipper
59          , Attribute& attr) const
60        {
61            return subject.parse(first, last, context
62              , detail::unused_skipper<Skipper>(skipper), attr);
63        }
64
65        template <typename Context>
66        info what(Context& context) const
67        {
68            return info("no_skip", subject.what(context));
69
70        }
71
72        Subject subject;
73    };
74
75    ///////////////////////////////////////////////////////////////////////////
76    // Parser generators: make_xxx function (objects)
77    ///////////////////////////////////////////////////////////////////////////
78    template <typename Subject, typename Modifiers>
79    struct make_directive<tag::no_skip, Subject, Modifiers>
80    {
81        typedef no_skip_directive<Subject> result_type;
82        result_type operator()(unused_type, Subject const& subject, unused_type) const
83        {
84            return result_type(subject);
85        }
86    };
87}}}
88
89namespace boost { namespace spirit { namespace traits
90{
91    template <typename Subject>
92    struct has_semantic_action<qi::no_skip_directive<Subject> >
93      : unary_has_semantic_action<Subject> {};
94}}}
95
96#endif