diff options
Diffstat (limited to 'MoonParser/pegtl/normal.hpp')
-rw-r--r-- | MoonParser/pegtl/normal.hpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/MoonParser/pegtl/normal.hpp b/MoonParser/pegtl/normal.hpp new file mode 100644 index 0000000..d5752d1 --- /dev/null +++ b/MoonParser/pegtl/normal.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_NORMAL_HPP | ||
5 | #define TAOCPP_PEGTL_INCLUDE_NORMAL_HPP | ||
6 | |||
7 | #include "apply_mode.hpp" | ||
8 | #include "config.hpp" | ||
9 | #include "nothing.hpp" | ||
10 | #include "parse_error.hpp" | ||
11 | #include "rewind_mode.hpp" | ||
12 | |||
13 | #include "internal/demangle.hpp" | ||
14 | #include "internal/dusel_mode.hpp" | ||
15 | #include "internal/duseltronik.hpp" | ||
16 | #include "internal/has_apply0.hpp" | ||
17 | #include "internal/skip_control.hpp" | ||
18 | |||
19 | namespace tao | ||
20 | { | ||
21 | namespace TAOCPP_PEGTL_NAMESPACE | ||
22 | { | ||
23 | template< typename Rule > | ||
24 | struct normal | ||
25 | { | ||
26 | template< typename Input, typename... States > | ||
27 | static void start( const Input&, States&&... ) noexcept | ||
28 | { | ||
29 | } | ||
30 | |||
31 | template< typename Input, typename... States > | ||
32 | static void success( const Input&, States&&... ) noexcept | ||
33 | { | ||
34 | } | ||
35 | |||
36 | template< typename Input, typename... States > | ||
37 | static void failure( const Input&, States&&... ) noexcept | ||
38 | { | ||
39 | } | ||
40 | |||
41 | template< typename Input, typename... States > | ||
42 | static void raise( const Input& in, States&&... ) | ||
43 | { | ||
44 | throw parse_error( "parse error matching " + internal::demangle< Rule >(), in ); | ||
45 | } | ||
46 | |||
47 | template< template< typename... > class Action, typename Input, typename... States > | ||
48 | static void apply0( const Input&, States&&... st ) | ||
49 | { | ||
50 | Action< Rule >::apply0( st... ); | ||
51 | } | ||
52 | |||
53 | template< template< typename... > class Action, typename Iterator, typename Input, typename... States > | ||
54 | static void apply( const Iterator& begin, const Input& in, States&&... st ) | ||
55 | { | ||
56 | using action_t = typename Input::action_t; | ||
57 | const action_t action_input( begin, in ); | ||
58 | Action< Rule >::apply( action_input, st... ); | ||
59 | } | ||
60 | |||
61 | template< apply_mode A, | ||
62 | rewind_mode M, | ||
63 | template< typename... > class Action, | ||
64 | template< typename... > class Control, | ||
65 | typename Input, | ||
66 | typename... States > | ||
67 | static bool match( Input& in, States&&... st ) | ||
68 | { | ||
69 | constexpr bool use_control = !internal::skip_control< Rule >::value; | ||
70 | constexpr bool use_action = use_control && ( A == apply_mode::ACTION ) && ( !is_nothing< Action, Rule >::value ); | ||
71 | constexpr bool use_apply0 = use_action && internal::has_apply0< Action< Rule >, internal::type_list< States... > >::value; | ||
72 | constexpr dusel_mode mode = static_cast< dusel_mode >( static_cast< char >( use_control ) + static_cast< char >( use_action ) + static_cast< char >( use_apply0 ) ); | ||
73 | return internal::duseltronik< Rule, A, M, Action, Control, mode >::match( in, st... ); | ||
74 | } | ||
75 | }; | ||
76 | |||
77 | } // namespace TAOCPP_PEGTL_NAMESPACE | ||
78 | |||
79 | } // namespace tao | ||
80 | |||
81 | #endif | ||