Chris@102
|
1 /*=============================================================================
|
Chris@102
|
2 Copyright (c) 2001-2014 Joel de Guzman
|
Chris@102
|
3 Copyright (c) 2001-2011 Hartmut Kaiser
|
Chris@102
|
4
|
Chris@102
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@102
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
7 ==============================================================================*/
|
Chris@102
|
8 #if !defined(BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM)
|
Chris@102
|
9 #define BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM
|
Chris@102
|
10
|
Chris@102
|
11 #if defined(_MSC_VER)
|
Chris@102
|
12 #pragma once
|
Chris@102
|
13 #endif
|
Chris@102
|
14
|
Chris@102
|
15 #include <boost/spirit/home/x3/core/skip_over.hpp>
|
Chris@102
|
16 #include <boost/spirit/home/x3/core/parser.hpp>
|
Chris@102
|
17 #include <boost/spirit/home/x3/support/unused.hpp>
|
Chris@102
|
18
|
Chris@102
|
19 namespace boost { namespace spirit { namespace x3
|
Chris@102
|
20 {
|
Chris@102
|
21 struct eol_parser : parser<eol_parser>
|
Chris@102
|
22 {
|
Chris@102
|
23 typedef unused_type attribute_type;
|
Chris@102
|
24 static bool const has_attribute = false;
|
Chris@102
|
25
|
Chris@102
|
26 template <typename Iterator, typename Context, typename Attribute>
|
Chris@102
|
27 bool parse(Iterator& first, Iterator const& last
|
Chris@102
|
28 , Context const& context, unused_type, Attribute& /*attr*/) const
|
Chris@102
|
29 {
|
Chris@102
|
30 x3::skip_over(first, last, context);
|
Chris@102
|
31 Iterator iter = first;
|
Chris@102
|
32 bool matched = false;
|
Chris@102
|
33 if (iter != last && *iter == '\r') // CR
|
Chris@102
|
34 {
|
Chris@102
|
35 matched = true;
|
Chris@102
|
36 ++iter;
|
Chris@102
|
37 }
|
Chris@102
|
38 if (iter != last && *iter == '\n') // LF
|
Chris@102
|
39 {
|
Chris@102
|
40 matched = true;
|
Chris@102
|
41 ++iter;
|
Chris@102
|
42 }
|
Chris@102
|
43
|
Chris@102
|
44 if (matched) first = iter;
|
Chris@102
|
45 return matched;
|
Chris@102
|
46 }
|
Chris@102
|
47 };
|
Chris@102
|
48
|
Chris@102
|
49 template<>
|
Chris@102
|
50 struct get_info<eol_parser>
|
Chris@102
|
51 {
|
Chris@102
|
52 typedef std::string result_type;
|
Chris@102
|
53 result_type operator()(eol_parser const &) const { return "eol"; }
|
Chris@102
|
54 };
|
Chris@102
|
55
|
Chris@102
|
56 eol_parser const eol = eol_parser();
|
Chris@102
|
57 }}}
|
Chris@102
|
58
|
Chris@102
|
59 #endif
|