aboutsummaryrefslogtreecommitdiff
path: root/MoonParser/pegtl/internal/one.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'MoonParser/pegtl/internal/one.hpp')
-rw-r--r--MoonParser/pegtl/internal/one.hpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/one.hpp b/MoonParser/pegtl/internal/one.hpp
new file mode 100644
index 0000000..a3941eb
--- /dev/null
+++ b/MoonParser/pegtl/internal/one.hpp
@@ -0,0 +1,81 @@
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_ONE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ONE_HPP
6
7#include <algorithm>
8#include <utility>
9
10#include "../config.hpp"
11
12#include "bump_help.hpp"
13#include "result_on_found.hpp"
14#include "skip_control.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename Char >
25 bool contains( const Char c, const std::initializer_list< Char >& l ) noexcept
26 {
27 return std::find( l.begin(), l.end(), c ) != l.end();
28 }
29
30 template< result_on_found R, typename Peek, typename Peek::data_t... Cs >
31 struct one
32 {
33 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
34
35 template< typename Input >
36 static bool match( Input& in )
37 {
38 if( !in.empty() ) {
39 if( const auto t = Peek::peek( in ) ) {
40 if( contains( t.data, { Cs... } ) == bool( R ) ) {
41 bump_help< R, Input, typename Peek::data_t, Cs... >( in, t.size );
42 return true;
43 }
44 }
45 }
46 return false;
47 }
48 };
49
50 template< result_on_found R, typename Peek, typename Peek::data_t C >
51 struct one< R, Peek, C >
52 {
53 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
54
55 template< typename Input >
56 static bool match( Input& in )
57 {
58 if( !in.empty() ) {
59 if( const auto t = Peek::peek( in ) ) {
60 if( ( t.data == C ) == bool( R ) ) {
61 bump_help< R, Input, typename Peek::data_t, C >( in, t.size );
62 return true;
63 }
64 }
65 }
66 return false;
67 }
68 };
69
70 template< result_on_found R, typename Peek, typename Peek::data_t... Cs >
71 struct skip_control< one< R, Peek, Cs... > > : std::true_type
72 {
73 };
74
75 } // namespace internal
76
77 } // namespace TAOCPP_PEGTL_NAMESPACE
78
79} // namespace tao
80
81#endif