1 #include "Declarator.hpp"
2 #include <soulng/util/Unicode.hpp>
3 #include <sngcpp/parser/Function.hpp>
4 #include <sngcpp/parser/Identifier.hpp>
5 #include <sngcpp/parser/Expression.hpp>
6 #include <sngcpp/parser/TypeExpr.hpp>
7 #include <sngcpp/lexer/CppLexer.hpp>
8 #include <sngcpp/lexer/CppTokens.hpp>
9
10
11
12 using namespace soulng::unicode;
13 using namespace CppTokens;
14 using namespace soulng::lexer;
15
16 soulng::parser::Match DeclaratorParser::InitDeclarator(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
17 {
18 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
19
20
21
22
23
24
25
26 #endif // SOULNG_PARSER_DEBUG_SUPPORT
27 Span s = Span();
28 std::unique_ptr<sngcpp::ast::Node> declarator;
29 std::unique_ptr<sngcpp::ast::Node> initializer;
30 soulng::parser::Match match(false);
31 soulng::parser::Match* parentMatch0 = &match;
32 {
33 soulng::parser::Match match(false);
34 soulng::parser::Match* parentMatch1 = &match;
35 {
36 int64_t pos = lexer.GetPos();
37 soulng::lexer::Span span = lexer.GetSpan();
38 soulng::parser::Match match = DeclaratorParser::Declarator(lexer, ctx);
39 declarator.reset(static_cast<sngcpp::ast::Node*>(match.value));
40 if (match.hit)
41 {
42 s = span;
43 }
44 *parentMatch1 = match;
45 }
46 *parentMatch0 = match;
47 }
48 if (match.hit)
49 {
50 soulng::parser::Match match(false);
51 soulng::parser::Match* parentMatch2 = &match;
52 {
53 soulng::parser::Match match(false);
54 soulng::parser::Match* parentMatch3 = &match;
55 {
56 soulng::parser::Match match(false);
57 soulng::parser::Match* parentMatch4 = &match;
58 {
59 int64_t save = lexer.GetPos();
60 soulng::parser::Match match(false);
61 soulng::parser::Match* parentMatch5 = &match;
62 {
63 int64_t pos = lexer.GetPos();
64 soulng::lexer::Span span = lexer.GetSpan();
65 soulng::parser::Match match = DeclaratorParser::Initializer(lexer, ctx);
66 initializer.reset(static_cast<sngcpp::ast::Node*>(match.value));
67 if (match.hit)
68 {
69 s.end = span.end;
70 {
71 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
72
73 #endif // SOULNG_PARSER_DEBUG_SUPPORT
74 return soulng::parser::Match(true, new sngcpp::ast::InitDeclaratorNode(s, declarator.release(), initializer.release()));
75 }
76 }
77 *parentMatch5 = match;
78 }
79 *parentMatch4 = match;
80 if (!match.hit)
81 {
82 soulng::parser::Match match(false);
83 soulng::parser::Match* parentMatch6 = &match;
84 lexer.SetPos(save);
85 {
86 soulng::parser::Match match(false);
87 soulng::parser::Match* parentMatch7 = &match;
88 {
89 int64_t pos = lexer.GetPos();
90 soulng::parser::Match match(true);
91 if (match.hit)
92 {
93 {
94 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
95
96 #endif // SOULNG_PARSER_DEBUG_SUPPORT
97 return soulng::parser::Match(true, declarator.release());
98 }
99 }
100 *parentMatch7 = match;
101 }
102 *parentMatch6 = match;
103 }
104 *parentMatch4 = match;
105 }
106 }
107 *parentMatch3 = match;
108 }
109 *parentMatch2 = match;
110 }
111 *parentMatch0 = match;
112 }
113 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
114
115
116
117
118
119 #endif // SOULNG_PARSER_DEBUG_SUPPORT
120 if (!match.hit)
121 {
122 match.value = nullptr;
123 }
124 return match;
125 }
126
127 soulng::parser::Match DeclaratorParser::Declarator(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
128 {
129 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
130
131
132
133
134
135
136
137 #endif // SOULNG_PARSER_DEBUG_SUPPORT
138 std::unique_ptr<sngcpp::ast::Node> node = std::unique_ptr<sngcpp::ast::Node>();
139 Span s = Span();
140 std::unique_ptr<sngcpp::ast::Node> idExpr;
141 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>id1;
142 std::unique_ptr<sngcpp::ast::Node> nns;
143 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>id2;
144 std::unique_ptr<sngcpp::ast::Node> params;
145 std::unique_ptr<soulng::parser::soulng::parser::Value<sngcpp::ast::Specifier>>cvseq;
146 std::unique_ptr<sngcpp::ast::Node> size;
147 soulng::parser::Match match(false);
148 soulng::parser::Match* parentMatch0 = &match;
149 {
150 int64_t pos = lexer.GetPos();
151 soulng::parser::Match match(false);
152 soulng::parser::Match* parentMatch1 = &match;
153 {
154 soulng::parser::Match match(false);
155 soulng::parser::Match* parentMatch2 = &match;
156 {
157 soulng::parser::Match match(false);
158 soulng::parser::Match* parentMatch3 = &match;
159 {
160 soulng::parser::Match match(false);
161 soulng::parser::Match* parentMatch4 = &match;
162 {
163 int64_t save = lexer.GetPos();
164 soulng::parser::Match match(false);
165 soulng::parser::Match* parentMatch5 = &match;
166 {
167 int64_t save = lexer.GetPos();
168 soulng::parser::Match match(false);
169 soulng::parser::Match* parentMatch6 = &match;
170 {
171 int64_t pos = lexer.GetPos();
172 soulng::lexer::Span span = lexer.GetSpan();
173 soulng::parser::Match match = ExpressionParser::IdExpression(lexer, ctx);
174 idExpr.reset(static_cast<sngcpp::ast::Node*>(match.value));
175 if (match.hit)
176 {
177 node.reset(new sngcpp::ast::IdDeclaratorNode(span, idExpr.release()));
178 s = span;
179 }
180 *parentMatch6 = match;
181 }
182 *parentMatch5 = match;
183 if (!match.hit)
184 {
185 soulng::parser::Match match(false);
186 soulng::parser::Match* parentMatch7 = &match;
187 lexer.SetPos(save);
188 {
189 soulng::parser::Match match(false);
190 soulng::parser::Match* parentMatch8 = &match;
191 {
192 soulng::parser::Match match(false);
193 soulng::parser::Match* parentMatch9 = &match;
194 {
195 soulng::parser::Match match(false);
196 soulng::parser::Match* parentMatch10 = &match;
197 {
198 soulng::parser::Match match(false);
199 soulng::parser::Match* parentMatch11 = &match;
200 {
201 soulng::parser::Match match(false);
202 soulng::parser::Match* parentMatch12 = &match;
203 {
204 int64_t pos = lexer.GetPos();
205 soulng::lexer::Span span = lexer.GetSpan();
206 soulng::parser::Match match(false);
207 if (*lexer == LPAREN)
208 {
209 ++lexer;
210 match.hit = true;
211 }
212 if (match.hit)
213 {
214 s = span;
215 }
216 *parentMatch12 = match;
217 }
218 *parentMatch11 = match;
219 }
220 if (match.hit)
221 {
222 soulng::parser::Match match(false);
223 soulng::parser::Match* parentMatch13 = &match;
224 {
225 soulng::parser::Match match(false);
226 if (*lexer == STAR)
227 {
228 ++lexer;
229 match.hit = true;
230 }
231 *parentMatch13 = match;
232 }
233 *parentMatch11 = match;
234 }
235 *parentMatch10 = match;
236 }
237 if (match.hit)
238 {
239 soulng::parser::Match match(false);
240 soulng::parser::Match* parentMatch14 = &match;
241 {
242 soulng::parser::Match match = IdentifierParser::Identifier(lexer);
243 id1.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
244 *parentMatch14 = match;
245 }
246 *parentMatch10 = match;
247 }
248 *parentMatch9 = match;
249 }
250 if (match.hit)
251 {
252 soulng::parser::Match match(false);
253 soulng::parser::Match* parentMatch15 = &match;
254 {
255 soulng::parser::Match match(false);
256 soulng::parser::Match* parentMatch16 = &match;
257 {
258 int64_t pos = lexer.GetPos();
259 soulng::lexer::Span span = lexer.GetSpan();
260 soulng::parser::Match match(false);
261 if (*lexer == RPAREN)
262 {
263 ++lexer;
264 match.hit = true;
265 }
266 if (match.hit)
267 {
268 s.end = span.end;
269 node.reset(new sngcpp::ast::FunctionPtrIdNode(s, id1->value));
270 }
271 *parentMatch16 = match;
272 }
273 *parentMatch15 = match;
274 }
275 *parentMatch9 = match;
276 }
277 *parentMatch8 = match;
278 }
279 *parentMatch7 = match;
280 }
281 *parentMatch5 = match;
282 }
283 }
284 *parentMatch4 = match;
285 if (!match.hit)
286 {
287 soulng::parser::Match match(false);
288 soulng::parser::Match* parentMatch17 = &match;
289 lexer.SetPos(save);
290 {
291 soulng::parser::Match match(false);
292 soulng::parser::Match* parentMatch18 = &match;
293 {
294 soulng::parser::Match match(false);
295 soulng::parser::Match* parentMatch19 = &match;
296 {
297 soulng::parser::Match match(false);
298 soulng::parser::Match* parentMatch20 = &match;
299 {
300 soulng::parser::Match match(false);
301 soulng::parser::Match* parentMatch21 = &match;
302 {
303 soulng::parser::Match match(false);
304 soulng::parser::Match* parentMatch22 = &match;
305 {
306 soulng::parser::Match match(false);
307 soulng::parser::Match* parentMatch23 = &match;
308 {
309 int64_t pos = lexer.GetPos();
310 soulng::lexer::Span span = lexer.GetSpan();
311 soulng::parser::Match match(false);
312 if (*lexer == LPAREN)
313 {
314 ++lexer;
315 match.hit = true;
316 }
317 if (match.hit)
318 {
319 s = span;
320 }
321 *parentMatch23 = match;
322 }
323 *parentMatch22 = match;
324 }
325 if (match.hit)
326 {
327 soulng::parser::Match match(false);
328 soulng::parser::Match* parentMatch24 = &match;
329 {
330 soulng::parser::Match match(false);
331 soulng::parser::Match* parentMatch25 = &match;
332 {
333 int64_t pos = lexer.GetPos();
334 soulng::parser::Match match = IdentifierParser::NestedNameSpecifier(lexer, ctx);
335 nns.reset(static_cast<sngcpp::ast::Node*>(match.value));
336 if (match.hit)
337 {
338 node.reset(nns.release());
339 }
340 *parentMatch25 = match;
341 }
342 *parentMatch24 = match;
343 }
344 *parentMatch22 = match;
345 }
346 *parentMatch21 = match;
347 }
348 if (match.hit)
349 {
350 soulng::parser::Match match(false);
351 soulng::parser::Match* parentMatch26 = &match;
352 {
353 soulng::parser::Match match(false);
354 if (*lexer == STAR)
355 {
356 ++lexer;
357 match.hit = true;
358 }
359 *parentMatch26 = match;
360 }
361 *parentMatch21 = match;
362 }
363 *parentMatch20 = match;
364 }
365 if (match.hit)
366 {
367 soulng::parser::Match match(false);
368 soulng::parser::Match* parentMatch27 = &match;
369 {
370 soulng::parser::Match match = IdentifierParser::Identifier(lexer);
371 id2.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
372 *parentMatch27 = match;
373 }
374 *parentMatch20 = match;
375 }
376 *parentMatch19 = match;
377 }
378 if (match.hit)
379 {
380 soulng::parser::Match match(false);
381 soulng::parser::Match* parentMatch28 = &match;
382 {
383 soulng::parser::Match match(false);
384 soulng::parser::Match* parentMatch29 = &match;
385 {
386 int64_t pos = lexer.GetPos();
387 soulng::lexer::Span span = lexer.GetSpan();
388 soulng::parser::Match match(false);
389 if (*lexer == RPAREN)
390 {
391 ++lexer;
392 match.hit = true;
393 }
394 if (match.hit)
395 {
396 s.end = span.end;
397 node.reset(new sngcpp::ast::MemberFunctionPtrIdNode(s, node.release(), id2->value));
398 }
399 *parentMatch29 = match;
400 }
401 *parentMatch28 = match;
402 }
403 *parentMatch19 = match;
404 }
405 *parentMatch18 = match;
406 }
407 *parentMatch17 = match;
408 }
409 *parentMatch4 = match;
410 }
411 }
412 *parentMatch3 = match;
413 }
414 *parentMatch2 = match;
415 }
416 if (match.hit)
417 {
418 soulng::parser::Match match(false);
419 soulng::parser::Match* parentMatch30 = &match;
420 {
421 soulng::parser::Match match(false);
422 soulng::parser::Match* parentMatch31 = &match;
423 {
424 soulng::parser::Match match(false);
425 soulng::parser::Match* parentMatch32 = &match;
426 {
427 int64_t save = lexer.GetPos();
428 soulng::parser::Match match(false);
429 soulng::parser::Match* parentMatch33 = &match;
430 {
431 soulng::parser::Match match(false);
432 soulng::parser::Match* parentMatch34 = &match;
433 {
434 soulng::parser::Match match(false);
435 soulng::parser::Match* parentMatch35 = &match;
436 {
437 int64_t pos = lexer.GetPos();
438 bool pass = true;
439 soulng::parser::Match match(true);
440 if (match.hit)
441 {
442 pass = !ctx->InFunctionBody();
443 }
444 if (match.hit && !pass)
445 {
446 match = soulng::parser::Match(false);
447 }
448 *parentMatch35 = match;
449 }
450 *parentMatch34 = match;
451 }
452 if (match.hit)
453 {
454 soulng::parser::Match match(false);
455 soulng::parser::Match* parentMatch36 = &match;
456 {
457 soulng::parser::Match match = FunctionParser::ParameterList(lexer, ctx);
458 params.reset(static_cast<sngcpp::ast::Node*>(match.value));
459 *parentMatch36 = match;
460 }
461 *parentMatch34 = match;
462 }
463 *parentMatch33 = match;
464 }
465 if (match.hit)
466 {
467 soulng::parser::Match match(false);
468 soulng::parser::Match* parentMatch37 = &match;
469 {
470 soulng::parser::Match match(false);
471 soulng::parser::Match* parentMatch38 = &match;
472 {
473 int64_t pos = lexer.GetPos();
474 soulng::lexer::Span span = lexer.GetSpan();
475 soulng::parser::Match match = TypeExprParser::CVSpecifierSequence(lexer);
476 cvseq.reset(static_cast<soulng::parser::soulng::parser::Value<sngcpp::ast::Specifier>*>(match.value));
477 if (match.hit)
478 {
479 s.end = span.end;
480 node.reset(new sngcpp::ast::FunctionDeclaratorNode(s, node.release(), params.release(), cvseq->value));
481 }
482 *parentMatch38 = match;
483 }
484 *parentMatch37 = match;
485 }
486 *parentMatch33 = match;
487 }
488 *parentMatch32 = match;
489 if (!match.hit)
490 {
491 soulng::parser::Match match(false);
492 soulng::parser::Match* parentMatch39 = &match;
493 lexer.SetPos(save);
494 {
495 soulng::parser::Match match(true);
496 soulng::parser::Match* parentMatch40 = &match;
497 {
498 while (true)
499 {
500 int64_t save = lexer.GetPos();
501 {
502 soulng::parser::Match match(false);
503 soulng::parser::Match* parentMatch41 = &match;
504 {
505 soulng::parser::Match match(false);
506 soulng::parser::Match* parentMatch42 = &match;
507 {
508 soulng::parser::Match match(false);
509 soulng::parser::Match* parentMatch43 = &match;
510 {
511 soulng::parser::Match match(false);
512 if (*lexer == LBRACKET)
513 {
514 ++lexer;
515 match.hit = true;
516 }
517 *parentMatch43 = match;
518 }
519 if (match.hit)
520 {
521 soulng::parser::Match match(false);
522 soulng::parser::Match* parentMatch44 = &match;
523 {
524 soulng::parser::Match match(true);
525 int64_t save = lexer.GetPos();
526 soulng::parser::Match* parentMatch45 = &match;
527 {
528 soulng::parser::Match match = ExpressionParser::ConstantExpression(lexer, ctx);
529 size.reset(static_cast<sngcpp::ast::Node*>(match.value));
530 if (match.hit)
531 {
532 *parentMatch45 = match;
533 }
534 else
535 {
536 lexer.SetPos(save);
537 }
538 }
539 *parentMatch44 = match;
540 }
541 *parentMatch43 = match;
542 }
543 *parentMatch42 = match;
544 }
545 if (match.hit)
546 {
547 soulng::parser::Match match(false);
548 soulng::parser::Match* parentMatch46 = &match;
549 {
550 soulng::parser::Match match(false);
551 soulng::parser::Match* parentMatch47 = &match;
552 {
553 int64_t pos = lexer.GetPos();
554 soulng::lexer::Span span = lexer.GetSpan();
555 soulng::parser::Match match(true);
556 soulng::parser::Match* parentMatch48 = &match;
557 {
558 soulng::lexer::Span span = lexer.GetSpan();
559 soulng::parser::Match match(false);
560 if (*lexer == RBRACKET)
561 {
562 ++lexer;
563 match.hit = true;
564 }
565 if (match.hit)
566 {
567 *parentMatch48 = match;
568 }
569 else
570 {
571 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RBRACKET)));
572 }
573 }
574 if (match.hit)
575 {
576 s.end = span.end;
577 node.reset(new sngcpp::ast::ArrayDeclaratorNode(s, node.release(), size.release()));
578 }
579 *parentMatch47 = match;
580 }
581 *parentMatch46 = match;
582 }
583 *parentMatch42 = match;
584 }
585 *parentMatch41 = match;
586 }
587 if (match.hit)
588 {
589 *parentMatch40 = match;
590 }
591 else
592 {
593 lexer.SetPos(save);
594 break;
595 }
596 }
597 }
598 }
599 *parentMatch39 = match;
600 }
601 *parentMatch32 = match;
602 }
603 }
604 *parentMatch31 = match;
605 }
606 *parentMatch30 = match;
607 }
608 *parentMatch2 = match;
609 }
610 *parentMatch1 = match;
611 }
612 if (match.hit)
613 {
614 {
615 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
616
617 #endif // SOULNG_PARSER_DEBUG_SUPPORT
618 return soulng::parser::Match(true, node.release());
619 }
620 }
621 *parentMatch0 = match;
622 }
623 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
624
625
626
627
628
629 #endif // SOULNG_PARSER_DEBUG_SUPPORT
630 if (!match.hit)
631 {
632 match.value = nullptr;
633 }
634 return match;
635 }
636
637 soulng::parser::Match DeclaratorParser::Initializer(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
638 {
639 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
640
641
642
643
644
645
646
647 #endif // SOULNG_PARSER_DEBUG_SUPPORT
648 Span s = Span();
649 std::unique_ptr<sngcpp::ast::Node> ic;
650 std::unique_ptr<sngcpp::ast::Node> exprs;
651 std::unique_ptr<sngcpp::ast::Node> bi;
652 soulng::parser::Match match(false);
653 soulng::parser::Match* parentMatch0 = &match;
654 {
655 int64_t save = lexer.GetPos();
656 soulng::parser::Match match(false);
657 soulng::parser::Match* parentMatch1 = &match;
658 {
659 int64_t save = lexer.GetPos();
660 soulng::parser::Match match(false);
661 soulng::parser::Match* parentMatch2 = &match;
662 {
663 soulng::parser::Match match(false);
664 soulng::parser::Match* parentMatch3 = &match;
665 {
666 int64_t pos = lexer.GetPos();
667 soulng::lexer::Span span = lexer.GetSpan();
668 soulng::parser::Match match(false);
669 if (*lexer == ASSIGN)
670 {
671 ++lexer;
672 match.hit = true;
673 }
674 if (match.hit)
675 {
676 s = span;
677 }
678 *parentMatch3 = match;
679 }
680 *parentMatch2 = match;
681 }
682 if (match.hit)
683 {
684 soulng::parser::Match match(false);
685 soulng::parser::Match* parentMatch4 = &match;
686 {
687 soulng::parser::Match match(false);
688 soulng::parser::Match* parentMatch5 = &match;
689 {
690 int64_t pos = lexer.GetPos();
691 soulng::lexer::Span span = lexer.GetSpan();
692 soulng::parser::Match match = DeclaratorParser::InitializerClause(lexer, ctx);
693 ic.reset(static_cast<sngcpp::ast::Node*>(match.value));
694 if (match.hit)
695 {
696 s.end = span.end;
697 {
698 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
699
700 #endif // SOULNG_PARSER_DEBUG_SUPPORT
701 return soulng::parser::Match(true, new sngcpp::ast::AssignmentInitializerNode(s, ic.release()));
702 }
703 }
704 *parentMatch5 = match;
705 }
706 *parentMatch4 = match;
707 }
708 *parentMatch2 = match;
709 }
710 *parentMatch1 = match;
711 if (!match.hit)
712 {
713 soulng::parser::Match match(false);
714 soulng::parser::Match* parentMatch6 = &match;
715 lexer.SetPos(save);
716 {
717 soulng::parser::Match match(false);
718 soulng::parser::Match* parentMatch7 = &match;
719 {
720 soulng::parser::Match match(false);
721 soulng::parser::Match* parentMatch8 = &match;
722 {
723 soulng::parser::Match match(false);
724 soulng::parser::Match* parentMatch9 = &match;
725 {
726 int64_t pos = lexer.GetPos();
727 soulng::lexer::Span span = lexer.GetSpan();
728 soulng::parser::Match match(false);
729 if (*lexer == LPAREN)
730 {
731 ++lexer;
732 match.hit = true;
733 }
734 if (match.hit)
735 {
736 s = span;
737 }
738 *parentMatch9 = match;
739 }
740 *parentMatch8 = match;
741 }
742 if (match.hit)
743 {
744 soulng::parser::Match match(false);
745 soulng::parser::Match* parentMatch10 = &match;
746 {
747 soulng::parser::Match match = ExpressionParser::ExpressionList(lexer, ctx);
748 exprs.reset(static_cast<sngcpp::ast::Node*>(match.value));
749 *parentMatch10 = match;
750 }
751 *parentMatch8 = match;
752 }
753 *parentMatch7 = match;
754 }
755 if (match.hit)
756 {
757 soulng::parser::Match match(false);
758 soulng::parser::Match* parentMatch11 = &match;
759 {
760 soulng::parser::Match match(false);
761 soulng::parser::Match* parentMatch12 = &match;
762 {
763 int64_t pos = lexer.GetPos();
764 soulng::lexer::Span span = lexer.GetSpan();
765 soulng::parser::Match match(false);
766 if (*lexer == RPAREN)
767 {
768 ++lexer;
769 match.hit = true;
770 }
771 if (match.hit)
772 {
773 s.end = span.end;
774 {
775 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
776
777 #endif // SOULNG_PARSER_DEBUG_SUPPORT
778 return soulng::parser::Match(true, new sngcpp::ast::ExpressionListInitializerNode(s, exprs.release()));
779 }
780 }
781 *parentMatch12 = match;
782 }
783 *parentMatch11 = match;
784 }
785 *parentMatch7 = match;
786 }
787 *parentMatch6 = match;
788 }
789 *parentMatch1 = match;
790 }
791 }
792 *parentMatch0 = match;
793 if (!match.hit)
794 {
795 soulng::parser::Match match(false);
796 soulng::parser::Match* parentMatch13 = &match;
797 lexer.SetPos(save);
798 {
799 soulng::parser::Match match(false);
800 soulng::parser::Match* parentMatch14 = &match;
801 {
802 int64_t pos = lexer.GetPos();
803 soulng::parser::Match match = DeclaratorParser::BracedInitializerList(lexer, ctx);
804 bi.reset(static_cast<sngcpp::ast::Node*>(match.value));
805 if (match.hit)
806 {
807 {
808 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
809
810 #endif // SOULNG_PARSER_DEBUG_SUPPORT
811 return soulng::parser::Match(true, bi.release());
812 }
813 }
814 *parentMatch14 = match;
815 }
816 *parentMatch13 = match;
817 }
818 *parentMatch0 = match;
819 }
820 }
821 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
822
823
824
825
826
827 #endif // SOULNG_PARSER_DEBUG_SUPPORT
828 if (!match.hit)
829 {
830 match.value = nullptr;
831 }
832 return match;
833 }
834
835 soulng::parser::Match DeclaratorParser::BraceOrEqualInitializer(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
836 {
837 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
838
839
840
841
842
843
844
845 #endif // SOULNG_PARSER_DEBUG_SUPPORT
846 Span s = Span();
847 std::unique_ptr<sngcpp::ast::Node> ic;
848 std::unique_ptr<sngcpp::ast::Node> bi;
849 soulng::parser::Match match(false);
850 soulng::parser::Match* parentMatch0 = &match;
851 {
852 int64_t save = lexer.GetPos();
853 soulng::parser::Match match(false);
854 soulng::parser::Match* parentMatch1 = &match;
855 {
856 soulng::parser::Match match(false);
857 soulng::parser::Match* parentMatch2 = &match;
858 {
859 int64_t pos = lexer.GetPos();
860 soulng::lexer::Span span = lexer.GetSpan();
861 soulng::parser::Match match(false);
862 if (*lexer == ASSIGN)
863 {
864 ++lexer;
865 match.hit = true;
866 }
867 if (match.hit)
868 {
869 s = span;
870 }
871 *parentMatch2 = match;
872 }
873 *parentMatch1 = match;
874 }
875 if (match.hit)
876 {
877 soulng::parser::Match match(false);
878 soulng::parser::Match* parentMatch3 = &match;
879 {
880 soulng::parser::Match match(false);
881 soulng::parser::Match* parentMatch4 = &match;
882 {
883 int64_t pos = lexer.GetPos();
884 soulng::lexer::Span span = lexer.GetSpan();
885 soulng::parser::Match match = DeclaratorParser::InitializerClause(lexer, ctx);
886 ic.reset(static_cast<sngcpp::ast::Node*>(match.value));
887 if (match.hit)
888 {
889 s.end = span.end;
890 {
891 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
892
893 #endif // SOULNG_PARSER_DEBUG_SUPPORT
894 return soulng::parser::Match(true, new sngcpp::ast::AssignmentInitializerNode(s, ic.release()));
895 }
896 }
897 *parentMatch4 = match;
898 }
899 *parentMatch3 = match;
900 }
901 *parentMatch1 = match;
902 }
903 *parentMatch0 = match;
904 if (!match.hit)
905 {
906 soulng::parser::Match match(false);
907 soulng::parser::Match* parentMatch5 = &match;
908 lexer.SetPos(save);
909 {
910 soulng::parser::Match match(false);
911 soulng::parser::Match* parentMatch6 = &match;
912 {
913 int64_t pos = lexer.GetPos();
914 soulng::parser::Match match = DeclaratorParser::BracedInitializerList(lexer, ctx);
915 bi.reset(static_cast<sngcpp::ast::Node*>(match.value));
916 if (match.hit)
917 {
918 {
919 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
920
921 #endif // SOULNG_PARSER_DEBUG_SUPPORT
922 return soulng::parser::Match(true, bi.release());
923 }
924 }
925 *parentMatch6 = match;
926 }
927 *parentMatch5 = match;
928 }
929 *parentMatch0 = match;
930 }
931 }
932 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
933
934
935
936
937
938 #endif // SOULNG_PARSER_DEBUG_SUPPORT
939 if (!match.hit)
940 {
941 match.value = nullptr;
942 }
943 return match;
944 }
945
946 soulng::parser::Match DeclaratorParser::BracedInitializerList(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
947 {
948 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
949
950
951
952
953
954
955
956 #endif // SOULNG_PARSER_DEBUG_SUPPORT
957 std::unique_ptr<sngcpp::ast::BracedInitializerListNode> node = std::unique_ptr<sngcpp::ast::BracedInitializerListNode>();
958 Span s = Span();
959 std::unique_ptr<sngcpp::ast::Node> left;
960 std::unique_ptr<sngcpp::ast::Node> right;
961 soulng::parser::Match match(false);
962 soulng::parser::Match* parentMatch0 = &match;
963 {
964 soulng::parser::Match match(false);
965 soulng::parser::Match* parentMatch1 = &match;
966 {
967 soulng::parser::Match match(false);
968 soulng::parser::Match* parentMatch2 = &match;
969 {
970 int64_t pos = lexer.GetPos();
971 soulng::lexer::Span span = lexer.GetSpan();
972 soulng::parser::Match match(false);
973 if (*lexer == LBRACE)
974 {
975 ++lexer;
976 match.hit = true;
977 }
978 if (match.hit)
979 {
980 s = span;
981 node.reset(new sngcpp::ast::BracedInitializerListNode(s));
982 }
983 *parentMatch2 = match;
984 }
985 *parentMatch1 = match;
986 }
987 if (match.hit)
988 {
989 soulng::parser::Match match(false);
990 soulng::parser::Match* parentMatch3 = &match;
991 {
992 soulng::parser::Match match(true);
993 int64_t save = lexer.GetPos();
994 soulng::parser::Match* parentMatch4 = &match;
995 {
996 soulng::parser::Match match(false);
997 soulng::parser::Match* parentMatch5 = &match;
998 {
999 soulng::parser::Match match(false);
1000 soulng::parser::Match* parentMatch6 = &match;
1001 {
1002 soulng::parser::Match match(false);
1003 soulng::parser::Match* parentMatch7 = &match;
1004 {
1005 int64_t pos = lexer.GetPos();
1006 soulng::lexer::Span span = lexer.GetSpan();
1007 soulng::parser::Match match = DeclaratorParser::InitializerClause(lexer, ctx);
1008 left.reset(static_cast<sngcpp::ast::Node*>(match.value));
1009 if (match.hit)
1010 {
1011 s.end = span.end;
1012 node->AddInitializer(s, left.release());
1013 }
1014 *parentMatch7 = match;
1015 }
1016 *parentMatch6 = match;
1017 }
1018 if (match.hit)
1019 {
1020 soulng::parser::Match match(false);
1021 soulng::parser::Match* parentMatch8 = &match;
1022 {
1023 soulng::parser::Match match(true);
1024 soulng::parser::Match* parentMatch9 = &match;
1025 {
1026 while (true)
1027 {
1028 int64_t save = lexer.GetPos();
1029 {
1030 soulng::parser::Match match(false);
1031 soulng::parser::Match* parentMatch10 = &match;
1032 {
1033 soulng::parser::Match match(false);
1034 soulng::parser::Match* parentMatch11 = &match;
1035 {
1036 soulng::parser::Match match(false);
1037 if (*lexer == COMMA)
1038 {
1039 ++lexer;
1040 match.hit = true;
1041 }
1042 *parentMatch11 = match;
1043 }
1044 if (match.hit)
1045 {
1046 soulng::parser::Match match(false);
1047 soulng::parser::Match* parentMatch12 = &match;
1048 {
1049 soulng::parser::Match match(false);
1050 soulng::parser::Match* parentMatch13 = &match;
1051 {
1052 int64_t pos = lexer.GetPos();
1053 soulng::lexer::Span span = lexer.GetSpan();
1054 soulng::parser::Match match = DeclaratorParser::InitializerClause(lexer, ctx);
1055 right.reset(static_cast<sngcpp::ast::Node*>(match.value));
1056 if (match.hit)
1057 {
1058 s.end = span.end;
1059 node->AddInitializer(s, right.release());
1060 }
1061 *parentMatch13 = match;
1062 }
1063 *parentMatch12 = match;
1064 }
1065 *parentMatch11 = match;
1066 }
1067 *parentMatch10 = match;
1068 }
1069 if (match.hit)
1070 {
1071 *parentMatch9 = match;
1072 }
1073 else
1074 {
1075 lexer.SetPos(save);
1076 break;
1077 }
1078 }
1079 }
1080 }
1081 *parentMatch8 = match;
1082 }
1083 *parentMatch6 = match;
1084 }
1085 *parentMatch5 = match;
1086 }
1087 if (match.hit)
1088 {
1089 *parentMatch4 = match;
1090 }
1091 else
1092 {
1093 lexer.SetPos(save);
1094 }
1095 }
1096 *parentMatch3 = match;
1097 }
1098 *parentMatch1 = match;
1099 }
1100 *parentMatch0 = match;
1101 }
1102 if (match.hit)
1103 {
1104 soulng::parser::Match match(false);
1105 soulng::parser::Match* parentMatch14 = &match;
1106 {
1107 soulng::parser::Match match(false);
1108 soulng::parser::Match* parentMatch15 = &match;
1109 {
1110 int64_t pos = lexer.GetPos();
1111 soulng::lexer::Span span = lexer.GetSpan();
1112 soulng::parser::Match match(false);
1113 if (*lexer == RBRACE)
1114 {
1115 ++lexer;
1116 match.hit = true;
1117 }
1118 if (match.hit)
1119 {
1120 node->SetEndBraceSpan(span);
1121 node->SetSpanEnd(span.end);
1122 {
1123 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1124
1125 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1126 return soulng::parser::Match(true, node.release());
1127 }
1128 }
1129 *parentMatch15 = match;
1130 }
1131 *parentMatch14 = match;
1132 }
1133 *parentMatch0 = match;
1134 }
1135 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1136
1137
1138
1139
1140
1141 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1142 if (!match.hit)
1143 {
1144 match.value = nullptr;
1145 }
1146 return match;
1147 }
1148
1149 soulng::parser::Match DeclaratorParser::InitializerClause(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
1150 {
1151 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1152
1153
1154
1155
1156
1157
1158
1159 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1160 std::unique_ptr<sngcpp::ast::Node> expr;
1161 std::unique_ptr<sngcpp::ast::Node> bi;
1162 soulng::parser::Match match(false);
1163 soulng::parser::Match* parentMatch0 = &match;
1164 {
1165 int64_t save = lexer.GetPos();
1166 soulng::parser::Match match(false);
1167 soulng::parser::Match* parentMatch1 = &match;
1168 {
1169 int64_t pos = lexer.GetPos();
1170 soulng::lexer::Span span = lexer.GetSpan();
1171 soulng::parser::Match match = ExpressionParser::AssignmentExpression(lexer, ctx);
1172 expr.reset(static_cast<sngcpp::ast::Node*>(match.value));
1173 if (match.hit)
1174 {
1175 {
1176 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1177
1178 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1179 return soulng::parser::Match(true, new sngcpp::ast::ExpressionInitializerNode(span, expr.release()));
1180 }
1181 }
1182 *parentMatch1 = match;
1183 }
1184 *parentMatch0 = match;
1185 if (!match.hit)
1186 {
1187 soulng::parser::Match match(false);
1188 soulng::parser::Match* parentMatch2 = &match;
1189 lexer.SetPos(save);
1190 {
1191 soulng::parser::Match match(false);
1192 soulng::parser::Match* parentMatch3 = &match;
1193 {
1194 int64_t pos = lexer.GetPos();
1195 soulng::parser::Match match = DeclaratorParser::BracedInitializerList(lexer, ctx);
1196 bi.reset(static_cast<sngcpp::ast::Node*>(match.value));
1197 if (match.hit)
1198 {
1199 {
1200 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1201
1202 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1203 return soulng::parser::Match(true, bi.release());
1204 }
1205 }
1206 *parentMatch3 = match;
1207 }
1208 *parentMatch2 = match;
1209 }
1210 *parentMatch0 = match;
1211 }
1212 }
1213 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1214
1215
1216
1217
1218
1219 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1220 if (!match.hit)
1221 {
1222 match.value = nullptr;
1223 }
1224 return match;
1225 }
1226
1227 soulng::parser::Match DeclaratorParser::InitializerList(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
1228 {
1229 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1230
1231
1232
1233
1234
1235
1236
1237 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1238 std::unique_ptr<sngcpp::ast::Node> node = std::unique_ptr<sngcpp::ast::Node>();
1239 Span s = Span();
1240 std::unique_ptr<sngcpp::ast::Node> left;
1241 std::unique_ptr<sngcpp::ast::Node> right;
1242 soulng::parser::Match match(false);
1243 soulng::parser::Match* parentMatch0 = &match;
1244 {
1245 int64_t pos = lexer.GetPos();
1246 soulng::parser::Match match(false);
1247 soulng::parser::Match* parentMatch1 = &match;
1248 {
1249 soulng::parser::Match match(false);
1250 soulng::parser::Match* parentMatch2 = &match;
1251 {
1252 soulng::parser::Match match(false);
1253 soulng::parser::Match* parentMatch3 = &match;
1254 {
1255 int64_t pos = lexer.GetPos();
1256 soulng::lexer::Span span = lexer.GetSpan();
1257 soulng::parser::Match match = DeclaratorParser::InitializerClause(lexer, ctx);
1258 left.reset(static_cast<sngcpp::ast::Node*>(match.value));
1259 if (match.hit)
1260 {
1261 s = span;
1262 node.reset(left.release());
1263 }
1264 *parentMatch3 = match;
1265 }
1266 *parentMatch2 = match;
1267 }
1268 if (match.hit)
1269 {
1270 soulng::parser::Match match(false);
1271 soulng::parser::Match* parentMatch4 = &match;
1272 {
1273 soulng::parser::Match match(true);
1274 soulng::parser::Match* parentMatch5 = &match;
1275 {
1276 while (true)
1277 {
1278 int64_t save = lexer.GetPos();
1279 {
1280 soulng::parser::Match match(false);
1281 soulng::parser::Match* parentMatch6 = &match;
1282 {
1283 soulng::parser::Match match(false);
1284 soulng::parser::Match* parentMatch7 = &match;
1285 {
1286 soulng::parser::Match match(false);
1287 if (*lexer == COMMA)
1288 {
1289 ++lexer;
1290 match.hit = true;
1291 }
1292 *parentMatch7 = match;
1293 }
1294 if (match.hit)
1295 {
1296 soulng::parser::Match match(false);
1297 soulng::parser::Match* parentMatch8 = &match;
1298 {
1299 soulng::parser::Match match(false);
1300 soulng::parser::Match* parentMatch9 = &match;
1301 {
1302 int64_t pos = lexer.GetPos();
1303 soulng::lexer::Span span = lexer.GetSpan();
1304 soulng::parser::Match match = DeclaratorParser::InitializerClause(lexer, ctx);
1305 right.reset(static_cast<sngcpp::ast::Node*>(match.value));
1306 if (match.hit)
1307 {
1308 s.end = span.end;
1309 node.reset(new sngcpp::ast::ExpressionSequenceNode(s, node.release(), right.release()));
1310 }
1311 *parentMatch9 = match;
1312 }
1313 *parentMatch8 = match;
1314 }
1315 *parentMatch7 = match;
1316 }
1317 *parentMatch6 = match;
1318 }
1319 if (match.hit)
1320 {
1321 *parentMatch5 = match;
1322 }
1323 else
1324 {
1325 lexer.SetPos(save);
1326 break;
1327 }
1328 }
1329 }
1330 }
1331 *parentMatch4 = match;
1332 }
1333 *parentMatch2 = match;
1334 }
1335 *parentMatch1 = match;
1336 }
1337 if (match.hit)
1338 {
1339 {
1340 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1341
1342 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1343 return soulng::parser::Match(true, node.release());
1344 }
1345 }
1346 *parentMatch0 = match;
1347 }
1348 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1349
1350
1351
1352
1353
1354 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1355 if (!match.hit)
1356 {
1357 match.value = nullptr;
1358 }
1359 return match;
1360 }