Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:34

0001 /*=============================================================================
0002     Copyright (c) 2001-2014 Joel de Guzman
0003     Copyright (c) 2001-2011 Hartmut Kaiser
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #if !defined(BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM)
0009 #define BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM
0010 
0011 #include <boost/spirit/home/x3/core/skip_over.hpp>
0012 #include <boost/spirit/home/x3/core/parser.hpp>
0013 #include <boost/spirit/home/x3/support/unused.hpp>
0014 
0015 namespace boost { namespace spirit { namespace x3
0016 {
0017     struct eol_parser : parser<eol_parser>
0018     {
0019         typedef unused_type attribute_type;
0020         static bool const has_attribute = false;
0021 
0022         template <typename Iterator, typename Context, typename Attribute>
0023         bool parse(Iterator& first, Iterator const& last
0024          , Context const& context, unused_type, Attribute& /*attr*/) const
0025         {
0026             x3::skip_over(first, last, context);
0027             Iterator iter = first;
0028             bool matched = false;
0029             if (iter != last && *iter == '\r')  // CR
0030             {
0031                 matched = true;
0032                 ++iter;
0033             }
0034             if (iter != last && *iter == '\n')  // LF
0035             {
0036                 matched = true;
0037                 ++iter;
0038             }
0039 
0040             if (matched) first = iter;
0041             return matched;
0042         }
0043     };
0044 
0045     template<>
0046     struct get_info<eol_parser>
0047     {
0048         typedef std::string result_type;
0049         result_type operator()(eol_parser const &) const { return "eol"; }
0050     };
0051 
0052     constexpr auto eol = eol_parser{};
0053 }}}
0054 
0055 #endif