Chris@16: /*============================================================================= Chris@16: Copyright (c) 2001-2011 Hartmut Kaiser Chris@16: Copyright (c) 2001-2011 Joel de Guzman Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: ==============================================================================*/ Chris@16: #if !defined(BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM) Chris@16: #define BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM Chris@16: Chris@16: #if defined(_MSC_VER) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace spirit Chris@16: { Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Enablers Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template <> Chris@16: struct use_terminal // enables eol Chris@16: : mpl::true_ {}; Chris@16: }} Chris@16: Chris@16: namespace boost { namespace spirit { namespace qi Chris@16: { Chris@16: #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS Chris@16: using spirit::eol; Chris@16: #endif Chris@16: using spirit::eol_type; Chris@16: Chris@16: struct eol_parser : primitive_parser Chris@16: { Chris@16: template Chris@16: struct attribute Chris@16: { Chris@16: typedef unused_type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: bool parse(Iterator& first, Iterator const& last Chris@16: , Context& /*context*/, Skipper const& skipper Chris@16: , Attribute& /*attr*/) const Chris@16: { Chris@16: qi::skip_over(first, last, skipper); Chris@16: Chris@16: Iterator it = first; Chris@16: bool matched = false; Chris@16: if (it != last && *it == '\r') // CR Chris@16: { Chris@16: matched = true; Chris@16: ++it; Chris@16: } Chris@16: if (it != last && *it == '\n') // LF Chris@16: { Chris@16: matched = true; Chris@16: ++it; Chris@16: } Chris@16: Chris@16: if (!matched) Chris@16: return false; Chris@16: Chris@16: first = it; Chris@16: return true; Chris@16: } Chris@16: Chris@16: template Chris@16: info what(Context& /*context*/) const Chris@16: { Chris@16: return info("eol"); Chris@16: } Chris@16: }; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: // Parser generators: make_xxx function (objects) Chris@16: /////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct make_primitive Chris@16: { Chris@16: typedef eol_parser result_type; Chris@16: result_type operator()(unused_type, unused_type) const Chris@16: { Chris@16: return result_type(); Chris@16: } Chris@16: }; Chris@16: }}} Chris@16: Chris@16: #endif Chris@16: Chris@16: