diff options
Diffstat (limited to 'MoonParser/pegtl/internal/string.hpp')
-rw-r--r-- | MoonParser/pegtl/internal/string.hpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/string.hpp b/MoonParser/pegtl/internal/string.hpp new file mode 100644 index 0000000..75245e3 --- /dev/null +++ b/MoonParser/pegtl/internal/string.hpp | |||
@@ -0,0 +1,68 @@ | |||
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_STRING_HPP | ||
5 | #define TAOCPP_PEGTL_INCLUDE_INTERNAL_STRING_HPP | ||
6 | |||
7 | #include <cstring> | ||
8 | #include <utility> | ||
9 | |||
10 | #include "../config.hpp" | ||
11 | |||
12 | #include "bump_help.hpp" | ||
13 | #include "result_on_found.hpp" | ||
14 | #include "skip_control.hpp" | ||
15 | #include "trivial.hpp" | ||
16 | |||
17 | #include "../analysis/counted.hpp" | ||
18 | |||
19 | namespace tao | ||
20 | { | ||
21 | namespace TAOCPP_PEGTL_NAMESPACE | ||
22 | { | ||
23 | namespace internal | ||
24 | { | ||
25 | inline bool unsafe_equals( const char* s, const std::initializer_list< char >& l ) noexcept | ||
26 | { | ||
27 | return std::memcmp( s, &*l.begin(), l.size() ) == 0; | ||
28 | } | ||
29 | |||
30 | template< char... Cs > | ||
31 | struct string; | ||
32 | |||
33 | template<> | ||
34 | struct string<> | ||
35 | : trivial< true > | ||
36 | { | ||
37 | }; | ||
38 | |||
39 | template< char... Cs > | ||
40 | struct string | ||
41 | { | ||
42 | using analyze_t = analysis::counted< analysis::rule_type::ANY, sizeof...( Cs ) >; | ||
43 | |||
44 | template< typename Input > | ||
45 | static bool match( Input& in ) | ||
46 | { | ||
47 | if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { | ||
48 | if( unsafe_equals( in.current(), { Cs... } ) ) { | ||
49 | bump_help< result_on_found::SUCCESS, Input, char, Cs... >( in, sizeof...( Cs ) ); | ||
50 | return true; | ||
51 | } | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
55 | }; | ||
56 | |||
57 | template< char... Cs > | ||
58 | struct skip_control< string< Cs... > > : std::true_type | ||
59 | { | ||
60 | }; | ||
61 | |||
62 | } // namespace internal | ||
63 | |||
64 | } // namespace TAOCPP_PEGTL_NAMESPACE | ||
65 | |||
66 | } // namespace tao | ||
67 | |||
68 | #endif | ||