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