| 176 | }; |
| 177 | |
| 178 | int main() |
| 179 | { |
| 180 | |
| 181 | // seq_parser_struct_rule |
| 182 | { |
| 183 | //////////////////////////////////////////////////////////////////////////// |
| 184 | // Parse-generated attribute. |
| 185 | |
| 186 | { |
| 187 | std::optional<s0> result = parse("s0 42 text 1 2 3", s0_rule, ws); |
| 188 | BOOST_TEST(result); |
| 189 | s0 & struct_ = *result; |
| 190 | BOOST_TEST(get(struct_, llong<0>{}) == 42); |
| 191 | BOOST_TEST(get(struct_, llong<1>{}) == "text"); |
| 192 | BOOST_TEST(get(struct_, llong<2>{}) == std::vector<int>({1, 2, 3})); |
| 193 | } |
| 194 | { |
| 195 | std::optional<s1> const result = |
| 196 | parse("s1 42 text 1 2 3", s1_rule_a, ws); |
| 197 | BOOST_TEST(result); |
| 198 | s1 const & struct_ = *result; |
| 199 | BOOST_TEST(get(struct_, llong<0>{}) == 42); |
| 200 | BOOST_TEST(get(struct_, llong<1>{}).index() == 0u); |
| 201 | BOOST_TEST(std::get<0>(get(struct_, llong<1>{})) == "text"); |
| 202 | BOOST_TEST(get(struct_, llong<2>{}) == std::vector<int>({1, 2, 3})); |
| 203 | } |
| 204 | { |
| 205 | std::optional<s1> const result = |
| 206 | parse("s1 42 13.0 1 2 3", s1_rule_b, ws); |
| 207 | BOOST_TEST(result); |
| 208 | s1 const & struct_ = *result; |
| 209 | BOOST_TEST(get(struct_, llong<0>{}) == 42); |
| 210 | BOOST_TEST(get(struct_, llong<1>{}).index() == 1u); |
| 211 | BOOST_TEST(std::get<1>(get(struct_, llong<1>{})) == 13.0); |
| 212 | BOOST_TEST(get(struct_, llong<2>{}) == std::vector<int>({1, 2, 3})); |
| 213 | } |
| 214 | { |
| 215 | std::optional<s2> const result = |
| 216 | parse("s2 42 text 1 2 3", s2_rule_a, ws); |
| 217 | BOOST_TEST(result); |
| 218 | s2 const & struct_ = *result; |
| 219 | BOOST_TEST(get(struct_, llong<0>{}) == 42); |
| 220 | BOOST_TEST(get(struct_, llong<1>{}) == "text"); |
| 221 | BOOST_TEST(get(struct_, llong<2>{}) == std::vector<int>({1, 2, 3})); |
| 222 | } |
| 223 | { |
| 224 | std::optional<s2> const result = |
| 225 | parse("s2 42 text 1 2 3", s2_rule_b, ws); |
| 226 | BOOST_TEST(result); |
| 227 | s2 const & struct_ = *result; |
| 228 | BOOST_TEST(get(struct_, llong<0>{}) == 42); |
| 229 | BOOST_TEST(get(struct_, llong<1>{}) == "text"); |
| 230 | BOOST_TEST(get(struct_, llong<2>{}) == std::vector<int>({1, 2, 3})); |
| 231 | } |
| 232 | |
| 233 | // Use the rule as part of a larger parse. |
| 234 | { |
| 235 | std::optional<tuple<int, s0>> const result = |