diff options
Diffstat (limited to 'MoonParser/pegtl/internal/apply.hpp')
-rw-r--r-- | MoonParser/pegtl/internal/apply.hpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/apply.hpp b/MoonParser/pegtl/internal/apply.hpp new file mode 100644 index 0000000..4e70255 --- /dev/null +++ b/MoonParser/pegtl/internal/apply.hpp | |||
@@ -0,0 +1,79 @@ | |||
1 | // Copyright (c) 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_APPLY_HPP | ||
5 | #define TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY_HPP | ||
6 | |||
7 | #include "../config.hpp" | ||
8 | |||
9 | #include "skip_control.hpp" | ||
10 | #include "trivial.hpp" | ||
11 | |||
12 | #include "../analysis/counted.hpp" | ||
13 | |||
14 | namespace tao | ||
15 | { | ||
16 | namespace TAOCPP_PEGTL_NAMESPACE | ||
17 | { | ||
18 | namespace internal | ||
19 | { | ||
20 | template< apply_mode A, typename... Actions > | ||
21 | struct apply_impl; | ||
22 | |||
23 | template< typename... Actions > | ||
24 | struct apply_impl< apply_mode::ACTION, Actions... > | ||
25 | { | ||
26 | template< typename Input, typename... States > | ||
27 | static bool match( Input& in, States&&... st ) | ||
28 | { | ||
29 | using action_t = typename Input::action_t; | ||
30 | const action_t i2( in.iterator(), in ); // No data -- range is from begin to begin. | ||
31 | #ifdef __cpp_fold_expressions | ||
32 | ( Actions::apply( i2, st... ), ... ); | ||
33 | #else | ||
34 | using swallow = bool[]; | ||
35 | (void)swallow{ ( Actions::apply( i2, st... ), true )..., true }; | ||
36 | #endif | ||
37 | return true; | ||
38 | } | ||
39 | }; | ||
40 | |||
41 | template< typename... Actions > | ||
42 | struct apply_impl< apply_mode::NOTHING, Actions... > | ||
43 | { | ||
44 | template< typename Input, typename... States > | ||
45 | static bool match( Input&, States&&... ) | ||
46 | { | ||
47 | return true; | ||
48 | } | ||
49 | }; | ||
50 | |||
51 | template< typename... Actions > | ||
52 | struct apply | ||
53 | { | ||
54 | using analyze_t = analysis::counted< analysis::rule_type::ANY, 0 >; | ||
55 | |||
56 | template< apply_mode A, | ||
57 | rewind_mode M, | ||
58 | template< typename... > class Action, | ||
59 | template< typename... > class Control, | ||
60 | typename Input, | ||
61 | typename... States > | ||
62 | static bool match( Input& in, States&&... st ) | ||
63 | { | ||
64 | return apply_impl< A, Actions... >::match( in, st... ); | ||
65 | } | ||
66 | }; | ||
67 | |||
68 | template< typename... Actions > | ||
69 | struct skip_control< apply< Actions... > > : std::true_type | ||
70 | { | ||
71 | }; | ||
72 | |||
73 | } // namespace internal | ||
74 | |||
75 | } // namespace TAOCPP_PEGTL_NAMESPACE | ||
76 | |||
77 | } // namespace tao | ||
78 | |||
79 | #endif | ||