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