aboutsummaryrefslogtreecommitdiff
path: root/MoonParser/pegtl/internal/ranges.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'MoonParser/pegtl/internal/ranges.hpp')
-rw-r--r--MoonParser/pegtl/internal/ranges.hpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/ranges.hpp b/MoonParser/pegtl/internal/ranges.hpp
new file mode 100644
index 0000000..e3ee65c
--- /dev/null
+++ b/MoonParser/pegtl/internal/ranges.hpp
@@ -0,0 +1,102 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGES_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGES_HPP
6
7#include "../config.hpp"
8
9#include "bump_help.hpp"
10#include "range.hpp"
11#include "skip_control.hpp"
12
13#include "../analysis/generic.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 template< int Eol, typename Char, Char... Cs >
22 struct ranges_impl;
23
24 template< int Eol, typename Char >
25 struct ranges_impl< Eol, Char >
26 {
27 static constexpr bool can_match_eol = false;
28
29 static bool match( const Char ) noexcept
30 {
31 return false;
32 }
33 };
34
35 template< int Eol, typename Char, Char Eq >
36 struct ranges_impl< Eol, Char, Eq >
37 {
38 static constexpr bool can_match_eol = ( Eq == Eol );
39
40 static bool match( const Char c ) noexcept
41 {
42 return c == Eq;
43 }
44 };
45
46 template< int Eol, typename Char, Char Lo, Char Hi, Char... Cs >
47 struct ranges_impl< Eol, Char, Lo, Hi, Cs... >
48 {
49 static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::can_match_eol );
50
51 static bool match( const Char c ) noexcept
52 {
53 return ( ( Lo <= c ) && ( c <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::match( c );
54 }
55 };
56
57 template< typename Peek, typename Peek::data_t... Cs >
58 struct ranges
59 {
60 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
61
62 template< int Eol >
63 struct can_match_eol
64 {
65 static constexpr bool value = ranges_impl< Eol, typename Peek::data_t, Cs... >::can_match_eol;
66 };
67
68 template< typename Input >
69 static bool match( Input& in )
70 {
71 using eol_t = typename Input::eol_t;
72
73 if( !in.empty() ) {
74 if( const auto t = Peek::peek( in ) ) {
75 if( ranges_impl< eol_t::ch, typename Peek::data_t, Cs... >::match( t.data ) ) {
76 bump_impl< can_match_eol< eol_t::ch >::value >::bump( in, t.size );
77 return true;
78 }
79 }
80 }
81 return false;
82 }
83 };
84
85 template< typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi >
86 struct ranges< Peek, Lo, Hi >
87 : range< result_on_found::SUCCESS, Peek, Lo, Hi >
88 {
89 };
90
91 template< typename Peek, typename Peek::data_t... Cs >
92 struct skip_control< ranges< Peek, Cs... > > : std::true_type
93 {
94 };
95
96 } // namespace internal
97
98 } // namespace TAOCPP_PEGTL_NAMESPACE
99
100} // namespace tao
101
102#endif