diff options
Diffstat (limited to 'MoonParser/pegtl/internal/minus.hpp')
-rw-r--r-- | MoonParser/pegtl/internal/minus.hpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/minus.hpp b/MoonParser/pegtl/internal/minus.hpp new file mode 100644 index 0000000..88242e5 --- /dev/null +++ b/MoonParser/pegtl/internal/minus.hpp | |||
@@ -0,0 +1,69 @@ | |||
1 | // Copyright (c) 2016-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_MINUS_HPP | ||
5 | #define TAOCPP_PEGTL_INCLUDE_INTERNAL_MINUS_HPP | ||
6 | |||
7 | #include "../config.hpp" | ||
8 | |||
9 | #include "skip_control.hpp" | ||
10 | |||
11 | #include "../apply_mode.hpp" | ||
12 | #include "../memory_input.hpp" | ||
13 | #include "../rewind_mode.hpp" | ||
14 | |||
15 | namespace tao | ||
16 | { | ||
17 | namespace TAOCPP_PEGTL_NAMESPACE | ||
18 | { | ||
19 | namespace internal | ||
20 | { | ||
21 | inline const char* source_pointer( const char* source ) noexcept | ||
22 | { | ||
23 | return source; | ||
24 | } | ||
25 | |||
26 | inline const char* source_pointer( const std::string& source ) noexcept | ||
27 | { | ||
28 | return source.c_str(); | ||
29 | } | ||
30 | |||
31 | template< typename R, typename S > | ||
32 | struct minus | ||
33 | { | ||
34 | using analyze_t = typename R::analyze_t; // NOTE: S is currently ignored for analyze(). | ||
35 | |||
36 | template< apply_mode A, | ||
37 | rewind_mode, | ||
38 | template< typename... > class Action, | ||
39 | template< typename... > class Control, | ||
40 | typename Input, | ||
41 | typename... States > | ||
42 | static bool match( Input& in, States&&... st ) | ||
43 | { | ||
44 | auto m = in.template mark< rewind_mode::REQUIRED >(); | ||
45 | |||
46 | if( !Control< R >::template match< A, rewind_mode::ACTIVE, Action, Control >( in, st... ) ) { | ||
47 | return false; | ||
48 | } | ||
49 | memory_input< tracking_mode::LAZY, typename Input::eol_t, const char* > i2( m.iterator(), in.current(), source_pointer( in.source() ) ); | ||
50 | |||
51 | if( !Control< S >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( i2, st... ) ) { | ||
52 | return m( true ); | ||
53 | } | ||
54 | return m( !i2.empty() ); | ||
55 | } | ||
56 | }; | ||
57 | |||
58 | template< typename R, typename S > | ||
59 | struct skip_control< minus< R, S > > : std::true_type | ||
60 | { | ||
61 | }; | ||
62 | |||
63 | } // namespace internal | ||
64 | |||
65 | } // namespace TAOCPP_PEGTL_NAMESPACE | ||
66 | |||
67 | } // namespace tao | ||
68 | |||
69 | #endif | ||