1 #include "CompileUnit.hpp"
2 #include <soulng/util/Unicode.hpp>
3 #include <sngcm/cmparser/Typedef.hpp>
4 #include <sngcm/cmparser/Identifier.hpp>
5 #include <sngcm/cmparser/Concept.hpp>
6 #include <sngcm/cmparser/Function.hpp>
7 #include <sngcm/cmparser/Class.hpp>
8 #include <sngcm/cmparser/Interface.hpp>
9 #include <sngcm/cmparser/Enumeration.hpp>
10 #include <sngcm/cmparser/Constant.hpp>
11 #include <sngcm/cmparser/Delegate.hpp>
12 #include <sngcm/cmparser/GlobalVariable.hpp>
13 #include <sngcm/cmlexer/CmajorLexer.hpp>
14 #include <sngcm/cmlexer/CmajorTokens.hpp>
15
16
17
18 using namespace soulng::unicode;
19 using namespace sngcm::ast;
20 using namespace CmajorTokens;
21
22 std::std::unique_ptr<sngcm::ast::CompileUnitNode>CompileUnitParser::Parse(CmajorLexer&lexer, ParsingContext*ctx)
23 {
24 std::unique_ptr<sngcm::ast::CompileUnitNode> value;
25 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
26
27
28
29
30
31 #endif // SOULNG_PARSER_DEBUG_SUPPORT
32 ++lexer;
33 soulng::lexer::Span span = lexer.GetSpan();
34 soulng::parser::Match match = CompileUnitParser::CompileUnit(lexer, ctx);
35 value.reset(static_cast<sngcm::ast::CompileUnitNode*>(match.value));
36 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
37
38
39
40
41
42 #endif // SOULNG_PARSER_DEBUG_SUPPORT
43 if (match.hit)
44 {
45 if (*lexer == soulng::lexer::END_TOKEN)
46 {
47 return value;
48 }
49 else
50 {
51 lexer.ThrowExpectationFailure(lexer.GetSpan(), ToUtf32(soulng::lexer::GetEndTokenInfo()));
52 }
53 }
54 else
55 {
56 lexer.ThrowExpectationFailure(span, U"compile unit");
57 }
58 return value;
59 }
60
61 soulng::parser::Match CompileUnitParser::CompileUnit(CmajorLexer& lexer, ParsingContext* ctx)
62 {
63 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
64
65
66
67
68
69
70
71 #endif // SOULNG_PARSER_DEBUG_SUPPORT
72 std::unique_ptr<CompileUnitNode> compileUnit = std::unique_ptr<CompileUnitNode>();
73 soulng::parser::Match match(false);
74 soulng::parser::Match* parentMatch0 = &match;
75 {
76 soulng::parser::Match match(false);
77 soulng::parser::Match* parentMatch1 = &match;
78 {
79 int64_t pos = lexer.GetPos();
80 soulng::lexer::Span span = lexer.GetSpan();
81 soulng::parser::Match match(true);
82 if (match.hit)
83 {
84 compileUnit.reset(new CompileUnitNode(span, lexer.FileName()));
85 }
86 *parentMatch1 = match;
87 }
88 *parentMatch0 = match;
89 }
90 if (match.hit)
91 {
92 soulng::parser::Match match(false);
93 soulng::parser::Match* parentMatch2 = &match;
94 {
95 soulng::parser::Match match(false);
96 soulng::parser::Match* parentMatch3 = &match;
97 {
98 int64_t pos = lexer.GetPos();
99 soulng::parser::Match match = CompileUnitParser::NamespaceContent(lexer, ctx, compileUnit.get(), compileUnit->GlobalNs());
100 if (match.hit)
101 {
102 {
103 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
104
105 #endif // SOULNG_PARSER_DEBUG_SUPPORT
106 return soulng::parser::Match(true, compileUnit.release());
107 }
108 }
109 *parentMatch3 = match;
110 }
111 *parentMatch2 = match;
112 }
113 *parentMatch0 = match;
114 }
115 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
116
117
118
119
120
121 #endif // SOULNG_PARSER_DEBUG_SUPPORT
122 if (!match.hit)
123 {
124 match.value = nullptr;
125 }
126 return match;
127 }
128
129 soulng::parser::Match CompileUnitParser::NamespaceContent(CmajorLexer& lexer, ParsingContext* ctx, sngcm::ast::CompileUnitNode* cu, sngcm::ast::NamespaceNode* ns)
130 {
131 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
132
133
134
135
136
137
138
139 #endif // SOULNG_PARSER_DEBUG_SUPPORT
140 soulng::parser::Match match(false);
141 soulng::parser::Match* parentMatch0 = &match;
142 {
143 soulng::parser::Match match = CompileUnitParser::UsingDirectives(lexer, ctx, ns);
144 *parentMatch0 = match;
145 }
146 if (match.hit)
147 {
148 soulng::parser::Match match(false);
149 soulng::parser::Match* parentMatch1 = &match;
150 {
151 soulng::parser::Match match = CompileUnitParser::Definitions(lexer, ctx, cu, ns);
152 *parentMatch1 = match;
153 }
154 *parentMatch0 = match;
155 }
156 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
157
158
159
160
161
162 #endif // SOULNG_PARSER_DEBUG_SUPPORT
163 if (!match.hit)
164 {
165 match.value = nullptr;
166 }
167 return match;
168 }
169
170 soulng::parser::Match CompileUnitParser::UsingDirectives(CmajorLexer& lexer, ParsingContext* ctx, sngcm::ast::NamespaceNode* ns)
171 {
172 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
173
174
175
176
177
178
179
180 #endif // SOULNG_PARSER_DEBUG_SUPPORT
181 soulng::parser::Match match(true);
182 soulng::parser::Match* parentMatch0 = &match;
183 {
184 while (true)
185 {
186 int64_t save = lexer.GetPos();
187 {
188 soulng::parser::Match match = CompileUnitParser::UsingDirective(lexer, ctx, ns);
189 if (match.hit)
190 {
191 *parentMatch0 = match;
192 }
193 else
194 {
195 lexer.SetPos(save);
196 break;
197 }
198 }
199 }
200 }
201 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
202
203
204
205
206
207 #endif // SOULNG_PARSER_DEBUG_SUPPORT
208 if (!match.hit)
209 {
210 match.value = nullptr;
211 }
212 return match;
213 }
214
215 soulng::parser::Match CompileUnitParser::UsingDirective(CmajorLexer& lexer, ParsingContext* ctx, sngcm::ast::NamespaceNode* ns)
216 {
217 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
218
219
220
221
222
223
224
225 #endif // SOULNG_PARSER_DEBUG_SUPPORT
226 std::unique_ptr<Node> usingAlias;
227 std::unique_ptr<Node> usingNs;
228 soulng::parser::Match match(false);
229 soulng::parser::Match* parentMatch0 = &match;
230 {
231 int64_t save = lexer.GetPos();
232 soulng::parser::Match match(false);
233 soulng::parser::Match* parentMatch1 = &match;
234 {
235 int64_t pos = lexer.GetPos();
236 soulng::parser::Match match = CompileUnitParser::UsingAliasDirective(lexer);
237 usingAlias.reset(static_cast<Node*>(match.value));
238 if (match.hit)
239 {
240 ns->AddMember(usingAlias.release());
241 }
242 *parentMatch1 = match;
243 }
244 *parentMatch0 = match;
245 if (!match.hit)
246 {
247 soulng::parser::Match match(false);
248 soulng::parser::Match* parentMatch2 = &match;
249 lexer.SetPos(save);
250 {
251 soulng::parser::Match match(false);
252 soulng::parser::Match* parentMatch3 = &match;
253 {
254 int64_t pos = lexer.GetPos();
255 soulng::parser::Match match = CompileUnitParser::UsingNamespaceDirective(lexer, ctx);
256 usingNs.reset(static_cast<Node*>(match.value));
257 if (match.hit)
258 {
259 ns->AddMember(usingNs.release());
260 }
261 *parentMatch3 = match;
262 }
263 *parentMatch2 = match;
264 }
265 *parentMatch0 = match;
266 }
267 }
268 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
269
270
271
272
273
274 #endif // SOULNG_PARSER_DEBUG_SUPPORT
275 if (!match.hit)
276 {
277 match.value = nullptr;
278 }
279 return match;
280 }
281
282 soulng::parser::Match CompileUnitParser::UsingAliasDirective(CmajorLexer& lexer)
283 {
284 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
285
286
287
288
289
290
291
292 #endif // SOULNG_PARSER_DEBUG_SUPPORT
293 Span s = Span();
294 std::unique_ptr<IdentifierNode> id;
295 std::unique_ptr<IdentifierNode> qid;
296 soulng::parser::Match match(false);
297 soulng::parser::Match* parentMatch0 = &match;
298 {
299 soulng::parser::Match match(false);
300 soulng::parser::Match* parentMatch1 = &match;
301 {
302 soulng::parser::Match match(false);
303 soulng::parser::Match* parentMatch2 = &match;
304 {
305 soulng::parser::Match match(false);
306 soulng::parser::Match* parentMatch3 = &match;
307 {
308 soulng::parser::Match match(false);
309 soulng::parser::Match* parentMatch4 = &match;
310 {
311 int64_t pos = lexer.GetPos();
312 soulng::lexer::Span span = lexer.GetSpan();
313 soulng::parser::Match match(false);
314 if (*lexer == USING)
315 {
316 ++lexer;
317 match.hit = true;
318 }
319 if (match.hit)
320 {
321 s = span;
322 }
323 *parentMatch4 = match;
324 }
325 *parentMatch3 = match;
326 }
327 if (match.hit)
328 {
329 soulng::parser::Match match(false);
330 soulng::parser::Match* parentMatch5 = &match;
331 {
332 soulng::parser::Match match = IdentifierParser::Identifier(lexer);
333 id.reset(static_cast<IdentifierNode*>(match.value));
334 *parentMatch5 = match;
335 }
336 *parentMatch3 = match;
337 }
338 *parentMatch2 = match;
339 }
340 if (match.hit)
341 {
342 soulng::parser::Match match(false);
343 soulng::parser::Match* parentMatch6 = &match;
344 {
345 soulng::parser::Match match(false);
346 if (*lexer == ASSIGN)
347 {
348 ++lexer;
349 match.hit = true;
350 }
351 *parentMatch6 = match;
352 }
353 *parentMatch2 = match;
354 }
355 *parentMatch1 = match;
356 }
357 if (match.hit)
358 {
359 soulng::parser::Match match(false);
360 soulng::parser::Match* parentMatch7 = &match;
361 {
362 soulng::parser::Match match(true);
363 soulng::parser::Match* parentMatch8 = &match;
364 {
365 soulng::lexer::Span span = lexer.GetSpan();
366 soulng::parser::Match match = IdentifierParser::QualifiedId(lexer);
367 qid.reset(static_cast<IdentifierNode*>(match.value));
368 if (match.hit)
369 {
370 *parentMatch8 = match;
371 }
372 else
373 {
374 lexer.ThrowExpectationFailure(span, U"identifier");
375 }
376 }
377 *parentMatch7 = match;
378 }
379 *parentMatch1 = match;
380 }
381 *parentMatch0 = match;
382 }
383 if (match.hit)
384 {
385 soulng::parser::Match match(false);
386 soulng::parser::Match* parentMatch9 = &match;
387 {
388 soulng::parser::Match match(false);
389 soulng::parser::Match* parentMatch10 = &match;
390 {
391 int64_t pos = lexer.GetPos();
392 soulng::lexer::Span span = lexer.GetSpan();
393 soulng::parser::Match match(true);
394 soulng::parser::Match* parentMatch11 = &match;
395 {
396 soulng::lexer::Span span = lexer.GetSpan();
397 soulng::parser::Match match(false);
398 if (*lexer == SEMICOLON)
399 {
400 ++lexer;
401 match.hit = true;
402 }
403 if (match.hit)
404 {
405 *parentMatch11 = match;
406 }
407 else
408 {
409 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
410 }
411 }
412 if (match.hit)
413 {
414 s.end = span.end;
415 {
416 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
417
418 #endif // SOULNG_PARSER_DEBUG_SUPPORT
419 return soulng::parser::Match(true, new AliasNode(s, id.release(), qid.release()));
420 }
421 }
422 *parentMatch10 = match;
423 }
424 *parentMatch9 = match;
425 }
426 *parentMatch0 = match;
427 }
428 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
429
430
431
432
433
434 #endif // SOULNG_PARSER_DEBUG_SUPPORT
435 if (!match.hit)
436 {
437 match.value = nullptr;
438 }
439 return match;
440 }
441
442 soulng::parser::Match CompileUnitParser::UsingNamespaceDirective(CmajorLexer& lexer, ParsingContext* ctx)
443 {
444 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
445
446
447
448
449
450
451
452 #endif // SOULNG_PARSER_DEBUG_SUPPORT
453 Span s = Span();
454 std::unique_ptr<IdentifierNode> ns;
455 soulng::parser::Match match(false);
456 soulng::parser::Match* parentMatch0 = &match;
457 {
458 soulng::parser::Match match(false);
459 soulng::parser::Match* parentMatch1 = &match;
460 {
461 soulng::parser::Match match(false);
462 soulng::parser::Match* parentMatch2 = &match;
463 {
464 int64_t pos = lexer.GetPos();
465 soulng::lexer::Span span = lexer.GetSpan();
466 soulng::parser::Match match(false);
467 if (*lexer == USING)
468 {
469 ++lexer;
470 match.hit = true;
471 }
472 if (match.hit)
473 {
474 s = span;
475 }
476 *parentMatch2 = match;
477 }
478 *parentMatch1 = match;
479 }
480 if (match.hit)
481 {
482 soulng::parser::Match match(false);
483 soulng::parser::Match* parentMatch3 = &match;
484 {
485 soulng::parser::Match match(true);
486 soulng::parser::Match* parentMatch4 = &match;
487 {
488 soulng::lexer::Span span = lexer.GetSpan();
489 soulng::parser::Match match = IdentifierParser::QualifiedId(lexer);
490 ns.reset(static_cast<IdentifierNode*>(match.value));
491 if (match.hit)
492 {
493 *parentMatch4 = match;
494 }
495 else
496 {
497 lexer.ThrowExpectationFailure(span, U"identifier");
498 }
499 }
500 *parentMatch3 = match;
501 }
502 *parentMatch1 = match;
503 }
504 *parentMatch0 = match;
505 }
506 if (match.hit)
507 {
508 soulng::parser::Match match(false);
509 soulng::parser::Match* parentMatch5 = &match;
510 {
511 soulng::parser::Match match(false);
512 soulng::parser::Match* parentMatch6 = &match;
513 {
514 int64_t pos = lexer.GetPos();
515 soulng::lexer::Span span = lexer.GetSpan();
516 soulng::parser::Match match(true);
517 soulng::parser::Match* parentMatch7 = &match;
518 {
519 soulng::lexer::Span span = lexer.GetSpan();
520 soulng::parser::Match match(false);
521 if (*lexer == SEMICOLON)
522 {
523 ++lexer;
524 match.hit = true;
525 }
526 if (match.hit)
527 {
528 *parentMatch7 = match;
529 }
530 else
531 {
532 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(SEMICOLON)));
533 }
534 }
535 if (match.hit)
536 {
537 s.end = span.end;
538 {
539 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
540
541 #endif // SOULNG_PARSER_DEBUG_SUPPORT
542 return soulng::parser::Match(true, new NamespaceImportNode(s, ns.release()));
543 }
544 }
545 *parentMatch6 = match;
546 }
547 *parentMatch5 = match;
548 }
549 *parentMatch0 = match;
550 }
551 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
552
553
554
555
556
557 #endif // SOULNG_PARSER_DEBUG_SUPPORT
558 if (!match.hit)
559 {
560 match.value = nullptr;
561 }
562 return match;
563 }
564
565 soulng::parser::Match CompileUnitParser::Definitions(CmajorLexer& lexer, ParsingContext* ctx, sngcm::ast::CompileUnitNode* cu, sngcm::ast::NamespaceNode* ns)
566 {
567 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
568
569
570
571
572
573
574
575 #endif // SOULNG_PARSER_DEBUG_SUPPORT
576 std::unique_ptr<Node> definition;
577 soulng::parser::Match match(true);
578 soulng::parser::Match* parentMatch0 = &match;
579 {
580 while (true)
581 {
582 int64_t save = lexer.GetPos();
583 {
584 soulng::parser::Match match(false);
585 soulng::parser::Match* parentMatch1 = &match;
586 {
587 soulng::parser::Match match(false);
588 soulng::parser::Match* parentMatch2 = &match;
589 {
590 int64_t pos = lexer.GetPos();
591 soulng::parser::Match match = CompileUnitParser::Definition(lexer, ctx, cu, ns);
592 definition.reset(static_cast<Node*>(match.value));
593 if (match.hit)
594 {
595 ns->AddMember(definition.release());
596 }
597 *parentMatch2 = match;
598 }
599 *parentMatch1 = match;
600 }
601 if (match.hit)
602 {
603 *parentMatch0 = match;
604 }
605 else
606 {
607 lexer.SetPos(save);
608 break;
609 }
610 }
611 }
612 }
613 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
614
615
616
617
618
619 #endif // SOULNG_PARSER_DEBUG_SUPPORT
620 if (!match.hit)
621 {
622 match.value = nullptr;
623 }
624 return match;
625 }
626
627 soulng::parser::Match CompileUnitParser::Definition(CmajorLexer& lexer, ParsingContext* ctx, sngcm::ast::CompileUnitNode* cu, sngcm::ast::NamespaceNode* ns)
628 {
629 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
630
631
632
633
634
635
636
637 #endif // SOULNG_PARSER_DEBUG_SUPPORT
638 std::unique_ptr<NamespaceNode> nsDefinition;
639 std::unique_ptr<TypedefNode> typedefDeclaration;
640 std::unique_ptr<ConceptNode> conceptDefinition;
641 std::unique_ptr<FunctionNode> functionDefinition;
642 std::unique_ptr<ClassNode> classDefinition;
643 std::unique_ptr<InterfaceNode> interfaceDefinition;
644 std::unique_ptr<EnumTypeNode> enumTypeDefinition;
645 std::unique_ptr<ConstantNode> constantDefinition;
646 std::unique_ptr<DelegateNode> delegateDefinition;
647 std::unique_ptr<ClassDelegateNode> classDelegateDefinition;
648 std::unique_ptr<GlobalVariableNode> globalVariableDefinition;
649 soulng::parser::Match match(false);
650 soulng::parser::Match* parentMatch0 = &match;
651 {
652 int64_t save = lexer.GetPos();
653 soulng::parser::Match match(false);
654 soulng::parser::Match* parentMatch1 = &match;
655 {
656 int64_t save = lexer.GetPos();
657 soulng::parser::Match match(false);
658 soulng::parser::Match* parentMatch2 = &match;
659 {
660 int64_t save = lexer.GetPos();
661 soulng::parser::Match match(false);
662 soulng::parser::Match* parentMatch3 = &match;
663 {
664 int64_t save = lexer.GetPos();
665 soulng::parser::Match match(false);
666 soulng::parser::Match* parentMatch4 = &match;
667 {
668 int64_t save = lexer.GetPos();
669 soulng::parser::Match match(false);
670 soulng::parser::Match* parentMatch5 = &match;
671 {
672 int64_t save = lexer.GetPos();
673 soulng::parser::Match match(false);
674 soulng::parser::Match* parentMatch6 = &match;
675 {
676 int64_t save = lexer.GetPos();
677 soulng::parser::Match match(false);
678 soulng::parser::Match* parentMatch7 = &match;
679 {
680 int64_t save = lexer.GetPos();
681 soulng::parser::Match match(false);
682 soulng::parser::Match* parentMatch8 = &match;
683 {
684 int64_t save = lexer.GetPos();
685 soulng::parser::Match match(false);
686 soulng::parser::Match* parentMatch9 = &match;
687 {
688 int64_t save = lexer.GetPos();
689 soulng::parser::Match match(false);
690 soulng::parser::Match* parentMatch10 = &match;
691 {
692 int64_t pos = lexer.GetPos();
693 soulng::parser::Match match = CompileUnitParser::NamespaceDefinition(lexer, ctx, cu, ns);
694 nsDefinition.reset(static_cast<NamespaceNode*>(match.value));
695 if (match.hit)
696 {
697 {
698 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
699
700 #endif // SOULNG_PARSER_DEBUG_SUPPORT
701 return soulng::parser::Match(true, nsDefinition.release());
702 }
703 }
704 *parentMatch10 = match;
705 }
706 *parentMatch9 = match;
707 if (!match.hit)
708 {
709 soulng::parser::Match match(false);
710 soulng::parser::Match* parentMatch11 = &match;
711 lexer.SetPos(save);
712 {
713 soulng::parser::Match match(false);
714 soulng::parser::Match* parentMatch12 = &match;
715 {
716 int64_t pos = lexer.GetPos();
717 soulng::parser::Match match = CompileUnitParser::TypedefDeclaration(lexer, ctx);
718 typedefDeclaration.reset(static_cast<TypedefNode*>(match.value));
719 if (match.hit)
720 {
721 {
722 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
723
724 #endif // SOULNG_PARSER_DEBUG_SUPPORT
725 return soulng::parser::Match(true, typedefDeclaration.release());
726 }
727 }
728 *parentMatch12 = match;
729 }
730 *parentMatch11 = match;
731 }
732 *parentMatch9 = match;
733 }
734 }
735 *parentMatch8 = match;
736 if (!match.hit)
737 {
738 soulng::parser::Match match(false);
739 soulng::parser::Match* parentMatch13 = &match;
740 lexer.SetPos(save);
741 {
742 soulng::parser::Match match(false);
743 soulng::parser::Match* parentMatch14 = &match;
744 {
745 int64_t pos = lexer.GetPos();
746 soulng::parser::Match match = CompileUnitParser::ConceptDefinition(lexer, ctx);
747 conceptDefinition.reset(static_cast<ConceptNode*>(match.value));
748 if (match.hit)
749 {
750 {
751 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
752
753 #endif // SOULNG_PARSER_DEBUG_SUPPORT
754 return soulng::parser::Match(true, conceptDefinition.release());
755 }
756 }
757 *parentMatch14 = match;
758 }
759 *parentMatch13 = match;
760 }
761 *parentMatch8 = match;
762 }
763 }
764 *parentMatch7 = match;
765 if (!match.hit)
766 {
767 soulng::parser::Match match(false);
768 soulng::parser::Match* parentMatch15 = &match;
769 lexer.SetPos(save);
770 {
771 soulng::parser::Match match(false);
772 soulng::parser::Match* parentMatch16 = &match;
773 {
774 int64_t pos = lexer.GetPos();
775 soulng::parser::Match match = CompileUnitParser::FunctionDefinition(lexer, ctx);
776 functionDefinition.reset(static_cast<FunctionNode*>(match.value));
777 if (match.hit)
778 {
779 {
780 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
781
782 #endif // SOULNG_PARSER_DEBUG_SUPPORT
783 return soulng::parser::Match(true, functionDefinition.release());
784 }
785 }
786 *parentMatch16 = match;
787 }
788 *parentMatch15 = match;
789 }
790 *parentMatch7 = match;
791 }
792 }
793 *parentMatch6 = match;
794 if (!match.hit)
795 {
796 soulng::parser::Match match(false);
797 soulng::parser::Match* parentMatch17 = &match;
798 lexer.SetPos(save);
799 {
800 soulng::parser::Match match(false);
801 soulng::parser::Match* parentMatch18 = &match;
802 {
803 int64_t pos = lexer.GetPos();
804 soulng::parser::Match match = CompileUnitParser::ClassDefinition(lexer, ctx);
805 classDefinition.reset(static_cast<ClassNode*>(match.value));
806 if (match.hit)
807 {
808 {
809 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
810
811 #endif // SOULNG_PARSER_DEBUG_SUPPORT
812 return soulng::parser::Match(true, classDefinition.release());
813 }
814 }
815 *parentMatch18 = match;
816 }
817 *parentMatch17 = match;
818 }
819 *parentMatch6 = match;
820 }
821 }
822 *parentMatch5 = match;
823 if (!match.hit)
824 {
825 soulng::parser::Match match(false);
826 soulng::parser::Match* parentMatch19 = &match;
827 lexer.SetPos(save);
828 {
829 soulng::parser::Match match(false);
830 soulng::parser::Match* parentMatch20 = &match;
831 {
832 int64_t pos = lexer.GetPos();
833 soulng::parser::Match match = CompileUnitParser::InterfaceDefinition(lexer, ctx);
834 interfaceDefinition.reset(static_cast<InterfaceNode*>(match.value));
835 if (match.hit)
836 {
837 {
838 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
839
840 #endif // SOULNG_PARSER_DEBUG_SUPPORT
841 return soulng::parser::Match(true, interfaceDefinition.release());
842 }
843 }
844 *parentMatch20 = match;
845 }
846 *parentMatch19 = match;
847 }
848 *parentMatch5 = match;
849 }
850 }
851 *parentMatch4 = match;
852 if (!match.hit)
853 {
854 soulng::parser::Match match(false);
855 soulng::parser::Match* parentMatch21 = &match;
856 lexer.SetPos(save);
857 {
858 soulng::parser::Match match(false);
859 soulng::parser::Match* parentMatch22 = &match;
860 {
861 int64_t pos = lexer.GetPos();
862 soulng::parser::Match match = CompileUnitParser::EnumTypeDefinition(lexer, ctx);
863 enumTypeDefinition.reset(static_cast<EnumTypeNode*>(match.value));
864 if (match.hit)
865 {
866 {
867 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
868
869 #endif // SOULNG_PARSER_DEBUG_SUPPORT
870 return soulng::parser::Match(true, enumTypeDefinition.release());
871 }
872 }
873 *parentMatch22 = match;
874 }
875 *parentMatch21 = match;
876 }
877 *parentMatch4 = match;
878 }
879 }
880 *parentMatch3 = match;
881 if (!match.hit)
882 {
883 soulng::parser::Match match(false);
884 soulng::parser::Match* parentMatch23 = &match;
885 lexer.SetPos(save);
886 {
887 soulng::parser::Match match(false);
888 soulng::parser::Match* parentMatch24 = &match;
889 {
890 int64_t pos = lexer.GetPos();
891 soulng::parser::Match match = CompileUnitParser::ConstantDefinition(lexer, ctx);
892 constantDefinition.reset(static_cast<ConstantNode*>(match.value));
893 if (match.hit)
894 {
895 {
896 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
897
898 #endif // SOULNG_PARSER_DEBUG_SUPPORT
899 return soulng::parser::Match(true, constantDefinition.release());
900 }
901 }
902 *parentMatch24 = match;
903 }
904 *parentMatch23 = match;
905 }
906 *parentMatch3 = match;
907 }
908 }
909 *parentMatch2 = match;
910 if (!match.hit)
911 {
912 soulng::parser::Match match(false);
913 soulng::parser::Match* parentMatch25 = &match;
914 lexer.SetPos(save);
915 {
916 soulng::parser::Match match(false);
917 soulng::parser::Match* parentMatch26 = &match;
918 {
919 int64_t pos = lexer.GetPos();
920 soulng::parser::Match match = CompileUnitParser::DelegateDefinition(lexer, ctx);
921 delegateDefinition.reset(static_cast<DelegateNode*>(match.value));
922 if (match.hit)
923 {
924 {
925 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
926
927 #endif // SOULNG_PARSER_DEBUG_SUPPORT
928 return soulng::parser::Match(true, delegateDefinition.release());
929 }
930 }
931 *parentMatch26 = match;
932 }
933 *parentMatch25 = match;
934 }
935 *parentMatch2 = match;
936 }
937 }
938 *parentMatch1 = match;
939 if (!match.hit)
940 {
941 soulng::parser::Match match(false);
942 soulng::parser::Match* parentMatch27 = &match;
943 lexer.SetPos(save);
944 {
945 soulng::parser::Match match(false);
946 soulng::parser::Match* parentMatch28 = &match;
947 {
948 int64_t pos = lexer.GetPos();
949 soulng::parser::Match match = CompileUnitParser::ClassDelegateDefinition(lexer, ctx);
950 classDelegateDefinition.reset(static_cast<ClassDelegateNode*>(match.value));
951 if (match.hit)
952 {
953 {
954 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
955
956 #endif // SOULNG_PARSER_DEBUG_SUPPORT
957 return soulng::parser::Match(true, classDelegateDefinition.release());
958 }
959 }
960 *parentMatch28 = match;
961 }
962 *parentMatch27 = match;
963 }
964 *parentMatch1 = match;
965 }
966 }
967 *parentMatch0 = match;
968 if (!match.hit)
969 {
970 soulng::parser::Match match(false);
971 soulng::parser::Match* parentMatch29 = &match;
972 lexer.SetPos(save);
973 {
974 soulng::parser::Match match(false);
975 soulng::parser::Match* parentMatch30 = &match;
976 {
977 int64_t pos = lexer.GetPos();
978 soulng::parser::Match match = CompileUnitParser::GlobalVariableDefinition(lexer, ctx, cu);
979 globalVariableDefinition.reset(static_cast<GlobalVariableNode*>(match.value));
980 if (match.hit)
981 {
982 {
983 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
984
985 #endif // SOULNG_PARSER_DEBUG_SUPPORT
986 return soulng::parser::Match(true, globalVariableDefinition.release());
987 }
988 }
989 *parentMatch30 = match;
990 }
991 *parentMatch29 = match;
992 }
993 *parentMatch0 = match;
994 }
995 }
996 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
997
998
999
1000
1001
1002 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1003 if (!match.hit)
1004 {
1005 match.value = nullptr;
1006 }
1007 return match;
1008 }
1009
1010 soulng::parser::Match CompileUnitParser::NamespaceDefinition(CmajorLexer& lexer, ParsingContext* ctx, sngcm::ast::CompileUnitNode* cu, sngcm::ast::NamespaceNode* ns)
1011 {
1012 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1013
1014
1015
1016
1017
1018
1019
1020 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1021 std::unique_ptr<NamespaceNode> nsNode = std::unique_ptr<NamespaceNode>();
1022 Span s = Span();
1023 std::unique_ptr<IdentifierNode> nsName;
1024 soulng::parser::Match match(false);
1025 soulng::parser::Match* parentMatch0 = &match;
1026 {
1027 soulng::parser::Match match(false);
1028 soulng::parser::Match* parentMatch1 = &match;
1029 {
1030 soulng::parser::Match match(false);
1031 soulng::parser::Match* parentMatch2 = &match;
1032 {
1033 soulng::parser::Match match(false);
1034 soulng::parser::Match* parentMatch3 = &match;
1035 {
1036 soulng::parser::Match match(false);
1037 soulng::parser::Match* parentMatch4 = &match;
1038 {
1039 int64_t pos = lexer.GetPos();
1040 soulng::lexer::Span span = lexer.GetSpan();
1041 soulng::parser::Match match(false);
1042 if (*lexer == NAMESPACE)
1043 {
1044 ++lexer;
1045 match.hit = true;
1046 }
1047 if (match.hit)
1048 {
1049 s = span;
1050 }
1051 *parentMatch4 = match;
1052 }
1053 *parentMatch3 = match;
1054 }
1055 if (match.hit)
1056 {
1057 soulng::parser::Match match(false);
1058 soulng::parser::Match* parentMatch5 = &match;
1059 {
1060 soulng::parser::Match match(false);
1061 soulng::parser::Match* parentMatch6 = &match;
1062 {
1063 soulng::parser::Match match(false);
1064 soulng::parser::Match* parentMatch7 = &match;
1065 {
1066 int64_t save = lexer.GetPos();
1067 soulng::parser::Match match(false);
1068 soulng::parser::Match* parentMatch8 = &match;
1069 {
1070 int64_t pos = lexer.GetPos();
1071 soulng::lexer::Span span = lexer.GetSpan();
1072 soulng::parser::Match match = IdentifierParser::QualifiedId(lexer);
1073 nsName.reset(static_cast<IdentifierNode*>(match.value));
1074 if (match.hit)
1075 {
1076 s.end = span.end;
1077 nsNode.reset(new NamespaceNode(s, nsName.release()));
1078 }
1079 *parentMatch8 = match;
1080 }
1081 *parentMatch7 = match;
1082 if (!match.hit)
1083 {
1084 soulng::parser::Match match(false);
1085 soulng::parser::Match* parentMatch9 = &match;
1086 lexer.SetPos(save);
1087 {
1088 soulng::parser::Match match(false);
1089 soulng::parser::Match* parentMatch10 = &match;
1090 {
1091 int64_t pos = lexer.GetPos();
1092 soulng::parser::Match match(true);
1093 if (match.hit)
1094 {
1095 nsNode.reset(new NamespaceNode(s, nullptr));
1096 }
1097 *parentMatch10 = match;
1098 }
1099 *parentMatch9 = match;
1100 }
1101 *parentMatch7 = match;
1102 }
1103 }
1104 *parentMatch6 = match;
1105 }
1106 *parentMatch5 = match;
1107 }
1108 *parentMatch3 = match;
1109 }
1110 *parentMatch2 = match;
1111 }
1112 if (match.hit)
1113 {
1114 soulng::parser::Match match(false);
1115 soulng::parser::Match* parentMatch11 = &match;
1116 {
1117 soulng::parser::Match match(true);
1118 soulng::parser::Match* parentMatch12 = &match;
1119 {
1120 soulng::lexer::Span span = lexer.GetSpan();
1121 soulng::parser::Match match(false);
1122 if (*lexer == LBRACE)
1123 {
1124 ++lexer;
1125 match.hit = true;
1126 }
1127 if (match.hit)
1128 {
1129 *parentMatch12 = match;
1130 }
1131 else
1132 {
1133 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(LBRACE)));
1134 }
1135 }
1136 *parentMatch11 = match;
1137 }
1138 *parentMatch2 = match;
1139 }
1140 *parentMatch1 = match;
1141 }
1142 if (match.hit)
1143 {
1144 soulng::parser::Match match(false);
1145 soulng::parser::Match* parentMatch13 = &match;
1146 {
1147 soulng::parser::Match match(true);
1148 soulng::parser::Match* parentMatch14 = &match;
1149 {
1150 soulng::lexer::Span span = lexer.GetSpan();
1151 soulng::parser::Match match = CompileUnitParser::NamespaceContent(lexer, ctx, cu, nsNode.get());
1152 if (match.hit)
1153 {
1154 *parentMatch14 = match;
1155 }
1156 else
1157 {
1158 lexer.ThrowExpectationFailure(span, U"namespace content");
1159 }
1160 }
1161 *parentMatch13 = match;
1162 }
1163 *parentMatch1 = match;
1164 }
1165 *parentMatch0 = match;
1166 }
1167 if (match.hit)
1168 {
1169 soulng::parser::Match match(false);
1170 soulng::parser::Match* parentMatch15 = &match;
1171 {
1172 soulng::parser::Match match(false);
1173 soulng::parser::Match* parentMatch16 = &match;
1174 {
1175 int64_t pos = lexer.GetPos();
1176 soulng::parser::Match match(true);
1177 soulng::parser::Match* parentMatch17 = &match;
1178 {
1179 soulng::lexer::Span span = lexer.GetSpan();
1180 soulng::parser::Match match(false);
1181 if (*lexer == RBRACE)
1182 {
1183 ++lexer;
1184 match.hit = true;
1185 }
1186 if (match.hit)
1187 {
1188 *parentMatch17 = match;
1189 }
1190 else
1191 {
1192 lexer.ThrowExpectationFailure(span, ToUtf32(GetTokenInfo(RBRACE)));
1193 }
1194 }
1195 if (match.hit)
1196 {
1197 {
1198 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1199
1200 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1201 return soulng::parser::Match(true, nsNode.release());
1202 }
1203 }
1204 *parentMatch16 = match;
1205 }
1206 *parentMatch15 = match;
1207 }
1208 *parentMatch0 = match;
1209 }
1210 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1211
1212
1213
1214
1215
1216 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1217 if (!match.hit)
1218 {
1219 match.value = nullptr;
1220 }
1221 return match;
1222 }
1223
1224 soulng::parser::Match CompileUnitParser::TypedefDeclaration(CmajorLexer& lexer, ParsingContext* ctx)
1225 {
1226 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1227
1228
1229
1230
1231
1232
1233
1234 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1235 std::unique_ptr<TypedefNode> typedefDeclaration;
1236 soulng::parser::Match match(false);
1237 soulng::parser::Match* parentMatch0 = &match;
1238 {
1239 int64_t pos = lexer.GetPos();
1240 soulng::parser::Match match = TypedefParser::Typedef(lexer, ctx);
1241 typedefDeclaration.reset(static_cast<TypedefNode*>(match.value));
1242 if (match.hit)
1243 {
1244 {
1245 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1246
1247 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1248 return soulng::parser::Match(true, typedefDeclaration.release());
1249 }
1250 }
1251 *parentMatch0 = match;
1252 }
1253 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1254
1255
1256
1257
1258
1259 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1260 if (!match.hit)
1261 {
1262 match.value = nullptr;
1263 }
1264 return match;
1265 }
1266
1267 soulng::parser::Match CompileUnitParser::ConceptDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1268 {
1269 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1270
1271
1272
1273
1274
1275
1276
1277 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1278 std::unique_ptr<ConceptNode> conceptDefinition;
1279 soulng::parser::Match match(false);
1280 soulng::parser::Match* parentMatch0 = &match;
1281 {
1282 int64_t pos = lexer.GetPos();
1283 soulng::parser::Match match = ConceptParser::Concept(lexer, ctx);
1284 conceptDefinition.reset(static_cast<ConceptNode*>(match.value));
1285 if (match.hit)
1286 {
1287 {
1288 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1289
1290 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1291 return soulng::parser::Match(true, conceptDefinition.release());
1292 }
1293 }
1294 *parentMatch0 = match;
1295 }
1296 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1297
1298
1299
1300
1301
1302 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1303 if (!match.hit)
1304 {
1305 match.value = nullptr;
1306 }
1307 return match;
1308 }
1309
1310 soulng::parser::Match CompileUnitParser::FunctionDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1311 {
1312 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1313
1314
1315
1316
1317
1318
1319
1320 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1321 std::unique_ptr<FunctionNode> functionDefinition;
1322 soulng::parser::Match match(false);
1323 soulng::parser::Match* parentMatch0 = &match;
1324 {
1325 int64_t pos = lexer.GetPos();
1326 soulng::parser::Match match = FunctionParser::Function(lexer, ctx);
1327 functionDefinition.reset(static_cast<FunctionNode*>(match.value));
1328 if (match.hit)
1329 {
1330 {
1331 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1332
1333 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1334 return soulng::parser::Match(true, functionDefinition.release());
1335 }
1336 }
1337 *parentMatch0 = match;
1338 }
1339 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1340
1341
1342
1343
1344
1345 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1346 if (!match.hit)
1347 {
1348 match.value = nullptr;
1349 }
1350 return match;
1351 }
1352
1353 soulng::parser::Match CompileUnitParser::ClassDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1354 {
1355 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1356
1357
1358
1359
1360
1361
1362
1363 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1364 std::unique_ptr<ClassNode> classDefinition;
1365 soulng::parser::Match match(false);
1366 soulng::parser::Match* parentMatch0 = &match;
1367 {
1368 int64_t pos = lexer.GetPos();
1369 soulng::parser::Match match = ClassParser::Class(lexer, ctx);
1370 classDefinition.reset(static_cast<ClassNode*>(match.value));
1371 if (match.hit)
1372 {
1373 {
1374 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1375
1376 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1377 return soulng::parser::Match(true, classDefinition.release());
1378 }
1379 }
1380 *parentMatch0 = match;
1381 }
1382 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1383
1384
1385
1386
1387
1388 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1389 if (!match.hit)
1390 {
1391 match.value = nullptr;
1392 }
1393 return match;
1394 }
1395
1396 soulng::parser::Match CompileUnitParser::InterfaceDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1397 {
1398 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1399
1400
1401
1402
1403
1404
1405
1406 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1407 std::unique_ptr<InterfaceNode> interfaceDefinition;
1408 soulng::parser::Match match(false);
1409 soulng::parser::Match* parentMatch0 = &match;
1410 {
1411 int64_t pos = lexer.GetPos();
1412 soulng::parser::Match match = InterfaceParser::Interface(lexer, ctx);
1413 interfaceDefinition.reset(static_cast<InterfaceNode*>(match.value));
1414 if (match.hit)
1415 {
1416 {
1417 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1418
1419 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1420 return soulng::parser::Match(true, interfaceDefinition.release());
1421 }
1422 }
1423 *parentMatch0 = match;
1424 }
1425 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1426
1427
1428
1429
1430
1431 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1432 if (!match.hit)
1433 {
1434 match.value = nullptr;
1435 }
1436 return match;
1437 }
1438
1439 soulng::parser::Match CompileUnitParser::EnumTypeDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1440 {
1441 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1442
1443
1444
1445
1446
1447
1448
1449 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1450 std::unique_ptr<EnumTypeNode> enumTypeDefinition;
1451 soulng::parser::Match match(false);
1452 soulng::parser::Match* parentMatch0 = &match;
1453 {
1454 int64_t pos = lexer.GetPos();
1455 soulng::parser::Match match = EnumerationParser::EnumType(lexer, ctx);
1456 enumTypeDefinition.reset(static_cast<EnumTypeNode*>(match.value));
1457 if (match.hit)
1458 {
1459 {
1460 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1461
1462 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1463 return soulng::parser::Match(true, enumTypeDefinition.release());
1464 }
1465 }
1466 *parentMatch0 = match;
1467 }
1468 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1469
1470
1471
1472
1473
1474 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1475 if (!match.hit)
1476 {
1477 match.value = nullptr;
1478 }
1479 return match;
1480 }
1481
1482 soulng::parser::Match CompileUnitParser::ConstantDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1483 {
1484 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1485
1486
1487
1488
1489
1490
1491
1492 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1493 std::unique_ptr<ConstantNode> constantDefinition;
1494 soulng::parser::Match match(false);
1495 soulng::parser::Match* parentMatch0 = &match;
1496 {
1497 int64_t pos = lexer.GetPos();
1498 soulng::parser::Match match = ConstantParser::Constant(lexer, ctx);
1499 constantDefinition.reset(static_cast<ConstantNode*>(match.value));
1500 if (match.hit)
1501 {
1502 {
1503 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1504
1505 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1506 return soulng::parser::Match(true, constantDefinition.release());
1507 }
1508 }
1509 *parentMatch0 = match;
1510 }
1511 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1512
1513
1514
1515
1516
1517 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1518 if (!match.hit)
1519 {
1520 match.value = nullptr;
1521 }
1522 return match;
1523 }
1524
1525 soulng::parser::Match CompileUnitParser::DelegateDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1526 {
1527 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1528
1529
1530
1531
1532
1533
1534
1535 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1536 std::unique_ptr<DelegateNode> delegateDefinition;
1537 soulng::parser::Match match(false);
1538 soulng::parser::Match* parentMatch0 = &match;
1539 {
1540 int64_t pos = lexer.GetPos();
1541 soulng::parser::Match match = DelegateParser::Delegate(lexer, ctx);
1542 delegateDefinition.reset(static_cast<DelegateNode*>(match.value));
1543 if (match.hit)
1544 {
1545 {
1546 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1547
1548 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1549 return soulng::parser::Match(true, delegateDefinition.release());
1550 }
1551 }
1552 *parentMatch0 = match;
1553 }
1554 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1555
1556
1557
1558
1559
1560 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1561 if (!match.hit)
1562 {
1563 match.value = nullptr;
1564 }
1565 return match;
1566 }
1567
1568 soulng::parser::Match CompileUnitParser::ClassDelegateDefinition(CmajorLexer& lexer, ParsingContext* ctx)
1569 {
1570 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1571
1572
1573
1574
1575
1576
1577
1578 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1579 std::unique_ptr<ClassDelegateNode> classDelegateDefinition;
1580 soulng::parser::Match match(false);
1581 soulng::parser::Match* parentMatch0 = &match;
1582 {
1583 int64_t pos = lexer.GetPos();
1584 soulng::parser::Match match = DelegateParser::ClassDelegate(lexer, ctx);
1585 classDelegateDefinition.reset(static_cast<ClassDelegateNode*>(match.value));
1586 if (match.hit)
1587 {
1588 {
1589 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1590
1591 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1592 return soulng::parser::Match(true, classDelegateDefinition.release());
1593 }
1594 }
1595 *parentMatch0 = match;
1596 }
1597 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1598
1599
1600
1601
1602
1603 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1604 if (!match.hit)
1605 {
1606 match.value = nullptr;
1607 }
1608 return match;
1609 }
1610
1611 soulng::parser::Match CompileUnitParser::GlobalVariableDefinition(CmajorLexer& lexer, ParsingContext* ctx, sngcm::ast::CompileUnitNode* cu)
1612 {
1613 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1614
1615
1616
1617
1618
1619
1620
1621 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1622 std::unique_ptr<GlobalVariableNode> globalVariableDefinition;
1623 soulng::parser::Match match(false);
1624 soulng::parser::Match* parentMatch0 = &match;
1625 {
1626 int64_t pos = lexer.GetPos();
1627 soulng::parser::Match match = GlobalVariableParser::GlobalVariable(lexer, ctx, cu);
1628 globalVariableDefinition.reset(static_cast<GlobalVariableNode*>(match.value));
1629 if (match.hit)
1630 {
1631 {
1632 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1633
1634 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1635 return soulng::parser::Match(true, globalVariableDefinition.release());
1636 }
1637 }
1638 *parentMatch0 = match;
1639 }
1640 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1641
1642
1643
1644
1645
1646 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1647 if (!match.hit)
1648 {
1649 match.value = nullptr;
1650 }
1651 return match;
1652 }