1 // Copyright (c) 2014-2018 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_PLUS_HPP
5 #define TAO_PEGTL_INTERNAL_PLUS_HPP
6 
7 #include <type_traits>
8 
9 #include "../config.hpp"
10 
11 #include "duseltronik.hpp"
12 #include "opt.hpp"
13 #include "seq.hpp"
14 #include "skip_control.hpp"
15 #include "star.hpp"
16 
17 #include "../apply_mode.hpp"
18 #include "../rewind_mode.hpp"
19 
20 #include "../analysis/generic.hpp"
21 
22 namespace tao
23 {
24    namespace TAO_PEGTL_NAMESPACE
25    {
26       namespace internal
27       {
28          // While plus<> could easily be implemented with
29          // seq< Rule, Rules ..., star< Rule, Rules ... > > we
30          // provide an explicit implementation to optimise away
31          // the otherwise created input mark.
32 
33          template< typename Rule, typename... Rules >
34          struct plus
35          {
36             using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rule, Rules..., opt< plus > >;
37 
38             template< apply_mode A,
39                       rewind_mode M,
40                       template< typename... > class Action,
41                       template< typename... > class Control,
42                       typename Input,
43                       typename... States >
matchtao::TAO_PEGTL_NAMESPACE::internal::plus44             static bool match( Input& in, States&&... st )
45             {
46                return seq< Rule, Rules... >::template match< A, M, Action, Control >( in, st... ) && star< Rule, Rules... >::template match< A, M, Action, Control >( in, st... );
47             }
48          };
49 
50          template< typename Rule, typename... Rules >
51          struct skip_control< plus< Rule, Rules... > > : std::true_type
52          {
53          };
54 
55       }  // namespace internal
56 
57    }  // namespace TAO_PEGTL_NAMESPACE
58 
59 }  // namespace tao
60 
61 #endif
62