diff options
Diffstat (limited to 'MoonParser/pegtl/internal/rep.hpp')
-rw-r--r-- | MoonParser/pegtl/internal/rep.hpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/MoonParser/pegtl/internal/rep.hpp b/MoonParser/pegtl/internal/rep.hpp new file mode 100644 index 0000000..df66ee2 --- /dev/null +++ b/MoonParser/pegtl/internal/rep.hpp | |||
@@ -0,0 +1,75 @@ | |||
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_REP_HPP | ||
5 | #define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_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/counted.hpp" | ||
17 | |||
18 | namespace tao | ||
19 | { | ||
20 | namespace TAOCPP_PEGTL_NAMESPACE | ||
21 | { | ||
22 | namespace internal | ||
23 | { | ||
24 | template< unsigned Num, typename... Rules > | ||
25 | struct rep; | ||
26 | |||
27 | template< unsigned Num > | ||
28 | struct rep< Num > | ||
29 | : trivial< true > | ||
30 | { | ||
31 | }; | ||
32 | |||
33 | template< typename Rule, typename... Rules > | ||
34 | struct rep< 0, Rule, Rules... > | ||
35 | : trivial< true > | ||
36 | { | ||
37 | }; | ||
38 | |||
39 | template< unsigned Num, typename... Rules > | ||
40 | struct rep | ||
41 | { | ||
42 | using analyze_t = analysis::counted< analysis::rule_type::SEQ, Num, Rules... >; | ||
43 | |||
44 | template< apply_mode A, | ||
45 | rewind_mode M, | ||
46 | template< typename... > class Action, | ||
47 | template< typename... > class Control, | ||
48 | typename Input, | ||
49 | typename... States > | ||
50 | static bool match( Input& in, States&&... st ) | ||
51 | { | ||
52 | auto m = in.template mark< M >(); | ||
53 | using m_t = decltype( m ); | ||
54 | |||
55 | for( unsigned i = 0; i != Num; ++i ) { | ||
56 | if( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { | ||
57 | return false; | ||
58 | } | ||
59 | } | ||
60 | return m( true ); | ||
61 | } | ||
62 | }; | ||
63 | |||
64 | template< unsigned Num, typename... Rules > | ||
65 | struct skip_control< rep< Num, Rules... > > : std::true_type | ||
66 | { | ||
67 | }; | ||
68 | |||
69 | } // namespace internal | ||
70 | |||
71 | } // namespace TAOCPP_PEGTL_NAMESPACE | ||
72 | |||
73 | } // namespace tao | ||
74 | |||
75 | #endif | ||