aboutsummaryrefslogtreecommitdiff
path: root/MoonParser/pegtl/internal/opt.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'MoonParser/pegtl/internal/opt.hpp')
-rw-r--r--MoonParser/pegtl/internal/opt.hpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/opt.hpp b/MoonParser/pegtl/internal/opt.hpp
new file mode 100644
index 0000000..a897443
--- /dev/null
+++ b/MoonParser/pegtl/internal/opt.hpp
@@ -0,0 +1,67 @@
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_OPT_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_OPT_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "duseltronik.hpp"
12#include "seq.hpp"
13#include "skip_control.hpp"
14#include "trivial.hpp"
15
16#include "../apply_mode.hpp"
17#include "../rewind_mode.hpp"
18
19#include "../analysis/generic.hpp"
20
21namespace tao
22{
23 namespace TAOCPP_PEGTL_NAMESPACE
24 {
25 namespace internal
26 {
27 template< typename... Rules >
28 struct opt;
29
30 template<>
31 struct opt<>
32 : trivial< true >
33 {
34 };
35
36 template< typename... Rules >
37 struct opt
38 {
39 using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >;
40
41 template< apply_mode A,
42 rewind_mode,
43 template< typename... > class Action,
44 template< typename... > class Control,
45 typename Input,
46 typename... States >
47 static bool match( Input& in, States&&... st )
48 {
49 if( !in.empty() ) {
50 duseltronik< seq< Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... );
51 }
52 return true;
53 }
54 };
55
56 template< typename... Rules >
57 struct skip_control< opt< Rules... > > : std::true_type
58 {
59 };
60
61 } // namespace internal
62
63 } // namespace TAOCPP_PEGTL_NAMESPACE
64
65} // namespace tao
66
67#endif