diff options
Diffstat (limited to 'MoonParser/pegtl/internal/state.hpp')
-rw-r--r-- | MoonParser/pegtl/internal/state.hpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/state.hpp b/MoonParser/pegtl/internal/state.hpp new file mode 100644 index 0000000..7fbe921 --- /dev/null +++ b/MoonParser/pegtl/internal/state.hpp | |||
@@ -0,0 +1,83 @@ | |||
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_STATE_HPP | ||
5 | #define TAOCPP_PEGTL_INCLUDE_INTERNAL_STATE_HPP | ||
6 | |||
7 | #include "../config.hpp" | ||
8 | |||
9 | #include "duseltronik.hpp" | ||
10 | #include "seq.hpp" | ||
11 | #include "skip_control.hpp" | ||
12 | |||
13 | #include "../apply_mode.hpp" | ||
14 | #include "../rewind_mode.hpp" | ||
15 | |||
16 | #include "../analysis/generic.hpp" | ||
17 | |||
18 | namespace tao | ||
19 | { | ||
20 | namespace TAOCPP_PEGTL_NAMESPACE | ||
21 | { | ||
22 | namespace internal | ||
23 | { | ||
24 | template< typename State, typename... Rules > | ||
25 | struct state | ||
26 | { | ||
27 | using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; | ||
28 | |||
29 | template< apply_mode A, | ||
30 | rewind_mode M, | ||
31 | template< typename... > class Action, | ||
32 | template< typename... > class Control, | ||
33 | typename Input, | ||
34 | typename... States > | ||
35 | static auto success( State& s, const Input& in, States&&... st ) -> decltype( s.template success< A, M, Action, Control >( in, st... ), void() ) | ||
36 | { | ||
37 | s.template success< A, M, Action, Control >( in, st... ); | ||
38 | } | ||
39 | |||
40 | // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. | ||
41 | |||
42 | template< apply_mode, | ||
43 | rewind_mode, | ||
44 | template< typename... > class Action, | ||
45 | template< typename... > class Control, | ||
46 | typename Input, | ||
47 | typename... States, | ||
48 | int = 0 > | ||
49 | static auto success( State& s, const Input& in, States&&... st ) -> decltype( s.success( in, st... ), void() ) | ||
50 | { | ||
51 | s.success( in, st... ); | ||
52 | } | ||
53 | |||
54 | template< apply_mode A, | ||
55 | rewind_mode M, | ||
56 | template< typename... > class Action, | ||
57 | template< typename... > class Control, | ||
58 | typename Input, | ||
59 | typename... States > | ||
60 | static bool match( Input& in, States&&... st ) | ||
61 | { | ||
62 | State s( const_cast< const Input& >( in ), st... ); | ||
63 | |||
64 | if( duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, s ) ) { | ||
65 | success< A, M, Action, Control >( s, in, st... ); | ||
66 | return true; | ||
67 | } | ||
68 | return false; | ||
69 | } | ||
70 | }; | ||
71 | |||
72 | template< typename State, typename... Rules > | ||
73 | struct skip_control< state< State, Rules... > > : std::true_type | ||
74 | { | ||
75 | }; | ||
76 | |||
77 | } // namespace internal | ||
78 | |||
79 | } // namespace TAOCPP_PEGTL_NAMESPACE | ||
80 | |||
81 | } // namespace tao | ||
82 | |||
83 | #endif | ||