1 #include "Enumeration.hpp"
2 #include <soulng/util/Unicode.hpp>
3 #include <sngcpp/parser/Expression.hpp>
4 #include <sngcpp/parser/Identifier.hpp>
5 #include <sngcpp/parser/TypeExpr.hpp>
6 #include <sngcpp/lexer/CppLexer.hpp>
7 #include <sngcpp/lexer/CppTokens.hpp>
8
9
10
11 using namespace soulng::unicode;
12 using namespace CppTokens;
13 using namespace soulng::lexer;
14
15 soulng::parser::Match EnumerationParser::EnumDeclaration(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
16 {
17 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
18
19
20
21
22
23
24
25 #endif // SOULNG_PARSER_DEBUG_SUPPORT
26 std::unique_ptr<sngcpp::ast::Node> enumSpecifier;
27 soulng::parser::Match match(false);
28 soulng::parser::Match* parentMatch0 = &match;
29 {
30 soulng::parser::Match match = EnumerationParser::EnumSpecifier(lexer, ctx);
31 enumSpecifier.reset(static_cast<sngcpp::ast::Node*>(match.value));
32 *parentMatch0 = match;
33 }
34 if (match.hit)
35 {
36 soulng::parser::Match match(false);
37 soulng::parser::Match* parentMatch1 = &match;
38 {
39 soulng::parser::Match match(false);
40 soulng::parser::Match* parentMatch2 = &match;
41 {
42 int64_t pos = lexer.GetPos();
43 soulng::parser::Match match(false);
44 if (*lexer == SEMICOLON)
45 {
46 ++lexer;
47 match.hit = true;
48 }
49 if (match.hit)
50 {
51 {
52 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
53
54 #endif // SOULNG_PARSER_DEBUG_SUPPORT
55 return soulng::parser::Match(true, enumSpecifier.release());
56 }
57 }
58 *parentMatch2 = match;
59 }
60 *parentMatch1 = match;
61 }
62 *parentMatch0 = match;
63 }
64 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
65
66
67
68
69
70 #endif // SOULNG_PARSER_DEBUG_SUPPORT
71 if (!match.hit)
72 {
73 match.value = nullptr;
74 }
75 return match;
76 }
77
78 soulng::parser::Match EnumerationParser::EnumSpecifier(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
79 {
80 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
81
82
83
84
85
86
87
88 #endif // SOULNG_PARSER_DEBUG_SUPPORT
89 std::unique_ptr<sngcpp::ast::EnumTypeNode> enumTypeNode = std::unique_ptr<sngcpp::ast::EnumTypeNode>();
90 Span openBraceSpan = Span();
91 Span closeBraceSpan = Span();
92 std::unique_ptr<sngcpp::ast::EnumTypeNode> enumHead;
93 soulng::parser::Match match(false);
94 soulng::parser::Match* parentMatch0 = &match;
95 {
96 int64_t pos = lexer.GetPos();
97 soulng::parser::Match match(false);
98 soulng::parser::Match* parentMatch1 = &match;
99 {
100 soulng::parser::Match match(false);
101 soulng::parser::Match* parentMatch2 = &match;
102 {
103 soulng::parser::Match match(false);
104 soulng::parser::Match* parentMatch3 = &match;
105 {
106 soulng::parser::Match match(false);
107 soulng::parser::Match* parentMatch4 = &match;
108 {
109 soulng::parser::Match match(false);
110 soulng::parser::Match* parentMatch5 = &match;
111 {
112 int64_t pos = lexer.GetPos();
113 soulng::parser::Match match = EnumerationParser::EnumHead(lexer, ctx);
114 enumHead.reset(static_cast<sngcpp::ast::EnumTypeNode*>(match.value));
115 if (match.hit)
116 {
117 enumTypeNode.reset(enumHead.release());
118 }
119 *parentMatch5 = match;
120 }
121 *parentMatch4 = match;
122 }
123 if (match.hit)
124 {
125 soulng::parser::Match match(false);
126 soulng::parser::Match* parentMatch6 = &match;
127 {
128 soulng::parser::Match match(false);
129 soulng::parser::Match* parentMatch7 = &match;
130 {
131 int64_t pos = lexer.GetPos();
132 soulng::lexer::Span span = lexer.GetSpan();
133 soulng::parser::Match match(false);
134 if (*lexer == LBRACE)
135 {
136 ++lexer;
137 match.hit = true;
138 }
139 if (match.hit)
140 {
141 openBraceSpan = span;
142 }
143 *parentMatch7 = match;
144 }
145 *parentMatch6 = match;
146 }
147 *parentMatch4 = match;
148 }
149 *parentMatch3 = match;
150 }
151 if (match.hit)
152 {
153 soulng::parser::Match match(false);
154 soulng::parser::Match* parentMatch8 = &match;
155 {
156 soulng::parser::Match match = EnumerationParser::Enumerators(lexer, ctx, enumTypeNode.get());
157 *parentMatch8 = match;
158 }
159 *parentMatch3 = match;
160 }
161 *parentMatch2 = match;
162 }
163 if (match.hit)
164 {
165 soulng::parser::Match match(false);
166 soulng::parser::Match* parentMatch9 = &match;
167 {
168 soulng::parser::Match match(false);
169 soulng::parser::Match* parentMatch10 = &match;
170 {
171 int64_t pos = lexer.GetPos();
172 soulng::lexer::Span span = lexer.GetSpan();
173 soulng::parser::Match match(true);
174 soulng::parser::Match* parentMatch11 = &match;
175 {
176 soulng::lexer::Span span = lexer.GetSpan();
177 soulng::parser::Match match(false);
178 if (*lexer == RBRACE)
179 {
180 ++lexer;
181 match.hit = true;
182 }
183 if (match.hit)
184 {
185 *parentMatch11 = match;
186 }
187 else
188 {
189 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RBRACE)));
190 }
191 }
192 if (match.hit)
193 {
194 closeBraceSpan = span;
195 }
196 *parentMatch10 = match;
197 }
198 *parentMatch9 = match;
199 }
200 *parentMatch2 = match;
201 }
202 *parentMatch1 = match;
203 }
204 if (match.hit)
205 {
206 enumTypeNode->SetOpenBraceSpan(openBraceSpan);
207 enumTypeNode->SetCloseBraceSpan(closeBraceSpan);
208 {
209 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
210
211 #endif // SOULNG_PARSER_DEBUG_SUPPORT
212 return soulng::parser::Match(true, enumTypeNode.release());
213 }
214 }
215 *parentMatch0 = match;
216 }
217 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
218
219
220
221
222
223 #endif // SOULNG_PARSER_DEBUG_SUPPORT
224 if (!match.hit)
225 {
226 match.value = nullptr;
227 }
228 return match;
229 }
230
231 soulng::parser::Match EnumerationParser::EnumHead(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
232 {
233 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
234
235
236
237
238
239
240
241 #endif // SOULNG_PARSER_DEBUG_SUPPORT
242 Span s = Span();
243 std::unique_ptr<soulng::parser::soulng::parser::Value<sngcpp::ast::EnumKey>>enumKey;
244 std::unique_ptr<sngcpp::ast::Node> enumName;
245 std::unique_ptr<sngcpp::ast::Node> enumBase;
246 soulng::parser::Match match(false);
247 soulng::parser::Match* parentMatch0 = &match;
248 {
249 int64_t pos = lexer.GetPos();
250 soulng::parser::Match match(false);
251 soulng::parser::Match* parentMatch1 = &match;
252 {
253 soulng::parser::Match match(false);
254 soulng::parser::Match* parentMatch2 = &match;
255 {
256 soulng::parser::Match match(false);
257 soulng::parser::Match* parentMatch3 = &match;
258 {
259 soulng::parser::Match match(false);
260 soulng::parser::Match* parentMatch4 = &match;
261 {
262 int64_t pos = lexer.GetPos();
263 soulng::lexer::Span span = lexer.GetSpan();
264 soulng::parser::Match match = EnumerationParser::EnumKey(lexer);
265 enumKey.reset(static_cast<soulng::parser::soulng::parser::Value<sngcpp::ast::EnumKey>*>(match.value));
266 if (match.hit)
267 {
268 s = span;
269 }
270 *parentMatch4 = match;
271 }
272 *parentMatch3 = match;
273 }
274 if (match.hit)
275 {
276 soulng::parser::Match match(false);
277 soulng::parser::Match* parentMatch5 = &match;
278 {
279 soulng::parser::Match match(false);
280 soulng::parser::Match* parentMatch6 = &match;
281 {
282 int64_t pos = lexer.GetPos();
283 soulng::lexer::Span span = lexer.GetSpan();
284 soulng::parser::Match match = EnumerationParser::EnumName(lexer, ctx);
285 enumName.reset(static_cast<sngcpp::ast::Node*>(match.value));
286 if (match.hit)
287 {
288 s.end = span.end;
289 }
290 *parentMatch6 = match;
291 }
292 *parentMatch5 = match;
293 }
294 *parentMatch3 = match;
295 }
296 *parentMatch2 = match;
297 }
298 if (match.hit)
299 {
300 soulng::parser::Match match(false);
301 soulng::parser::Match* parentMatch7 = &match;
302 {
303 soulng::parser::Match match(true);
304 int64_t save = lexer.GetPos();
305 soulng::parser::Match* parentMatch8 = &match;
306 {
307 soulng::parser::Match match(false);
308 soulng::parser::Match* parentMatch9 = &match;
309 {
310 soulng::parser::Match match(false);
311 soulng::parser::Match* parentMatch10 = &match;
312 {
313 int64_t pos = lexer.GetPos();
314 soulng::lexer::Span span = lexer.GetSpan();
315 soulng::parser::Match match = EnumerationParser::EnumBase(lexer, ctx);
316 enumBase.reset(static_cast<sngcpp::ast::Node*>(match.value));
317 if (match.hit)
318 {
319 s.end = span.end;
320 }
321 *parentMatch10 = match;
322 }
323 *parentMatch9 = match;
324 }
325 if (match.hit)
326 {
327 *parentMatch8 = match;
328 }
329 else
330 {
331 lexer.SetPos(save);
332 }
333 }
334 *parentMatch7 = match;
335 }
336 *parentMatch2 = match;
337 }
338 *parentMatch1 = match;
339 }
340 if (match.hit)
341 {
342 {
343 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
344
345 #endif // SOULNG_PARSER_DEBUG_SUPPORT
346 return soulng::parser::Match(true, new sngcpp::ast::EnumTypeNode(s, enumKey->value, enumName.release(), enumBase.release()));
347 }
348 }
349 *parentMatch0 = match;
350 }
351 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
352
353
354
355
356
357 #endif // SOULNG_PARSER_DEBUG_SUPPORT
358 if (!match.hit)
359 {
360 match.value = nullptr;
361 }
362 return match;
363 }
364
365 soulng::parser::Match EnumerationParser::OpaqueEnumDeclaration(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
366 {
367 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
368
369
370
371
372
373
374
375 #endif // SOULNG_PARSER_DEBUG_SUPPORT
376 Span s = Span();
377 std::unique_ptr<soulng::parser::soulng::parser::Value<sngcpp::ast::EnumKey>>enumKey;
378 std::unique_ptr<sngcpp::ast::Node> enumName;
379 std::unique_ptr<sngcpp::ast::Node> enumBase;
380 soulng::parser::Match match(false);
381 soulng::parser::Match* parentMatch0 = &match;
382 {
383 soulng::parser::Match match(false);
384 soulng::parser::Match* parentMatch1 = &match;
385 {
386 soulng::parser::Match match(false);
387 soulng::parser::Match* parentMatch2 = &match;
388 {
389 soulng::parser::Match match(false);
390 soulng::parser::Match* parentMatch3 = &match;
391 {
392 int64_t pos = lexer.GetPos();
393 soulng::lexer::Span span = lexer.GetSpan();
394 soulng::parser::Match match = EnumerationParser::EnumKey(lexer);
395 enumKey.reset(static_cast<soulng::parser::soulng::parser::Value<sngcpp::ast::EnumKey>*>(match.value));
396 if (match.hit)
397 {
398 s = span;
399 }
400 *parentMatch3 = match;
401 }
402 *parentMatch2 = match;
403 }
404 if (match.hit)
405 {
406 soulng::parser::Match match(false);
407 soulng::parser::Match* parentMatch4 = &match;
408 {
409 soulng::parser::Match match = EnumerationParser::EnumName(lexer, ctx);
410 enumName.reset(static_cast<sngcpp::ast::Node*>(match.value));
411 *parentMatch4 = match;
412 }
413 *parentMatch2 = match;
414 }
415 *parentMatch1 = match;
416 }
417 if (match.hit)
418 {
419 soulng::parser::Match match(false);
420 soulng::parser::Match* parentMatch5 = &match;
421 {
422 soulng::parser::Match match(true);
423 int64_t save = lexer.GetPos();
424 soulng::parser::Match* parentMatch6 = &match;
425 {
426 soulng::parser::Match match(false);
427 soulng::parser::Match* parentMatch7 = &match;
428 {
429 soulng::parser::Match match = EnumerationParser::EnumBase(lexer, ctx);
430 enumBase.reset(static_cast<sngcpp::ast::Node*>(match.value));
431 *parentMatch7 = match;
432 }
433 if (match.hit)
434 {
435 *parentMatch6 = match;
436 }
437 else
438 {
439 lexer.SetPos(save);
440 }
441 }
442 *parentMatch5 = match;
443 }
444 *parentMatch1 = match;
445 }
446 *parentMatch0 = match;
447 }
448 if (match.hit)
449 {
450 soulng::parser::Match match(false);
451 soulng::parser::Match* parentMatch8 = &match;
452 {
453 soulng::parser::Match match(false);
454 soulng::parser::Match* parentMatch9 = &match;
455 {
456 int64_t pos = lexer.GetPos();
457 soulng::lexer::Span span = lexer.GetSpan();
458 soulng::parser::Match match(false);
459 if (*lexer == SEMICOLON)
460 {
461 ++lexer;
462 match.hit = true;
463 }
464 if (match.hit)
465 {
466 s.end = span.end;
467 {
468 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
469
470 #endif // SOULNG_PARSER_DEBUG_SUPPORT
471 return soulng::parser::Match(true, new sngcpp::ast::EnumTypeNode(s, enumKey->value, enumName.release(), enumBase.release()));
472 }
473 }
474 *parentMatch9 = match;
475 }
476 *parentMatch8 = match;
477 }
478 *parentMatch0 = match;
479 }
480 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
481
482
483
484
485
486 #endif // SOULNG_PARSER_DEBUG_SUPPORT
487 if (!match.hit)
488 {
489 match.value = nullptr;
490 }
491 return match;
492 }
493
494 soulng::parser::Match EnumerationParser::EnumKey(CppLexer& lexer)
495 {
496 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
497
498
499
500
501
502
503
504 #endif // SOULNG_PARSER_DEBUG_SUPPORT
505 soulng::parser::Match match(false);
506 soulng::parser::Match* parentMatch0 = &match;
507 {
508 int64_t save = lexer.GetPos();
509 soulng::parser::Match match(false);
510 soulng::parser::Match* parentMatch1 = &match;
511 {
512 int64_t save = lexer.GetPos();
513 soulng::parser::Match match(false);
514 soulng::parser::Match* parentMatch2 = &match;
515 {
516 soulng::parser::Match match(false);
517 if (*lexer == ENUM)
518 {
519 ++lexer;
520 match.hit = true;
521 }
522 *parentMatch2 = match;
523 }
524 if (match.hit)
525 {
526 soulng::parser::Match match(false);
527 soulng::parser::Match* parentMatch3 = &match;
528 {
529 soulng::parser::Match match(false);
530 soulng::parser::Match* parentMatch4 = &match;
531 {
532 int64_t pos = lexer.GetPos();
533 soulng::parser::Match match(false);
534 if (*lexer == CLASS)
535 {
536 ++lexer;
537 match.hit = true;
538 }
539 if (match.hit)
540 {
541 {
542 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
543
544 #endif // SOULNG_PARSER_DEBUG_SUPPORT
545 return soulng::parser::Match(true, new soulng::parser::Value<sngcpp::ast::EnumKey>(sngcpp::ast::EnumKey::enumClass_));
546 }
547 }
548 *parentMatch4 = match;
549 }
550 *parentMatch3 = match;
551 }
552 *parentMatch2 = match;
553 }
554 *parentMatch1 = match;
555 if (!match.hit)
556 {
557 soulng::parser::Match match(false);
558 soulng::parser::Match* parentMatch5 = &match;
559 lexer.SetPos(save);
560 {
561 soulng::parser::Match match(false);
562 soulng::parser::Match* parentMatch6 = &match;
563 {
564 soulng::parser::Match match(false);
565 if (*lexer == ENUM)
566 {
567 ++lexer;
568 match.hit = true;
569 }
570 *parentMatch6 = match;
571 }
572 if (match.hit)
573 {
574 soulng::parser::Match match(false);
575 soulng::parser::Match* parentMatch7 = &match;
576 {
577 soulng::parser::Match match(false);
578 soulng::parser::Match* parentMatch8 = &match;
579 {
580 int64_t pos = lexer.GetPos();
581 soulng::parser::Match match(false);
582 if (*lexer == STRUCT)
583 {
584 ++lexer;
585 match.hit = true;
586 }
587 if (match.hit)
588 {
589 {
590 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
591
592 #endif // SOULNG_PARSER_DEBUG_SUPPORT
593 return soulng::parser::Match(true, new soulng::parser::Value<sngcpp::ast::EnumKey>(sngcpp::ast::EnumKey::enumStruct_));
594 }
595 }
596 *parentMatch8 = match;
597 }
598 *parentMatch7 = match;
599 }
600 *parentMatch6 = match;
601 }
602 *parentMatch5 = match;
603 }
604 *parentMatch1 = match;
605 }
606 }
607 *parentMatch0 = match;
608 if (!match.hit)
609 {
610 soulng::parser::Match match(false);
611 soulng::parser::Match* parentMatch9 = &match;
612 lexer.SetPos(save);
613 {
614 soulng::parser::Match match(false);
615 soulng::parser::Match* parentMatch10 = &match;
616 {
617 int64_t pos = lexer.GetPos();
618 soulng::parser::Match match(false);
619 if (*lexer == ENUM)
620 {
621 ++lexer;
622 match.hit = true;
623 }
624 if (match.hit)
625 {
626 {
627 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
628
629 #endif // SOULNG_PARSER_DEBUG_SUPPORT
630 return soulng::parser::Match(true, new soulng::parser::Value<sngcpp::ast::EnumKey>(sngcpp::ast::EnumKey::enum_));
631 }
632 }
633 *parentMatch10 = match;
634 }
635 *parentMatch9 = match;
636 }
637 *parentMatch0 = match;
638 }
639 }
640 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
641
642
643
644
645
646 #endif // SOULNG_PARSER_DEBUG_SUPPORT
647 if (!match.hit)
648 {
649 match.value = nullptr;
650 }
651 return match;
652 }
653
654 soulng::parser::Match EnumerationParser::EnumName(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
655 {
656 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
657
658
659
660
661
662
663
664 #endif // SOULNG_PARSER_DEBUG_SUPPORT
665 std::unique_ptr<sngcpp::ast::Node> enumName;
666 soulng::parser::Match match(false);
667 soulng::parser::Match* parentMatch0 = &match;
668 {
669 int64_t pos = lexer.GetPos();
670 soulng::parser::Match match = IdentifierParser::QualifiedIdNode(lexer, ctx);
671 enumName.reset(static_cast<sngcpp::ast::Node*>(match.value));
672 if (match.hit)
673 {
674 {
675 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
676
677 #endif // SOULNG_PARSER_DEBUG_SUPPORT
678 return soulng::parser::Match(true, enumName.release());
679 }
680 }
681 *parentMatch0 = match;
682 }
683 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
684
685
686
687
688
689 #endif // SOULNG_PARSER_DEBUG_SUPPORT
690 if (!match.hit)
691 {
692 match.value = nullptr;
693 }
694 return match;
695 }
696
697 soulng::parser::Match EnumerationParser::EnumBase(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
698 {
699 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
700
701
702
703
704
705
706
707 #endif // SOULNG_PARSER_DEBUG_SUPPORT
708 std::unique_ptr<sngcpp::ast::Node> typeExpr;
709 soulng::parser::Match match(false);
710 soulng::parser::Match* parentMatch0 = &match;
711 {
712 soulng::parser::Match match(false);
713 if (*lexer == COLON)
714 {
715 ++lexer;
716 match.hit = true;
717 }
718 *parentMatch0 = match;
719 }
720 if (match.hit)
721 {
722 soulng::parser::Match match(false);
723 soulng::parser::Match* parentMatch1 = &match;
724 {
725 soulng::parser::Match match(false);
726 soulng::parser::Match* parentMatch2 = &match;
727 {
728 int64_t pos = lexer.GetPos();
729 soulng::parser::Match match = TypeExprParser::TypeExpr(lexer, ctx);
730 typeExpr.reset(static_cast<sngcpp::ast::Node*>(match.value));
731 if (match.hit)
732 {
733 {
734 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
735
736 #endif // SOULNG_PARSER_DEBUG_SUPPORT
737 return soulng::parser::Match(true, typeExpr.release());
738 }
739 }
740 *parentMatch2 = match;
741 }
742 *parentMatch1 = match;
743 }
744 *parentMatch0 = match;
745 }
746 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
747
748
749
750
751
752 #endif // SOULNG_PARSER_DEBUG_SUPPORT
753 if (!match.hit)
754 {
755 match.value = nullptr;
756 }
757 return match;
758 }
759
760 soulng::parser::Match EnumerationParser::Enumerators(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx, sngcpp::ast::EnumTypeNode* enumTypeNode)
761 {
762 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
763
764
765
766
767
768
769
770 #endif // SOULNG_PARSER_DEBUG_SUPPORT
771 Span s = Span();
772 std::unique_ptr<sngcpp::ast::EnumeratorNode> left;
773 std::unique_ptr<sngcpp::ast::EnumeratorNode> right;
774 soulng::parser::Match match(true);
775 int64_t save = lexer.GetPos();
776 soulng::parser::Match* parentMatch0 = &match;
777 {
778 soulng::parser::Match match(false);
779 soulng::parser::Match* parentMatch1 = &match;
780 {
781 soulng::parser::Match match(false);
782 soulng::parser::Match* parentMatch2 = &match;
783 {
784 soulng::parser::Match match(false);
785 soulng::parser::Match* parentMatch3 = &match;
786 {
787 int64_t pos = lexer.GetPos();
788 soulng::lexer::Span span = lexer.GetSpan();
789 soulng::parser::Match match = EnumerationParser::EnumeratorDefinition(lexer, ctx);
790 left.reset(static_cast<sngcpp::ast::EnumeratorNode*>(match.value));
791 if (match.hit)
792 {
793 s = span;
794 enumTypeNode->AddEnumerator(s, left.release());
795 }
796 *parentMatch3 = match;
797 }
798 *parentMatch2 = match;
799 }
800 if (match.hit)
801 {
802 soulng::parser::Match match(false);
803 soulng::parser::Match* parentMatch4 = &match;
804 {
805 soulng::parser::Match match(true);
806 soulng::parser::Match* parentMatch5 = &match;
807 {
808 while (true)
809 {
810 int64_t save = lexer.GetPos();
811 {
812 soulng::parser::Match match(false);
813 soulng::parser::Match* parentMatch6 = &match;
814 {
815 soulng::parser::Match match(false);
816 soulng::parser::Match* parentMatch7 = &match;
817 {
818 soulng::parser::Match match(false);
819 if (*lexer == COMMA)
820 {
821 ++lexer;
822 match.hit = true;
823 }
824 *parentMatch7 = match;
825 }
826 if (match.hit)
827 {
828 soulng::parser::Match match(false);
829 soulng::parser::Match* parentMatch8 = &match;
830 {
831 soulng::parser::Match match(false);
832 soulng::parser::Match* parentMatch9 = &match;
833 {
834 int64_t pos = lexer.GetPos();
835 soulng::lexer::Span span = lexer.GetSpan();
836 soulng::parser::Match match = EnumerationParser::EnumeratorDefinition(lexer, ctx);
837 right.reset(static_cast<sngcpp::ast::EnumeratorNode*>(match.value));
838 if (match.hit)
839 {
840 s.end = span.end;
841 enumTypeNode->AddEnumerator(s, right.release());
842 }
843 *parentMatch9 = match;
844 }
845 *parentMatch8 = match;
846 }
847 *parentMatch7 = match;
848 }
849 *parentMatch6 = match;
850 }
851 if (match.hit)
852 {
853 *parentMatch5 = match;
854 }
855 else
856 {
857 lexer.SetPos(save);
858 break;
859 }
860 }
861 }
862 }
863 *parentMatch4 = match;
864 }
865 *parentMatch2 = match;
866 }
867 *parentMatch1 = match;
868 }
869 if (match.hit)
870 {
871 *parentMatch0 = match;
872 }
873 else
874 {
875 lexer.SetPos(save);
876 }
877 }
878 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
879
880
881
882
883
884 #endif // SOULNG_PARSER_DEBUG_SUPPORT
885 if (!match.hit)
886 {
887 match.value = nullptr;
888 }
889 return match;
890 }
891
892 soulng::parser::Match EnumerationParser::EnumeratorDefinition(CppLexer& lexer, sngcpp::cppparser::ParsingContext* ctx)
893 {
894 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
895
896
897
898
899
900
901
902 #endif // SOULNG_PARSER_DEBUG_SUPPORT
903 Span s = Span();
904 Span assignmentSpan = Span();
905 std::u32string valueStr = std::u32string();
906 std::unique_ptr<sngcpp::ast::Node> value = std::unique_ptr<sngcpp::ast::Node>();
907 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>enumerator;
908 std::unique_ptr<sngcpp::ast::Node> expr;
909 soulng::parser::Match match(false);
910 soulng::parser::Match* parentMatch0 = &match;
911 {
912 int64_t pos = lexer.GetPos();
913 soulng::parser::Match match(false);
914 soulng::parser::Match* parentMatch1 = &match;
915 {
916 soulng::parser::Match match(false);
917 soulng::parser::Match* parentMatch2 = &match;
918 {
919 soulng::parser::Match match(false);
920 soulng::parser::Match* parentMatch3 = &match;
921 {
922 int64_t pos = lexer.GetPos();
923 soulng::lexer::Span span = lexer.GetSpan();
924 soulng::parser::Match match = EnumerationParser::Enumerator(lexer);
925 enumerator.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
926 if (match.hit)
927 {
928 s = span;
929 }
930 *parentMatch3 = match;
931 }
932 *parentMatch2 = match;
933 }
934 if (match.hit)
935 {
936 soulng::parser::Match match(false);
937 soulng::parser::Match* parentMatch4 = &match;
938 {
939 soulng::parser::Match match(true);
940 int64_t save = lexer.GetPos();
941 soulng::parser::Match* parentMatch5 = &match;
942 {
943 soulng::parser::Match match(false);
944 soulng::parser::Match* parentMatch6 = &match;
945 {
946 soulng::parser::Match match(false);
947 soulng::parser::Match* parentMatch7 = &match;
948 {
949 soulng::parser::Match match(false);
950 soulng::parser::Match* parentMatch8 = &match;
951 {
952 int64_t pos = lexer.GetPos();
953 soulng::lexer::Span span = lexer.GetSpan();
954 soulng::parser::Match match(false);
955 if (*lexer == ASSIGN)
956 {
957 ++lexer;
958 match.hit = true;
959 }
960 if (match.hit)
961 {
962 assignmentSpan = span;
963 }
964 *parentMatch8 = match;
965 }
966 *parentMatch7 = match;
967 }
968 if (match.hit)
969 {
970 soulng::parser::Match match(false);
971 soulng::parser::Match* parentMatch9 = &match;
972 {
973 soulng::parser::Match match(false);
974 soulng::parser::Match* parentMatch10 = &match;
975 {
976 int64_t pos = lexer.GetPos();
977 soulng::parser::Match match = ExpressionParser::ConstantExpression(lexer, ctx);
978 expr.reset(static_cast<sngcpp::ast::Node*>(match.value));
979 if (match.hit)
980 {
981 value.reset(expr.release());
982 value->SetFullSpan();
983 valueStr = lexer.GetMatch(value->GetSpan());
984 s.end = value->GetSpan().end;
985 }
986 *parentMatch10 = match;
987 }
988 *parentMatch9 = match;
989 }
990 *parentMatch7 = match;
991 }
992 *parentMatch6 = match;
993 }
994 if (match.hit)
995 {
996 *parentMatch5 = match;
997 }
998 else
999 {
1000 lexer.SetPos(save);
1001 }
1002 }
1003 *parentMatch4 = match;
1004 }
1005 *parentMatch2 = match;
1006 }
1007 *parentMatch1 = match;
1008 }
1009 if (match.hit)
1010 {
1011 {
1012 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1013
1014 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1015 return soulng::parser::Match(true, new sngcpp::ast::EnumeratorNode(s, enumerator->value, value.release(), valueStr));
1016 }
1017 }
1018 *parentMatch0 = match;
1019 }
1020 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1021
1022
1023
1024
1025
1026 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1027 if (!match.hit)
1028 {
1029 match.value = nullptr;
1030 }
1031 return match;
1032 }
1033
1034 soulng::parser::Match EnumerationParser::Enumerator(CppLexer& lexer)
1035 {
1036 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1037
1038
1039
1040
1041
1042
1043
1044 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1045 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>id;
1046 soulng::parser::Match match(false);
1047 soulng::parser::Match* parentMatch0 = &match;
1048 {
1049 int64_t pos = lexer.GetPos();
1050 soulng::parser::Match match = IdentifierParser::Identifier(lexer);
1051 id.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
1052 if (match.hit)
1053 {
1054 {
1055 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1056
1057 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1058 return soulng::parser::Match(true, new soulng::parser::Value<std::u32string>(id->value));
1059 }
1060 }
1061 *parentMatch0 = match;
1062 }
1063 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1064
1065
1066
1067
1068
1069 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1070 if (!match.hit)
1071 {
1072 match.value = nullptr;
1073 }
1074 return match;
1075 }