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_SEQ_HPP 5 #define TAO_PEGTL_INTERNAL_SEQ_HPP 6 7 #include "../config.hpp" 8 9 #include "rule_conjunction.hpp" 10 #include "skip_control.hpp" 11 #include "trivial.hpp" 12 13 #include "../apply_mode.hpp" 14 #include "../rewind_mode.hpp" 15 16 #include "../analysis/generic.hpp" 17 18 namespace tao 19 { 20 namespace TAO_PEGTL_NAMESPACE 21 { 22 namespace internal 23 { 24 template< typename... Rules > 25 struct seq; 26 27 template<> 28 struct seq<> 29 : trivial< true > 30 { 31 }; 32 33 template< typename Rule > 34 struct seq< Rule > 35 { 36 using analyze_t = typename Rule::analyze_t; 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::seq44 static bool match( Input& in, States&&... st ) 45 { 46 return Control< Rule >::template match< A, M, Action, Control >( in, st... ); 47 } 48 }; 49 50 template< typename... Rules > 51 struct seq 52 { 53 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; 54 55 template< apply_mode A, 56 rewind_mode M, 57 template< typename... > class Action, 58 template< typename... > class Control, 59 typename Input, 60 typename... States > matchtao::TAO_PEGTL_NAMESPACE::internal::seq61 static bool match( Input& in, States&&... st ) 62 { 63 auto m = in.template mark< M >(); 64 using m_t = decltype( m ); 65 return m( rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); 66 } 67 }; 68 69 template< typename... Rules > 70 struct skip_control< seq< Rules... > > : std::true_type 71 { 72 }; 73 74 } // namespace internal 75 76 } // namespace TAO_PEGTL_NAMESPACE 77 78 } // namespace tao 79 80 #endif 81