1 #include "Statement.hpp"
2 #include <soulng/util/Unicode.hpp>
3 #include <sngcpp/parser/Declaration.hpp>
4 #include <sngcpp/parser/Declarator.hpp>
5 #include <sngcpp/parser/Expression.hpp>
6 #include <sngcpp/parser/Identifier.hpp>
7 #include <sngcpp/parser/TypeExpr.hpp>
8 #include <sngcpp/lexer/CppLexer.hpp>
9 #include <sngcpp/lexer/CppTokens.hpp>
10
11
12
13 using namespace soulng::unicode;
14 using namespace CppTokens;
15 using namespace soulng::lexer;
16
17 soulng::parser::Match StatementParser::Statement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
18 {
19 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
20
21
22
23
24
25
26
27 #endif // SOULNG_PARSER_DEBUG_SUPPORT
28 std::unique_ptr<sngcpp::ast::Node> labeledStatement;
29 std::unique_ptr<sngcpp::ast::Node> expressionStatement;
30 std::unique_ptr<sngcpp::ast::CompoundStatementNode> compoundStatement;
31 std::unique_ptr<sngcpp::ast::Node> selectionStatement;
32 std::unique_ptr<sngcpp::ast::Node> iterationStatement;
33 std::unique_ptr<sngcpp::ast::Node> jumpStatement;
34 std::unique_ptr<sngcpp::ast::Node> declarationStatement;
35 std::unique_ptr<sngcpp::ast::Node> tryStatement;
36 soulng::parser::Match match(false);
37 soulng::parser::Match* parentMatch0 = &match;
38 {
39 int64_t save = lexer.GetPos();
40 soulng::parser::Match match(false);
41 soulng::parser::Match* parentMatch1 = &match;
42 {
43 int64_t save = lexer.GetPos();
44 soulng::parser::Match match(false);
45 soulng::parser::Match* parentMatch2 = &match;
46 {
47 int64_t save = lexer.GetPos();
48 soulng::parser::Match match(false);
49 soulng::parser::Match* parentMatch3 = &match;
50 {
51 int64_t save = lexer.GetPos();
52 soulng::parser::Match match(false);
53 soulng::parser::Match* parentMatch4 = &match;
54 {
55 int64_t save = lexer.GetPos();
56 soulng::parser::Match match(false);
57 soulng::parser::Match* parentMatch5 = &match;
58 {
59 int64_t save = lexer.GetPos();
60 soulng::parser::Match match(false);
61 soulng::parser::Match* parentMatch6 = &match;
62 {
63 int64_t save = lexer.GetPos();
64 soulng::parser::Match match(false);
65 soulng::parser::Match* parentMatch7 = &match;
66 {
67 int64_t pos = lexer.GetPos();
68 soulng::parser::Match match = StatementParser::LabeledStatement(lexer, ctx);
69 labeledStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
70 if (match.hit)
71 {
72 {
73 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
74
75 #endif // SOULNG_PARSER_DEBUG_SUPPORT
76 return soulng::parser::Match(true, labeledStatement.release());
77 }
78 }
79 *parentMatch7 = match;
80 }
81 *parentMatch6 = match;
82 if (!match.hit)
83 {
84 soulng::parser::Match match(false);
85 soulng::parser::Match* parentMatch8 = &match;
86 lexer.SetPos(save);
87 {
88 soulng::parser::Match match(false);
89 soulng::parser::Match* parentMatch9 = &match;
90 {
91 int64_t pos = lexer.GetPos();
92 soulng::parser::Match match = StatementParser::ExpressionStatement(lexer, ctx);
93 expressionStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
94 if (match.hit)
95 {
96 {
97 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
98
99 #endif // SOULNG_PARSER_DEBUG_SUPPORT
100 return soulng::parser::Match(true, expressionStatement.release());
101 }
102 }
103 *parentMatch9 = match;
104 }
105 *parentMatch8 = match;
106 }
107 *parentMatch6 = match;
108 }
109 }
110 *parentMatch5 = match;
111 if (!match.hit)
112 {
113 soulng::parser::Match match(false);
114 soulng::parser::Match* parentMatch10 = &match;
115 lexer.SetPos(save);
116 {
117 soulng::parser::Match match(false);
118 soulng::parser::Match* parentMatch11 = &match;
119 {
120 int64_t pos = lexer.GetPos();
121 soulng::parser::Match match = StatementParser::CompoundStatement(lexer, ctx);
122 compoundStatement.reset(static_cast<sngcpp::ast::CompoundStatementNode*>(match.value));
123 if (match.hit)
124 {
125 {
126 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
127
128 #endif // SOULNG_PARSER_DEBUG_SUPPORT
129 return soulng::parser::Match(true, compoundStatement.release());
130 }
131 }
132 *parentMatch11 = match;
133 }
134 *parentMatch10 = match;
135 }
136 *parentMatch5 = match;
137 }
138 }
139 *parentMatch4 = match;
140 if (!match.hit)
141 {
142 soulng::parser::Match match(false);
143 soulng::parser::Match* parentMatch12 = &match;
144 lexer.SetPos(save);
145 {
146 soulng::parser::Match match(false);
147 soulng::parser::Match* parentMatch13 = &match;
148 {
149 int64_t pos = lexer.GetPos();
150 soulng::parser::Match match = StatementParser::SelectionStatement(lexer, ctx);
151 selectionStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
152 if (match.hit)
153 {
154 {
155 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
156
157 #endif // SOULNG_PARSER_DEBUG_SUPPORT
158 return soulng::parser::Match(true, selectionStatement.release());
159 }
160 }
161 *parentMatch13 = match;
162 }
163 *parentMatch12 = match;
164 }
165 *parentMatch4 = match;
166 }
167 }
168 *parentMatch3 = match;
169 if (!match.hit)
170 {
171 soulng::parser::Match match(false);
172 soulng::parser::Match* parentMatch14 = &match;
173 lexer.SetPos(save);
174 {
175 soulng::parser::Match match(false);
176 soulng::parser::Match* parentMatch15 = &match;
177 {
178 int64_t pos = lexer.GetPos();
179 soulng::parser::Match match = StatementParser::IterationStatement(lexer, ctx);
180 iterationStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
181 if (match.hit)
182 {
183 {
184 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
185
186 #endif // SOULNG_PARSER_DEBUG_SUPPORT
187 return soulng::parser::Match(true, iterationStatement.release());
188 }
189 }
190 *parentMatch15 = match;
191 }
192 *parentMatch14 = match;
193 }
194 *parentMatch3 = match;
195 }
196 }
197 *parentMatch2 = match;
198 if (!match.hit)
199 {
200 soulng::parser::Match match(false);
201 soulng::parser::Match* parentMatch16 = &match;
202 lexer.SetPos(save);
203 {
204 soulng::parser::Match match(false);
205 soulng::parser::Match* parentMatch17 = &match;
206 {
207 int64_t pos = lexer.GetPos();
208 soulng::parser::Match match = StatementParser::JumpStatement(lexer, ctx);
209 jumpStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
210 if (match.hit)
211 {
212 {
213 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
214
215 #endif // SOULNG_PARSER_DEBUG_SUPPORT
216 return soulng::parser::Match(true, jumpStatement.release());
217 }
218 }
219 *parentMatch17 = match;
220 }
221 *parentMatch16 = match;
222 }
223 *parentMatch2 = match;
224 }
225 }
226 *parentMatch1 = match;
227 if (!match.hit)
228 {
229 soulng::parser::Match match(false);
230 soulng::parser::Match* parentMatch18 = &match;
231 lexer.SetPos(save);
232 {
233 soulng::parser::Match match(false);
234 soulng::parser::Match* parentMatch19 = &match;
235 {
236 int64_t pos = lexer.GetPos();
237 soulng::parser::Match match = StatementParser::DeclarationStatement(lexer, ctx);
238 declarationStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
239 if (match.hit)
240 {
241 {
242 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
243
244 #endif // SOULNG_PARSER_DEBUG_SUPPORT
245 return soulng::parser::Match(true, declarationStatement.release());
246 }
247 }
248 *parentMatch19 = match;
249 }
250 *parentMatch18 = match;
251 }
252 *parentMatch1 = match;
253 }
254 }
255 *parentMatch0 = match;
256 if (!match.hit)
257 {
258 soulng::parser::Match match(false);
259 soulng::parser::Match* parentMatch20 = &match;
260 lexer.SetPos(save);
261 {
262 soulng::parser::Match match(false);
263 soulng::parser::Match* parentMatch21 = &match;
264 {
265 int64_t pos = lexer.GetPos();
266 soulng::parser::Match match = StatementParser::TryStatement(lexer, ctx);
267 tryStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
268 if (match.hit)
269 {
270 {
271 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
272
273 #endif // SOULNG_PARSER_DEBUG_SUPPORT
274 return soulng::parser::Match(true, tryStatement.release());
275 }
276 }
277 *parentMatch21 = match;
278 }
279 *parentMatch20 = match;
280 }
281 *parentMatch0 = match;
282 }
283 }
284 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
285
286
287
288
289
290 #endif // SOULNG_PARSER_DEBUG_SUPPORT
291 if (!match.hit)
292 {
293 match.value = nullptr;
294 }
295 return match;
296 }
297
298 soulng::parser::Match StatementParser::LabeledStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
299 {
300 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
301
302
303
304
305
306
307
308 #endif // SOULNG_PARSER_DEBUG_SUPPORT
309 Span s = Span();
310 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>id;
311 std::unique_ptr<sngcpp::ast::Node> ls;
312 std::unique_ptr<sngcpp::ast::Node> caseExpr;
313 std::unique_ptr<sngcpp::ast::Node> cs;
314 std::unique_ptr<sngcpp::ast::Node> ds;
315 soulng::parser::Match match(false);
316 soulng::parser::Match* parentMatch0 = &match;
317 {
318 int64_t save = lexer.GetPos();
319 soulng::parser::Match match(false);
320 soulng::parser::Match* parentMatch1 = &match;
321 {
322 int64_t save = lexer.GetPos();
323 soulng::parser::Match match(false);
324 soulng::parser::Match* parentMatch2 = &match;
325 {
326 soulng::parser::Match match(false);
327 soulng::parser::Match* parentMatch3 = &match;
328 {
329 soulng::parser::Match match(false);
330 soulng::parser::Match* parentMatch4 = &match;
331 {
332 int64_t pos = lexer.GetPos();
333 soulng::lexer::Span span = lexer.GetSpan();
334 soulng::parser::Match match = IdentifierParser::Identifier(lexer);
335 id.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
336 if (match.hit)
337 {
338 s = span;
339 }
340 *parentMatch4 = match;
341 }
342 *parentMatch3 = match;
343 }
344 if (match.hit)
345 {
346 soulng::parser::Match match(false);
347 soulng::parser::Match* parentMatch5 = &match;
348 {
349 soulng::parser::Match match(false);
350 if (*lexer == COLON)
351 {
352 ++lexer;
353 match.hit = true;
354 }
355 *parentMatch5 = match;
356 }
357 *parentMatch3 = match;
358 }
359 *parentMatch2 = match;
360 }
361 if (match.hit)
362 {
363 soulng::parser::Match match(false);
364 soulng::parser::Match* parentMatch6 = &match;
365 {
366 soulng::parser::Match match(false);
367 soulng::parser::Match* parentMatch7 = &match;
368 {
369 int64_t pos = lexer.GetPos();
370 soulng::lexer::Span span = lexer.GetSpan();
371 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
372 ls.reset(static_cast<sngcpp::ast::Node*>(match.value));
373 if (match.hit)
374 {
375 s.end = span.end;
376 {
377 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
378
379 #endif // SOULNG_PARSER_DEBUG_SUPPORT
380 return soulng::parser::Match(true, new sngcpp::ast::LabeledStatementNode(s, id->value, ls.release()));
381 }
382 }
383 *parentMatch7 = match;
384 }
385 *parentMatch6 = match;
386 }
387 *parentMatch2 = match;
388 }
389 *parentMatch1 = match;
390 if (!match.hit)
391 {
392 soulng::parser::Match match(false);
393 soulng::parser::Match* parentMatch8 = &match;
394 lexer.SetPos(save);
395 {
396 soulng::parser::Match match(false);
397 soulng::parser::Match* parentMatch9 = &match;
398 {
399 soulng::parser::Match match(false);
400 soulng::parser::Match* parentMatch10 = &match;
401 {
402 soulng::parser::Match match(false);
403 soulng::parser::Match* parentMatch11 = &match;
404 {
405 soulng::parser::Match match(false);
406 soulng::parser::Match* parentMatch12 = &match;
407 {
408 int64_t pos = lexer.GetPos();
409 soulng::lexer::Span span = lexer.GetSpan();
410 soulng::parser::Match match(false);
411 if (*lexer == CASE)
412 {
413 ++lexer;
414 match.hit = true;
415 }
416 if (match.hit)
417 {
418 s = span;
419 }
420 *parentMatch12 = match;
421 }
422 *parentMatch11 = match;
423 }
424 if (match.hit)
425 {
426 soulng::parser::Match match(false);
427 soulng::parser::Match* parentMatch13 = &match;
428 {
429 soulng::parser::Match match(true);
430 soulng::parser::Match* parentMatch14 = &match;
431 {
432 soulng::lexer::Span span = lexer.GetSpan();
433 soulng::parser::Match match = ExpressionParser::ConstantExpression(lexer, ctx);
434 caseExpr.reset(static_cast<sngcpp::ast::Node*>(match.value));
435 if (match.hit)
436 {
437 *parentMatch14 = match;
438 }
439 else
440 {
441 lexer.ThrowExpectationFailure(span, U"ConstantExpression");
442 }
443 }
444 *parentMatch13 = match;
445 }
446 *parentMatch11 = match;
447 }
448 *parentMatch10 = match;
449 }
450 if (match.hit)
451 {
452 soulng::parser::Match match(false);
453 soulng::parser::Match* parentMatch15 = &match;
454 {
455 soulng::parser::Match match(true);
456 soulng::parser::Match* parentMatch16 = &match;
457 {
458 soulng::lexer::Span span = lexer.GetSpan();
459 soulng::parser::Match match(false);
460 if (*lexer == COLON)
461 {
462 ++lexer;
463 match.hit = true;
464 }
465 if (match.hit)
466 {
467 *parentMatch16 = match;
468 }
469 else
470 {
471 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(COLON)));
472 }
473 }
474 *parentMatch15 = match;
475 }
476 *parentMatch10 = match;
477 }
478 *parentMatch9 = match;
479 }
480 if (match.hit)
481 {
482 soulng::parser::Match match(false);
483 soulng::parser::Match* parentMatch17 = &match;
484 {
485 soulng::parser::Match match(false);
486 soulng::parser::Match* parentMatch18 = &match;
487 {
488 int64_t pos = lexer.GetPos();
489 soulng::lexer::Span span = lexer.GetSpan();
490 soulng::parser::Match match(true);
491 soulng::parser::Match* parentMatch19 = &match;
492 {
493 soulng::lexer::Span span = lexer.GetSpan();
494 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
495 cs.reset(static_cast<sngcpp::ast::Node*>(match.value));
496 if (match.hit)
497 {
498 *parentMatch19 = match;
499 }
500 else
501 {
502 lexer.ThrowExpectationFailure(span, U"Statement");
503 }
504 }
505 if (match.hit)
506 {
507 s.end = span.end;
508 {
509 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
510
511 #endif // SOULNG_PARSER_DEBUG_SUPPORT
512 return soulng::parser::Match(true, new sngcpp::ast::CaseStatementNode(s, caseExpr.release(), cs.release()));
513 }
514 }
515 *parentMatch18 = match;
516 }
517 *parentMatch17 = match;
518 }
519 *parentMatch9 = match;
520 }
521 *parentMatch8 = match;
522 }
523 *parentMatch1 = match;
524 }
525 }
526 *parentMatch0 = match;
527 if (!match.hit)
528 {
529 soulng::parser::Match match(false);
530 soulng::parser::Match* parentMatch20 = &match;
531 lexer.SetPos(save);
532 {
533 soulng::parser::Match match(false);
534 soulng::parser::Match* parentMatch21 = &match;
535 {
536 soulng::parser::Match match(false);
537 soulng::parser::Match* parentMatch22 = &match;
538 {
539 soulng::parser::Match match(false);
540 soulng::parser::Match* parentMatch23 = &match;
541 {
542 int64_t pos = lexer.GetPos();
543 soulng::lexer::Span span = lexer.GetSpan();
544 soulng::parser::Match match(false);
545 if (*lexer == DEFAULT)
546 {
547 ++lexer;
548 match.hit = true;
549 }
550 if (match.hit)
551 {
552 s = span;
553 }
554 *parentMatch23 = match;
555 }
556 *parentMatch22 = match;
557 }
558 if (match.hit)
559 {
560 soulng::parser::Match match(false);
561 soulng::parser::Match* parentMatch24 = &match;
562 {
563 soulng::parser::Match match(true);
564 soulng::parser::Match* parentMatch25 = &match;
565 {
566 soulng::lexer::Span span = lexer.GetSpan();
567 soulng::parser::Match match(false);
568 if (*lexer == COLON)
569 {
570 ++lexer;
571 match.hit = true;
572 }
573 if (match.hit)
574 {
575 *parentMatch25 = match;
576 }
577 else
578 {
579 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(COLON)));
580 }
581 }
582 *parentMatch24 = match;
583 }
584 *parentMatch22 = match;
585 }
586 *parentMatch21 = match;
587 }
588 if (match.hit)
589 {
590 soulng::parser::Match match(false);
591 soulng::parser::Match* parentMatch26 = &match;
592 {
593 soulng::parser::Match match(false);
594 soulng::parser::Match* parentMatch27 = &match;
595 {
596 int64_t pos = lexer.GetPos();
597 soulng::lexer::Span span = lexer.GetSpan();
598 soulng::parser::Match match(true);
599 soulng::parser::Match* parentMatch28 = &match;
600 {
601 soulng::lexer::Span span = lexer.GetSpan();
602 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
603 ds.reset(static_cast<sngcpp::ast::Node*>(match.value));
604 if (match.hit)
605 {
606 *parentMatch28 = match;
607 }
608 else
609 {
610 lexer.ThrowExpectationFailure(span, U"Statement");
611 }
612 }
613 if (match.hit)
614 {
615 s.end = span.end;
616 {
617 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
618
619 #endif // SOULNG_PARSER_DEBUG_SUPPORT
620 return soulng::parser::Match(true, new sngcpp::ast::DefaultStatementNode(s, ds.release()));
621 }
622 }
623 *parentMatch27 = match;
624 }
625 *parentMatch26 = match;
626 }
627 *parentMatch21 = match;
628 }
629 *parentMatch20 = match;
630 }
631 *parentMatch0 = match;
632 }
633 }
634 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
635
636
637
638
639
640 #endif // SOULNG_PARSER_DEBUG_SUPPORT
641 if (!match.hit)
642 {
643 match.value = nullptr;
644 }
645 return match;
646 }
647
648 soulng::parser::Match StatementParser::ExpressionStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
649 {
650 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
651
652
653
654
655
656
657
658 #endif // SOULNG_PARSER_DEBUG_SUPPORT
659 Span s = Span();
660 std::unique_ptr<sngcpp::ast::Node> expr;
661 soulng::parser::Match match(false);
662 soulng::parser::Match* parentMatch0 = &match;
663 {
664 soulng::parser::Match match(false);
665 soulng::parser::Match* parentMatch1 = &match;
666 {
667 soulng::parser::Match match(false);
668 soulng::parser::Match* parentMatch2 = &match;
669 {
670 int64_t pos = lexer.GetPos();
671 soulng::lexer::Span span = lexer.GetSpan();
672 soulng::parser::Match match(true);
673 if (match.hit)
674 {
675 s = span;
676 }
677 *parentMatch2 = match;
678 }
679 *parentMatch1 = match;
680 }
681 if (match.hit)
682 {
683 soulng::parser::Match match(false);
684 soulng::parser::Match* parentMatch3 = &match;
685 {
686 soulng::parser::Match match(true);
687 int64_t save = lexer.GetPos();
688 soulng::parser::Match* parentMatch4 = &match;
689 {
690 soulng::parser::Match match = ExpressionParser::Expression(lexer, ctx);
691 expr.reset(static_cast<sngcpp::ast::Node*>(match.value));
692 if (match.hit)
693 {
694 *parentMatch4 = match;
695 }
696 else
697 {
698 lexer.SetPos(save);
699 }
700 }
701 *parentMatch3 = match;
702 }
703 *parentMatch1 = match;
704 }
705 *parentMatch0 = match;
706 }
707 if (match.hit)
708 {
709 soulng::parser::Match match(false);
710 soulng::parser::Match* parentMatch5 = &match;
711 {
712 soulng::parser::Match match(false);
713 soulng::parser::Match* parentMatch6 = &match;
714 {
715 int64_t pos = lexer.GetPos();
716 soulng::lexer::Span span = lexer.GetSpan();
717 soulng::parser::Match match(false);
718 if (*lexer == SEMICOLON)
719 {
720 ++lexer;
721 match.hit = true;
722 }
723 if (match.hit)
724 {
725 s.end = span.end;
726 {
727 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
728
729 #endif // SOULNG_PARSER_DEBUG_SUPPORT
730 return soulng::parser::Match(true, new sngcpp::ast::ExpressionStatementNode(s, expr.release()));
731 }
732 }
733 *parentMatch6 = match;
734 }
735 *parentMatch5 = match;
736 }
737 *parentMatch0 = match;
738 }
739 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
740
741
742
743
744
745 #endif // SOULNG_PARSER_DEBUG_SUPPORT
746 if (!match.hit)
747 {
748 match.value = nullptr;
749 }
750 return match;
751 }
752
753 soulng::parser::Match StatementParser::CompoundStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
754 {
755 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
756
757
758
759
760
761
762
763 #endif // SOULNG_PARSER_DEBUG_SUPPORT
764 std::unique_ptr<sngcpp::ast::CompoundStatementNode> node = std::unique_ptr<sngcpp::ast::CompoundStatementNode>();
765 std::unique_ptr<sngcpp::ast::Node> stmt;
766 soulng::parser::Match match(false);
767 soulng::parser::Match* parentMatch0 = &match;
768 {
769 soulng::parser::Match match(false);
770 soulng::parser::Match* parentMatch1 = &match;
771 {
772 soulng::parser::Match match(false);
773 soulng::parser::Match* parentMatch2 = &match;
774 {
775 int64_t pos = lexer.GetPos();
776 soulng::lexer::Span span = lexer.GetSpan();
777 soulng::parser::Match match(false);
778 if (*lexer == LBRACE)
779 {
780 ++lexer;
781 match.hit = true;
782 }
783 if (match.hit)
784 {
785 node.reset(new sngcpp::ast::CompoundStatementNode(span));
786 }
787 *parentMatch2 = match;
788 }
789 *parentMatch1 = match;
790 }
791 if (match.hit)
792 {
793 soulng::parser::Match match(false);
794 soulng::parser::Match* parentMatch3 = &match;
795 {
796 soulng::parser::Match match(true);
797 soulng::parser::Match* parentMatch4 = &match;
798 {
799 while (true)
800 {
801 int64_t save = lexer.GetPos();
802 {
803 soulng::parser::Match match(false);
804 soulng::parser::Match* parentMatch5 = &match;
805 {
806 soulng::parser::Match match(false);
807 soulng::parser::Match* parentMatch6 = &match;
808 {
809 int64_t pos = lexer.GetPos();
810 soulng::lexer::Span span = lexer.GetSpan();
811 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
812 stmt.reset(static_cast<sngcpp::ast::Node*>(match.value));
813 if (match.hit)
814 {
815 node->AddStatement(span, stmt.release());
816 }
817 *parentMatch6 = match;
818 }
819 *parentMatch5 = match;
820 }
821 if (match.hit)
822 {
823 *parentMatch4 = match;
824 }
825 else
826 {
827 lexer.SetPos(save);
828 break;
829 }
830 }
831 }
832 }
833 *parentMatch3 = match;
834 }
835 *parentMatch1 = match;
836 }
837 *parentMatch0 = match;
838 }
839 if (match.hit)
840 {
841 soulng::parser::Match match(false);
842 soulng::parser::Match* parentMatch7 = &match;
843 {
844 soulng::parser::Match match(false);
845 soulng::parser::Match* parentMatch8 = &match;
846 {
847 int64_t pos = lexer.GetPos();
848 soulng::lexer::Span span = lexer.GetSpan();
849 soulng::parser::Match match(true);
850 soulng::parser::Match* parentMatch9 = &match;
851 {
852 soulng::lexer::Span span = lexer.GetSpan();
853 soulng::parser::Match match(false);
854 if (*lexer == RBRACE)
855 {
856 ++lexer;
857 match.hit = true;
858 }
859 if (match.hit)
860 {
861 *parentMatch9 = match;
862 }
863 else
864 {
865 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RBRACE)));
866 }
867 }
868 if (match.hit)
869 {
870 node->SetEndBraceSpan(span);
871 {
872 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
873
874 #endif // SOULNG_PARSER_DEBUG_SUPPORT
875 return soulng::parser::Match(true, node.release());
876 }
877 }
878 *parentMatch8 = match;
879 }
880 *parentMatch7 = match;
881 }
882 *parentMatch0 = match;
883 }
884 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
885
886
887
888
889
890 #endif // SOULNG_PARSER_DEBUG_SUPPORT
891 if (!match.hit)
892 {
893 match.value = nullptr;
894 }
895 return match;
896 }
897
898 soulng::parser::Match StatementParser::SelectionStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
899 {
900 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
901
902
903
904
905
906
907
908 #endif // SOULNG_PARSER_DEBUG_SUPPORT
909 Span s = Span();
910 Span elseSpan = Span();
911 std::unique_ptr<sngcpp::ast::Node> cond1;
912 std::unique_ptr<sngcpp::ast::Node> thenS;
913 std::unique_ptr<sngcpp::ast::Node> elseS;
914 std::unique_ptr<sngcpp::ast::Node> cond2;
915 std::unique_ptr<sngcpp::ast::Node> stmt;
916 soulng::parser::Match match(false);
917 soulng::parser::Match* parentMatch0 = &match;
918 {
919 int64_t save = lexer.GetPos();
920 soulng::parser::Match match(false);
921 soulng::parser::Match* parentMatch1 = &match;
922 {
923 int64_t pos = lexer.GetPos();
924 soulng::parser::Match match(false);
925 soulng::parser::Match* parentMatch2 = &match;
926 {
927 soulng::parser::Match match(false);
928 soulng::parser::Match* parentMatch3 = &match;
929 {
930 soulng::parser::Match match(false);
931 soulng::parser::Match* parentMatch4 = &match;
932 {
933 soulng::parser::Match match(false);
934 soulng::parser::Match* parentMatch5 = &match;
935 {
936 soulng::parser::Match match(false);
937 soulng::parser::Match* parentMatch6 = &match;
938 {
939 soulng::parser::Match match(false);
940 soulng::parser::Match* parentMatch7 = &match;
941 {
942 soulng::parser::Match match(false);
943 soulng::parser::Match* parentMatch8 = &match;
944 {
945 int64_t pos = lexer.GetPos();
946 soulng::lexer::Span span = lexer.GetSpan();
947 soulng::parser::Match match(false);
948 if (*lexer == IF)
949 {
950 ++lexer;
951 match.hit = true;
952 }
953 if (match.hit)
954 {
955 s = span;
956 }
957 *parentMatch8 = match;
958 }
959 *parentMatch7 = match;
960 }
961 if (match.hit)
962 {
963 soulng::parser::Match match(false);
964 soulng::parser::Match* parentMatch9 = &match;
965 {
966 soulng::parser::Match match(true);
967 soulng::parser::Match* parentMatch10 = &match;
968 {
969 soulng::lexer::Span span = lexer.GetSpan();
970 soulng::parser::Match match(false);
971 if (*lexer == LPAREN)
972 {
973 ++lexer;
974 match.hit = true;
975 }
976 if (match.hit)
977 {
978 *parentMatch10 = match;
979 }
980 else
981 {
982 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(LPAREN)));
983 }
984 }
985 *parentMatch9 = match;
986 }
987 *parentMatch7 = match;
988 }
989 *parentMatch6 = match;
990 }
991 if (match.hit)
992 {
993 soulng::parser::Match match(false);
994 soulng::parser::Match* parentMatch11 = &match;
995 {
996 soulng::parser::Match match(true);
997 soulng::parser::Match* parentMatch12 = &match;
998 {
999 soulng::lexer::Span span = lexer.GetSpan();
1000 soulng::parser::Match match = StatementParser::Condition(lexer, ctx);
1001 cond1.reset(static_cast<sngcpp::ast::Node*>(match.value));
1002 if (match.hit)
1003 {
1004 *parentMatch12 = match;
1005 }
1006 else
1007 {
1008 lexer.ThrowExpectationFailure(span, U"Condition");
1009 }
1010 }
1011 *parentMatch11 = match;
1012 }
1013 *parentMatch6 = match;
1014 }
1015 *parentMatch5 = match;
1016 }
1017 if (match.hit)
1018 {
1019 soulng::parser::Match match(false);
1020 soulng::parser::Match* parentMatch13 = &match;
1021 {
1022 soulng::parser::Match match(true);
1023 soulng::parser::Match* parentMatch14 = &match;
1024 {
1025 soulng::lexer::Span span = lexer.GetSpan();
1026 soulng::parser::Match match(false);
1027 if (*lexer == RPAREN)
1028 {
1029 ++lexer;
1030 match.hit = true;
1031 }
1032 if (match.hit)
1033 {
1034 *parentMatch14 = match;
1035 }
1036 else
1037 {
1038 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RPAREN)));
1039 }
1040 }
1041 *parentMatch13 = match;
1042 }
1043 *parentMatch5 = match;
1044 }
1045 *parentMatch4 = match;
1046 }
1047 if (match.hit)
1048 {
1049 soulng::parser::Match match(false);
1050 soulng::parser::Match* parentMatch15 = &match;
1051 {
1052 soulng::parser::Match match(false);
1053 soulng::parser::Match* parentMatch16 = &match;
1054 {
1055 int64_t pos = lexer.GetPos();
1056 soulng::lexer::Span span = lexer.GetSpan();
1057 soulng::parser::Match match(true);
1058 soulng::parser::Match* parentMatch17 = &match;
1059 {
1060 soulng::lexer::Span span = lexer.GetSpan();
1061 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
1062 thenS.reset(static_cast<sngcpp::ast::Node*>(match.value));
1063 if (match.hit)
1064 {
1065 *parentMatch17 = match;
1066 }
1067 else
1068 {
1069 lexer.ThrowExpectationFailure(span, U"Statement");
1070 }
1071 }
1072 if (match.hit)
1073 {
1074 s.end = span.end;
1075 }
1076 *parentMatch16 = match;
1077 }
1078 *parentMatch15 = match;
1079 }
1080 *parentMatch4 = match;
1081 }
1082 *parentMatch3 = match;
1083 }
1084 if (match.hit)
1085 {
1086 soulng::parser::Match match(false);
1087 soulng::parser::Match* parentMatch18 = &match;
1088 {
1089 soulng::parser::Match match(true);
1090 int64_t save = lexer.GetPos();
1091 soulng::parser::Match* parentMatch19 = &match;
1092 {
1093 soulng::parser::Match match(false);
1094 soulng::parser::Match* parentMatch20 = &match;
1095 {
1096 soulng::parser::Match match(false);
1097 soulng::parser::Match* parentMatch21 = &match;
1098 {
1099 soulng::parser::Match match(false);
1100 soulng::parser::Match* parentMatch22 = &match;
1101 {
1102 int64_t pos = lexer.GetPos();
1103 soulng::lexer::Span span = lexer.GetSpan();
1104 soulng::parser::Match match(false);
1105 if (*lexer == ELSE)
1106 {
1107 ++lexer;
1108 match.hit = true;
1109 }
1110 if (match.hit)
1111 {
1112 elseSpan = span;
1113 }
1114 *parentMatch22 = match;
1115 }
1116 *parentMatch21 = match;
1117 }
1118 if (match.hit)
1119 {
1120 soulng::parser::Match match(false);
1121 soulng::parser::Match* parentMatch23 = &match;
1122 {
1123 soulng::parser::Match match(false);
1124 soulng::parser::Match* parentMatch24 = &match;
1125 {
1126 int64_t pos = lexer.GetPos();
1127 soulng::lexer::Span span = lexer.GetSpan();
1128 soulng::parser::Match match(true);
1129 soulng::parser::Match* parentMatch25 = &match;
1130 {
1131 soulng::lexer::Span span = lexer.GetSpan();
1132 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
1133 elseS.reset(static_cast<sngcpp::ast::Node*>(match.value));
1134 if (match.hit)
1135 {
1136 *parentMatch25 = match;
1137 }
1138 else
1139 {
1140 lexer.ThrowExpectationFailure(span, U"Statement");
1141 }
1142 }
1143 if (match.hit)
1144 {
1145 s.end = span.end;
1146 }
1147 *parentMatch24 = match;
1148 }
1149 *parentMatch23 = match;
1150 }
1151 *parentMatch21 = match;
1152 }
1153 *parentMatch20 = match;
1154 }
1155 if (match.hit)
1156 {
1157 *parentMatch19 = match;
1158 }
1159 else
1160 {
1161 lexer.SetPos(save);
1162 }
1163 }
1164 *parentMatch18 = match;
1165 }
1166 *parentMatch3 = match;
1167 }
1168 *parentMatch2 = match;
1169 }
1170 if (match.hit)
1171 {
1172 {
1173 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1174
1175 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1176 return soulng::parser::Match(true, new sngcpp::ast::IfStatementNode(s, cond1.release(), thenS.release(), elseS.release(), elseSpan));
1177 }
1178 }
1179 *parentMatch1 = match;
1180 }
1181 *parentMatch0 = match;
1182 if (!match.hit)
1183 {
1184 soulng::parser::Match match(false);
1185 soulng::parser::Match* parentMatch26 = &match;
1186 lexer.SetPos(save);
1187 {
1188 soulng::parser::Match match(false);
1189 soulng::parser::Match* parentMatch27 = &match;
1190 {
1191 int64_t pos = lexer.GetPos();
1192 soulng::parser::Match match(false);
1193 soulng::parser::Match* parentMatch28 = &match;
1194 {
1195 soulng::parser::Match match(false);
1196 soulng::parser::Match* parentMatch29 = &match;
1197 {
1198 soulng::parser::Match match(false);
1199 soulng::parser::Match* parentMatch30 = &match;
1200 {
1201 soulng::parser::Match match(false);
1202 soulng::parser::Match* parentMatch31 = &match;
1203 {
1204 soulng::parser::Match match(false);
1205 soulng::parser::Match* parentMatch32 = &match;
1206 {
1207 soulng::parser::Match match(false);
1208 soulng::parser::Match* parentMatch33 = &match;
1209 {
1210 int64_t pos = lexer.GetPos();
1211 soulng::lexer::Span span = lexer.GetSpan();
1212 soulng::parser::Match match(false);
1213 if (*lexer == SWITCH)
1214 {
1215 ++lexer;
1216 match.hit = true;
1217 }
1218 if (match.hit)
1219 {
1220 s = span;
1221 }
1222 *parentMatch33 = match;
1223 }
1224 *parentMatch32 = match;
1225 }
1226 if (match.hit)
1227 {
1228 soulng::parser::Match match(false);
1229 soulng::parser::Match* parentMatch34 = &match;
1230 {
1231 soulng::parser::Match match(true);
1232 soulng::parser::Match* parentMatch35 = &match;
1233 {
1234 soulng::lexer::Span span = lexer.GetSpan();
1235 soulng::parser::Match match(false);
1236 if (*lexer == LPAREN)
1237 {
1238 ++lexer;
1239 match.hit = true;
1240 }
1241 if (match.hit)
1242 {
1243 *parentMatch35 = match;
1244 }
1245 else
1246 {
1247 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(LPAREN)));
1248 }
1249 }
1250 *parentMatch34 = match;
1251 }
1252 *parentMatch32 = match;
1253 }
1254 *parentMatch31 = match;
1255 }
1256 if (match.hit)
1257 {
1258 soulng::parser::Match match(false);
1259 soulng::parser::Match* parentMatch36 = &match;
1260 {
1261 soulng::parser::Match match(true);
1262 soulng::parser::Match* parentMatch37 = &match;
1263 {
1264 soulng::lexer::Span span = lexer.GetSpan();
1265 soulng::parser::Match match = StatementParser::Condition(lexer, ctx);
1266 cond2.reset(static_cast<sngcpp::ast::Node*>(match.value));
1267 if (match.hit)
1268 {
1269 *parentMatch37 = match;
1270 }
1271 else
1272 {
1273 lexer.ThrowExpectationFailure(span, U"Condition");
1274 }
1275 }
1276 *parentMatch36 = match;
1277 }
1278 *parentMatch31 = match;
1279 }
1280 *parentMatch30 = match;
1281 }
1282 if (match.hit)
1283 {
1284 soulng::parser::Match match(false);
1285 soulng::parser::Match* parentMatch38 = &match;
1286 {
1287 soulng::parser::Match match(true);
1288 soulng::parser::Match* parentMatch39 = &match;
1289 {
1290 soulng::lexer::Span span = lexer.GetSpan();
1291 soulng::parser::Match match(false);
1292 if (*lexer == RPAREN)
1293 {
1294 ++lexer;
1295 match.hit = true;
1296 }
1297 if (match.hit)
1298 {
1299 *parentMatch39 = match;
1300 }
1301 else
1302 {
1303 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RPAREN)));
1304 }
1305 }
1306 *parentMatch38 = match;
1307 }
1308 *parentMatch30 = match;
1309 }
1310 *parentMatch29 = match;
1311 }
1312 if (match.hit)
1313 {
1314 soulng::parser::Match match(false);
1315 soulng::parser::Match* parentMatch40 = &match;
1316 {
1317 soulng::parser::Match match(false);
1318 soulng::parser::Match* parentMatch41 = &match;
1319 {
1320 int64_t pos = lexer.GetPos();
1321 soulng::lexer::Span span = lexer.GetSpan();
1322 soulng::parser::Match match(true);
1323 soulng::parser::Match* parentMatch42 = &match;
1324 {
1325 soulng::lexer::Span span = lexer.GetSpan();
1326 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
1327 stmt.reset(static_cast<sngcpp::ast::Node*>(match.value));
1328 if (match.hit)
1329 {
1330 *parentMatch42 = match;
1331 }
1332 else
1333 {
1334 lexer.ThrowExpectationFailure(span, U"Statement");
1335 }
1336 }
1337 if (match.hit)
1338 {
1339 s.end = span.end;
1340 }
1341 *parentMatch41 = match;
1342 }
1343 *parentMatch40 = match;
1344 }
1345 *parentMatch29 = match;
1346 }
1347 *parentMatch28 = match;
1348 }
1349 if (match.hit)
1350 {
1351 {
1352 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1353
1354 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1355 return soulng::parser::Match(true, new sngcpp::ast::SwitchStatementNode(s, cond2.release(), stmt.release()));
1356 }
1357 }
1358 *parentMatch27 = match;
1359 }
1360 *parentMatch26 = match;
1361 }
1362 *parentMatch0 = match;
1363 }
1364 }
1365 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1366
1367
1368
1369
1370
1371 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1372 if (!match.hit)
1373 {
1374 match.value = nullptr;
1375 }
1376 return match;
1377 }
1378
1379 soulng::parser::Match StatementParser::IterationStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
1380 {
1381 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1382
1383
1384
1385
1386
1387
1388
1389 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1390 Span s = Span();
1391 Span whileSpan = Span();
1392 std::unique_ptr<sngcpp::ast::Node> cond1;
1393 std::unique_ptr<sngcpp::ast::Node> stmt1;
1394 std::unique_ptr<sngcpp::ast::Node> stmt2;
1395 std::unique_ptr<sngcpp::ast::Node> cond2;
1396 std::unique_ptr<sngcpp::ast::Node> forRange;
1397 std::unique_ptr<sngcpp::ast::Node> forRangeInit;
1398 std::unique_ptr<sngcpp::ast::Node> stmt3;
1399 std::unique_ptr<sngcpp::ast::Node> forInit;
1400 std::unique_ptr<sngcpp::ast::Node> cond4;
1401 std::unique_ptr<sngcpp::ast::Node> loopExpr;
1402 std::unique_ptr<sngcpp::ast::Node> stmt4;
1403 soulng::parser::Match match(false);
1404 soulng::parser::Match* parentMatch0 = &match;
1405 {
1406 int64_t save = lexer.GetPos();
1407 soulng::parser::Match match(false);
1408 soulng::parser::Match* parentMatch1 = &match;
1409 {
1410 int64_t save = lexer.GetPos();
1411 soulng::parser::Match match(false);
1412 soulng::parser::Match* parentMatch2 = &match;
1413 {
1414 int64_t save = lexer.GetPos();
1415 soulng::parser::Match match(false);
1416 soulng::parser::Match* parentMatch3 = &match;
1417 {
1418 soulng::parser::Match match(false);
1419 soulng::parser::Match* parentMatch4 = &match;
1420 {
1421 soulng::parser::Match match(false);
1422 soulng::parser::Match* parentMatch5 = &match;
1423 {
1424 soulng::parser::Match match(false);
1425 soulng::parser::Match* parentMatch6 = &match;
1426 {
1427 soulng::parser::Match match(false);
1428 soulng::parser::Match* parentMatch7 = &match;
1429 {
1430 int64_t pos = lexer.GetPos();
1431 soulng::lexer::Span span = lexer.GetSpan();
1432 soulng::parser::Match match(false);
1433 if (*lexer == WHILE)
1434 {
1435 ++lexer;
1436 match.hit = true;
1437 }
1438 if (match.hit)
1439 {
1440 s = span;
1441 }
1442 *parentMatch7 = match;
1443 }
1444 *parentMatch6 = match;
1445 }
1446 if (match.hit)
1447 {
1448 soulng::parser::Match match(false);
1449 soulng::parser::Match* parentMatch8 = &match;
1450 {
1451 soulng::parser::Match match(true);
1452 soulng::parser::Match* parentMatch9 = &match;
1453 {
1454 soulng::lexer::Span span = lexer.GetSpan();
1455 soulng::parser::Match match(false);
1456 if (*lexer == LPAREN)
1457 {
1458 ++lexer;
1459 match.hit = true;
1460 }
1461 if (match.hit)
1462 {
1463 *parentMatch9 = match;
1464 }
1465 else
1466 {
1467 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(LPAREN)));
1468 }
1469 }
1470 *parentMatch8 = match;
1471 }
1472 *parentMatch6 = match;
1473 }
1474 *parentMatch5 = match;
1475 }
1476 if (match.hit)
1477 {
1478 soulng::parser::Match match(false);
1479 soulng::parser::Match* parentMatch10 = &match;
1480 {
1481 soulng::parser::Match match(true);
1482 soulng::parser::Match* parentMatch11 = &match;
1483 {
1484 soulng::lexer::Span span = lexer.GetSpan();
1485 soulng::parser::Match match = StatementParser::Condition(lexer, ctx);
1486 cond1.reset(static_cast<sngcpp::ast::Node*>(match.value));
1487 if (match.hit)
1488 {
1489 *parentMatch11 = match;
1490 }
1491 else
1492 {
1493 lexer.ThrowExpectationFailure(span, U"Condition");
1494 }
1495 }
1496 *parentMatch10 = match;
1497 }
1498 *parentMatch5 = match;
1499 }
1500 *parentMatch4 = match;
1501 }
1502 if (match.hit)
1503 {
1504 soulng::parser::Match match(false);
1505 soulng::parser::Match* parentMatch12 = &match;
1506 {
1507 soulng::parser::Match match(true);
1508 soulng::parser::Match* parentMatch13 = &match;
1509 {
1510 soulng::lexer::Span span = lexer.GetSpan();
1511 soulng::parser::Match match(false);
1512 if (*lexer == RPAREN)
1513 {
1514 ++lexer;
1515 match.hit = true;
1516 }
1517 if (match.hit)
1518 {
1519 *parentMatch13 = match;
1520 }
1521 else
1522 {
1523 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RPAREN)));
1524 }
1525 }
1526 *parentMatch12 = match;
1527 }
1528 *parentMatch4 = match;
1529 }
1530 *parentMatch3 = match;
1531 }
1532 if (match.hit)
1533 {
1534 soulng::parser::Match match(false);
1535 soulng::parser::Match* parentMatch14 = &match;
1536 {
1537 soulng::parser::Match match(false);
1538 soulng::parser::Match* parentMatch15 = &match;
1539 {
1540 int64_t pos = lexer.GetPos();
1541 soulng::lexer::Span span = lexer.GetSpan();
1542 soulng::parser::Match match(true);
1543 soulng::parser::Match* parentMatch16 = &match;
1544 {
1545 soulng::lexer::Span span = lexer.GetSpan();
1546 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
1547 stmt1.reset(static_cast<sngcpp::ast::Node*>(match.value));
1548 if (match.hit)
1549 {
1550 *parentMatch16 = match;
1551 }
1552 else
1553 {
1554 lexer.ThrowExpectationFailure(span, U"Statement");
1555 }
1556 }
1557 if (match.hit)
1558 {
1559 s.end = span.end;
1560 {
1561 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1562
1563 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1564 return soulng::parser::Match(true, new sngcpp::ast::WhileStatementNode(s, cond1.release(), stmt1.release()));
1565 }
1566 }
1567 *parentMatch15 = match;
1568 }
1569 *parentMatch14 = match;
1570 }
1571 *parentMatch3 = match;
1572 }
1573 *parentMatch2 = match;
1574 if (!match.hit)
1575 {
1576 soulng::parser::Match match(false);
1577 soulng::parser::Match* parentMatch17 = &match;
1578 lexer.SetPos(save);
1579 {
1580 soulng::parser::Match match(false);
1581 soulng::parser::Match* parentMatch18 = &match;
1582 {
1583 soulng::parser::Match match(false);
1584 soulng::parser::Match* parentMatch19 = &match;
1585 {
1586 soulng::parser::Match match(false);
1587 soulng::parser::Match* parentMatch20 = &match;
1588 {
1589 soulng::parser::Match match(false);
1590 soulng::parser::Match* parentMatch21 = &match;
1591 {
1592 soulng::parser::Match match(false);
1593 soulng::parser::Match* parentMatch22 = &match;
1594 {
1595 soulng::parser::Match match(false);
1596 soulng::parser::Match* parentMatch23 = &match;
1597 {
1598 soulng::parser::Match match(false);
1599 soulng::parser::Match* parentMatch24 = &match;
1600 {
1601 int64_t pos = lexer.GetPos();
1602 soulng::lexer::Span span = lexer.GetSpan();
1603 soulng::parser::Match match(false);
1604 if (*lexer == DO)
1605 {
1606 ++lexer;
1607 match.hit = true;
1608 }
1609 if (match.hit)
1610 {
1611 s = span;
1612 }
1613 *parentMatch24 = match;
1614 }
1615 *parentMatch23 = match;
1616 }
1617 if (match.hit)
1618 {
1619 soulng::parser::Match match(false);
1620 soulng::parser::Match* parentMatch25 = &match;
1621 {
1622 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
1623 stmt2.reset(static_cast<sngcpp::ast::Node*>(match.value));
1624 *parentMatch25 = match;
1625 }
1626 *parentMatch23 = match;
1627 }
1628 *parentMatch22 = match;
1629 }
1630 if (match.hit)
1631 {
1632 soulng::parser::Match match(false);
1633 soulng::parser::Match* parentMatch26 = &match;
1634 {
1635 soulng::parser::Match match(false);
1636 soulng::parser::Match* parentMatch27 = &match;
1637 {
1638 int64_t pos = lexer.GetPos();
1639 soulng::lexer::Span span = lexer.GetSpan();
1640 soulng::parser::Match match(true);
1641 soulng::parser::Match* parentMatch28 = &match;
1642 {
1643 soulng::lexer::Span span = lexer.GetSpan();
1644 soulng::parser::Match match(false);
1645 if (*lexer == WHILE)
1646 {
1647 ++lexer;
1648 match.hit = true;
1649 }
1650 if (match.hit)
1651 {
1652 *parentMatch28 = match;
1653 }
1654 else
1655 {
1656 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(WHILE)));
1657 }
1658 }
1659 if (match.hit)
1660 {
1661 whileSpan = span;
1662 }
1663 *parentMatch27 = match;
1664 }
1665 *parentMatch26 = match;
1666 }
1667 *parentMatch22 = match;
1668 }
1669 *parentMatch21 = match;
1670 }
1671 if (match.hit)
1672 {
1673 soulng::parser::Match match(false);
1674 soulng::parser::Match* parentMatch29 = &match;
1675 {
1676 soulng::parser::Match match(true);
1677 soulng::parser::Match* parentMatch30 = &match;
1678 {
1679 soulng::lexer::Span span = lexer.GetSpan();
1680 soulng::parser::Match match(false);
1681 if (*lexer == LPAREN)
1682 {
1683 ++lexer;
1684 match.hit = true;
1685 }
1686 if (match.hit)
1687 {
1688 *parentMatch30 = match;
1689 }
1690 else
1691 {
1692 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(LPAREN)));
1693 }
1694 }
1695 *parentMatch29 = match;
1696 }
1697 *parentMatch21 = match;
1698 }
1699 *parentMatch20 = match;
1700 }
1701 if (match.hit)
1702 {
1703 soulng::parser::Match match(false);
1704 soulng::parser::Match* parentMatch31 = &match;
1705 {
1706 soulng::parser::Match match(true);
1707 soulng::parser::Match* parentMatch32 = &match;
1708 {
1709 soulng::lexer::Span span = lexer.GetSpan();
1710 soulng::parser::Match match = ExpressionParser::Expression(lexer, ctx);
1711 cond2.reset(static_cast<sngcpp::ast::Node*>(match.value));
1712 if (match.hit)
1713 {
1714 *parentMatch32 = match;
1715 }
1716 else
1717 {
1718 lexer.ThrowExpectationFailure(span, U"Expression");
1719 }
1720 }
1721 *parentMatch31 = match;
1722 }
1723 *parentMatch20 = match;
1724 }
1725 *parentMatch19 = match;
1726 }
1727 if (match.hit)
1728 {
1729 soulng::parser::Match match(false);
1730 soulng::parser::Match* parentMatch33 = &match;
1731 {
1732 soulng::parser::Match match(true);
1733 soulng::parser::Match* parentMatch34 = &match;
1734 {
1735 soulng::lexer::Span span = lexer.GetSpan();
1736 soulng::parser::Match match(false);
1737 if (*lexer == RPAREN)
1738 {
1739 ++lexer;
1740 match.hit = true;
1741 }
1742 if (match.hit)
1743 {
1744 *parentMatch34 = match;
1745 }
1746 else
1747 {
1748 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RPAREN)));
1749 }
1750 }
1751 *parentMatch33 = match;
1752 }
1753 *parentMatch19 = match;
1754 }
1755 *parentMatch18 = match;
1756 }
1757 if (match.hit)
1758 {
1759 soulng::parser::Match match(false);
1760 soulng::parser::Match* parentMatch35 = &match;
1761 {
1762 soulng::parser::Match match(false);
1763 soulng::parser::Match* parentMatch36 = &match;
1764 {
1765 int64_t pos = lexer.GetPos();
1766 soulng::lexer::Span span = lexer.GetSpan();
1767 soulng::parser::Match match(true);
1768 soulng::parser::Match* parentMatch37 = &match;
1769 {
1770 soulng::lexer::Span span = lexer.GetSpan();
1771 soulng::parser::Match match(false);
1772 if (*lexer == SEMICOLON)
1773 {
1774 ++lexer;
1775 match.hit = true;
1776 }
1777 if (match.hit)
1778 {
1779 *parentMatch37 = match;
1780 }
1781 else
1782 {
1783 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
1784 }
1785 }
1786 if (match.hit)
1787 {
1788 s.end = span.end;
1789 {
1790 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1791
1792 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1793 return soulng::parser::Match(true, new sngcpp::ast::DoStatementNode(s, stmt2.release(), cond2.release(), whileSpan));
1794 }
1795 }
1796 *parentMatch36 = match;
1797 }
1798 *parentMatch35 = match;
1799 }
1800 *parentMatch18 = match;
1801 }
1802 *parentMatch17 = match;
1803 }
1804 *parentMatch2 = match;
1805 }
1806 }
1807 *parentMatch1 = match;
1808 if (!match.hit)
1809 {
1810 soulng::parser::Match match(false);
1811 soulng::parser::Match* parentMatch38 = &match;
1812 lexer.SetPos(save);
1813 {
1814 soulng::parser::Match match(false);
1815 soulng::parser::Match* parentMatch39 = &match;
1816 {
1817 soulng::parser::Match match(false);
1818 soulng::parser::Match* parentMatch40 = &match;
1819 {
1820 soulng::parser::Match match(false);
1821 soulng::parser::Match* parentMatch41 = &match;
1822 {
1823 soulng::parser::Match match(false);
1824 soulng::parser::Match* parentMatch42 = &match;
1825 {
1826 soulng::parser::Match match(false);
1827 soulng::parser::Match* parentMatch43 = &match;
1828 {
1829 soulng::parser::Match match(false);
1830 soulng::parser::Match* parentMatch44 = &match;
1831 {
1832 soulng::parser::Match match(false);
1833 soulng::parser::Match* parentMatch45 = &match;
1834 {
1835 int64_t pos = lexer.GetPos();
1836 soulng::lexer::Span span = lexer.GetSpan();
1837 soulng::parser::Match match(false);
1838 if (*lexer == FOR)
1839 {
1840 ++lexer;
1841 match.hit = true;
1842 }
1843 if (match.hit)
1844 {
1845 s = span;
1846 }
1847 *parentMatch45 = match;
1848 }
1849 *parentMatch44 = match;
1850 }
1851 if (match.hit)
1852 {
1853 soulng::parser::Match match(false);
1854 soulng::parser::Match* parentMatch46 = &match;
1855 {
1856 soulng::parser::Match match(false);
1857 if (*lexer == LPAREN)
1858 {
1859 ++lexer;
1860 match.hit = true;
1861 }
1862 *parentMatch46 = match;
1863 }
1864 *parentMatch44 = match;
1865 }
1866 *parentMatch43 = match;
1867 }
1868 if (match.hit)
1869 {
1870 soulng::parser::Match match(false);
1871 soulng::parser::Match* parentMatch47 = &match;
1872 {
1873 soulng::parser::Match match = StatementParser::ForRangeDeclaration(lexer, ctx);
1874 forRange.reset(static_cast<sngcpp::ast::Node*>(match.value));
1875 *parentMatch47 = match;
1876 }
1877 *parentMatch43 = match;
1878 }
1879 *parentMatch42 = match;
1880 }
1881 if (match.hit)
1882 {
1883 soulng::parser::Match match(false);
1884 soulng::parser::Match* parentMatch48 = &match;
1885 {
1886 soulng::parser::Match match(false);
1887 if (*lexer == COLON)
1888 {
1889 ++lexer;
1890 match.hit = true;
1891 }
1892 *parentMatch48 = match;
1893 }
1894 *parentMatch42 = match;
1895 }
1896 *parentMatch41 = match;
1897 }
1898 if (match.hit)
1899 {
1900 soulng::parser::Match match(false);
1901 soulng::parser::Match* parentMatch49 = &match;
1902 {
1903 soulng::parser::Match match(true);
1904 soulng::parser::Match* parentMatch50 = &match;
1905 {
1906 soulng::lexer::Span span = lexer.GetSpan();
1907 soulng::parser::Match match = StatementParser::ForRangeInitializer(lexer, ctx);
1908 forRangeInit.reset(static_cast<sngcpp::ast::Node*>(match.value));
1909 if (match.hit)
1910 {
1911 *parentMatch50 = match;
1912 }
1913 else
1914 {
1915 lexer.ThrowExpectationFailure(span, U"ForRangeInitializer");
1916 }
1917 }
1918 *parentMatch49 = match;
1919 }
1920 *parentMatch41 = match;
1921 }
1922 *parentMatch40 = match;
1923 }
1924 if (match.hit)
1925 {
1926 soulng::parser::Match match(false);
1927 soulng::parser::Match* parentMatch51 = &match;
1928 {
1929 soulng::parser::Match match(true);
1930 soulng::parser::Match* parentMatch52 = &match;
1931 {
1932 soulng::lexer::Span span = lexer.GetSpan();
1933 soulng::parser::Match match(false);
1934 if (*lexer == RPAREN)
1935 {
1936 ++lexer;
1937 match.hit = true;
1938 }
1939 if (match.hit)
1940 {
1941 *parentMatch52 = match;
1942 }
1943 else
1944 {
1945 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RPAREN)));
1946 }
1947 }
1948 *parentMatch51 = match;
1949 }
1950 *parentMatch40 = match;
1951 }
1952 *parentMatch39 = match;
1953 }
1954 if (match.hit)
1955 {
1956 soulng::parser::Match match(false);
1957 soulng::parser::Match* parentMatch53 = &match;
1958 {
1959 soulng::parser::Match match(false);
1960 soulng::parser::Match* parentMatch54 = &match;
1961 {
1962 int64_t pos = lexer.GetPos();
1963 soulng::lexer::Span span = lexer.GetSpan();
1964 soulng::parser::Match match(true);
1965 soulng::parser::Match* parentMatch55 = &match;
1966 {
1967 soulng::lexer::Span span = lexer.GetSpan();
1968 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
1969 stmt3.reset(static_cast<sngcpp::ast::Node*>(match.value));
1970 if (match.hit)
1971 {
1972 *parentMatch55 = match;
1973 }
1974 else
1975 {
1976 lexer.ThrowExpectationFailure(span, U"Statement");
1977 }
1978 }
1979 if (match.hit)
1980 {
1981 s.end = span.end;
1982 {
1983 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1984
1985 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1986 return soulng::parser::Match(true, new sngcpp::ast::RangeForStatementNode(s, forRange.release(), forRangeInit.release(), stmt3.release()));
1987 }
1988 }
1989 *parentMatch54 = match;
1990 }
1991 *parentMatch53 = match;
1992 }
1993 *parentMatch39 = match;
1994 }
1995 *parentMatch38 = match;
1996 }
1997 *parentMatch1 = match;
1998 }
1999 }
2000 *parentMatch0 = match;
2001 if (!match.hit)
2002 {
2003 soulng::parser::Match match(false);
2004 soulng::parser::Match* parentMatch56 = &match;
2005 lexer.SetPos(save);
2006 {
2007 soulng::parser::Match match(false);
2008 soulng::parser::Match* parentMatch57 = &match;
2009 {
2010 soulng::parser::Match match(false);
2011 soulng::parser::Match* parentMatch58 = &match;
2012 {
2013 soulng::parser::Match match(false);
2014 soulng::parser::Match* parentMatch59 = &match;
2015 {
2016 soulng::parser::Match match(false);
2017 soulng::parser::Match* parentMatch60 = &match;
2018 {
2019 soulng::parser::Match match(false);
2020 soulng::parser::Match* parentMatch61 = &match;
2021 {
2022 soulng::parser::Match match(false);
2023 soulng::parser::Match* parentMatch62 = &match;
2024 {
2025 soulng::parser::Match match(false);
2026 soulng::parser::Match* parentMatch63 = &match;
2027 {
2028 soulng::parser::Match match(false);
2029 soulng::parser::Match* parentMatch64 = &match;
2030 {
2031 int64_t pos = lexer.GetPos();
2032 soulng::lexer::Span span = lexer.GetSpan();
2033 soulng::parser::Match match(false);
2034 if (*lexer == FOR)
2035 {
2036 ++lexer;
2037 match.hit = true;
2038 }
2039 if (match.hit)
2040 {
2041 s = span;
2042 }
2043 *parentMatch64 = match;
2044 }
2045 *parentMatch63 = match;
2046 }
2047 if (match.hit)
2048 {
2049 soulng::parser::Match match(false);
2050 soulng::parser::Match* parentMatch65 = &match;
2051 {
2052 soulng::parser::Match match(false);
2053 if (*lexer == LPAREN)
2054 {
2055 ++lexer;
2056 match.hit = true;
2057 }
2058 *parentMatch65 = match;
2059 }
2060 *parentMatch63 = match;
2061 }
2062 *parentMatch62 = match;
2063 }
2064 if (match.hit)
2065 {
2066 soulng::parser::Match match(false);
2067 soulng::parser::Match* parentMatch66 = &match;
2068 {
2069 soulng::parser::Match match = StatementParser::ForInitStatement(lexer, ctx);
2070 forInit.reset(static_cast<sngcpp::ast::Node*>(match.value));
2071 *parentMatch66 = match;
2072 }
2073 *parentMatch62 = match;
2074 }
2075 *parentMatch61 = match;
2076 }
2077 if (match.hit)
2078 {
2079 soulng::parser::Match match(false);
2080 soulng::parser::Match* parentMatch67 = &match;
2081 {
2082 soulng::parser::Match match(true);
2083 int64_t save = lexer.GetPos();
2084 soulng::parser::Match* parentMatch68 = &match;
2085 {
2086 soulng::parser::Match match = StatementParser::Condition(lexer, ctx);
2087 cond4.reset(static_cast<sngcpp::ast::Node*>(match.value));
2088 if (match.hit)
2089 {
2090 *parentMatch68 = match;
2091 }
2092 else
2093 {
2094 lexer.SetPos(save);
2095 }
2096 }
2097 *parentMatch67 = match;
2098 }
2099 *parentMatch61 = match;
2100 }
2101 *parentMatch60 = match;
2102 }
2103 if (match.hit)
2104 {
2105 soulng::parser::Match match(false);
2106 soulng::parser::Match* parentMatch69 = &match;
2107 {
2108 soulng::parser::Match match(false);
2109 if (*lexer == SEMICOLON)
2110 {
2111 ++lexer;
2112 match.hit = true;
2113 }
2114 *parentMatch69 = match;
2115 }
2116 *parentMatch60 = match;
2117 }
2118 *parentMatch59 = match;
2119 }
2120 if (match.hit)
2121 {
2122 soulng::parser::Match match(false);
2123 soulng::parser::Match* parentMatch70 = &match;
2124 {
2125 soulng::parser::Match match(true);
2126 int64_t save = lexer.GetPos();
2127 soulng::parser::Match* parentMatch71 = &match;
2128 {
2129 soulng::parser::Match match = ExpressionParser::Expression(lexer, ctx);
2130 loopExpr.reset(static_cast<sngcpp::ast::Node*>(match.value));
2131 if (match.hit)
2132 {
2133 *parentMatch71 = match;
2134 }
2135 else
2136 {
2137 lexer.SetPos(save);
2138 }
2139 }
2140 *parentMatch70 = match;
2141 }
2142 *parentMatch59 = match;
2143 }
2144 *parentMatch58 = match;
2145 }
2146 if (match.hit)
2147 {
2148 soulng::parser::Match match(false);
2149 soulng::parser::Match* parentMatch72 = &match;
2150 {
2151 soulng::parser::Match match(true);
2152 soulng::parser::Match* parentMatch73 = &match;
2153 {
2154 soulng::lexer::Span span = lexer.GetSpan();
2155 soulng::parser::Match match(false);
2156 if (*lexer == RPAREN)
2157 {
2158 ++lexer;
2159 match.hit = true;
2160 }
2161 if (match.hit)
2162 {
2163 *parentMatch73 = match;
2164 }
2165 else
2166 {
2167 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RPAREN)));
2168 }
2169 }
2170 *parentMatch72 = match;
2171 }
2172 *parentMatch58 = match;
2173 }
2174 *parentMatch57 = match;
2175 }
2176 if (match.hit)
2177 {
2178 soulng::parser::Match match(false);
2179 soulng::parser::Match* parentMatch74 = &match;
2180 {
2181 soulng::parser::Match match(false);
2182 soulng::parser::Match* parentMatch75 = &match;
2183 {
2184 int64_t pos = lexer.GetPos();
2185 soulng::lexer::Span span = lexer.GetSpan();
2186 soulng::parser::Match match(true);
2187 soulng::parser::Match* parentMatch76 = &match;
2188 {
2189 soulng::lexer::Span span = lexer.GetSpan();
2190 soulng::parser::Match match = StatementParser::Statement(lexer, ctx);
2191 stmt4.reset(static_cast<sngcpp::ast::Node*>(match.value));
2192 if (match.hit)
2193 {
2194 *parentMatch76 = match;
2195 }
2196 else
2197 {
2198 lexer.ThrowExpectationFailure(span, U"Statement");
2199 }
2200 }
2201 if (match.hit)
2202 {
2203 s.end = span.end;
2204 {
2205 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2206
2207 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2208 return soulng::parser::Match(true, new sngcpp::ast::ForStatementNode(s, forInit.release(), cond4.release(), loopExpr.release(), stmt4.release()));
2209 }
2210 }
2211 *parentMatch75 = match;
2212 }
2213 *parentMatch74 = match;
2214 }
2215 *parentMatch57 = match;
2216 }
2217 *parentMatch56 = match;
2218 }
2219 *parentMatch0 = match;
2220 }
2221 }
2222 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2223
2224
2225
2226
2227
2228 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2229 if (!match.hit)
2230 {
2231 match.value = nullptr;
2232 }
2233 return match;
2234 }
2235
2236 soulng::parser::Match StatementParser::JumpStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
2237 {
2238 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2239
2240
2241
2242
2243
2244
2245
2246 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2247 Span s = Span();
2248 std::unique_ptr<sngcpp::ast::Node> expr;
2249 std::unique_ptr<sngcpp::ast::Node> bi;
2250 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>target;
2251 soulng::parser::Match match(false);
2252 soulng::parser::Match* parentMatch0 = &match;
2253 {
2254 int64_t save = lexer.GetPos();
2255 soulng::parser::Match match(false);
2256 soulng::parser::Match* parentMatch1 = &match;
2257 {
2258 int64_t save = lexer.GetPos();
2259 soulng::parser::Match match(false);
2260 soulng::parser::Match* parentMatch2 = &match;
2261 {
2262 int64_t save = lexer.GetPos();
2263 soulng::parser::Match match(false);
2264 soulng::parser::Match* parentMatch3 = &match;
2265 {
2266 int64_t save = lexer.GetPos();
2267 soulng::parser::Match match(false);
2268 soulng::parser::Match* parentMatch4 = &match;
2269 {
2270 soulng::parser::Match match(false);
2271 soulng::parser::Match* parentMatch5 = &match;
2272 {
2273 int64_t pos = lexer.GetPos();
2274 soulng::lexer::Span span = lexer.GetSpan();
2275 soulng::parser::Match match(false);
2276 if (*lexer == BREAK)
2277 {
2278 ++lexer;
2279 match.hit = true;
2280 }
2281 if (match.hit)
2282 {
2283 s = span;
2284 }
2285 *parentMatch5 = match;
2286 }
2287 *parentMatch4 = match;
2288 }
2289 if (match.hit)
2290 {
2291 soulng::parser::Match match(false);
2292 soulng::parser::Match* parentMatch6 = &match;
2293 {
2294 soulng::parser::Match match(false);
2295 soulng::parser::Match* parentMatch7 = &match;
2296 {
2297 int64_t pos = lexer.GetPos();
2298 soulng::lexer::Span span = lexer.GetSpan();
2299 soulng::parser::Match match(true);
2300 soulng::parser::Match* parentMatch8 = &match;
2301 {
2302 soulng::lexer::Span span = lexer.GetSpan();
2303 soulng::parser::Match match(false);
2304 if (*lexer == SEMICOLON)
2305 {
2306 ++lexer;
2307 match.hit = true;
2308 }
2309 if (match.hit)
2310 {
2311 *parentMatch8 = match;
2312 }
2313 else
2314 {
2315 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
2316 }
2317 }
2318 if (match.hit)
2319 {
2320 s.end = span.end;
2321 {
2322 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2323
2324 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2325 return soulng::parser::Match(true, new sngcpp::ast::BreakStatementNode(s));
2326 }
2327 }
2328 *parentMatch7 = match;
2329 }
2330 *parentMatch6 = match;
2331 }
2332 *parentMatch4 = match;
2333 }
2334 *parentMatch3 = match;
2335 if (!match.hit)
2336 {
2337 soulng::parser::Match match(false);
2338 soulng::parser::Match* parentMatch9 = &match;
2339 lexer.SetPos(save);
2340 {
2341 soulng::parser::Match match(false);
2342 soulng::parser::Match* parentMatch10 = &match;
2343 {
2344 soulng::parser::Match match(false);
2345 soulng::parser::Match* parentMatch11 = &match;
2346 {
2347 int64_t pos = lexer.GetPos();
2348 soulng::lexer::Span span = lexer.GetSpan();
2349 soulng::parser::Match match(false);
2350 if (*lexer == CONTINUE)
2351 {
2352 ++lexer;
2353 match.hit = true;
2354 }
2355 if (match.hit)
2356 {
2357 s = span;
2358 }
2359 *parentMatch11 = match;
2360 }
2361 *parentMatch10 = match;
2362 }
2363 if (match.hit)
2364 {
2365 soulng::parser::Match match(false);
2366 soulng::parser::Match* parentMatch12 = &match;
2367 {
2368 soulng::parser::Match match(false);
2369 soulng::parser::Match* parentMatch13 = &match;
2370 {
2371 int64_t pos = lexer.GetPos();
2372 soulng::lexer::Span span = lexer.GetSpan();
2373 soulng::parser::Match match(true);
2374 soulng::parser::Match* parentMatch14 = &match;
2375 {
2376 soulng::lexer::Span span = lexer.GetSpan();
2377 soulng::parser::Match match(false);
2378 if (*lexer == SEMICOLON)
2379 {
2380 ++lexer;
2381 match.hit = true;
2382 }
2383 if (match.hit)
2384 {
2385 *parentMatch14 = match;
2386 }
2387 else
2388 {
2389 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
2390 }
2391 }
2392 if (match.hit)
2393 {
2394 s.end = span.end;
2395 {
2396 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2397
2398 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2399 return soulng::parser::Match(true, new sngcpp::ast::ContinueStatementNode(s));
2400 }
2401 }
2402 *parentMatch13 = match;
2403 }
2404 *parentMatch12 = match;
2405 }
2406 *parentMatch10 = match;
2407 }
2408 *parentMatch9 = match;
2409 }
2410 *parentMatch3 = match;
2411 }
2412 }
2413 *parentMatch2 = match;
2414 if (!match.hit)
2415 {
2416 soulng::parser::Match match(false);
2417 soulng::parser::Match* parentMatch15 = &match;
2418 lexer.SetPos(save);
2419 {
2420 soulng::parser::Match match(false);
2421 soulng::parser::Match* parentMatch16 = &match;
2422 {
2423 soulng::parser::Match match(false);
2424 soulng::parser::Match* parentMatch17 = &match;
2425 {
2426 soulng::parser::Match match(false);
2427 soulng::parser::Match* parentMatch18 = &match;
2428 {
2429 int64_t pos = lexer.GetPos();
2430 soulng::lexer::Span span = lexer.GetSpan();
2431 soulng::parser::Match match(false);
2432 if (*lexer == RETURN)
2433 {
2434 ++lexer;
2435 match.hit = true;
2436 }
2437 if (match.hit)
2438 {
2439 s = span;
2440 }
2441 *parentMatch18 = match;
2442 }
2443 *parentMatch17 = match;
2444 }
2445 if (match.hit)
2446 {
2447 soulng::parser::Match match(false);
2448 soulng::parser::Match* parentMatch19 = &match;
2449 {
2450 soulng::parser::Match match(true);
2451 int64_t save = lexer.GetPos();
2452 soulng::parser::Match* parentMatch20 = &match;
2453 {
2454 soulng::parser::Match match = ExpressionParser::Expression(lexer, ctx);
2455 expr.reset(static_cast<sngcpp::ast::Node*>(match.value));
2456 if (match.hit)
2457 {
2458 *parentMatch20 = match;
2459 }
2460 else
2461 {
2462 lexer.SetPos(save);
2463 }
2464 }
2465 *parentMatch19 = match;
2466 }
2467 *parentMatch17 = match;
2468 }
2469 *parentMatch16 = match;
2470 }
2471 if (match.hit)
2472 {
2473 soulng::parser::Match match(false);
2474 soulng::parser::Match* parentMatch21 = &match;
2475 {
2476 soulng::parser::Match match(false);
2477 soulng::parser::Match* parentMatch22 = &match;
2478 {
2479 int64_t pos = lexer.GetPos();
2480 soulng::lexer::Span span = lexer.GetSpan();
2481 soulng::parser::Match match(true);
2482 soulng::parser::Match* parentMatch23 = &match;
2483 {
2484 soulng::lexer::Span span = lexer.GetSpan();
2485 soulng::parser::Match match(false);
2486 if (*lexer == SEMICOLON)
2487 {
2488 ++lexer;
2489 match.hit = true;
2490 }
2491 if (match.hit)
2492 {
2493 *parentMatch23 = match;
2494 }
2495 else
2496 {
2497 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
2498 }
2499 }
2500 if (match.hit)
2501 {
2502 s.end = span.end;
2503 {
2504 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2505
2506 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2507 return soulng::parser::Match(true, new sngcpp::ast::ReturnStatementNode(s, expr.release()));
2508 }
2509 }
2510 *parentMatch22 = match;
2511 }
2512 *parentMatch21 = match;
2513 }
2514 *parentMatch16 = match;
2515 }
2516 *parentMatch15 = match;
2517 }
2518 *parentMatch2 = match;
2519 }
2520 }
2521 *parentMatch1 = match;
2522 if (!match.hit)
2523 {
2524 soulng::parser::Match match(false);
2525 soulng::parser::Match* parentMatch24 = &match;
2526 lexer.SetPos(save);
2527 {
2528 soulng::parser::Match match(false);
2529 soulng::parser::Match* parentMatch25 = &match;
2530 {
2531 soulng::parser::Match match(false);
2532 soulng::parser::Match* parentMatch26 = &match;
2533 {
2534 soulng::parser::Match match(false);
2535 soulng::parser::Match* parentMatch27 = &match;
2536 {
2537 int64_t pos = lexer.GetPos();
2538 soulng::lexer::Span span = lexer.GetSpan();
2539 soulng::parser::Match match(false);
2540 if (*lexer == RETURN)
2541 {
2542 ++lexer;
2543 match.hit = true;
2544 }
2545 if (match.hit)
2546 {
2547 s = span;
2548 }
2549 *parentMatch27 = match;
2550 }
2551 *parentMatch26 = match;
2552 }
2553 if (match.hit)
2554 {
2555 soulng::parser::Match match(false);
2556 soulng::parser::Match* parentMatch28 = &match;
2557 {
2558 soulng::parser::Match match = DeclaratorParser::BracedInitializerList(lexer, ctx);
2559 bi.reset(static_cast<sngcpp::ast::Node*>(match.value));
2560 *parentMatch28 = match;
2561 }
2562 *parentMatch26 = match;
2563 }
2564 *parentMatch25 = match;
2565 }
2566 if (match.hit)
2567 {
2568 soulng::parser::Match match(false);
2569 soulng::parser::Match* parentMatch29 = &match;
2570 {
2571 soulng::parser::Match match(false);
2572 soulng::parser::Match* parentMatch30 = &match;
2573 {
2574 int64_t pos = lexer.GetPos();
2575 soulng::lexer::Span span = lexer.GetSpan();
2576 soulng::parser::Match match(true);
2577 soulng::parser::Match* parentMatch31 = &match;
2578 {
2579 soulng::lexer::Span span = lexer.GetSpan();
2580 soulng::parser::Match match(false);
2581 if (*lexer == SEMICOLON)
2582 {
2583 ++lexer;
2584 match.hit = true;
2585 }
2586 if (match.hit)
2587 {
2588 *parentMatch31 = match;
2589 }
2590 else
2591 {
2592 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
2593 }
2594 }
2595 if (match.hit)
2596 {
2597 s.end = span.end;
2598 {
2599 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2600
2601 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2602 return soulng::parser::Match(true, new sngcpp::ast::ReturnStatementNode(s, bi.release()));
2603 }
2604 }
2605 *parentMatch30 = match;
2606 }
2607 *parentMatch29 = match;
2608 }
2609 *parentMatch25 = match;
2610 }
2611 *parentMatch24 = match;
2612 }
2613 *parentMatch1 = match;
2614 }
2615 }
2616 *parentMatch0 = match;
2617 if (!match.hit)
2618 {
2619 soulng::parser::Match match(false);
2620 soulng::parser::Match* parentMatch32 = &match;
2621 lexer.SetPos(save);
2622 {
2623 soulng::parser::Match match(false);
2624 soulng::parser::Match* parentMatch33 = &match;
2625 {
2626 soulng::parser::Match match(false);
2627 soulng::parser::Match* parentMatch34 = &match;
2628 {
2629 soulng::parser::Match match(false);
2630 soulng::parser::Match* parentMatch35 = &match;
2631 {
2632 int64_t pos = lexer.GetPos();
2633 soulng::lexer::Span span = lexer.GetSpan();
2634 soulng::parser::Match match(false);
2635 if (*lexer == GOTO)
2636 {
2637 ++lexer;
2638 match.hit = true;
2639 }
2640 if (match.hit)
2641 {
2642 s = span;
2643 }
2644 *parentMatch35 = match;
2645 }
2646 *parentMatch34 = match;
2647 }
2648 if (match.hit)
2649 {
2650 soulng::parser::Match match(false);
2651 soulng::parser::Match* parentMatch36 = &match;
2652 {
2653 soulng::parser::Match match(true);
2654 soulng::parser::Match* parentMatch37 = &match;
2655 {
2656 soulng::lexer::Span span = lexer.GetSpan();
2657 soulng::parser::Match match = IdentifierParser::Identifier(lexer);
2658 target.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
2659 if (match.hit)
2660 {
2661 *parentMatch37 = match;
2662 }
2663 else
2664 {
2665 lexer.ThrowExpectationFailure(span, U"Identifier");
2666 }
2667 }
2668 *parentMatch36 = match;
2669 }
2670 *parentMatch34 = match;
2671 }
2672 *parentMatch33 = match;
2673 }
2674 if (match.hit)
2675 {
2676 soulng::parser::Match match(false);
2677 soulng::parser::Match* parentMatch38 = &match;
2678 {
2679 soulng::parser::Match match(false);
2680 soulng::parser::Match* parentMatch39 = &match;
2681 {
2682 int64_t pos = lexer.GetPos();
2683 soulng::lexer::Span span = lexer.GetSpan();
2684 soulng::parser::Match match(true);
2685 soulng::parser::Match* parentMatch40 = &match;
2686 {
2687 soulng::lexer::Span span = lexer.GetSpan();
2688 soulng::parser::Match match(false);
2689 if (*lexer == SEMICOLON)
2690 {
2691 ++lexer;
2692 match.hit = true;
2693 }
2694 if (match.hit)
2695 {
2696 *parentMatch40 = match;
2697 }
2698 else
2699 {
2700 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
2701 }
2702 }
2703 if (match.hit)
2704 {
2705 s.end = span.end;
2706 {
2707 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2708
2709 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2710 return soulng::parser::Match(true, new sngcpp::ast::GotoStatementNode(s, target->value));
2711 }
2712 }
2713 *parentMatch39 = match;
2714 }
2715 *parentMatch38 = match;
2716 }
2717 *parentMatch33 = match;
2718 }
2719 *parentMatch32 = match;
2720 }
2721 *parentMatch0 = match;
2722 }
2723 }
2724 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2725
2726
2727
2728
2729
2730 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2731 if (!match.hit)
2732 {
2733 match.value = nullptr;
2734 }
2735 return match;
2736 }
2737
2738 soulng::parser::Match StatementParser::DeclarationStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
2739 {
2740 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2741
2742
2743
2744
2745
2746
2747
2748 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2749 std::unique_ptr<sngcpp::ast::Node> declaration;
2750 soulng::parser::Match match(false);
2751 soulng::parser::Match* parentMatch0 = &match;
2752 {
2753 int64_t pos = lexer.GetPos();
2754 soulng::lexer::Span span = lexer.GetSpan();
2755 soulng::parser::Match match = DeclarationParser::BlockDeclaration(lexer, ctx);
2756 declaration.reset(static_cast<sngcpp::ast::Node*>(match.value));
2757 if (match.hit)
2758 {
2759 {
2760 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2761
2762 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2763 return soulng::parser::Match(true, new sngcpp::ast::DeclarationStatementNode(span, declaration.release()));
2764 }
2765 }
2766 *parentMatch0 = match;
2767 }
2768 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2769
2770
2771
2772
2773
2774 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2775 if (!match.hit)
2776 {
2777 match.value = nullptr;
2778 }
2779 return match;
2780 }
2781
2782 soulng::parser::Match StatementParser::TryStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
2783 {
2784 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2785
2786
2787
2788
2789
2790
2791
2792 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2793 std::unique_ptr<sngcpp::ast::TryStatementNode> node = std::unique_ptr<sngcpp::ast::TryStatementNode>();
2794 Span s = Span();
2795 std::unique_ptr<sngcpp::ast::CompoundStatementNode> tryBlock;
2796 soulng::parser::Match match(false);
2797 soulng::parser::Match* parentMatch0 = &match;
2798 {
2799 soulng::parser::Match match(false);
2800 soulng::parser::Match* parentMatch1 = &match;
2801 {
2802 soulng::parser::Match match(false);
2803 soulng::parser::Match* parentMatch2 = &match;
2804 {
2805 int64_t pos = lexer.GetPos();
2806 soulng::lexer::Span span = lexer.GetSpan();
2807 soulng::parser::Match match(false);
2808 if (*lexer == TRY)
2809 {
2810 ++lexer;
2811 match.hit = true;
2812 }
2813 if (match.hit)
2814 {
2815 s = span;
2816 }
2817 *parentMatch2 = match;
2818 }
2819 *parentMatch1 = match;
2820 }
2821 if (match.hit)
2822 {
2823 soulng::parser::Match match(false);
2824 soulng::parser::Match* parentMatch3 = &match;
2825 {
2826 soulng::parser::Match match(false);
2827 soulng::parser::Match* parentMatch4 = &match;
2828 {
2829 int64_t pos = lexer.GetPos();
2830 soulng::lexer::Span span = lexer.GetSpan();
2831 soulng::parser::Match match(true);
2832 soulng::parser::Match* parentMatch5 = &match;
2833 {
2834 soulng::lexer::Span span = lexer.GetSpan();
2835 soulng::parser::Match match = StatementParser::CompoundStatement(lexer, ctx);
2836 tryBlock.reset(static_cast<sngcpp::ast::CompoundStatementNode*>(match.value));
2837 if (match.hit)
2838 {
2839 *parentMatch5 = match;
2840 }
2841 else
2842 {
2843 lexer.ThrowExpectationFailure(span, U"CompoundStatement");
2844 }
2845 }
2846 if (match.hit)
2847 {
2848 s.end = span.end;
2849 node.reset(new sngcpp::ast::TryStatementNode(s, tryBlock.release()));
2850 }
2851 *parentMatch4 = match;
2852 }
2853 *parentMatch3 = match;
2854 }
2855 *parentMatch1 = match;
2856 }
2857 *parentMatch0 = match;
2858 }
2859 if (match.hit)
2860 {
2861 soulng::parser::Match match(false);
2862 soulng::parser::Match* parentMatch6 = &match;
2863 {
2864 soulng::parser::Match match(false);
2865 soulng::parser::Match* parentMatch7 = &match;
2866 {
2867 int64_t pos = lexer.GetPos();
2868 soulng::parser::Match match(true);
2869 soulng::parser::Match* parentMatch8 = &match;
2870 {
2871 soulng::lexer::Span span = lexer.GetSpan();
2872 soulng::parser::Match match = StatementParser::HandlerSequence(lexer, ctx, node.get());
2873 if (match.hit)
2874 {
2875 *parentMatch8 = match;
2876 }
2877 else
2878 {
2879 lexer.ThrowExpectationFailure(span, U"HandlerSequence");
2880 }
2881 }
2882 if (match.hit)
2883 {
2884 {
2885 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2886
2887 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2888 return soulng::parser::Match(true, node.release());
2889 }
2890 }
2891 *parentMatch7 = match;
2892 }
2893 *parentMatch6 = match;
2894 }
2895 *parentMatch0 = match;
2896 }
2897 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2898
2899
2900
2901
2902
2903 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2904 if (!match.hit)
2905 {
2906 match.value = nullptr;
2907 }
2908 return match;
2909 }
2910
2911 soulng::parser::Match StatementParser::HandlerSequence(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx, sngcpp::ast::TryStatementNode* tryStatementNode)
2912 {
2913 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2914
2915
2916
2917
2918
2919
2920
2921 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2922 std::unique_ptr<sngcpp::ast::Node> handler;
2923 soulng::parser::Match match(false);
2924 soulng::parser::Match* parentMatch0 = &match;
2925 {
2926 soulng::parser::Match match(false);
2927 soulng::parser::Match* parentMatch1 = &match;
2928 {
2929 soulng::parser::Match match(false);
2930 soulng::parser::Match* parentMatch2 = &match;
2931 {
2932 int64_t pos = lexer.GetPos();
2933 soulng::lexer::Span span = lexer.GetSpan();
2934 soulng::parser::Match match = StatementParser::Handler(lexer, ctx);
2935 handler.reset(static_cast<sngcpp::ast::Node*>(match.value));
2936 if (match.hit)
2937 {
2938 tryStatementNode->AddHandler(span, handler.release());
2939 }
2940 *parentMatch2 = match;
2941 }
2942 *parentMatch1 = match;
2943 }
2944 *parentMatch0 = match;
2945 }
2946 if (match.hit)
2947 {
2948 soulng::parser::Match match(true);
2949 soulng::parser::Match* parentMatch3 = &match;
2950 while (true)
2951 {
2952 int64_t save = lexer.GetPos();
2953 {
2954 soulng::parser::Match match(false);
2955 soulng::parser::Match* parentMatch4 = &match;
2956 {
2957 soulng::parser::Match match(false);
2958 soulng::parser::Match* parentMatch5 = &match;
2959 {
2960 int64_t pos = lexer.GetPos();
2961 soulng::lexer::Span span = lexer.GetSpan();
2962 soulng::parser::Match match = StatementParser::Handler(lexer, ctx);
2963 handler.reset(static_cast<sngcpp::ast::Node*>(match.value));
2964 if (match.hit)
2965 {
2966 tryStatementNode->AddHandler(span, handler.release());
2967 }
2968 *parentMatch5 = match;
2969 }
2970 *parentMatch4 = match;
2971 }
2972 if (match.hit)
2973 {
2974 *parentMatch3 = match;
2975 }
2976 else
2977 {
2978 lexer.SetPos(save);
2979 break;
2980 }
2981 }
2982 }
2983 }
2984 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
2985
2986
2987
2988
2989
2990 #endif // SOULNG_PARSER_DEBUG_SUPPORT
2991 if (!match.hit)
2992 {
2993 match.value = nullptr;
2994 }
2995 return match;
2996 }
2997
2998 soulng::parser::Match StatementParser::Handler(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
2999 {
3000 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3001
3002
3003
3004
3005
3006
3007
3008 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3009 Span s = Span();
3010 std::unique_ptr<sngcpp::ast::Node> exceptionDeclaration;
3011 std::unique_ptr<sngcpp::ast::CompoundStatementNode> catchBlock;
3012 soulng::parser::Match match(false);
3013 soulng::parser::Match* parentMatch0 = &match;
3014 {
3015 soulng::parser::Match match(false);
3016 soulng::parser::Match* parentMatch1 = &match;
3017 {
3018 soulng::parser::Match match(false);
3019 soulng::parser::Match* parentMatch2 = &match;
3020 {
3021 soulng::parser::Match match(false);
3022 soulng::parser::Match* parentMatch3 = &match;
3023 {
3024 soulng::parser::Match match(false);
3025 soulng::parser::Match* parentMatch4 = &match;
3026 {
3027 int64_t pos = lexer.GetPos();
3028 soulng::lexer::Span span = lexer.GetSpan();
3029 soulng::parser::Match match(false);
3030 if (*lexer == CATCH)
3031 {
3032 ++lexer;
3033 match.hit = true;
3034 }
3035 if (match.hit)
3036 {
3037 s = span;
3038 }
3039 *parentMatch4 = match;
3040 }
3041 *parentMatch3 = match;
3042 }
3043 if (match.hit)
3044 {
3045 soulng::parser::Match match(false);
3046 soulng::parser::Match* parentMatch5 = &match;
3047 {
3048 soulng::parser::Match match(true);
3049 soulng::parser::Match* parentMatch6 = &match;
3050 {
3051 soulng::lexer::Span span = lexer.GetSpan();
3052 soulng::parser::Match match(false);
3053 if (*lexer == LPAREN)
3054 {
3055 ++lexer;
3056 match.hit = true;
3057 }
3058 if (match.hit)
3059 {
3060 *parentMatch6 = match;
3061 }
3062 else
3063 {
3064 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(LPAREN)));
3065 }
3066 }
3067 *parentMatch5 = match;
3068 }
3069 *parentMatch3 = match;
3070 }
3071 *parentMatch2 = match;
3072 }
3073 if (match.hit)
3074 {
3075 soulng::parser::Match match(false);
3076 soulng::parser::Match* parentMatch7 = &match;
3077 {
3078 soulng::parser::Match match(true);
3079 soulng::parser::Match* parentMatch8 = &match;
3080 {
3081 soulng::lexer::Span span = lexer.GetSpan();
3082 soulng::parser::Match match = StatementParser::ExceptionDeclaration(lexer, ctx);
3083 exceptionDeclaration.reset(static_cast<sngcpp::ast::Node*>(match.value));
3084 if (match.hit)
3085 {
3086 *parentMatch8 = match;
3087 }
3088 else
3089 {
3090 lexer.ThrowExpectationFailure(span, U"ExceptionDeclaration");
3091 }
3092 }
3093 *parentMatch7 = match;
3094 }
3095 *parentMatch2 = match;
3096 }
3097 *parentMatch1 = match;
3098 }
3099 if (match.hit)
3100 {
3101 soulng::parser::Match match(false);
3102 soulng::parser::Match* parentMatch9 = &match;
3103 {
3104 soulng::parser::Match match(true);
3105 soulng::parser::Match* parentMatch10 = &match;
3106 {
3107 soulng::lexer::Span span = lexer.GetSpan();
3108 soulng::parser::Match match(false);
3109 if (*lexer == RPAREN)
3110 {
3111 ++lexer;
3112 match.hit = true;
3113 }
3114 if (match.hit)
3115 {
3116 *parentMatch10 = match;
3117 }
3118 else
3119 {
3120 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RPAREN)));
3121 }
3122 }
3123 *parentMatch9 = match;
3124 }
3125 *parentMatch1 = match;
3126 }
3127 *parentMatch0 = match;
3128 }
3129 if (match.hit)
3130 {
3131 soulng::parser::Match match(false);
3132 soulng::parser::Match* parentMatch11 = &match;
3133 {
3134 soulng::parser::Match match(false);
3135 soulng::parser::Match* parentMatch12 = &match;
3136 {
3137 int64_t pos = lexer.GetPos();
3138 soulng::lexer::Span span = lexer.GetSpan();
3139 soulng::parser::Match match(true);
3140 soulng::parser::Match* parentMatch13 = &match;
3141 {
3142 soulng::lexer::Span span = lexer.GetSpan();
3143 soulng::parser::Match match = StatementParser::CompoundStatement(lexer, ctx);
3144 catchBlock.reset(static_cast<sngcpp::ast::CompoundStatementNode*>(match.value));
3145 if (match.hit)
3146 {
3147 *parentMatch13 = match;
3148 }
3149 else
3150 {
3151 lexer.ThrowExpectationFailure(span, U"CompoundStatement");
3152 }
3153 }
3154 if (match.hit)
3155 {
3156 s.end = span.end;
3157 {
3158 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3159
3160 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3161 return soulng::parser::Match(true, new sngcpp::ast::HandlerNode(s, exceptionDeclaration.release(), catchBlock.release()));
3162 }
3163 }
3164 *parentMatch12 = match;
3165 }
3166 *parentMatch11 = match;
3167 }
3168 *parentMatch0 = match;
3169 }
3170 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3171
3172
3173
3174
3175
3176 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3177 if (!match.hit)
3178 {
3179 match.value = nullptr;
3180 }
3181 return match;
3182 }
3183
3184 soulng::parser::Match StatementParser::Condition(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
3185 {
3186 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3187
3188
3189
3190
3191
3192
3193
3194 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3195 Span s = Span();
3196 std::unique_ptr<sngcpp::ast::Node> typeExpr;
3197 std::unique_ptr<sngcpp::ast::Node> declarator;
3198 std::unique_ptr<sngcpp::ast::Node> ic;
3199 std::unique_ptr<sngcpp::ast::Node> bi;
3200 std::unique_ptr<sngcpp::ast::Node> expr;
3201 soulng::parser::Match match(false);
3202 soulng::parser::Match* parentMatch0 = &match;
3203 {
3204 int64_t save = lexer.GetPos();
3205 soulng::parser::Match match(false);
3206 soulng::parser::Match* parentMatch1 = &match;
3207 {
3208 soulng::parser::Match match(false);
3209 soulng::parser::Match* parentMatch2 = &match;
3210 {
3211 soulng::parser::Match match(false);
3212 soulng::parser::Match* parentMatch3 = &match;
3213 {
3214 int64_t pos = lexer.GetPos();
3215 soulng::lexer::Span span = lexer.GetSpan();
3216 soulng::parser::Match match = TypeExprParser::TypeExpr(lexer, ctx);
3217 typeExpr.reset(static_cast<sngcpp::ast::Node*>(match.value));
3218 if (match.hit)
3219 {
3220 s = span;
3221 }
3222 *parentMatch3 = match;
3223 }
3224 *parentMatch2 = match;
3225 }
3226 if (match.hit)
3227 {
3228 soulng::parser::Match match(false);
3229 soulng::parser::Match* parentMatch4 = &match;
3230 {
3231 soulng::parser::Match match = DeclaratorParser::Declarator(lexer, ctx);
3232 declarator.reset(static_cast<sngcpp::ast::Node*>(match.value));
3233 *parentMatch4 = match;
3234 }
3235 *parentMatch2 = match;
3236 }
3237 *parentMatch1 = match;
3238 }
3239 if (match.hit)
3240 {
3241 soulng::parser::Match match(false);
3242 soulng::parser::Match* parentMatch5 = &match;
3243 {
3244 soulng::parser::Match match(false);
3245 soulng::parser::Match* parentMatch6 = &match;
3246 {
3247 soulng::parser::Match match(false);
3248 soulng::parser::Match* parentMatch7 = &match;
3249 {
3250 int64_t save = lexer.GetPos();
3251 soulng::parser::Match match(false);
3252 soulng::parser::Match* parentMatch8 = &match;
3253 {
3254 soulng::parser::Match match(false);
3255 if (*lexer == ASSIGN)
3256 {
3257 ++lexer;
3258 match.hit = true;
3259 }
3260 *parentMatch8 = match;
3261 }
3262 if (match.hit)
3263 {
3264 soulng::parser::Match match(false);
3265 soulng::parser::Match* parentMatch9 = &match;
3266 {
3267 soulng::parser::Match match(false);
3268 soulng::parser::Match* parentMatch10 = &match;
3269 {
3270 int64_t pos = lexer.GetPos();
3271 soulng::lexer::Span span = lexer.GetSpan();
3272 soulng::parser::Match match = DeclaratorParser::InitializerClause(lexer, ctx);
3273 ic.reset(static_cast<sngcpp::ast::Node*>(match.value));
3274 if (match.hit)
3275 {
3276 s.end = span.end;
3277 {
3278 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3279
3280 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3281 return soulng::parser::Match(true, new sngcpp::ast::SimpleDeclarationNode(s, sngcpp::ast::Specifier::none, typeExpr.release(), new sngcpp::ast::InitDeclaratorNode(s, declarator.release(), new sngcpp::ast::AssignmentInitializerNode(s, ic.release()))));
3282 }
3283 }
3284 *parentMatch10 = match;
3285 }
3286 *parentMatch9 = match;
3287 }
3288 *parentMatch8 = match;
3289 }
3290 *parentMatch7 = match;
3291 if (!match.hit)
3292 {
3293 soulng::parser::Match match(false);
3294 soulng::parser::Match* parentMatch11 = &match;
3295 lexer.SetPos(save);
3296 {
3297 soulng::parser::Match match(false);
3298 soulng::parser::Match* parentMatch12 = &match;
3299 {
3300 int64_t pos = lexer.GetPos();
3301 soulng::lexer::Span span = lexer.GetSpan();
3302 soulng::parser::Match match = DeclaratorParser::BracedInitializerList(lexer, ctx);
3303 bi.reset(static_cast<sngcpp::ast::Node*>(match.value));
3304 if (match.hit)
3305 {
3306 s.end = span.end;
3307 {
3308 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3309
3310 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3311 return soulng::parser::Match(true, new sngcpp::ast::SimpleDeclarationNode(s, sngcpp::ast::Specifier::none, typeExpr.release(), new sngcpp::ast::InitDeclaratorNode(s, declarator.release(), bi.release())));
3312 }
3313 }
3314 *parentMatch12 = match;
3315 }
3316 *parentMatch11 = match;
3317 }
3318 *parentMatch7 = match;
3319 }
3320 }
3321 *parentMatch6 = match;
3322 }
3323 *parentMatch5 = match;
3324 }
3325 *parentMatch1 = match;
3326 }
3327 *parentMatch0 = match;
3328 if (!match.hit)
3329 {
3330 soulng::parser::Match match(false);
3331 soulng::parser::Match* parentMatch13 = &match;
3332 lexer.SetPos(save);
3333 {
3334 soulng::parser::Match match(false);
3335 soulng::parser::Match* parentMatch14 = &match;
3336 {
3337 int64_t pos = lexer.GetPos();
3338 soulng::parser::Match match = ExpressionParser::Expression(lexer, ctx);
3339 expr.reset(static_cast<sngcpp::ast::Node*>(match.value));
3340 if (match.hit)
3341 {
3342 {
3343 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3344
3345 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3346 return soulng::parser::Match(true, expr.release());
3347 }
3348 }
3349 *parentMatch14 = match;
3350 }
3351 *parentMatch13 = match;
3352 }
3353 *parentMatch0 = match;
3354 }
3355 }
3356 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3357
3358
3359
3360
3361
3362 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3363 if (!match.hit)
3364 {
3365 match.value = nullptr;
3366 }
3367 return match;
3368 }
3369
3370 soulng::parser::Match StatementParser::ForRangeDeclaration(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
3371 {
3372 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3373
3374
3375
3376
3377
3378
3379
3380 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3381 Span s = Span();
3382 std::unique_ptr<sngcpp::ast::Node> typeExpr;
3383 std::unique_ptr<sngcpp::ast::Node> declarator;
3384 soulng::parser::Match match(false);
3385 soulng::parser::Match* parentMatch0 = &match;
3386 {
3387 soulng::parser::Match match(false);
3388 soulng::parser::Match* parentMatch1 = &match;
3389 {
3390 int64_t pos = lexer.GetPos();
3391 soulng::lexer::Span span = lexer.GetSpan();
3392 soulng::parser::Match match = TypeExprParser::TypeExpr(lexer, ctx);
3393 typeExpr.reset(static_cast<sngcpp::ast::Node*>(match.value));
3394 if (match.hit)
3395 {
3396 s = span;
3397 }
3398 *parentMatch1 = match;
3399 }
3400 *parentMatch0 = match;
3401 }
3402 if (match.hit)
3403 {
3404 soulng::parser::Match match(false);
3405 soulng::parser::Match* parentMatch2 = &match;
3406 {
3407 soulng::parser::Match match(false);
3408 soulng::parser::Match* parentMatch3 = &match;
3409 {
3410 int64_t pos = lexer.GetPos();
3411 soulng::lexer::Span span = lexer.GetSpan();
3412 soulng::parser::Match match = DeclaratorParser::Declarator(lexer, ctx);
3413 declarator.reset(static_cast<sngcpp::ast::Node*>(match.value));
3414 if (match.hit)
3415 {
3416 s.end = span.end;
3417 {
3418 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3419
3420 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3421 return soulng::parser::Match(true, new sngcpp::ast::SimpleDeclarationNode(s, sngcpp::ast::Specifier::none, typeExpr.release(), declarator.release()));
3422 }
3423 }
3424 *parentMatch3 = match;
3425 }
3426 *parentMatch2 = match;
3427 }
3428 *parentMatch0 = match;
3429 }
3430 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3431
3432
3433
3434
3435
3436 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3437 if (!match.hit)
3438 {
3439 match.value = nullptr;
3440 }
3441 return match;
3442 }
3443
3444 soulng::parser::Match StatementParser::ForRangeInitializer(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
3445 {
3446 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3447
3448
3449
3450
3451
3452
3453
3454 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3455 std::unique_ptr<sngcpp::ast::Node> expr;
3456 std::unique_ptr<sngcpp::ast::Node> bi;
3457 soulng::parser::Match match(false);
3458 soulng::parser::Match* parentMatch0 = &match;
3459 {
3460 int64_t save = lexer.GetPos();
3461 soulng::parser::Match match(false);
3462 soulng::parser::Match* parentMatch1 = &match;
3463 {
3464 int64_t pos = lexer.GetPos();
3465 soulng::parser::Match match = ExpressionParser::Expression(lexer, ctx);
3466 expr.reset(static_cast<sngcpp::ast::Node*>(match.value));
3467 if (match.hit)
3468 {
3469 {
3470 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3471
3472 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3473 return soulng::parser::Match(true, expr.release());
3474 }
3475 }
3476 *parentMatch1 = match;
3477 }
3478 *parentMatch0 = match;
3479 if (!match.hit)
3480 {
3481 soulng::parser::Match match(false);
3482 soulng::parser::Match* parentMatch2 = &match;
3483 lexer.SetPos(save);
3484 {
3485 soulng::parser::Match match(false);
3486 soulng::parser::Match* parentMatch3 = &match;
3487 {
3488 int64_t pos = lexer.GetPos();
3489 soulng::parser::Match match = DeclaratorParser::BracedInitializerList(lexer, ctx);
3490 bi.reset(static_cast<sngcpp::ast::Node*>(match.value));
3491 if (match.hit)
3492 {
3493 {
3494 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3495
3496 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3497 return soulng::parser::Match(true, bi.release());
3498 }
3499 }
3500 *parentMatch3 = match;
3501 }
3502 *parentMatch2 = match;
3503 }
3504 *parentMatch0 = match;
3505 }
3506 }
3507 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3508
3509
3510
3511
3512
3513 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3514 if (!match.hit)
3515 {
3516 match.value = nullptr;
3517 }
3518 return match;
3519 }
3520
3521 soulng::parser::Match StatementParser::ForInitStatement(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
3522 {
3523 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3524
3525
3526
3527
3528
3529
3530
3531 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3532 std::unique_ptr<sngcpp::ast::Node> expressionStatement;
3533 std::unique_ptr<sngcpp::ast::Node> simpleDeclaration;
3534 soulng::parser::Match match(false);
3535 soulng::parser::Match* parentMatch0 = &match;
3536 {
3537 int64_t save = lexer.GetPos();
3538 soulng::parser::Match match(false);
3539 soulng::parser::Match* parentMatch1 = &match;
3540 {
3541 int64_t pos = lexer.GetPos();
3542 soulng::parser::Match match = StatementParser::ExpressionStatement(lexer, ctx);
3543 expressionStatement.reset(static_cast<sngcpp::ast::Node*>(match.value));
3544 if (match.hit)
3545 {
3546 {
3547 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3548
3549 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3550 return soulng::parser::Match(true, expressionStatement.release());
3551 }
3552 }
3553 *parentMatch1 = match;
3554 }
3555 *parentMatch0 = match;
3556 if (!match.hit)
3557 {
3558 soulng::parser::Match match(false);
3559 soulng::parser::Match* parentMatch2 = &match;
3560 lexer.SetPos(save);
3561 {
3562 soulng::parser::Match match(false);
3563 soulng::parser::Match* parentMatch3 = &match;
3564 {
3565 int64_t pos = lexer.GetPos();
3566 soulng::parser::Match match = DeclarationParser::SimpleDeclaration(lexer, ctx);
3567 simpleDeclaration.reset(static_cast<sngcpp::ast::Node*>(match.value));
3568 if (match.hit)
3569 {
3570 {
3571 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3572
3573 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3574 return soulng::parser::Match(true, simpleDeclaration.release());
3575 }
3576 }
3577 *parentMatch3 = match;
3578 }
3579 *parentMatch2 = match;
3580 }
3581 *parentMatch0 = match;
3582 }
3583 }
3584 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3585
3586
3587
3588
3589
3590 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3591 if (!match.hit)
3592 {
3593 match.value = nullptr;
3594 }
3595 return match;
3596 }
3597
3598 soulng::parser::Match StatementParser::ExceptionDeclaration(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
3599 {
3600 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3601
3602
3603
3604
3605
3606
3607
3608 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3609 Span s = Span();
3610 std::unique_ptr<sngcpp::ast::Node> typeExpr;
3611 std::unique_ptr<sngcpp::ast::Node> declarator;
3612 soulng::parser::Match match(false);
3613 soulng::parser::Match* parentMatch0 = &match;
3614 {
3615 int64_t save = lexer.GetPos();
3616 soulng::parser::Match match(false);
3617 soulng::parser::Match* parentMatch1 = &match;
3618 {
3619 int64_t pos = lexer.GetPos();
3620 soulng::parser::Match match(false);
3621 soulng::parser::Match* parentMatch2 = &match;
3622 {
3623 soulng::parser::Match match(false);
3624 soulng::parser::Match* parentMatch3 = &match;
3625 {
3626 soulng::parser::Match match(false);
3627 soulng::parser::Match* parentMatch4 = &match;
3628 {
3629 int64_t pos = lexer.GetPos();
3630 soulng::lexer::Span span = lexer.GetSpan();
3631 soulng::parser::Match match = TypeExprParser::TypeExpr(lexer, ctx);
3632 typeExpr.reset(static_cast<sngcpp::ast::Node*>(match.value));
3633 if (match.hit)
3634 {
3635 s = span;
3636 }
3637 *parentMatch4 = match;
3638 }
3639 *parentMatch3 = match;
3640 }
3641 if (match.hit)
3642 {
3643 soulng::parser::Match match(false);
3644 soulng::parser::Match* parentMatch5 = &match;
3645 {
3646 soulng::parser::Match match(true);
3647 int64_t save = lexer.GetPos();
3648 soulng::parser::Match* parentMatch6 = &match;
3649 {
3650 soulng::parser::Match match(false);
3651 soulng::parser::Match* parentMatch7 = &match;
3652 {
3653 soulng::parser::Match match(false);
3654 soulng::parser::Match* parentMatch8 = &match;
3655 {
3656 int64_t pos = lexer.GetPos();
3657 soulng::lexer::Span span = lexer.GetSpan();
3658 soulng::parser::Match match = DeclaratorParser::Declarator(lexer, ctx);
3659 declarator.reset(static_cast<sngcpp::ast::Node*>(match.value));
3660 if (match.hit)
3661 {
3662 s.end = span.end;
3663 }
3664 *parentMatch8 = match;
3665 }
3666 *parentMatch7 = match;
3667 }
3668 if (match.hit)
3669 {
3670 *parentMatch6 = match;
3671 }
3672 else
3673 {
3674 lexer.SetPos(save);
3675 }
3676 }
3677 *parentMatch5 = match;
3678 }
3679 *parentMatch3 = match;
3680 }
3681 *parentMatch2 = match;
3682 }
3683 if (match.hit)
3684 {
3685 {
3686 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3687
3688 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3689 return soulng::parser::Match(true, new sngcpp::ast::SimpleDeclarationNode(s, sngcpp::ast::Specifier::none, typeExpr.release(), declarator.release()));
3690 }
3691 }
3692 *parentMatch1 = match;
3693 }
3694 *parentMatch0 = match;
3695 if (!match.hit)
3696 {
3697 soulng::parser::Match match(false);
3698 soulng::parser::Match* parentMatch9 = &match;
3699 lexer.SetPos(save);
3700 {
3701 soulng::parser::Match match(false);
3702 soulng::parser::Match* parentMatch10 = &match;
3703 {
3704 int64_t pos = lexer.GetPos();
3705 soulng::lexer::Span span = lexer.GetSpan();
3706 soulng::parser::Match match(false);
3707 if (*lexer == ELLIPSES)
3708 {
3709 ++lexer;
3710 match.hit = true;
3711 }
3712 if (match.hit)
3713 {
3714 {
3715 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3716
3717 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3718 return soulng::parser::Match(true, new sngcpp::ast::CatchAllNode(span));
3719 }
3720 }
3721 *parentMatch10 = match;
3722 }
3723 *parentMatch9 = match;
3724 }
3725 *parentMatch0 = match;
3726 }
3727 }
3728 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
3729
3730
3731
3732
3733
3734 #endif // SOULNG_PARSER_DEBUG_SUPPORT
3735 if (!match.hit)
3736 {
3737 match.value = nullptr;
3738 }
3739 return match;
3740 }