annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/auxiliary/eol.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 Hartmut Kaiser
Chris@16 3 Copyright (c) 2001-2011 Joel de Guzman
Chris@16 4
Chris@16 5 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 ==============================================================================*/
Chris@16 8 #if !defined(BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM)
Chris@16 9 #define BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM
Chris@16 10
Chris@16 11 #if defined(_MSC_VER)
Chris@16 12 #pragma once
Chris@16 13 #endif
Chris@16 14
Chris@16 15 #include <boost/mpl/bool.hpp>
Chris@16 16 #include <boost/spirit/home/qi/domain.hpp>
Chris@16 17 #include <boost/spirit/home/qi/parser.hpp>
Chris@16 18 #include <boost/spirit/home/qi/meta_compiler.hpp>
Chris@16 19 #include <boost/spirit/home/qi/skip_over.hpp>
Chris@16 20 #include <boost/spirit/home/support/common_terminals.hpp>
Chris@16 21
Chris@16 22 namespace boost { namespace spirit
Chris@16 23 {
Chris@16 24 ///////////////////////////////////////////////////////////////////////////
Chris@16 25 // Enablers
Chris@16 26 ///////////////////////////////////////////////////////////////////////////
Chris@16 27 template <>
Chris@16 28 struct use_terminal<qi::domain, tag::eol> // enables eol
Chris@16 29 : mpl::true_ {};
Chris@16 30 }}
Chris@16 31
Chris@16 32 namespace boost { namespace spirit { namespace qi
Chris@16 33 {
Chris@16 34 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
Chris@16 35 using spirit::eol;
Chris@16 36 #endif
Chris@16 37 using spirit::eol_type;
Chris@16 38
Chris@16 39 struct eol_parser : primitive_parser<eol_parser>
Chris@16 40 {
Chris@16 41 template <typename Context, typename Iterator>
Chris@16 42 struct attribute
Chris@16 43 {
Chris@16 44 typedef unused_type type;
Chris@16 45 };
Chris@16 46
Chris@16 47 template <typename Iterator, typename Context
Chris@16 48 , typename Skipper, typename Attribute>
Chris@16 49 bool parse(Iterator& first, Iterator const& last
Chris@16 50 , Context& /*context*/, Skipper const& skipper
Chris@16 51 , Attribute& /*attr*/) const
Chris@16 52 {
Chris@16 53 qi::skip_over(first, last, skipper);
Chris@16 54
Chris@16 55 Iterator it = first;
Chris@16 56 bool matched = false;
Chris@16 57 if (it != last && *it == '\r') // CR
Chris@16 58 {
Chris@16 59 matched = true;
Chris@16 60 ++it;
Chris@16 61 }
Chris@16 62 if (it != last && *it == '\n') // LF
Chris@16 63 {
Chris@16 64 matched = true;
Chris@16 65 ++it;
Chris@16 66 }
Chris@16 67
Chris@16 68 if (!matched)
Chris@16 69 return false;
Chris@16 70
Chris@16 71 first = it;
Chris@16 72 return true;
Chris@16 73 }
Chris@16 74
Chris@16 75 template <typename Context>
Chris@16 76 info what(Context& /*context*/) const
Chris@16 77 {
Chris@16 78 return info("eol");
Chris@16 79 }
Chris@16 80 };
Chris@16 81
Chris@16 82 ///////////////////////////////////////////////////////////////////////////
Chris@16 83 // Parser generators: make_xxx function (objects)
Chris@16 84 ///////////////////////////////////////////////////////////////////////////
Chris@16 85 template <typename Modifiers>
Chris@16 86 struct make_primitive<tag::eol, Modifiers>
Chris@16 87 {
Chris@16 88 typedef eol_parser result_type;
Chris@16 89 result_type operator()(unused_type, unused_type) const
Chris@16 90 {
Chris@16 91 return result_type();
Chris@16 92 }
Chris@16 93 };
Chris@16 94 }}}
Chris@16 95
Chris@16 96 #endif
Chris@16 97
Chris@16 98