aboutsummaryrefslogtreecommitdiff
path: root/MoonParser/pegtl/internal/sor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'MoonParser/pegtl/internal/sor.hpp')
-rw-r--r--MoonParser/pegtl/internal/sor.hpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/sor.hpp b/MoonParser/pegtl/internal/sor.hpp
new file mode 100644
index 0000000..6d85a5c
--- /dev/null
+++ b/MoonParser/pegtl/internal/sor.hpp
@@ -0,0 +1,74 @@
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_SOR_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_SOR_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../apply_mode.hpp"
12#include "../rewind_mode.hpp"
13
14#include "../analysis/generic.hpp"
15
16#include "integer_sequence.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename... Rules >
25 struct sor;
26
27 template<>
28 struct sor<>
29 : trivial< false >
30 {
31 };
32
33 template< typename... Rules >
34 struct sor
35 : sor< index_sequence_for< Rules... >, Rules... >
36 {
37 };
38
39 template< std::size_t... Indices, typename... Rules >
40 struct sor< index_sequence< Indices... >, Rules... >
41 {
42 using analyze_t = analysis::generic< analysis::rule_type::SOR, Rules... >;
43
44 template< apply_mode A,
45 rewind_mode M,
46 template< typename... > class Action,
47 template< typename... > class Control,
48 typename Input,
49 typename... States >
50 static bool match( Input& in, States&&... st )
51 {
52#ifdef __cpp_fold_expressions
53 return ( Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::REQUIRED, Action, Control > ( in, st... ) || ... );
54#else
55 bool result = false;
56 using swallow = bool[];
57 (void)swallow{ result = result || Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::REQUIRED, Action, Control > ( in, st... )... };
58 return result;
59#endif
60 }
61 };
62
63 template< typename... Rules >
64 struct skip_control< sor< Rules... > > : std::true_type
65 {
66 };
67
68 } // namespace internal
69
70 } // namespace TAOCPP_PEGTL_NAMESPACE
71
72} // namespace tao
73
74#endif