annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/auxiliary/eps.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 /*=============================================================================
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_EPS_MARCH_23_2007_0454PM)
Chris@16 8 #define BOOST_SPIRIT_EPS_MARCH_23_2007_0454PM
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/qi/domain.hpp>
Chris@16 15 #include <boost/spirit/home/qi/skip_over.hpp>
Chris@16 16 #include <boost/spirit/home/qi/meta_compiler.hpp>
Chris@16 17 #include <boost/spirit/home/support/unused.hpp>
Chris@16 18 #include <boost/spirit/home/support/info.hpp>
Chris@16 19 #include <boost/spirit/home/support/common_terminals.hpp>
Chris@16 20 #include <boost/fusion/include/at.hpp>
Chris@16 21 #include <boost/type_traits/is_convertible.hpp>
Chris@16 22
Chris@16 23 namespace boost { namespace spirit
Chris@16 24 {
Chris@16 25 ///////////////////////////////////////////////////////////////////////////
Chris@16 26 // Enablers
Chris@16 27 ///////////////////////////////////////////////////////////////////////////
Chris@16 28 template <>
Chris@16 29 struct use_terminal<qi::domain, tag::eps> // enables eps
Chris@16 30 : mpl::true_ {};
Chris@16 31
Chris@16 32 template <typename A0>
Chris@16 33 struct use_terminal<qi::domain
Chris@16 34 , terminal_ex<tag::eps, fusion::vector1<A0> > // enables eps(bool-condition)
Chris@16 35 > : is_convertible<A0, bool> {};
Chris@16 36
Chris@16 37 template <> // enables eps(f)
Chris@16 38 struct use_lazy_terminal<
Chris@16 39 qi::domain, tag::eps, 1 /*arity*/
Chris@16 40 > : mpl::true_ {};
Chris@16 41 }}
Chris@16 42
Chris@16 43 namespace boost { namespace spirit { namespace qi
Chris@16 44 {
Chris@16 45 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
Chris@16 46 using spirit::eps;
Chris@16 47 #endif
Chris@16 48 using spirit::eps_type;
Chris@16 49
Chris@16 50 struct eps_parser : primitive_parser<eps_parser>
Chris@16 51 {
Chris@16 52 template <typename Context, typename Iterator>
Chris@16 53 struct attribute
Chris@16 54 {
Chris@16 55 typedef unused_type type;
Chris@16 56 };
Chris@16 57
Chris@16 58 template <typename Iterator, typename Context
Chris@16 59 , typename Skipper, typename Attribute>
Chris@16 60 bool parse(Iterator& first, Iterator const& last
Chris@16 61 , Context& /*context*/, Skipper const& skipper
Chris@16 62 , Attribute& /*attr*/) const
Chris@16 63 {
Chris@16 64 qi::skip_over(first, last, skipper);
Chris@16 65 return true;
Chris@16 66 }
Chris@16 67
Chris@16 68 template <typename Context>
Chris@16 69 info what(Context& /*context*/) const
Chris@16 70 {
Chris@16 71 return info("eps");
Chris@16 72 }
Chris@16 73 };
Chris@16 74
Chris@16 75 struct semantic_predicate : primitive_parser<semantic_predicate>
Chris@16 76 {
Chris@16 77 template <typename Context, typename Iterator>
Chris@16 78 struct attribute
Chris@16 79 {
Chris@16 80 typedef unused_type type;
Chris@16 81 };
Chris@16 82
Chris@16 83 semantic_predicate(bool predicate_)
Chris@16 84 : predicate(predicate_) {}
Chris@16 85
Chris@16 86 template <typename Iterator, typename Context
Chris@16 87 , typename Skipper, typename Attribute>
Chris@16 88 bool parse(Iterator& first, Iterator const& last
Chris@16 89 , Context& /*context*/, Skipper const& skipper
Chris@16 90 , Attribute& /*attr*/) const
Chris@16 91 {
Chris@16 92 qi::skip_over(first, last, skipper);
Chris@16 93 return predicate;
Chris@16 94 }
Chris@16 95
Chris@16 96 template <typename Context>
Chris@16 97 info what(Context& /*context*/) const
Chris@16 98 {
Chris@16 99 return info("semantic-predicate");
Chris@16 100 }
Chris@16 101
Chris@16 102 bool predicate;
Chris@16 103 };
Chris@16 104
Chris@16 105 ///////////////////////////////////////////////////////////////////////////
Chris@16 106 // Parser generators: make_xxx function (objects)
Chris@16 107 ///////////////////////////////////////////////////////////////////////////
Chris@16 108 template <typename Modifiers>
Chris@16 109 struct make_primitive<tag::eps, Modifiers>
Chris@16 110 {
Chris@16 111 typedef eps_parser result_type;
Chris@16 112 result_type operator()(unused_type, unused_type) const
Chris@16 113 {
Chris@16 114 return result_type();
Chris@16 115 }
Chris@16 116 };
Chris@16 117
Chris@16 118 template <typename Modifiers, typename A0>
Chris@16 119 struct make_primitive<
Chris@16 120 terminal_ex<tag::eps, fusion::vector1<A0> >
Chris@16 121 , Modifiers>
Chris@16 122 {
Chris@16 123 typedef semantic_predicate result_type;
Chris@16 124 template <typename Terminal>
Chris@16 125 result_type operator()(Terminal const& term, unused_type) const
Chris@16 126 {
Chris@16 127 return result_type(fusion::at_c<0>(term.args) ? true : false);
Chris@16 128 }
Chris@16 129 };
Chris@16 130 }}}
Chris@16 131
Chris@16 132 #endif