annotate DEPENDENCIES/generic/include/boost/spirit/home/lex/meta_compiler.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 2 // Copyright (c) 2001-2011 Joel de Guzman
Chris@16 3 //
Chris@16 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #if !defined(BOOST_SPIRIT_LEX_META_COMPILER_APR_20_2009_0756PM)
Chris@16 8 #define BOOST_SPIRIT_LEX_META_COMPILER_APR_20_2009_0756PM
Chris@16 9
Chris@16 10 #if defined(_MSC_VER)
Chris@16 11 #pragma once
Chris@16 12 #endif
Chris@16 13
Chris@16 14 #include <boost/spirit/home/support/meta_compiler.hpp>
Chris@16 15 #include <boost/spirit/home/lex/domain.hpp>
Chris@16 16 #include <boost/spirit/home/lex/lexer_type.hpp>
Chris@16 17 #include <boost/type_traits/remove_reference.hpp>
Chris@16 18 #include <boost/utility/enable_if.hpp>
Chris@16 19
Chris@16 20 namespace boost { namespace spirit
Chris@16 21 {
Chris@16 22 template <typename T>
Chris@16 23 struct use_terminal<lex::domain, T
Chris@16 24 , typename enable_if<traits::is_lexer<T> >::type> // enables lexers
Chris@16 25 : mpl::true_ {};
Chris@16 26
Chris@16 27 namespace lex
Chris@16 28 {
Chris@16 29 template <typename T, typename Modifiers, typename Enable = void>
Chris@16 30 struct make_primitive // by default, return it as-is
Chris@16 31 {
Chris@16 32 typedef T result_type;
Chris@16 33
Chris@16 34 template <typename T_>
Chris@16 35 T_& operator()(T_& val, unused_type) const
Chris@16 36 {
Chris@16 37 return val;
Chris@16 38 }
Chris@16 39
Chris@16 40 template <typename T_>
Chris@16 41 T_ const& operator()(T_ const& val, unused_type) const
Chris@16 42 {
Chris@16 43 return val;
Chris@16 44 }
Chris@16 45 };
Chris@16 46
Chris@16 47 template <typename Tag, typename Elements
Chris@16 48 , typename Modifiers, typename Enable = void>
Chris@16 49 struct make_composite;
Chris@16 50 }
Chris@16 51
Chris@16 52 // Lex primitive meta-compiler
Chris@16 53 template <>
Chris@16 54 struct make_component<lex::domain, proto::tag::terminal>
Chris@16 55 {
Chris@16 56 template <typename Sig>
Chris@16 57 struct result;
Chris@16 58
Chris@16 59 template <typename This, typename Elements, typename Modifiers>
Chris@16 60 struct result<This(Elements, Modifiers)>
Chris@16 61 {
Chris@16 62 typedef typename lex::make_primitive<
Chris@16 63 typename remove_const<typename Elements::car_type>::type,
Chris@16 64 typename remove_reference<Modifiers>::type>::result_type
Chris@16 65 type;
Chris@16 66 };
Chris@16 67
Chris@16 68 template <typename Elements, typename Modifiers>
Chris@16 69 typename result<make_component(Elements, Modifiers)>::type
Chris@16 70 operator()(Elements const& elements, Modifiers const& modifiers) const
Chris@16 71 {
Chris@16 72 typedef typename remove_const<typename Elements::car_type>::type term;
Chris@16 73 return lex::make_primitive<term, Modifiers>()(elements.car, modifiers);
Chris@16 74 }
Chris@16 75 };
Chris@16 76
Chris@16 77 // Lex composite meta-compiler
Chris@16 78 template <typename Tag>
Chris@16 79 struct make_component<lex::domain, Tag>
Chris@16 80 {
Chris@16 81 template <typename Sig>
Chris@16 82 struct result;
Chris@16 83
Chris@16 84 template <typename This, typename Elements, typename Modifiers>
Chris@16 85 struct result<This(Elements, Modifiers)>
Chris@16 86 {
Chris@16 87 typedef typename
Chris@16 88 lex::make_composite<Tag, Elements
Chris@16 89 , typename remove_reference<Modifiers>::type>::result_type
Chris@16 90 type;
Chris@16 91 };
Chris@16 92
Chris@16 93 template <typename Elements, typename Modifiers>
Chris@16 94 typename result<make_component(Elements, Modifiers)>::type
Chris@16 95 operator()(Elements const& elements, Modifiers const& modifiers) const
Chris@16 96 {
Chris@16 97 return lex::make_composite<Tag, Elements, Modifiers>()(
Chris@16 98 elements, modifiers);
Chris@16 99 }
Chris@16 100 };
Chris@16 101
Chris@16 102 }}
Chris@16 103
Chris@16 104 #endif