1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 Copyright (c) 2001-2011 Joel de Guzman
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM)
9 #define BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM
15 #include <boost/mpl/bool.hpp>
16 #include <boost/spirit/home/qi/domain.hpp>
17 #include <boost/spirit/home/qi/parser.hpp>
18 #include <boost/spirit/home/qi/meta_compiler.hpp>
19 #include <boost/spirit/home/qi/skip_over.hpp>
20 #include <boost/spirit/home/support/common_terminals.hpp>
22 namespace boost { namespace spirit
24 ///////////////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////////////
28 struct use_terminal<qi::domain, tag::eol> // enables eol
32 namespace boost { namespace spirit { namespace qi
34 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
37 using spirit::eol_type;
39 struct eol_parser : primitive_parser<eol_parser>
41 template <typename Context, typename Iterator>
44 typedef unused_type type;
47 template <typename Iterator, typename Context
48 , typename Skipper, typename Attribute>
49 bool parse(Iterator& first, Iterator const& last
50 , Context& /*context*/, Skipper const& skipper
51 , Attribute& /*attr*/) const
53 qi::skip_over(first, last, skipper);
57 if (it != last && *it == '\r') // CR
62 if (it != last && *it == '\n') // LF
75 template <typename Context>
76 info what(Context& /*context*/) const
82 ///////////////////////////////////////////////////////////////////////////
83 // Parser generators: make_xxx function (objects)
84 ///////////////////////////////////////////////////////////////////////////
85 template <typename Modifiers>
86 struct make_primitive<tag::eol, Modifiers>
88 typedef eol_parser result_type;
89 result_type operator()(unused_type, unused_type) const