Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/lex/meta_compiler.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Copyright (c) 2001-2011 Hartmut Kaiser | |
2 // Copyright (c) 2001-2011 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(BOOST_SPIRIT_LEX_META_COMPILER_APR_20_2009_0756PM) | |
8 #define BOOST_SPIRIT_LEX_META_COMPILER_APR_20_2009_0756PM | |
9 | |
10 #if defined(_MSC_VER) | |
11 #pragma once | |
12 #endif | |
13 | |
14 #include <boost/spirit/home/support/meta_compiler.hpp> | |
15 #include <boost/spirit/home/lex/domain.hpp> | |
16 #include <boost/spirit/home/lex/lexer_type.hpp> | |
17 #include <boost/type_traits/remove_reference.hpp> | |
18 #include <boost/utility/enable_if.hpp> | |
19 | |
20 namespace boost { namespace spirit | |
21 { | |
22 template <typename T> | |
23 struct use_terminal<lex::domain, T | |
24 , typename enable_if<traits::is_lexer<T> >::type> // enables lexers | |
25 : mpl::true_ {}; | |
26 | |
27 namespace lex | |
28 { | |
29 template <typename T, typename Modifiers, typename Enable = void> | |
30 struct make_primitive // by default, return it as-is | |
31 { | |
32 typedef T result_type; | |
33 | |
34 template <typename T_> | |
35 T_& operator()(T_& val, unused_type) const | |
36 { | |
37 return val; | |
38 } | |
39 | |
40 template <typename T_> | |
41 T_ const& operator()(T_ const& val, unused_type) const | |
42 { | |
43 return val; | |
44 } | |
45 }; | |
46 | |
47 template <typename Tag, typename Elements | |
48 , typename Modifiers, typename Enable = void> | |
49 struct make_composite; | |
50 } | |
51 | |
52 // Lex primitive meta-compiler | |
53 template <> | |
54 struct make_component<lex::domain, proto::tag::terminal> | |
55 { | |
56 template <typename Sig> | |
57 struct result; | |
58 | |
59 template <typename This, typename Elements, typename Modifiers> | |
60 struct result<This(Elements, Modifiers)> | |
61 { | |
62 typedef typename lex::make_primitive< | |
63 typename remove_const<typename Elements::car_type>::type, | |
64 typename remove_reference<Modifiers>::type>::result_type | |
65 type; | |
66 }; | |
67 | |
68 template <typename Elements, typename Modifiers> | |
69 typename result<make_component(Elements, Modifiers)>::type | |
70 operator()(Elements const& elements, Modifiers const& modifiers) const | |
71 { | |
72 typedef typename remove_const<typename Elements::car_type>::type term; | |
73 return lex::make_primitive<term, Modifiers>()(elements.car, modifiers); | |
74 } | |
75 }; | |
76 | |
77 // Lex composite meta-compiler | |
78 template <typename Tag> | |
79 struct make_component<lex::domain, Tag> | |
80 { | |
81 template <typename Sig> | |
82 struct result; | |
83 | |
84 template <typename This, typename Elements, typename Modifiers> | |
85 struct result<This(Elements, Modifiers)> | |
86 { | |
87 typedef typename | |
88 lex::make_composite<Tag, Elements | |
89 , typename remove_reference<Modifiers>::type>::result_type | |
90 type; | |
91 }; | |
92 | |
93 template <typename Elements, typename Modifiers> | |
94 typename result<make_component(Elements, Modifiers)>::type | |
95 operator()(Elements const& elements, Modifiers const& modifiers) const | |
96 { | |
97 return lex::make_composite<Tag, Elements, Modifiers>()( | |
98 elements, modifiers); | |
99 } | |
100 }; | |
101 | |
102 }} | |
103 | |
104 #endif |