1 using System;
2 using System.Collections;
3 using System.Lex;
4 using System.Parsing;
5 using AssemblyTokens;
6
7
8
9 public static class AssemblyParser
10 {
11 public static void Parse(AssemblyLexer& lexer, List<UniquePtr<cmsx.assembly.Instruction>>* instructionList)
12 {
13 #if (DEBUG)
14 if (lexer.Log() != null)
15 {
16 lexer.Log()->WriteBeginRule(u"parse");
17 lexer.Log()->IncIndent();
18 }
19 #endif
20 ++lexer;
21 System.Lex.Span span = lexer.GetSpan();
22 Match match = AssemblyFile(lexer, instructionList);
23 if (match.hit)
24 {
25 if (*lexer == System.Lex.END_TOKEN)
26 {
27 return;
28 }
29 else
30 {
31 lexer.ThrowExpectationFailure(lexer.GetSpan(), GetEndTokenInfo());
32 }
33 }
34 else
35 {
36 lexer.ThrowExpectationFailure(span, u"AssemblyFile");
37 }
38 return;
39 }
40 public static Match AssemblyFile(AssemblyLexer& lexer, List<UniquePtr<cmsx.assembly.Instruction>>* instructionList)
41 {
42 #if (DEBUG)
43 Span debugSpan;
44 bool writeToLog = lexer.Log() != null;
45 if (writeToLog)
46 {
47 debugSpan = lexer.GetSpan();
48 System.Lex.WriteBeginRuleToLog(lexer, u"AssemblyFile");
49 }
50 #endif
51 Match match(true);
52 Match* parentMatch0 = &match;
53 {
54 while (true)
55 {
56 long save = lexer.GetPos();
57 {
58 Match match = AssemblyParser.AssemblyLine(lexer, instructionList);
59 if (match.hit)
60 {
61 *parentMatch0 = match;
62 }
63 else
64 {
65 lexer.SetPos(save);
66 break;
67 }
68 }
69 }
70 }
71 #if (DEBUG)
72 if (writeToLog)
73 {
74 if (match.hit)
75 {
76 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"AssemblyFile");
77 }
78 else
79 {
80 System.Lex.WriteFailureToLog(lexer, u"AssemblyFile");
81 }
82 }
83 #endif
84 if (!match.hit)
85 {
86 match.value = null;
87 }
88 return match;
89 }
90 public static Match AssemblyLine(AssemblyLexer& lexer, List<UniquePtr<cmsx.assembly.Instruction>>* instructionList)
91 {
92 #if (DEBUG)
93 Span debugSpan;
94 bool writeToLog = lexer.Log() != null;
95 if (writeToLog)
96 {
97 debugSpan = lexer.GetSpan();
98 System.Lex.WriteBeginRuleToLog(lexer, u"AssemblyLine");
99 }
100 #endif
101 Match match(false);
102 Match* parentMatch0 = &match;
103 {
104 long save = lexer.GetPos();
105 Match match(false);
106 Match* parentMatch1 = &match;
107 {
108 long save = lexer.GetPos();
109 Match match(false);
110 Match* parentMatch2 = &match;
111 {
112 long save = lexer.GetPos();
113 Match match = AssemblyParser.CommentLine(lexer);
114 *parentMatch2 = match;
115 if (!match.hit)
116 {
117 Match match(false);
118 Match* parentMatch3 = &match;
119 lexer.SetPos(save);
120 {
121 Match match = AssemblyParser.EmptyLine(lexer);
122 *parentMatch3 = match;
123 }
124 *parentMatch2 = match;
125 }
126 }
127 *parentMatch1 = match;
128 if (!match.hit)
129 {
130 Match match(false);
131 Match* parentMatch4 = &match;
132 lexer.SetPos(save);
133 {
134 Match match = AssemblyParser.ModeLine(lexer, instructionList);
135 *parentMatch4 = match;
136 }
137 *parentMatch1 = match;
138 }
139 }
140 *parentMatch0 = match;
141 if (!match.hit)
142 {
143 Match match(false);
144 Match* parentMatch5 = &match;
145 lexer.SetPos(save);
146 {
147 Match match = AssemblyParser.InstructionLine(lexer, instructionList);
148 *parentMatch5 = match;
149 }
150 *parentMatch0 = match;
151 }
152 }
153 #if (DEBUG)
154 if (writeToLog)
155 {
156 if (match.hit)
157 {
158 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"AssemblyLine");
159 }
160 else
161 {
162 System.Lex.WriteFailureToLog(lexer, u"AssemblyLine");
163 }
164 }
165 #endif
166 if (!match.hit)
167 {
168 match.value = null;
169 }
170 return match;
171 }
172 public static Match CommentLine(AssemblyLexer& lexer)
173 {
174 #if (DEBUG)
175 Span debugSpan;
176 bool writeToLog = lexer.Log() != null;
177 if (writeToLog)
178 {
179 debugSpan = lexer.GetSpan();
180 System.Lex.WriteBeginRuleToLog(lexer, u"CommentLine");
181 }
182 #endif
183 Match match(false);
184 Match* parentMatch0 = &match;
185 {
186 Match match = AssemblyParser.Comment(lexer);
187 *parentMatch0 = match;
188 }
189 if (match.hit)
190 {
191 Match match(false);
192 Match* parentMatch1 = &match;
193 {
194 Match match(false);
195 if (*lexer == NEWLINE)
196 {
197 ++lexer;
198 match.hit = true;
199 }
200 *parentMatch1 = match;
201 }
202 *parentMatch0 = match;
203 }
204 #if (DEBUG)
205 if (writeToLog)
206 {
207 if (match.hit)
208 {
209 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"CommentLine");
210 }
211 else
212 {
213 System.Lex.WriteFailureToLog(lexer, u"CommentLine");
214 }
215 }
216 #endif
217 if (!match.hit)
218 {
219 match.value = null;
220 }
221 return match;
222 }
223 public static Match Comment(AssemblyLexer& lexer)
224 {
225 #if (DEBUG)
226 Span debugSpan;
227 bool writeToLog = lexer.Log() != null;
228 if (writeToLog)
229 {
230 debugSpan = lexer.GetSpan();
231 System.Lex.WriteBeginRuleToLog(lexer, u"Comment");
232 }
233 #endif
234 Match match(false);
235 Match* parentMatch0 = &match;
236 {
237 Match match(false);
238 Match* parentMatch1 = &match;
239 {
240 Match match(true);
241 long save = lexer.GetPos();
242 Match* parentMatch2 = &match;
243 {
244 Match match(false);
245 if (*lexer == SPACE)
246 {
247 ++lexer;
248 match.hit = true;
249 }
250 if (match.hit)
251 {
252 *parentMatch2 = match;
253 }
254 else
255 {
256 lexer.SetPos(save);
257 }
258 }
259 *parentMatch1 = match;
260 }
261 if (match.hit)
262 {
263 Match match(false);
264 Match* parentMatch3 = &match;
265 {
266 Match match(false);
267 Match* parentMatch4 = &match;
268 {
269 Match match(false);
270 Match* parentMatch5 = &match;
271 long save = lexer.GetPos();
272 {
273 Match match(false);
274 if (*lexer != System.Lex.END_TOKEN)
275 {
276 ++lexer;
277 match.hit = true;
278 }
279 *parentMatch5 = match;
280 }
281 if (match.hit)
282 {
283 Match match(false);
284 Match* parentMatch6 = &match;
285 {
286 long tmp = lexer.GetPos();
287 lexer.SetPos(save);
288 save = tmp;
289 Match match(false);
290 Match* parentMatch7 = &match;
291 {
292 Match match(false);
293 Match* parentMatch8 = &match;
294 {
295 long save = lexer.GetPos();
296 Match match(false);
297 Match* parentMatch9 = &match;
298 {
299 long save = lexer.GetPos();
300 Match match(false);
301 Match* parentMatch10 = &match;
302 {
303 long save = lexer.GetPos();
304 Match match(false);
305 Match* parentMatch11 = &match;
306 {
307 long save = lexer.GetPos();
308 Match match(false);
309 Match* parentMatch12 = &match;
310 {
311 long save = lexer.GetPos();
312 Match match(false);
313 if (*lexer == NEWLINE)
314 {
315 ++lexer;
316 match.hit = true;
317 }
318 *parentMatch12 = match;
319 if (!match.hit)
320 {
321 Match match(false);
322 Match* parentMatch13 = &match;
323 lexer.SetPos(save);
324 {
325 Match match(false);
326 if (*lexer == SYMBOL)
327 {
328 ++lexer;
329 match.hit = true;
330 }
331 *parentMatch13 = match;
332 }
333 *parentMatch12 = match;
334 }
335 }
336 *parentMatch11 = match;
337 if (!match.hit)
338 {
339 Match match(false);
340 Match* parentMatch14 = &match;
341 lexer.SetPos(save);
342 {
343 Match match(false);
344 if (*lexer == LOCAL_SYMBOL)
345 {
346 ++lexer;
347 match.hit = true;
348 }
349 *parentMatch14 = match;
350 }
351 *parentMatch11 = match;
352 }
353 }
354 *parentMatch10 = match;
355 if (!match.hit)
356 {
357 Match match(false);
358 Match* parentMatch15 = &match;
359 lexer.SetPos(save);
360 {
361 Match match(false);
362 if (*lexer == DOT)
363 {
364 ++lexer;
365 match.hit = true;
366 }
367 *parentMatch15 = match;
368 }
369 *parentMatch10 = match;
370 }
371 }
372 *parentMatch9 = match;
373 if (!match.hit)
374 {
375 Match match(false);
376 Match* parentMatch16 = &match;
377 lexer.SetPos(save);
378 {
379 Match match(false);
380 if (*lexer == SEMICOLON)
381 {
382 ++lexer;
383 match.hit = true;
384 }
385 *parentMatch16 = match;
386 }
387 *parentMatch9 = match;
388 }
389 }
390 *parentMatch8 = match;
391 if (!match.hit)
392 {
393 Match match(false);
394 Match* parentMatch17 = &match;
395 lexer.SetPos(save);
396 {
397 Match match(false);
398 if (*lexer == AT)
399 {
400 ++lexer;
401 match.hit = true;
402 }
403 *parentMatch17 = match;
404 }
405 *parentMatch8 = match;
406 }
407 }
408 *parentMatch7 = match;
409 }
410 *parentMatch6 = match;
411 }
412 if (!match.hit)
413 {
414 lexer.SetPos(save);
415 }
416 *parentMatch5 = Match(!match.hit, match.value);
417 }
418 *parentMatch4 = match;
419 }
420 *parentMatch3 = match;
421 }
422 *parentMatch1 = match;
423 }
424 *parentMatch0 = match;
425 }
426 if (match.hit)
427 {
428 Match match(false);
429 Match* parentMatch18 = &match;
430 {
431 Match match(true);
432 Match* parentMatch19 = &match;
433 {
434 while (true)
435 {
436 long save = lexer.GetPos();
437 {
438 Match match(false);
439 Match* parentMatch20 = &match;
440 {
441 Match match(false);
442 Match* parentMatch21 = &match;
443 long save = lexer.GetPos();
444 {
445 Match match(false);
446 if (*lexer != System.Lex.END_TOKEN)
447 {
448 ++lexer;
449 match.hit = true;
450 }
451 *parentMatch21 = match;
452 }
453 if (match.hit)
454 {
455 Match match(false);
456 Match* parentMatch22 = &match;
457 {
458 long tmp = lexer.GetPos();
459 lexer.SetPos(save);
460 save = tmp;
461 Match match(false);
462 if (*lexer == NEWLINE)
463 {
464 ++lexer;
465 match.hit = true;
466 }
467 *parentMatch22 = match;
468 }
469 if (!match.hit)
470 {
471 lexer.SetPos(save);
472 }
473 *parentMatch21 = Match(!match.hit, match.value);
474 }
475 *parentMatch20 = match;
476 }
477 if (match.hit)
478 {
479 *parentMatch19 = match;
480 }
481 else
482 {
483 lexer.SetPos(save);
484 break;
485 }
486 }
487 }
488 }
489 *parentMatch18 = match;
490 }
491 *parentMatch0 = match;
492 }
493 #if (DEBUG)
494 if (writeToLog)
495 {
496 if (match.hit)
497 {
498 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Comment");
499 }
500 else
501 {
502 System.Lex.WriteFailureToLog(lexer, u"Comment");
503 }
504 }
505 #endif
506 if (!match.hit)
507 {
508 match.value = null;
509 }
510 return match;
511 }
512 public static Match EmptyLine(AssemblyLexer& lexer)
513 {
514 #if (DEBUG)
515 Span debugSpan;
516 bool writeToLog = lexer.Log() != null;
517 if (writeToLog)
518 {
519 debugSpan = lexer.GetSpan();
520 System.Lex.WriteBeginRuleToLog(lexer, u"EmptyLine");
521 }
522 #endif
523 Match match(false);
524 Match* parentMatch0 = &match;
525 {
526 Match match(true);
527 long save = lexer.GetPos();
528 Match* parentMatch1 = &match;
529 {
530 Match match(false);
531 if (*lexer == SPACE)
532 {
533 ++lexer;
534 match.hit = true;
535 }
536 if (match.hit)
537 {
538 *parentMatch1 = match;
539 }
540 else
541 {
542 lexer.SetPos(save);
543 }
544 }
545 *parentMatch0 = match;
546 }
547 if (match.hit)
548 {
549 Match match(false);
550 Match* parentMatch2 = &match;
551 {
552 Match match(false);
553 if (*lexer == NEWLINE)
554 {
555 ++lexer;
556 match.hit = true;
557 }
558 *parentMatch2 = match;
559 }
560 *parentMatch0 = match;
561 }
562 #if (DEBUG)
563 if (writeToLog)
564 {
565 if (match.hit)
566 {
567 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"EmptyLine");
568 }
569 else
570 {
571 System.Lex.WriteFailureToLog(lexer, u"EmptyLine");
572 }
573 }
574 #endif
575 if (!match.hit)
576 {
577 match.value = null;
578 }
579 return match;
580 }
581 public static Match ModeLine(AssemblyLexer& lexer, List<UniquePtr<cmsx.assembly.Instruction>>* instructionList)
582 {
583 #if (DEBUG)
584 Span debugSpan;
585 bool writeToLog = lexer.Log() != null;
586 if (writeToLog)
587 {
588 debugSpan = lexer.GetSpan();
589 System.Lex.WriteBeginRuleToLog(lexer, u"ModeLine");
590 }
591 #endif
592 Match match(false);
593 Match* parentMatch0 = &match;
594 {
595 Match match(false);
596 Match* parentMatch1 = &match;
597 {
598 Match match(false);
599 Match* parentMatch2 = &match;
600 {
601 Match match(false);
602 Match* parentMatch3 = &match;
603 {
604 Match match(true);
605 long save = lexer.GetPos();
606 Match* parentMatch4 = &match;
607 {
608 Match match(false);
609 if (*lexer == SPACE)
610 {
611 ++lexer;
612 match.hit = true;
613 }
614 if (match.hit)
615 {
616 *parentMatch4 = match;
617 }
618 else
619 {
620 lexer.SetPos(save);
621 }
622 }
623 *parentMatch3 = match;
624 }
625 if (match.hit)
626 {
627 Match match(false);
628 Match* parentMatch5 = &match;
629 {
630 Match match(false);
631 if (*lexer == DOT)
632 {
633 ++lexer;
634 match.hit = true;
635 }
636 *parentMatch5 = match;
637 }
638 *parentMatch3 = match;
639 }
640 *parentMatch2 = match;
641 }
642 if (match.hit)
643 {
644 Match match(false);
645 Match* parentMatch6 = &match;
646 {
647 Match match(false);
648 Match* parentMatch7 = &match;
649 {
650 long pos = lexer.GetPos();
651 Span span = lexer.GetSpan();
652 bool pass = true;
653 Match match(false);
654 if (*lexer == SYMBOL)
655 {
656 ++lexer;
657 match.hit = true;
658 }
659 if (match.hit)
660 {
661 cmsx.assembly.Instruction* modeInst = cmsx.assembly.MakeModeInst(span, lexer.GetToken(pos));
662 pass = modeInst != null;
663 if (pass)
664 {
665 instructionList->Add(UniquePtr<cmsx.assembly.Instruction>(modeInst));
666 }
667 }
668 if (match.hit && !pass)
669 {
670 match = Match(false);
671 }
672 *parentMatch7 = match;
673 }
674 *parentMatch6 = match;
675 }
676 *parentMatch2 = match;
677 }
678 *parentMatch1 = match;
679 }
680 if (match.hit)
681 {
682 Match match(false);
683 Match* parentMatch8 = &match;
684 {
685 Match match(true);
686 long save = lexer.GetPos();
687 Match* parentMatch9 = &match;
688 {
689 Match match(false);
690 if (*lexer == SPACE)
691 {
692 ++lexer;
693 match.hit = true;
694 }
695 if (match.hit)
696 {
697 *parentMatch9 = match;
698 }
699 else
700 {
701 lexer.SetPos(save);
702 }
703 }
704 *parentMatch8 = match;
705 }
706 *parentMatch1 = match;
707 }
708 *parentMatch0 = match;
709 }
710 if (match.hit)
711 {
712 Match match(false);
713 Match* parentMatch10 = &match;
714 {
715 Match match(false);
716 if (*lexer == NEWLINE)
717 {
718 ++lexer;
719 match.hit = true;
720 }
721 *parentMatch10 = match;
722 }
723 *parentMatch0 = match;
724 }
725 #if (DEBUG)
726 if (writeToLog)
727 {
728 if (match.hit)
729 {
730 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"ModeLine");
731 }
732 else
733 {
734 System.Lex.WriteFailureToLog(lexer, u"ModeLine");
735 }
736 }
737 #endif
738 if (!match.hit)
739 {
740 match.value = null;
741 }
742 return match;
743 }
744 public static Match InstructionLine(AssemblyLexer& lexer, List<UniquePtr<cmsx.assembly.Instruction>>* instructionList)
745 {
746 #if (DEBUG)
747 Span debugSpan;
748 bool writeToLog = lexer.Log() != null;
749 if (writeToLog)
750 {
751 debugSpan = lexer.GetSpan();
752 System.Lex.WriteBeginRuleToLog(lexer, u"InstructionLine");
753 }
754 #endif
755 UniquePtr<cmsx.assembly.Instruction> left;
756 UniquePtr<cmsx.assembly.Instruction> right;
757 Match match(false);
758 Match* parentMatch0 = &match;
759 {
760 Match match(false);
761 Match* parentMatch1 = &match;
762 {
763 Match match(false);
764 Match* parentMatch2 = &match;
765 {
766 Match match(false);
767 Match* parentMatch3 = &match;
768 {
769 long pos = lexer.GetPos();
770 Match match = AssemblyParser.Instruction(lexer);
771 left.Reset(cast<cmsx.assembly.Instruction*>(match.value));
772 if (match.hit)
773 {
774 instructionList->Add(UniquePtr<cmsx.assembly.Instruction>(left.Release()));
775 }
776 *parentMatch3 = match;
777 }
778 *parentMatch2 = match;
779 }
780 if (match.hit)
781 {
782 Match match(false);
783 Match* parentMatch4 = &match;
784 {
785 Match match(true);
786 Match* parentMatch5 = &match;
787 {
788 while (true)
789 {
790 long save = lexer.GetPos();
791 {
792 Match match(false);
793 Match* parentMatch6 = &match;
794 {
795 Match match(false);
796 Match* parentMatch7 = &match;
797 {
798 Match match(false);
799 Match* parentMatch8 = &match;
800 {
801 Match match(true);
802 long save = lexer.GetPos();
803 Match* parentMatch9 = &match;
804 {
805 Match match(false);
806 if (*lexer == SPACE)
807 {
808 ++lexer;
809 match.hit = true;
810 }
811 if (match.hit)
812 {
813 *parentMatch9 = match;
814 }
815 else
816 {
817 lexer.SetPos(save);
818 }
819 }
820 *parentMatch8 = match;
821 }
822 if (match.hit)
823 {
824 Match match(false);
825 Match* parentMatch10 = &match;
826 {
827 Match match(false);
828 if (*lexer == SEMICOLON)
829 {
830 ++lexer;
831 match.hit = true;
832 }
833 *parentMatch10 = match;
834 }
835 *parentMatch8 = match;
836 }
837 *parentMatch7 = match;
838 }
839 if (match.hit)
840 {
841 Match match(false);
842 Match* parentMatch11 = &match;
843 {
844 Match match(false);
845 Match* parentMatch12 = &match;
846 {
847 long pos = lexer.GetPos();
848 Match match = AssemblyParser.Instruction(lexer);
849 right.Reset(cast<cmsx.assembly.Instruction*>(match.value));
850 if (match.hit)
851 {
852 instructionList->Add(UniquePtr<cmsx.assembly.Instruction>(right.Release()));
853 }
854 *parentMatch12 = match;
855 }
856 *parentMatch11 = match;
857 }
858 *parentMatch7 = match;
859 }
860 *parentMatch6 = match;
861 }
862 if (match.hit)
863 {
864 *parentMatch5 = match;
865 }
866 else
867 {
868 lexer.SetPos(save);
869 break;
870 }
871 }
872 }
873 }
874 *parentMatch4 = match;
875 }
876 *parentMatch2 = match;
877 }
878 *parentMatch1 = match;
879 }
880 if (match.hit)
881 {
882 Match match(false);
883 Match* parentMatch13 = &match;
884 {
885 Match match(true);
886 long save = lexer.GetPos();
887 Match* parentMatch14 = &match;
888 {
889 Match match = AssemblyParser.Comment(lexer);
890 if (match.hit)
891 {
892 *parentMatch14 = match;
893 }
894 else
895 {
896 lexer.SetPos(save);
897 }
898 }
899 *parentMatch13 = match;
900 }
901 *parentMatch1 = match;
902 }
903 *parentMatch0 = match;
904 }
905 if (match.hit)
906 {
907 Match match(false);
908 Match* parentMatch15 = &match;
909 {
910 Match match(false);
911 if (*lexer == NEWLINE)
912 {
913 ++lexer;
914 match.hit = true;
915 }
916 *parentMatch15 = match;
917 }
918 *parentMatch0 = match;
919 }
920 #if (DEBUG)
921 if (writeToLog)
922 {
923 if (match.hit)
924 {
925 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"InstructionLine");
926 }
927 else
928 {
929 System.Lex.WriteFailureToLog(lexer, u"InstructionLine");
930 }
931 }
932 #endif
933 if (!match.hit)
934 {
935 match.value = null;
936 }
937 return match;
938 }
939 public static Match Instruction(AssemblyLexer& lexer)
940 {
941 #if (DEBUG)
942 Span debugSpan;
943 bool writeToLog = lexer.Log() != null;
944 if (writeToLog)
945 {
946 debugSpan = lexer.GetSpan();
947 System.Lex.WriteBeginRuleToLog(lexer, u"Instruction");
948 }
949 #endif
950 Span s;
951 UniquePtr<cmsx.assembly.Node> label;
952 UniquePtr<cmsx.assembly.Node> lbl;
953 UniquePtr<cmsx.assembly.OpCode> opcode;
954 UniquePtr<cmsx.assembly.OperandList> operands;
955 Match match(false);
956 Match* parentMatch0 = &match;
957 {
958 long pos = lexer.GetPos();
959 Match match(false);
960 Match* parentMatch1 = &match;
961 {
962 Match match(false);
963 Match* parentMatch2 = &match;
964 {
965 Match match(false);
966 Match* parentMatch3 = &match;
967 {
968 Match match(false);
969 Match* parentMatch4 = &match;
970 {
971 Match match(false);
972 Match* parentMatch5 = &match;
973 {
974 Match match(false);
975 Match* parentMatch6 = &match;
976 {
977 long pos = lexer.GetPos();
978 Match match(true);
979 if (match.hit)
980 {
981 lexer.PushSpan();
982 }
983 *parentMatch6 = match;
984 }
985 *parentMatch5 = match;
986 }
987 if (match.hit)
988 {
989 Match match(false);
990 Match* parentMatch7 = &match;
991 {
992 Match match(false);
993 Match* parentMatch8 = &match;
994 {
995 long pos = lexer.GetPos();
996 Match match = AssemblyParser.Label(lexer);
997 lbl.Reset(cast<cmsx.assembly.Node*>(match.value));
998 if (match.hit)
999 {
1000 lexer.SetSpan(pos);
1001 label.Reset(lbl.Release());
1002 }
1003 *parentMatch8 = match;
1004 }
1005 *parentMatch7 = match;
1006 }
1007 *parentMatch5 = match;
1008 }
1009 *parentMatch4 = match;
1010 }
1011 if (match.hit)
1012 {
1013 Match match(false);
1014 Match* parentMatch9 = &match;
1015 {
1016 Match match(false);
1017 Match* parentMatch10 = &match;
1018 {
1019 long pos = lexer.GetPos();
1020 Match match = AssemblyParser.SplitLine(lexer, !label.IsNull());
1021 if (match.hit)
1022 {
1023 lexer.SetSpan(pos);
1024 }
1025 *parentMatch10 = match;
1026 }
1027 *parentMatch9 = match;
1028 }
1029 *parentMatch4 = match;
1030 }
1031 *parentMatch3 = match;
1032 }
1033 if (match.hit)
1034 {
1035 Match match(false);
1036 Match* parentMatch11 = &match;
1037 {
1038 Match match(false);
1039 Match* parentMatch12 = &match;
1040 {
1041 long pos = lexer.GetPos();
1042 Match match = AssemblyParser.OpCode(lexer);
1043 opcode.Reset(cast<cmsx.assembly.OpCode*>(match.value));
1044 if (match.hit)
1045 {
1046 lexer.SetSpan(pos);
1047 }
1048 *parentMatch12 = match;
1049 }
1050 *parentMatch11 = match;
1051 }
1052 *parentMatch3 = match;
1053 }
1054 *parentMatch2 = match;
1055 }
1056 if (match.hit)
1057 {
1058 Match match(false);
1059 Match* parentMatch13 = &match;
1060 {
1061 Match match(false);
1062 Match* parentMatch14 = &match;
1063 {
1064 long pos = lexer.GetPos();
1065 Match match = AssemblyParser.Operands(lexer);
1066 operands.Reset(cast<cmsx.assembly.OperandList*>(match.value));
1067 if (match.hit)
1068 {
1069 lexer.SetSpan(pos);
1070 }
1071 *parentMatch14 = match;
1072 }
1073 *parentMatch13 = match;
1074 }
1075 *parentMatch2 = match;
1076 }
1077 *parentMatch1 = match;
1078 }
1079 if (match.hit)
1080 {
1081 {
1082 #if (DEBUG)
1083 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Instruction");
1084 #endif
1085 return Match(true, new cmsx.assembly.Instruction(lexer.PopSpan(), label.Release(), opcode.Release(), operands.Release()));
1086 }
1087 }
1088 *parentMatch0 = match;
1089 }
1090 #if (DEBUG)
1091 if (writeToLog)
1092 {
1093 if (match.hit)
1094 {
1095 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Instruction");
1096 }
1097 else
1098 {
1099 System.Lex.WriteFailureToLog(lexer, u"Instruction");
1100 }
1101 }
1102 #endif
1103 if (!match.hit)
1104 {
1105 match.value = null;
1106 }
1107 return match;
1108 }
1109 public static Match Label(AssemblyLexer& lexer)
1110 {
1111 #if (DEBUG)
1112 Span debugSpan;
1113 bool writeToLog = lexer.Log() != null;
1114 if (writeToLog)
1115 {
1116 debugSpan = lexer.GetSpan();
1117 System.Lex.WriteBeginRuleToLog(lexer, u"Label");
1118 }
1119 #endif
1120 Match match(false);
1121 Match* parentMatch0 = &match;
1122 {
1123 long save = lexer.GetPos();
1124 long pos = lexer.GetPos();
1125 Span span = lexer.GetSpan();
1126 switch (*lexer)
1127 {
1128 case LOCAL_SYMBOL:
1129 {
1130 ++lexer;
1131 {
1132 #if (DEBUG)
1133 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Label");
1134 #endif
1135 return Match(true, cmsx.assembly.MakeLocalSymbolNode(span, lexer.GetToken(pos)));
1136 }
1137 break;
1138 }
1139 case SYMBOL:
1140 {
1141 ++lexer;
1142 {
1143 #if (DEBUG)
1144 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Label");
1145 #endif
1146 return Match(true, cmsx.assembly.MakeSymbolNode(span, lexer.GetToken(pos)));
1147 }
1148 break;
1149 }
1150 }
1151 *parentMatch0 = match;
1152 if (!match.hit)
1153 {
1154 Match match(false);
1155 Match* parentMatch1 = &match;
1156 lexer.SetPos(save);
1157 {
1158 Match match(false);
1159 Match* parentMatch2 = &match;
1160 {
1161 long pos = lexer.GetPos();
1162 Match match(true);
1163 if (match.hit)
1164 {
1165 {
1166 #if (DEBUG)
1167 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Label");
1168 #endif
1169 return Match(true, null);
1170 }
1171 }
1172 *parentMatch2 = match;
1173 }
1174 *parentMatch1 = match;
1175 }
1176 *parentMatch0 = match;
1177 }
1178 }
1179 #if (DEBUG)
1180 if (writeToLog)
1181 {
1182 if (match.hit)
1183 {
1184 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Label");
1185 }
1186 else
1187 {
1188 System.Lex.WriteFailureToLog(lexer, u"Label");
1189 }
1190 }
1191 #endif
1192 if (!match.hit)
1193 {
1194 match.value = null;
1195 }
1196 return match;
1197 }
1198 public static Match SplitLine(AssemblyLexer& lexer, bool hasLabel)
1199 {
1200 #if (DEBUG)
1201 Span debugSpan;
1202 bool writeToLog = lexer.Log() != null;
1203 if (writeToLog)
1204 {
1205 debugSpan = lexer.GetSpan();
1206 System.Lex.WriteBeginRuleToLog(lexer, u"SplitLine");
1207 }
1208 #endif
1209 Match match(false);
1210 Match* parentMatch0 = &match;
1211 {
1212 long save = lexer.GetPos();
1213 Match match(false);
1214 Match* parentMatch1 = &match;
1215 {
1216 Match match(false);
1217 if (*lexer == SPACE)
1218 {
1219 ++lexer;
1220 match.hit = true;
1221 }
1222 *parentMatch1 = match;
1223 }
1224 if (match.hit)
1225 {
1226 Match match(false);
1227 Match* parentMatch2 = &match;
1228 {
1229 Match match(true);
1230 long save = lexer.GetPos();
1231 Match* parentMatch3 = &match;
1232 {
1233 Match match(false);
1234 Match* parentMatch4 = &match;
1235 {
1236 Match match(false);
1237 Match* parentMatch5 = &match;
1238 {
1239 Match match(false);
1240 if (*lexer == NEWLINE)
1241 {
1242 ++lexer;
1243 match.hit = true;
1244 }
1245 *parentMatch5 = match;
1246 }
1247 if (match.hit)
1248 {
1249 Match match(false);
1250 Match* parentMatch6 = &match;
1251 {
1252 Match match(false);
1253 if (*lexer == SPACE)
1254 {
1255 ++lexer;
1256 match.hit = true;
1257 }
1258 *parentMatch6 = match;
1259 }
1260 *parentMatch5 = match;
1261 }
1262 *parentMatch4 = match;
1263 }
1264 if (match.hit)
1265 {
1266 *parentMatch3 = match;
1267 }
1268 else
1269 {
1270 lexer.SetPos(save);
1271 }
1272 }
1273 *parentMatch2 = match;
1274 }
1275 *parentMatch1 = match;
1276 }
1277 *parentMatch0 = match;
1278 if (!match.hit)
1279 {
1280 Match match(false);
1281 Match* parentMatch7 = &match;
1282 lexer.SetPos(save);
1283 {
1284 Match match(false);
1285 Match* parentMatch8 = &match;
1286 {
1287 Match match(false);
1288 Match* parentMatch9 = &match;
1289 {
1290 Match match(false);
1291 Match* parentMatch10 = &match;
1292 {
1293 long pos = lexer.GetPos();
1294 bool pass = true;
1295 Match match(true);
1296 if (match.hit)
1297 {
1298 pass = hasLabel;
1299 }
1300 if (match.hit && !pass)
1301 {
1302 match = Match(false);
1303 }
1304 *parentMatch10 = match;
1305 }
1306 *parentMatch9 = match;
1307 }
1308 if (match.hit)
1309 {
1310 Match match(false);
1311 Match* parentMatch11 = &match;
1312 {
1313 Match match(false);
1314 if (*lexer == NEWLINE)
1315 {
1316 ++lexer;
1317 match.hit = true;
1318 }
1319 *parentMatch11 = match;
1320 }
1321 *parentMatch9 = match;
1322 }
1323 *parentMatch8 = match;
1324 }
1325 if (match.hit)
1326 {
1327 Match match(false);
1328 Match* parentMatch12 = &match;
1329 {
1330 Match match(false);
1331 if (*lexer == SPACE)
1332 {
1333 ++lexer;
1334 match.hit = true;
1335 }
1336 *parentMatch12 = match;
1337 }
1338 *parentMatch8 = match;
1339 }
1340 *parentMatch7 = match;
1341 }
1342 *parentMatch0 = match;
1343 }
1344 }
1345 #if (DEBUG)
1346 if (writeToLog)
1347 {
1348 if (match.hit)
1349 {
1350 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"SplitLine");
1351 }
1352 else
1353 {
1354 System.Lex.WriteFailureToLog(lexer, u"SplitLine");
1355 }
1356 }
1357 #endif
1358 if (!match.hit)
1359 {
1360 match.value = null;
1361 }
1362 return match;
1363 }
1364 public static Match OpCode(AssemblyLexer& lexer)
1365 {
1366 #if (DEBUG)
1367 Span debugSpan;
1368 bool writeToLog = lexer.Log() != null;
1369 if (writeToLog)
1370 {
1371 debugSpan = lexer.GetSpan();
1372 System.Lex.WriteBeginRuleToLog(lexer, u"OpCode");
1373 }
1374 #endif
1375 Match match(false);
1376 Match* parentMatch0 = &match;
1377 {
1378 Match match(false);
1379 Match* parentMatch1 = &match;
1380 {
1381 Match match(false);
1382 Match* parentMatch2 = &match;
1383 {
1384 long pos = lexer.GetPos();
1385 Match match(true);
1386 if (match.hit)
1387 {
1388 lexer.PushSpan();
1389 }
1390 *parentMatch2 = match;
1391 }
1392 *parentMatch1 = match;
1393 }
1394 if (match.hit)
1395 {
1396 Match match(false);
1397 Match* parentMatch3 = &match;
1398 {
1399 Match match(true);
1400 long save = lexer.GetPos();
1401 Match* parentMatch4 = &match;
1402 {
1403 Match match(false);
1404 Match* parentMatch5 = &match;
1405 {
1406 Match match(false);
1407 Match* parentMatch6 = &match;
1408 {
1409 long pos = lexer.GetPos();
1410 Match match(false);
1411 if (*lexer == DECIMAL_CONSTANT)
1412 {
1413 ++lexer;
1414 match.hit = true;
1415 }
1416 if (match.hit)
1417 {
1418 lexer.SetSpan(pos);
1419 }
1420 *parentMatch6 = match;
1421 }
1422 *parentMatch5 = match;
1423 }
1424 if (match.hit)
1425 {
1426 *parentMatch4 = match;
1427 }
1428 else
1429 {
1430 lexer.SetPos(save);
1431 }
1432 }
1433 *parentMatch3 = match;
1434 }
1435 *parentMatch1 = match;
1436 }
1437 *parentMatch0 = match;
1438 }
1439 if (match.hit)
1440 {
1441 Match match(false);
1442 Match* parentMatch7 = &match;
1443 {
1444 Match match(false);
1445 Match* parentMatch8 = &match;
1446 {
1447 long pos = lexer.GetPos();
1448 Match match(false);
1449 if (*lexer == SYMBOL)
1450 {
1451 ++lexer;
1452 match.hit = true;
1453 }
1454 if (match.hit)
1455 {
1456 lexer.SetSpan(pos);
1457 Span s = lexer.PopSpan();
1458 {
1459 #if (DEBUG)
1460 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"OpCode");
1461 #endif
1462 return Match(true, cmsx.assembly.MakeOpCode(s, lexer.GetMatch(s)));
1463 }
1464 }
1465 *parentMatch8 = match;
1466 }
1467 *parentMatch7 = match;
1468 }
1469 *parentMatch0 = match;
1470 }
1471 #if (DEBUG)
1472 if (writeToLog)
1473 {
1474 if (match.hit)
1475 {
1476 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"OpCode");
1477 }
1478 else
1479 {
1480 System.Lex.WriteFailureToLog(lexer, u"OpCode");
1481 }
1482 }
1483 #endif
1484 if (!match.hit)
1485 {
1486 match.value = null;
1487 }
1488 return match;
1489 }
1490 public static Match Operands(AssemblyLexer& lexer)
1491 {
1492 #if (DEBUG)
1493 Span debugSpan;
1494 bool writeToLog = lexer.Log() != null;
1495 if (writeToLog)
1496 {
1497 debugSpan = lexer.GetSpan();
1498 System.Lex.WriteBeginRuleToLog(lexer, u"Operands");
1499 }
1500 #endif
1501 UniquePtr<cmsx.assembly.OperandList> operandList;
1502 UniquePtr<cmsx.assembly.Node> left;
1503 UniquePtr<cmsx.assembly.Node> right;
1504 Match match(false);
1505 Match* parentMatch0 = &match;
1506 {
1507 long pos = lexer.GetPos();
1508 Match match(false);
1509 Match* parentMatch1 = &match;
1510 {
1511 Match match(false);
1512 Match* parentMatch2 = &match;
1513 {
1514 long save = lexer.GetPos();
1515 Match match(false);
1516 Match* parentMatch3 = &match;
1517 {
1518 Match match(false);
1519 Match* parentMatch4 = &match;
1520 {
1521 Match match(true);
1522 long save = lexer.GetPos();
1523 Match* parentMatch5 = &match;
1524 {
1525 Match match(false);
1526 if (*lexer == SPACE)
1527 {
1528 ++lexer;
1529 match.hit = true;
1530 }
1531 if (match.hit)
1532 {
1533 *parentMatch5 = match;
1534 }
1535 else
1536 {
1537 lexer.SetPos(save);
1538 }
1539 }
1540 *parentMatch4 = match;
1541 }
1542 if (match.hit)
1543 {
1544 Match match(false);
1545 Match* parentMatch6 = &match;
1546 {
1547 Match match(false);
1548 Match* parentMatch7 = &match;
1549 {
1550 long pos = lexer.GetPos();
1551 Span span = lexer.GetSpan();
1552 Match match = AssemblyParser.Expression(lexer);
1553 left.Reset(cast<cmsx.assembly.Node*>(match.value));
1554 if (match.hit)
1555 {
1556 operandList.Reset(new cmsx.assembly.OperandList(span, left.Release()));
1557 }
1558 *parentMatch7 = match;
1559 }
1560 *parentMatch6 = match;
1561 }
1562 *parentMatch4 = match;
1563 }
1564 *parentMatch3 = match;
1565 }
1566 if (match.hit)
1567 {
1568 Match match(false);
1569 Match* parentMatch8 = &match;
1570 {
1571 Match match(true);
1572 Match* parentMatch9 = &match;
1573 {
1574 while (true)
1575 {
1576 long save = lexer.GetPos();
1577 {
1578 Match match(false);
1579 Match* parentMatch10 = &match;
1580 {
1581 Match match(false);
1582 Match* parentMatch11 = &match;
1583 {
1584 Match match(false);
1585 if (*lexer == COMMA)
1586 {
1587 ++lexer;
1588 match.hit = true;
1589 }
1590 *parentMatch11 = match;
1591 }
1592 if (match.hit)
1593 {
1594 Match match(false);
1595 Match* parentMatch12 = &match;
1596 {
1597 Match match(false);
1598 Match* parentMatch13 = &match;
1599 {
1600 long pos = lexer.GetPos();
1601 Match match = AssemblyParser.Expression(lexer);
1602 right.Reset(cast<cmsx.assembly.Node*>(match.value));
1603 if (match.hit)
1604 {
1605 operandList->AddOperand(right.Release());
1606 }
1607 *parentMatch13 = match;
1608 }
1609 *parentMatch12 = match;
1610 }
1611 *parentMatch11 = match;
1612 }
1613 *parentMatch10 = match;
1614 }
1615 if (match.hit)
1616 {
1617 *parentMatch9 = match;
1618 }
1619 else
1620 {
1621 lexer.SetPos(save);
1622 break;
1623 }
1624 }
1625 }
1626 }
1627 *parentMatch8 = match;
1628 }
1629 *parentMatch3 = match;
1630 }
1631 *parentMatch2 = match;
1632 if (!match.hit)
1633 {
1634 Match match(false);
1635 Match* parentMatch14 = &match;
1636 lexer.SetPos(save);
1637 {
1638 Match match(false);
1639 Match* parentMatch15 = &match;
1640 {
1641 Match match(true);
1642 long save = lexer.GetPos();
1643 Match* parentMatch16 = &match;
1644 {
1645 Match match(false);
1646 if (*lexer == SPACE)
1647 {
1648 ++lexer;
1649 match.hit = true;
1650 }
1651 if (match.hit)
1652 {
1653 *parentMatch16 = match;
1654 }
1655 else
1656 {
1657 lexer.SetPos(save);
1658 }
1659 }
1660 *parentMatch15 = match;
1661 }
1662 if (match.hit)
1663 {
1664 Match match(false);
1665 Match* parentMatch17 = &match;
1666 {
1667 Match match(false);
1668 Match* parentMatch18 = &match;
1669 {
1670 long pos = lexer.GetPos();
1671 Span span = lexer.GetSpan();
1672 Match match(true);
1673 if (match.hit)
1674 {
1675 operandList.Reset(new cmsx.assembly.OperandList(span, new cmsx.assembly.DecimalConstant(span, 0u)));
1676 }
1677 *parentMatch18 = match;
1678 }
1679 *parentMatch17 = match;
1680 }
1681 *parentMatch15 = match;
1682 }
1683 *parentMatch14 = match;
1684 }
1685 *parentMatch2 = match;
1686 }
1687 }
1688 *parentMatch1 = match;
1689 }
1690 if (match.hit)
1691 {
1692 {
1693 #if (DEBUG)
1694 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Operands");
1695 #endif
1696 return Match(true, operandList.Release());
1697 }
1698 }
1699 *parentMatch0 = match;
1700 }
1701 #if (DEBUG)
1702 if (writeToLog)
1703 {
1704 if (match.hit)
1705 {
1706 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Operands");
1707 }
1708 else
1709 {
1710 System.Lex.WriteFailureToLog(lexer, u"Operands");
1711 }
1712 }
1713 #endif
1714 if (!match.hit)
1715 {
1716 match.value = null;
1717 }
1718 return match;
1719 }
1720 public static Match Expression(AssemblyLexer& lexer)
1721 {
1722 #if (DEBUG)
1723 Span debugSpan;
1724 bool writeToLog = lexer.Log() != null;
1725 if (writeToLog)
1726 {
1727 debugSpan = lexer.GetSpan();
1728 System.Lex.WriteBeginRuleToLog(lexer, u"Expression");
1729 }
1730 #endif
1731 UniquePtr<cmsx.assembly.Node> expr;
1732 UniquePtr<cmsx.assembly.Node> left;
1733 UniquePtr<Value<cmsx.assembly.Operator>> op;
1734 UniquePtr<cmsx.assembly.Node> right;
1735 Match match(false);
1736 Match* parentMatch0 = &match;
1737 {
1738 long pos = lexer.GetPos();
1739 Match match(false);
1740 Match* parentMatch1 = &match;
1741 {
1742 Match match(false);
1743 Match* parentMatch2 = &match;
1744 {
1745 Match match(false);
1746 Match* parentMatch3 = &match;
1747 {
1748 long pos = lexer.GetPos();
1749 Match match = AssemblyParser.Term(lexer);
1750 left.Reset(cast<cmsx.assembly.Node*>(match.value));
1751 if (match.hit)
1752 {
1753 expr.Reset(left.Release());
1754 }
1755 *parentMatch3 = match;
1756 }
1757 *parentMatch2 = match;
1758 }
1759 if (match.hit)
1760 {
1761 Match match(false);
1762 Match* parentMatch4 = &match;
1763 {
1764 Match match(true);
1765 Match* parentMatch5 = &match;
1766 {
1767 while (true)
1768 {
1769 long save = lexer.GetPos();
1770 {
1771 Match match(false);
1772 Match* parentMatch6 = &match;
1773 {
1774 Match match(false);
1775 Match* parentMatch7 = &match;
1776 {
1777 Match match = AssemblyParser.WeakOperator(lexer);
1778 op.Reset(cast<Value<cmsx.assembly.Operator>*>(match.value));
1779 *parentMatch7 = match;
1780 }
1781 if (match.hit)
1782 {
1783 Match match(false);
1784 Match* parentMatch8 = &match;
1785 {
1786 Match match(false);
1787 Match* parentMatch9 = &match;
1788 {
1789 long pos = lexer.GetPos();
1790 Span span = lexer.GetSpan();
1791 Match match = AssemblyParser.Term(lexer);
1792 right.Reset(cast<cmsx.assembly.Node*>(match.value));
1793 if (match.hit)
1794 {
1795 expr.Reset(new cmsx.assembly.BinaryExpression(span, expr.Release(), op->value, right.Release()));
1796 }
1797 *parentMatch9 = match;
1798 }
1799 *parentMatch8 = match;
1800 }
1801 *parentMatch7 = match;
1802 }
1803 *parentMatch6 = match;
1804 }
1805 if (match.hit)
1806 {
1807 *parentMatch5 = match;
1808 }
1809 else
1810 {
1811 lexer.SetPos(save);
1812 break;
1813 }
1814 }
1815 }
1816 }
1817 *parentMatch4 = match;
1818 }
1819 *parentMatch2 = match;
1820 }
1821 *parentMatch1 = match;
1822 }
1823 if (match.hit)
1824 {
1825 {
1826 #if (DEBUG)
1827 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Expression");
1828 #endif
1829 return Match(true, expr.Release());
1830 }
1831 }
1832 *parentMatch0 = match;
1833 }
1834 #if (DEBUG)
1835 if (writeToLog)
1836 {
1837 if (match.hit)
1838 {
1839 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Expression");
1840 }
1841 else
1842 {
1843 System.Lex.WriteFailureToLog(lexer, u"Expression");
1844 }
1845 }
1846 #endif
1847 if (!match.hit)
1848 {
1849 match.value = null;
1850 }
1851 return match;
1852 }
1853 public static Match WeakOperator(AssemblyLexer& lexer)
1854 {
1855 #if (DEBUG)
1856 Span debugSpan;
1857 bool writeToLog = lexer.Log() != null;
1858 if (writeToLog)
1859 {
1860 debugSpan = lexer.GetSpan();
1861 System.Lex.WriteBeginRuleToLog(lexer, u"WeakOperator");
1862 }
1863 #endif
1864 Match match(false);
1865 long pos = lexer.GetPos();
1866 Span span = lexer.GetSpan();
1867 switch (*lexer)
1868 {
1869 case PLUS:
1870 {
1871 ++lexer;
1872 {
1873 #if (DEBUG)
1874 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"WeakOperator");
1875 #endif
1876 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.add));
1877 }
1878 break;
1879 }
1880 case MINUS:
1881 {
1882 ++lexer;
1883 {
1884 #if (DEBUG)
1885 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"WeakOperator");
1886 #endif
1887 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.subtract));
1888 }
1889 break;
1890 }
1891 case BAR:
1892 {
1893 ++lexer;
1894 {
1895 #if (DEBUG)
1896 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"WeakOperator");
1897 #endif
1898 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.bitwiseOr));
1899 }
1900 break;
1901 }
1902 case CARET:
1903 {
1904 ++lexer;
1905 {
1906 #if (DEBUG)
1907 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"WeakOperator");
1908 #endif
1909 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.bitwiseXor));
1910 }
1911 break;
1912 }
1913 }
1914 #if (DEBUG)
1915 if (writeToLog)
1916 {
1917 if (match.hit)
1918 {
1919 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"WeakOperator");
1920 }
1921 else
1922 {
1923 System.Lex.WriteFailureToLog(lexer, u"WeakOperator");
1924 }
1925 }
1926 #endif
1927 if (!match.hit)
1928 {
1929 match.value = null;
1930 }
1931 return match;
1932 }
1933 public static Match Term(AssemblyLexer& lexer)
1934 {
1935 #if (DEBUG)
1936 Span debugSpan;
1937 bool writeToLog = lexer.Log() != null;
1938 if (writeToLog)
1939 {
1940 debugSpan = lexer.GetSpan();
1941 System.Lex.WriteBeginRuleToLog(lexer, u"Term");
1942 }
1943 #endif
1944 UniquePtr<cmsx.assembly.Node> expr;
1945 UniquePtr<cmsx.assembly.Node> left;
1946 UniquePtr<Value<cmsx.assembly.Operator>> op;
1947 UniquePtr<cmsx.assembly.Node> right;
1948 Match match(false);
1949 Match* parentMatch0 = &match;
1950 {
1951 long pos = lexer.GetPos();
1952 Match match(false);
1953 Match* parentMatch1 = &match;
1954 {
1955 Match match(false);
1956 Match* parentMatch2 = &match;
1957 {
1958 Match match(false);
1959 Match* parentMatch3 = &match;
1960 {
1961 long pos = lexer.GetPos();
1962 Match match = AssemblyParser.PrimaryExpression(lexer);
1963 left.Reset(cast<cmsx.assembly.Node*>(match.value));
1964 if (match.hit)
1965 {
1966 expr.Reset(left.Release());
1967 }
1968 *parentMatch3 = match;
1969 }
1970 *parentMatch2 = match;
1971 }
1972 if (match.hit)
1973 {
1974 Match match(false);
1975 Match* parentMatch4 = &match;
1976 {
1977 Match match(true);
1978 Match* parentMatch5 = &match;
1979 {
1980 while (true)
1981 {
1982 long save = lexer.GetPos();
1983 {
1984 Match match(false);
1985 Match* parentMatch6 = &match;
1986 {
1987 Match match(false);
1988 Match* parentMatch7 = &match;
1989 {
1990 Match match = AssemblyParser.StrongOperator(lexer);
1991 op.Reset(cast<Value<cmsx.assembly.Operator>*>(match.value));
1992 *parentMatch7 = match;
1993 }
1994 if (match.hit)
1995 {
1996 Match match(false);
1997 Match* parentMatch8 = &match;
1998 {
1999 Match match(false);
2000 Match* parentMatch9 = &match;
2001 {
2002 long pos = lexer.GetPos();
2003 Span span = lexer.GetSpan();
2004 Match match = AssemblyParser.PrimaryExpression(lexer);
2005 right.Reset(cast<cmsx.assembly.Node*>(match.value));
2006 if (match.hit)
2007 {
2008 expr.Reset(new cmsx.assembly.BinaryExpression(span, expr.Release(), op->value, right.Release()));
2009 }
2010 *parentMatch9 = match;
2011 }
2012 *parentMatch8 = match;
2013 }
2014 *parentMatch7 = match;
2015 }
2016 *parentMatch6 = match;
2017 }
2018 if (match.hit)
2019 {
2020 *parentMatch5 = match;
2021 }
2022 else
2023 {
2024 lexer.SetPos(save);
2025 break;
2026 }
2027 }
2028 }
2029 }
2030 *parentMatch4 = match;
2031 }
2032 *parentMatch2 = match;
2033 }
2034 *parentMatch1 = match;
2035 }
2036 if (match.hit)
2037 {
2038 {
2039 #if (DEBUG)
2040 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Term");
2041 #endif
2042 return Match(true, expr.Release());
2043 }
2044 }
2045 *parentMatch0 = match;
2046 }
2047 #if (DEBUG)
2048 if (writeToLog)
2049 {
2050 if (match.hit)
2051 {
2052 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Term");
2053 }
2054 else
2055 {
2056 System.Lex.WriteFailureToLog(lexer, u"Term");
2057 }
2058 }
2059 #endif
2060 if (!match.hit)
2061 {
2062 match.value = null;
2063 }
2064 return match;
2065 }
2066 public static Match StrongOperator(AssemblyLexer& lexer)
2067 {
2068 #if (DEBUG)
2069 Span debugSpan;
2070 bool writeToLog = lexer.Log() != null;
2071 if (writeToLog)
2072 {
2073 debugSpan = lexer.GetSpan();
2074 System.Lex.WriteBeginRuleToLog(lexer, u"StrongOperator");
2075 }
2076 #endif
2077 Match match(false);
2078 long pos = lexer.GetPos();
2079 Span span = lexer.GetSpan();
2080 switch (*lexer)
2081 {
2082 case AST:
2083 {
2084 ++lexer;
2085 {
2086 #if (DEBUG)
2087 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2088 #endif
2089 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.multiply));
2090 }
2091 break;
2092 }
2093 case SLASH:
2094 {
2095 ++lexer;
2096 {
2097 #if (DEBUG)
2098 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2099 #endif
2100 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.divide));
2101 }
2102 break;
2103 }
2104 case SLASHSLASH:
2105 {
2106 ++lexer;
2107 {
2108 #if (DEBUG)
2109 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2110 #endif
2111 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.fractionalDivide));
2112 }
2113 break;
2114 }
2115 case PERCENT:
2116 {
2117 ++lexer;
2118 {
2119 #if (DEBUG)
2120 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2121 #endif
2122 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.modulus));
2123 }
2124 break;
2125 }
2126 case SHIFT_LEFT:
2127 {
2128 ++lexer;
2129 {
2130 #if (DEBUG)
2131 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2132 #endif
2133 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.shiftLeft));
2134 }
2135 break;
2136 }
2137 case SHIFT_RIGHT:
2138 {
2139 ++lexer;
2140 {
2141 #if (DEBUG)
2142 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2143 #endif
2144 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.shiftRight));
2145 }
2146 break;
2147 }
2148 case AMP:
2149 {
2150 ++lexer;
2151 {
2152 #if (DEBUG)
2153 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2154 #endif
2155 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.bitwiseAnd));
2156 }
2157 break;
2158 }
2159 }
2160 #if (DEBUG)
2161 if (writeToLog)
2162 {
2163 if (match.hit)
2164 {
2165 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"StrongOperator");
2166 }
2167 else
2168 {
2169 System.Lex.WriteFailureToLog(lexer, u"StrongOperator");
2170 }
2171 }
2172 #endif
2173 if (!match.hit)
2174 {
2175 match.value = null;
2176 }
2177 return match;
2178 }
2179 public static Match PrimaryExpression(AssemblyLexer& lexer)
2180 {
2181 #if (DEBUG)
2182 Span debugSpan;
2183 bool writeToLog = lexer.Log() != null;
2184 if (writeToLog)
2185 {
2186 debugSpan = lexer.GetSpan();
2187 System.Lex.WriteBeginRuleToLog(lexer, u"PrimaryExpression");
2188 }
2189 #endif
2190 Span s;
2191 UniquePtr<cmsx.assembly.Node> localSymbol;
2192 UniquePtr<cmsx.assembly.Node> constant;
2193 UniquePtr<cmsx.assembly.Node> symbol;
2194 UniquePtr<cmsx.assembly.Node> at;
2195 UniquePtr<cmsx.assembly.Node> expr;
2196 UniquePtr<Value<cmsx.assembly.Operator>> op;
2197 UniquePtr<cmsx.assembly.Node> primaryExpr;
2198 Match match(false);
2199 Match* parentMatch0 = &match;
2200 {
2201 long save = lexer.GetPos();
2202 Match match(false);
2203 Match* parentMatch1 = &match;
2204 {
2205 long save = lexer.GetPos();
2206 Match match(false);
2207 Match* parentMatch2 = &match;
2208 {
2209 long save = lexer.GetPos();
2210 Match match(false);
2211 Match* parentMatch3 = &match;
2212 {
2213 long save = lexer.GetPos();
2214 Match match(false);
2215 Match* parentMatch4 = &match;
2216 {
2217 long save = lexer.GetPos();
2218 Match match(false);
2219 Match* parentMatch5 = &match;
2220 {
2221 long pos = lexer.GetPos();
2222 Match match = AssemblyParser.LocalSymbol(lexer);
2223 localSymbol.Reset(cast<cmsx.assembly.Node*>(match.value));
2224 if (match.hit)
2225 {
2226 {
2227 #if (DEBUG)
2228 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"PrimaryExpression");
2229 #endif
2230 return Match(true, localSymbol.Release());
2231 }
2232 }
2233 *parentMatch5 = match;
2234 }
2235 *parentMatch4 = match;
2236 if (!match.hit)
2237 {
2238 Match match(false);
2239 Match* parentMatch6 = &match;
2240 lexer.SetPos(save);
2241 {
2242 Match match(false);
2243 Match* parentMatch7 = &match;
2244 {
2245 long pos = lexer.GetPos();
2246 Match match = AssemblyParser.Constant(lexer);
2247 constant.Reset(cast<cmsx.assembly.Node*>(match.value));
2248 if (match.hit)
2249 {
2250 {
2251 #if (DEBUG)
2252 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"PrimaryExpression");
2253 #endif
2254 return Match(true, constant.Release());
2255 }
2256 }
2257 *parentMatch7 = match;
2258 }
2259 *parentMatch6 = match;
2260 }
2261 *parentMatch4 = match;
2262 }
2263 }
2264 *parentMatch3 = match;
2265 if (!match.hit)
2266 {
2267 Match match(false);
2268 Match* parentMatch8 = &match;
2269 lexer.SetPos(save);
2270 {
2271 Match match(false);
2272 Match* parentMatch9 = &match;
2273 {
2274 long pos = lexer.GetPos();
2275 Match match = AssemblyParser.Symbol(lexer);
2276 symbol.Reset(cast<cmsx.assembly.Node*>(match.value));
2277 if (match.hit)
2278 {
2279 {
2280 #if (DEBUG)
2281 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"PrimaryExpression");
2282 #endif
2283 return Match(true, symbol.Release());
2284 }
2285 }
2286 *parentMatch9 = match;
2287 }
2288 *parentMatch8 = match;
2289 }
2290 *parentMatch3 = match;
2291 }
2292 }
2293 *parentMatch2 = match;
2294 if (!match.hit)
2295 {
2296 Match match(false);
2297 Match* parentMatch10 = &match;
2298 lexer.SetPos(save);
2299 {
2300 Match match(false);
2301 Match* parentMatch11 = &match;
2302 {
2303 long pos = lexer.GetPos();
2304 Match match = AssemblyParser.At(lexer);
2305 at.Reset(cast<cmsx.assembly.Node*>(match.value));
2306 if (match.hit)
2307 {
2308 {
2309 #if (DEBUG)
2310 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"PrimaryExpression");
2311 #endif
2312 return Match(true, at.Release());
2313 }
2314 }
2315 *parentMatch11 = match;
2316 }
2317 *parentMatch10 = match;
2318 }
2319 *parentMatch2 = match;
2320 }
2321 }
2322 *parentMatch1 = match;
2323 if (!match.hit)
2324 {
2325 Match match(false);
2326 Match* parentMatch12 = &match;
2327 lexer.SetPos(save);
2328 {
2329 Match match(false);
2330 Match* parentMatch13 = &match;
2331 {
2332 Match match(false);
2333 Match* parentMatch14 = &match;
2334 {
2335 Match match(false);
2336 Match* parentMatch15 = &match;
2337 {
2338 long pos = lexer.GetPos();
2339 Span span = lexer.GetSpan();
2340 Match match(false);
2341 if (*lexer == LPAREN)
2342 {
2343 ++lexer;
2344 match.hit = true;
2345 }
2346 if (match.hit)
2347 {
2348 s = span;
2349 }
2350 *parentMatch15 = match;
2351 }
2352 *parentMatch14 = match;
2353 }
2354 if (match.hit)
2355 {
2356 Match match(false);
2357 Match* parentMatch16 = &match;
2358 {
2359 Match match = AssemblyParser.Expression(lexer);
2360 expr.Reset(cast<cmsx.assembly.Node*>(match.value));
2361 *parentMatch16 = match;
2362 }
2363 *parentMatch14 = match;
2364 }
2365 *parentMatch13 = match;
2366 }
2367 if (match.hit)
2368 {
2369 Match match(false);
2370 Match* parentMatch17 = &match;
2371 {
2372 Match match(false);
2373 Match* parentMatch18 = &match;
2374 {
2375 long pos = lexer.GetPos();
2376 Span span = lexer.GetSpan();
2377 Match match(false);
2378 if (*lexer == RPAREN)
2379 {
2380 ++lexer;
2381 match.hit = true;
2382 }
2383 if (match.hit)
2384 {
2385 s.end = span.end;
2386 {
2387 #if (DEBUG)
2388 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"PrimaryExpression");
2389 #endif
2390 return Match(true, new cmsx.assembly.ParenthesizedExpression(s, expr.Release()));
2391 }
2392 }
2393 *parentMatch18 = match;
2394 }
2395 *parentMatch17 = match;
2396 }
2397 *parentMatch13 = match;
2398 }
2399 *parentMatch12 = match;
2400 }
2401 *parentMatch1 = match;
2402 }
2403 }
2404 *parentMatch0 = match;
2405 if (!match.hit)
2406 {
2407 Match match(false);
2408 Match* parentMatch19 = &match;
2409 lexer.SetPos(save);
2410 {
2411 Match match(false);
2412 Match* parentMatch20 = &match;
2413 {
2414 Match match(false);
2415 Match* parentMatch21 = &match;
2416 {
2417 long pos = lexer.GetPos();
2418 Span span = lexer.GetSpan();
2419 Match match = AssemblyParser.UnaryOperator(lexer);
2420 op.Reset(cast<Value<cmsx.assembly.Operator>*>(match.value));
2421 if (match.hit)
2422 {
2423 s = span;
2424 }
2425 *parentMatch21 = match;
2426 }
2427 *parentMatch20 = match;
2428 }
2429 if (match.hit)
2430 {
2431 Match match(false);
2432 Match* parentMatch22 = &match;
2433 {
2434 Match match(false);
2435 Match* parentMatch23 = &match;
2436 {
2437 long pos = lexer.GetPos();
2438 Span span = lexer.GetSpan();
2439 Match match = AssemblyParser.PrimaryExpression(lexer);
2440 primaryExpr.Reset(cast<cmsx.assembly.Node*>(match.value));
2441 if (match.hit)
2442 {
2443 s.end = span.end;
2444 {
2445 #if (DEBUG)
2446 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"PrimaryExpression");
2447 #endif
2448 return Match(true, new cmsx.assembly.UnaryExpression(s, op->value, primaryExpr.Release()));
2449 }
2450 }
2451 *parentMatch23 = match;
2452 }
2453 *parentMatch22 = match;
2454 }
2455 *parentMatch20 = match;
2456 }
2457 *parentMatch19 = match;
2458 }
2459 *parentMatch0 = match;
2460 }
2461 }
2462 #if (DEBUG)
2463 if (writeToLog)
2464 {
2465 if (match.hit)
2466 {
2467 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"PrimaryExpression");
2468 }
2469 else
2470 {
2471 System.Lex.WriteFailureToLog(lexer, u"PrimaryExpression");
2472 }
2473 }
2474 #endif
2475 if (!match.hit)
2476 {
2477 match.value = null;
2478 }
2479 return match;
2480 }
2481 public static Match UnaryOperator(AssemblyLexer& lexer)
2482 {
2483 #if (DEBUG)
2484 Span debugSpan;
2485 bool writeToLog = lexer.Log() != null;
2486 if (writeToLog)
2487 {
2488 debugSpan = lexer.GetSpan();
2489 System.Lex.WriteBeginRuleToLog(lexer, u"UnaryOperator");
2490 }
2491 #endif
2492 Match match(false);
2493 long pos = lexer.GetPos();
2494 Span span = lexer.GetSpan();
2495 switch (*lexer)
2496 {
2497 case PLUS:
2498 {
2499 ++lexer;
2500 {
2501 #if (DEBUG)
2502 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"UnaryOperator");
2503 #endif
2504 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.unaryPlus));
2505 }
2506 break;
2507 }
2508 case MINUS:
2509 {
2510 ++lexer;
2511 {
2512 #if (DEBUG)
2513 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"UnaryOperator");
2514 #endif
2515 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.unaryMinus));
2516 }
2517 break;
2518 }
2519 case TILDE:
2520 {
2521 ++lexer;
2522 {
2523 #if (DEBUG)
2524 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"UnaryOperator");
2525 #endif
2526 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.complement));
2527 }
2528 break;
2529 }
2530 case DOLLAR:
2531 {
2532 ++lexer;
2533 {
2534 #if (DEBUG)
2535 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"UnaryOperator");
2536 #endif
2537 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.register));
2538 }
2539 break;
2540 }
2541 case AMP:
2542 {
2543 ++lexer;
2544 {
2545 #if (DEBUG)
2546 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"UnaryOperator");
2547 #endif
2548 return Match(true, new Value<cmsx.assembly.Operator>(cmsx.assembly.Operator.serial));
2549 }
2550 break;
2551 }
2552 }
2553 #if (DEBUG)
2554 if (writeToLog)
2555 {
2556 if (match.hit)
2557 {
2558 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"UnaryOperator");
2559 }
2560 else
2561 {
2562 System.Lex.WriteFailureToLog(lexer, u"UnaryOperator");
2563 }
2564 }
2565 #endif
2566 if (!match.hit)
2567 {
2568 match.value = null;
2569 }
2570 return match;
2571 }
2572 public static Match LocalSymbol(AssemblyLexer& lexer)
2573 {
2574 #if (DEBUG)
2575 Span debugSpan;
2576 bool writeToLog = lexer.Log() != null;
2577 if (writeToLog)
2578 {
2579 debugSpan = lexer.GetSpan();
2580 System.Lex.WriteBeginRuleToLog(lexer, u"LocalSymbol");
2581 }
2582 #endif
2583 Match match(false);
2584 Match* parentMatch0 = &match;
2585 {
2586 long pos = lexer.GetPos();
2587 Span span = lexer.GetSpan();
2588 Match match(false);
2589 if (*lexer == LOCAL_SYMBOL)
2590 {
2591 ++lexer;
2592 match.hit = true;
2593 }
2594 if (match.hit)
2595 {
2596 {
2597 #if (DEBUG)
2598 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"LocalSymbol");
2599 #endif
2600 return Match(true, cmsx.assembly.MakeLocalSymbolNode(span, lexer.GetToken(pos)));
2601 }
2602 }
2603 *parentMatch0 = match;
2604 }
2605 #if (DEBUG)
2606 if (writeToLog)
2607 {
2608 if (match.hit)
2609 {
2610 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"LocalSymbol");
2611 }
2612 else
2613 {
2614 System.Lex.WriteFailureToLog(lexer, u"LocalSymbol");
2615 }
2616 }
2617 #endif
2618 if (!match.hit)
2619 {
2620 match.value = null;
2621 }
2622 return match;
2623 }
2624 public static Match Constant(AssemblyLexer& lexer)
2625 {
2626 #if (DEBUG)
2627 Span debugSpan;
2628 bool writeToLog = lexer.Log() != null;
2629 if (writeToLog)
2630 {
2631 debugSpan = lexer.GetSpan();
2632 System.Lex.WriteBeginRuleToLog(lexer, u"Constant");
2633 }
2634 #endif
2635 Match match(false);
2636 long pos = lexer.GetPos();
2637 Span span = lexer.GetSpan();
2638 switch (*lexer)
2639 {
2640 case DECIMAL_CONSTANT:
2641 {
2642 ++lexer;
2643 {
2644 #if (DEBUG)
2645 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Constant");
2646 #endif
2647 return Match(true, new cmsx.assembly.DecimalConstant(span, ParseULong(ToUtf8(lexer.GetMatch(span)))));
2648 }
2649 break;
2650 }
2651 case HEX_CONSTANT:
2652 {
2653 ++lexer;
2654 {
2655 #if (DEBUG)
2656 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Constant");
2657 #endif
2658 return Match(true, cmsx.assembly.MakeHexConstant(span, lexer.GetToken(pos)));
2659 }
2660 break;
2661 }
2662 case CHAR_CONSTANT:
2663 {
2664 ++lexer;
2665 {
2666 #if (DEBUG)
2667 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Constant");
2668 #endif
2669 return Match(true, cmsx.assembly.MakeCharConstant(span, lexer.GetToken(pos)));
2670 }
2671 break;
2672 }
2673 case STRING_CONSTANT:
2674 {
2675 ++lexer;
2676 {
2677 #if (DEBUG)
2678 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Constant");
2679 #endif
2680 return Match(true, cmsx.assembly.MakeStringConstant(span, lexer.GetToken(pos)));
2681 }
2682 break;
2683 }
2684 case CLSID_CONSTANT:
2685 {
2686 ++lexer;
2687 {
2688 #if (DEBUG)
2689 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Constant");
2690 #endif
2691 return Match(true, cmsx.assembly.MakeClsIdConstant(span, lexer.GetToken(pos)));
2692 }
2693 break;
2694 }
2695 }
2696 #if (DEBUG)
2697 if (writeToLog)
2698 {
2699 if (match.hit)
2700 {
2701 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Constant");
2702 }
2703 else
2704 {
2705 System.Lex.WriteFailureToLog(lexer, u"Constant");
2706 }
2707 }
2708 #endif
2709 if (!match.hit)
2710 {
2711 match.value = null;
2712 }
2713 return match;
2714 }
2715 public static Match Symbol(AssemblyLexer& lexer)
2716 {
2717 #if (DEBUG)
2718 Span debugSpan;
2719 bool writeToLog = lexer.Log() != null;
2720 if (writeToLog)
2721 {
2722 debugSpan = lexer.GetSpan();
2723 System.Lex.WriteBeginRuleToLog(lexer, u"Symbol");
2724 }
2725 #endif
2726 Match match(false);
2727 Match* parentMatch0 = &match;
2728 {
2729 long pos = lexer.GetPos();
2730 Span span = lexer.GetSpan();
2731 Match match(false);
2732 if (*lexer == SYMBOL)
2733 {
2734 ++lexer;
2735 match.hit = true;
2736 }
2737 if (match.hit)
2738 {
2739 {
2740 #if (DEBUG)
2741 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Symbol");
2742 #endif
2743 return Match(true, cmsx.assembly.MakeSymbolNode(span, lexer.GetToken(pos)));
2744 }
2745 }
2746 *parentMatch0 = match;
2747 }
2748 #if (DEBUG)
2749 if (writeToLog)
2750 {
2751 if (match.hit)
2752 {
2753 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Symbol");
2754 }
2755 else
2756 {
2757 System.Lex.WriteFailureToLog(lexer, u"Symbol");
2758 }
2759 }
2760 #endif
2761 if (!match.hit)
2762 {
2763 match.value = null;
2764 }
2765 return match;
2766 }
2767 public static Match At(AssemblyLexer& lexer)
2768 {
2769 #if (DEBUG)
2770 Span debugSpan;
2771 bool writeToLog = lexer.Log() != null;
2772 if (writeToLog)
2773 {
2774 debugSpan = lexer.GetSpan();
2775 System.Lex.WriteBeginRuleToLog(lexer, u"At");
2776 }
2777 #endif
2778 Match match(false);
2779 Match* parentMatch0 = &match;
2780 {
2781 long pos = lexer.GetPos();
2782 Span span = lexer.GetSpan();
2783 Match match(false);
2784 if (*lexer == AT)
2785 {
2786 ++lexer;
2787 match.hit = true;
2788 }
2789 if (match.hit)
2790 {
2791 {
2792 #if (DEBUG)
2793 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"At");
2794 #endif
2795 return Match(true, new cmsx.assembly.At(span));
2796 }
2797 }
2798 *parentMatch0 = match;
2799 }
2800 #if (DEBUG)
2801 if (writeToLog)
2802 {
2803 if (match.hit)
2804 {
2805 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"At");
2806 }
2807 else
2808 {
2809 System.Lex.WriteFailureToLog(lexer, u"At");
2810 }
2811 }
2812 #endif
2813 if (!match.hit)
2814 {
2815 match.value = null;
2816 }
2817 return match;
2818 }
2819 }