1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_MINUS_HPP
#define TAOCPP_PEGTL_INCLUDE_INTERNAL_MINUS_HPP
#include "../config.hpp"
#include "skip_control.hpp"
#include "../apply_mode.hpp"
#include "../memory_input.hpp"
#include "../rewind_mode.hpp"
namespace tao
{
namespace TAOCPP_PEGTL_NAMESPACE
{
namespace internal
{
inline const char* source_pointer( const char* source ) noexcept
{
return source;
}
inline const char* source_pointer( const std::string& source ) noexcept
{
return source.c_str();
}
template< typename R, typename S >
struct minus
{
using analyze_t = typename R::analyze_t; // NOTE: S is currently ignored for analyze().
template< apply_mode A,
rewind_mode,
template< typename... > class Action,
template< typename... > class Control,
typename Input,
typename... States >
static bool match( Input& in, States&&... st )
{
auto m = in.template mark< rewind_mode::REQUIRED >();
if( !Control< R >::template match< A, rewind_mode::ACTIVE, Action, Control >( in, st... ) ) {
return false;
}
memory_input< tracking_mode::LAZY, typename Input::eol_t, const char* > i2( m.iterator(), in.current(), source_pointer( in.source() ) );
if( !Control< S >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( i2, st... ) ) {
return m( true );
}
return m( !i2.empty() );
}
};
template< typename R, typename S >
struct skip_control< minus< R, S > > : std::true_type
{
};
} // namespace internal
} // namespace TAOCPP_PEGTL_NAMESPACE
} // namespace tao
#endif
|