1 // Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey
2 // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3 
4 #ifndef TAO_PEGTL_INTERNAL_ANY_HPP
5 #define TAO_PEGTL_INTERNAL_ANY_HPP
6 
7 #include "../config.hpp"
8 
9 #include "peek_char.hpp"
10 #include "skip_control.hpp"
11 
12 #include "../analysis/generic.hpp"
13 
14 namespace tao
15 {
16    namespace TAO_PEGTL_NAMESPACE
17    {
18       namespace internal
19       {
20          template< typename Peek >
21          struct any;
22 
23          template<>
24          struct any< peek_char >
25          {
26             using analyze_t = analysis::generic< analysis::rule_type::any >;
27 
28             template< typename Input >
matchtao::TAO_PEGTL_NAMESPACE::internal::any29             static bool match( Input& in ) noexcept( noexcept( in.empty() ) )
30             {
31                if( !in.empty() ) {
32                   in.bump();
33                   return true;
34                }
35                return false;
36             }
37          };
38 
39          template< typename Peek >
40          struct any
41          {
42             using analyze_t = analysis::generic< analysis::rule_type::any >;
43 
44             template< typename Input >
matchtao::TAO_PEGTL_NAMESPACE::internal::any45             static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) )
46             {
47                if( const auto t = Peek::peek( in ) ) {
48                   in.bump( t.size );
49                   return true;
50                }
51                return false;
52             }
53          };
54 
55          template< typename Peek >
56          struct skip_control< any< Peek > > : std::true_type
57          {
58          };
59 
60       }  // namespace internal
61 
62    }  // namespace TAO_PEGTL_NAMESPACE
63 
64 }  // namespace tao
65 
66 #endif
67