comparison DEPENDENCIES/generic/include/boost/spirit/home/x3/directive/lexeme.hpp @ 102:f46d142149f5

Whoops, finish that update
author Chris Cannam
date Mon, 07 Sep 2015 11:13:41 +0100
parents
children
comparison
equal deleted inserted replaced
101:c530137014c0 102:f46d142149f5
1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #if !defined(SPIRIT_LEXEME_MARCH_24_2007_0802AM)
8 #define SPIRIT_LEXEME_MARCH_24_2007_0802AM
9
10 #if defined(_MSC_VER)
11 #pragma once
12 #endif
13
14 #include <boost/spirit/home/x3/support/context.hpp>
15 #include <boost/spirit/home/x3/support/unused.hpp>
16 #include <boost/spirit/home/x3/core/skip_over.hpp>
17 #include <boost/spirit/home/x3/core/parser.hpp>
18 #include <boost/type_traits/remove_reference.hpp>
19 #include <boost/utility/enable_if.hpp>
20
21 namespace boost { namespace spirit { namespace x3
22 {
23 template <typename Subject>
24 struct lexeme_directive : unary_parser<Subject, lexeme_directive<Subject>>
25 {
26 typedef unary_parser<Subject, lexeme_directive<Subject> > base_type;
27 static bool const is_pass_through_unary = true;
28 static bool const handles_container = Subject::handles_container;
29
30 lexeme_directive(Subject const& subject)
31 : base_type(subject) {}
32
33 template <typename Iterator, typename Context
34 , typename RContext, typename Attribute>
35 typename enable_if<has_skipper<Context>, bool>::type
36 parse(Iterator& first, Iterator const& last
37 , Context const& context, RContext& rcontext, Attribute& attr) const
38 {
39 x3::skip_over(first, last, context);
40 auto const& skipper = x3::get<skipper_tag>(context);
41
42 typedef unused_skipper<
43 typename remove_reference<decltype(skipper)>::type>
44 unused_skipper_type;
45 unused_skipper_type unused_skipper(skipper);
46
47 return this->subject.parse(
48 first, last
49 , make_context<skipper_tag>(unused_skipper, context)
50 , rcontext
51 , attr);
52 }
53
54 template <typename Iterator, typename Context
55 , typename RContext, typename Attribute>
56 typename disable_if<has_skipper<Context>, bool>::type
57 parse(Iterator& first, Iterator const& last
58 , Context const& context, RContext& rcontext, Attribute& attr) const
59 {
60 // no need to pre-skip if skipper is unused
61 //- x3::skip_over(first, last, context);
62
63 return this->subject.parse(
64 first, last
65 , context
66 , rcontext
67 , attr);
68 }
69 };
70
71 struct lexeme_gen
72 {
73 template <typename Subject>
74 lexeme_directive<typename extension::as_parser<Subject>::value_type>
75 operator[](Subject const& subject) const
76 {
77 return {as_parser(subject)};
78 }
79 };
80
81 lexeme_gen const lexeme = lexeme_gen();
82 }}}
83
84 #endif