sequence.hpp
Go to the documentation of this file.
1 // Copyright (C) 2020-2024 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_DSL_SEQUENCE_HPP_INCLUDED
5 #define LEXY_DSL_SEQUENCE_HPP_INCLUDED
6 
7 #include <lexy/dsl/base.hpp>
8 
9 namespace lexyd
10 {
11 template <typename... R>
12 struct _seq_impl;
13 template <>
14 struct _seq_impl<>
15 {
16  template <typename NextParser>
17  using p = NextParser;
18 };
19 template <typename R1>
20 struct _seq_impl<R1>
21 {
22  template <typename NextParser>
24 };
25 template <typename R1, typename R2>
26 struct _seq_impl<R1, R2>
27 {
28  template <typename NextParser>
30 };
31 template <typename R1, typename R2, typename R3>
32 struct _seq_impl<R1, R2, R3>
33 {
34  template <typename NextParser>
36 };
37 template <typename R1, typename R2, typename R3, typename R4>
38 struct _seq_impl<R1, R2, R3, R4>
39 {
40  template <typename NextParser>
41  using p = lexy::parser_for<
43 };
44 template <typename R1, typename R2, typename R3, typename R4, typename R5>
45 struct _seq_impl<R1, R2, R3, R4, R5>
46 {
47  template <typename NextParser>
48  using p = lexy::parser_for<
49  R1, lexy::parser_for<
51 };
52 template <typename R1, typename R2, typename R3, typename R4, typename R5, typename R6>
53 struct _seq_impl<R1, R2, R3, R4, R5, R6>
54 {
55  template <typename NextParser>
56  using p = lexy::parser_for<
57  R1,
59  R2,
62 };
63 template <typename R1, typename R2, typename R3, typename R4, typename R5, typename R6, typename R7>
64 struct _seq_impl<R1, R2, R3, R4, R5, R6, R7>
65 {
66  template <typename NextParser>
67  using p = lexy::parser_for<
68  R1,
70  R2, lexy::parser_for<
71  R3, lexy::parser_for<
72  R4, lexy::parser_for<
74 };
75 template <typename R1, typename R2, typename R3, typename R4, typename R5, typename R6, typename R7,
76  typename... T>
77 struct _seq_impl<R1, R2, R3, R4, R5, R6, R7, T...>
78 {
79  template <typename NextParser>
80  using p = lexy::parser_for<
81  R1,
83  R2,
85  R3,
87  R4, lexy::parser_for<
88  R5, lexy::parser_for<
90  NextParser>>>>>>>>;
91 };
92 
93 template <typename... R>
94 struct _seq : rule_base
95 {
96  static_assert(sizeof...(R) > 1);
97 
98  template <typename NextParser>
99  using p = lexy::parser_for<_seq_impl<R...>, NextParser>;
100 };
101 
102 template <typename R, typename S, typename = std::enable_if_t<lexy::is_rule<R> && lexy::is_rule<S>>>
103 constexpr auto operator+(R, S)
104 {
105  return _seq<R, S>{};
106 }
107 template <typename... R, typename S>
108 constexpr auto operator+(_seq<R...>, S)
109 {
110  return _seq<R..., S>{};
111 }
112 template <typename R, typename... S>
113 constexpr auto operator+(R, _seq<S...>)
114 {
115  return _seq<R, S...>{};
116 }
117 template <typename... R, typename... S>
119 {
120  return _seq<R..., S...>{};
121 }
122 } // namespace lexyd
123 
124 #endif // LEXY_DSL_SEQUENCE_HPP_INCLUDED
125 
lexyd::_seq
Definition: sequence.hpp:94
lexyd::_seq_impl
Definition: operator.hpp:17
lexyd::_seq_impl< R1, R2, R3, R4, R5, R6 >::p
lexy::parser_for< R1, lexy::parser_for< R2, lexy::parser_for< R3, lexy::parser_for< R4, lexy::parser_for< R5, lexy::parser_for< R6, NextParser > >> >> > p
Definition: sequence.hpp:61
lexyd::_seq_impl< R1, R2, R3, R4, R5, R6, R7 >::p
lexy::parser_for< R1, lexy::parser_for< R2, lexy::parser_for< R3, lexy::parser_for< R4, lexy::parser_for< R5, lexy::parser_for< R6, lexy::parser_for< R7, NextParser > >> >> >> p
Definition: sequence.hpp:73
lexyd::_seq_impl< R1, R2, R3, R4, R5, R6, R7, T... >::p
lexy::parser_for< R1, lexy::parser_for< R2, lexy::parser_for< R3, lexy::parser_for< R4, lexy::parser_for< R5, lexy::parser_for< R6, lexy::parser_for< R7, lexy::parser_for< _seq_impl< T... >, NextParser > >> >> >> > p
Definition: sequence.hpp:90
lexyd::_seq_impl< R1 >::p
lexy::parser_for< R1, NextParser > p
Definition: sequence.hpp:23
lexyd::_seq_impl< R1, R2, R3 >::p
lexy::parser_for< R1, lexy::parser_for< R2, lexy::parser_for< R3, NextParser > >> p
Definition: sequence.hpp:35
lexyd::_seq_impl< R1, R2 >::p
lexy::parser_for< R1, lexy::parser_for< R2, NextParser > > p
Definition: sequence.hpp:29
lexyd::_seq_impl< R1, R2, R3, R4, R5 >::p
lexy::parser_for< R1, lexy::parser_for< R2, lexy::parser_for< R3, lexy::parser_for< R4, lexy::parser_for< R5, NextParser > >> >> p
Definition: sequence.hpp:50
lexyd::rule_base
Definition: grammar.hpp:17
base.hpp
lexyd::_seq::p
lexy::parser_for< _seq_impl< R... >, NextParser > p
Definition: sequence.hpp:99
lexyd::_seq_impl<>::p
NextParser p
Definition: sequence.hpp:17
lexy::parser_for
typename Rule::template p< NextParser > parser_for
Definition: dsl/base.hpp:113
lexyd::_seq_impl< R1, R2, R3, R4 >::p
lexy::parser_for< R1, lexy::parser_for< R2, lexy::parser_for< R3, lexy::parser_for< R4, NextParser > >> > p
Definition: sequence.hpp:42
lexyd::operator+
constexpr auto operator+(Rule rule, _br< Condition, R... >)
Definition: branch.hpp:72
lexyd
Definition: trace.hpp:22


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:17