1 #include "PatchFileParser.hpp"
2 #include <soulng/util/Unicode.hpp>
3 #include <soulng/lexer/TrivialLexer.hpp>
4 #include <soulng/parser/Range.hpp>
5
6
7
8 static const soulng::parser::Range s0[] = {{58, 58} {13, 13} {10, 10}};
9
10 static const soulng::parser::Range s1[] = {{58, 58} {13, 13} {10, 10}};
11
12 static const soulng::parser::Range s2[] = {{48, 57}};
13
14 static const soulng::parser::Range s3[] = {{48, 57}};
15
16 static const soulng::parser::Range s4[] = {{47, 47} {13, 13} {10, 10}};
17
18 static const soulng::parser::Range s5[] = {{47, 47} {13, 13} {10, 10}};
19
20 static const int s6[] = {13, 10};
21
22 using namespace soulng::unicode;
23 using namespace soulng::lexer;
24
25 std::std::unique_ptr<cpp2cm::PatchFile>PatchFileParser::Parse(TrivialLexer&lexer)
26 {
27 std::unique_ptr<cpp2cm::PatchFile> value;
28 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
29
30
31
32
33
34 #endif // SOULNG_PARSER_DEBUG_SUPPORT
35 ++lexer;
36 soulng::lexer::Span span = lexer.GetSpan();
37 soulng::parser::Match match = PatchFileParser::PatchFile(lexer);
38 value.reset(static_cast<cpp2cm::PatchFile*>(match.value));
39 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
40
41
42
43
44
45 #endif // SOULNG_PARSER_DEBUG_SUPPORT
46 if (match.hit)
47 {
48 if (*lexer == soulng::lexer::END_TOKEN)
49 {
50 return value;
51 }
52 else
53 {
54 lexer.ThrowExpectationFailure(lexer.GetSpan(), ToUtf32(soulng::lexer::GetEndTokenInfo()));
55 }
56 }
57 else
58 {
59 lexer.ThrowExpectationFailure(span, U"PatchFile");
60 }
61 return value;
62 }
63
64 soulng::parser::Match PatchFileParser::PatchFile(TrivialLexer& lexer)
65 {
66 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
67
68
69
70
71
72
73
74 #endif // SOULNG_PARSER_DEBUG_SUPPORT
75 std::unique_ptr<cpp2cm::PatchFile> patchFile = std::unique_ptr<cpp2cm::PatchFile>();
76 std::unique_ptr<cpp2cm::Patch> patch;
77 soulng::parser::Match match(false);
78 soulng::parser::Match* parentMatch0 = &match;
79 {
80 int64_t pos = lexer.GetPos();
81 soulng::parser::Match match(false);
82 soulng::parser::Match* parentMatch1 = &match;
83 {
84 soulng::parser::Match match(false);
85 soulng::parser::Match* parentMatch2 = &match;
86 {
87 soulng::parser::Match match(false);
88 soulng::parser::Match* parentMatch3 = &match;
89 {
90 soulng::parser::Match match(false);
91 soulng::parser::Match* parentMatch4 = &match;
92 {
93 int64_t pos = lexer.GetPos();
94 soulng::parser::Match match(true);
95 if (match.hit)
96 {
97 patchFile.reset(new cpp2cm::PatchFile(lexer.FileName()));
98 }
99 *parentMatch4 = match;
100 }
101 *parentMatch3 = match;
102 }
103 if (match.hit)
104 {
105 soulng::parser::Match match(false);
106 soulng::parser::Match* parentMatch5 = &match;
107 {
108 soulng::parser::Match match(false);
109 soulng::parser::Match* parentMatch6 = &match;
110 {
111 soulng::parser::Match match(false);
112 soulng::parser::Match* parentMatch7 = &match;
113 {
114 soulng::parser::Match match(false);
115 soulng::parser::Match* parentMatch8 = &match;
116 {
117 int64_t pos = lexer.GetPos();
118 soulng::parser::Match match = PatchFileParser::PatchLine(lexer);
119 patch.reset(static_cast<cpp2cm::Patch*>(match.value));
120 if (match.hit)
121 {
122 patchFile->AddPatch(patch.release());
123 }
124 *parentMatch8 = match;
125 }
126 *parentMatch7 = match;
127 }
128 *parentMatch6 = match;
129 }
130 if (match.hit)
131 {
132 soulng::parser::Match match(true);
133 soulng::parser::Match* parentMatch9 = &match;
134 while (true)
135 {
136 int64_t save = lexer.GetPos();
137 {
138 soulng::parser::Match match(false);
139 soulng::parser::Match* parentMatch10 = &match;
140 {
141 soulng::parser::Match match(false);
142 soulng::parser::Match* parentMatch11 = &match;
143 {
144 int64_t pos = lexer.GetPos();
145 soulng::parser::Match match = PatchFileParser::PatchLine(lexer);
146 patch.reset(static_cast<cpp2cm::Patch*>(match.value));
147 if (match.hit)
148 {
149 patchFile->AddPatch(patch.release());
150 }
151 *parentMatch11 = match;
152 }
153 *parentMatch10 = match;
154 }
155 if (match.hit)
156 {
157 *parentMatch9 = match;
158 }
159 else
160 {
161 lexer.SetPos(save);
162 break;
163 }
164 }
165 }
166 }
167 *parentMatch5 = match;
168 }
169 *parentMatch3 = match;
170 }
171 *parentMatch2 = match;
172 }
173 if (match.hit)
174 {
175 soulng::parser::Match match(false);
176 soulng::parser::Match* parentMatch12 = &match;
177 {
178 soulng::parser::Match match(true);
179 soulng::parser::Match* parentMatch13 = &match;
180 {
181 while (true)
182 {
183 int64_t save = lexer.GetPos();
184 {
185 soulng::parser::Match match = PatchFileParser::Newline(lexer);
186 if (match.hit)
187 {
188 *parentMatch13 = match;
189 }
190 else
191 {
192 lexer.SetPos(save);
193 break;
194 }
195 }
196 }
197 }
198 *parentMatch12 = match;
199 }
200 *parentMatch2 = match;
201 }
202 *parentMatch1 = match;
203 }
204 if (match.hit)
205 {
206 {
207 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
208
209 #endif // SOULNG_PARSER_DEBUG_SUPPORT
210 return soulng::parser::Match(true, patchFile.release());
211 }
212 }
213 *parentMatch0 = match;
214 }
215 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
216
217
218
219
220
221 #endif // SOULNG_PARSER_DEBUG_SUPPORT
222 if (!match.hit)
223 {
224 match.value = nullptr;
225 }
226 return match;
227 }
228
229 soulng::parser::Match PatchFileParser::PatchLine(TrivialLexer& lexer)
230 {
231 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
232
233
234
235
236
237
238
239 #endif // SOULNG_PARSER_DEBUG_SUPPORT
240 std::unique_ptr<cpp2cm::Patch> patch = std::unique_ptr<cpp2cm::Patch>();
241 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>filename;
242 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>lineNumber;
243 std::unique_ptr<cpp2cm::Patch> p;
244 soulng::parser::Match match(false);
245 soulng::parser::Match* parentMatch0 = &match;
246 {
247 int64_t pos = lexer.GetPos();
248 soulng::parser::Match match(false);
249 soulng::parser::Match* parentMatch1 = &match;
250 {
251 soulng::parser::Match match(false);
252 soulng::parser::Match* parentMatch2 = &match;
253 {
254 soulng::parser::Match match(false);
255 soulng::parser::Match* parentMatch3 = &match;
256 {
257 soulng::parser::Match match(false);
258 soulng::parser::Match* parentMatch4 = &match;
259 {
260 soulng::parser::Match match(false);
261 soulng::parser::Match* parentMatch5 = &match;
262 {
263 soulng::parser::Match match(false);
264 soulng::parser::Match* parentMatch6 = &match;
265 {
266 soulng::parser::Match match = PatchFileParser::FileName(lexer);
267 filename.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
268 *parentMatch6 = match;
269 }
270 if (match.hit)
271 {
272 soulng::parser::Match match(false);
273 soulng::parser::Match* parentMatch7 = &match;
274 {
275 soulng::parser::Match match(false);
276 if (*lexer == 58)
277 {
278 ++lexer;
279 match.hit = true;
280 }
281 *parentMatch7 = match;
282 }
283 *parentMatch6 = match;
284 }
285 *parentMatch5 = match;
286 }
287 if (match.hit)
288 {
289 soulng::parser::Match match(false);
290 soulng::parser::Match* parentMatch8 = &match;
291 {
292 soulng::parser::Match match = PatchFileParser::LineNumber(lexer);
293 lineNumber.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
294 *parentMatch8 = match;
295 }
296 *parentMatch5 = match;
297 }
298 *parentMatch4 = match;
299 }
300 if (match.hit)
301 {
302 soulng::parser::Match match(false);
303 soulng::parser::Match* parentMatch9 = &match;
304 {
305 soulng::parser::Match match(false);
306 if (*lexer == 58)
307 {
308 ++lexer;
309 match.hit = true;
310 }
311 *parentMatch9 = match;
312 }
313 *parentMatch4 = match;
314 }
315 *parentMatch3 = match;
316 }
317 if (match.hit)
318 {
319 soulng::parser::Match match(false);
320 soulng::parser::Match* parentMatch10 = &match;
321 {
322 soulng::parser::Match match(false);
323 soulng::parser::Match* parentMatch11 = &match;
324 {
325 int64_t pos = lexer.GetPos();
326 soulng::parser::Match match = PatchFileParser::Patch(lexer);
327 p.reset(static_cast<cpp2cm::Patch*>(match.value));
328 if (match.hit)
329 {
330 patch.reset(p.release());
331 }
332 *parentMatch11 = match;
333 }
334 *parentMatch10 = match;
335 }
336 *parentMatch3 = match;
337 }
338 *parentMatch2 = match;
339 }
340 if (match.hit)
341 {
342 soulng::parser::Match match(false);
343 soulng::parser::Match* parentMatch12 = &match;
344 {
345 soulng::parser::Match match = PatchFileParser::Newline(lexer);
346 *parentMatch12 = match;
347 }
348 *parentMatch2 = match;
349 }
350 *parentMatch1 = match;
351 }
352 if (match.hit)
353 {
354 patch->SetFileName(filename->value);
355 patch->SetLineNumber(lineNumber->value);
356 {
357 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
358
359 #endif // SOULNG_PARSER_DEBUG_SUPPORT
360 return soulng::parser::Match(true, patch.release());
361 }
362 }
363 *parentMatch0 = match;
364 }
365 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
366
367
368
369
370
371 #endif // SOULNG_PARSER_DEBUG_SUPPORT
372 if (!match.hit)
373 {
374 match.value = nullptr;
375 }
376 return match;
377 }
378
379 soulng::parser::Match PatchFileParser::FileName(TrivialLexer& lexer)
380 {
381 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
382
383
384
385
386
387
388
389 #endif // SOULNG_PARSER_DEBUG_SUPPORT
390 Span s = Span();
391 soulng::parser::Match match(false);
392 soulng::parser::Match* parentMatch0 = &match;
393 {
394 int64_t pos = lexer.GetPos();
395 soulng::parser::Match match(false);
396 soulng::parser::Match* parentMatch1 = &match;
397 {
398 soulng::parser::Match match(false);
399 soulng::parser::Match* parentMatch2 = &match;
400 {
401 soulng::parser::Match match(false);
402 soulng::parser::Match* parentMatch3 = &match;
403 {
404 int64_t pos = lexer.GetPos();
405 soulng::lexer::Span span = lexer.GetSpan();
406 soulng::parser::Match match(lexer.Pos() != lexer.End());
407 for (const soulng::parser::Range& range : s0)
408 {
409 if (*lexer >= range.first && *lexer <= range.last)
410 {
411 match.hit = false;
412 break;
413 }
414 }
415 if (match.hit)
416 {
417 ++lexer;
418 }
419 if (match.hit)
420 {
421 s = span;
422 }
423 *parentMatch3 = match;
424 }
425 *parentMatch2 = match;
426 }
427 if (match.hit)
428 {
429 soulng::parser::Match match(false);
430 soulng::parser::Match* parentMatch4 = &match;
431 {
432 soulng::parser::Match match(true);
433 soulng::parser::Match* parentMatch5 = &match;
434 {
435 while (true)
436 {
437 int64_t save = lexer.GetPos();
438 {
439 soulng::parser::Match match(false);
440 soulng::parser::Match* parentMatch6 = &match;
441 {
442 soulng::parser::Match match(false);
443 soulng::parser::Match* parentMatch7 = &match;
444 {
445 int64_t pos = lexer.GetPos();
446 soulng::lexer::Span span = lexer.GetSpan();
447 soulng::parser::Match match(lexer.Pos() != lexer.End());
448 for (const soulng::parser::Range& range : s1)
449 {
450 if (*lexer >= range.first && *lexer <= range.last)
451 {
452 match.hit = false;
453 break;
454 }
455 }
456 if (match.hit)
457 {
458 ++lexer;
459 }
460 if (match.hit)
461 {
462 s.end = span.end;
463 }
464 *parentMatch7 = match;
465 }
466 *parentMatch6 = match;
467 }
468 if (match.hit)
469 {
470 *parentMatch5 = match;
471 }
472 else
473 {
474 lexer.SetPos(save);
475 break;
476 }
477 }
478 }
479 }
480 *parentMatch4 = match;
481 }
482 *parentMatch2 = match;
483 }
484 *parentMatch1 = match;
485 }
486 if (match.hit)
487 {
488 {
489 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
490
491 #endif // SOULNG_PARSER_DEBUG_SUPPORT
492 return soulng::parser::Match(true, new soulng::parser::Value<std::u32string>(lexer.GetMatch(s)));
493 }
494 }
495 *parentMatch0 = match;
496 }
497 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
498
499
500
501
502
503 #endif // SOULNG_PARSER_DEBUG_SUPPORT
504 if (!match.hit)
505 {
506 match.value = nullptr;
507 }
508 return match;
509 }
510
511 soulng::parser::Match PatchFileParser::LineNumber(TrivialLexer& lexer)
512 {
513 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
514
515
516
517
518
519
520
521 #endif // SOULNG_PARSER_DEBUG_SUPPORT
522 Span s = Span();
523 soulng::parser::Match match(false);
524 soulng::parser::Match* parentMatch0 = &match;
525 {
526 int64_t pos = lexer.GetPos();
527 soulng::parser::Match match(false);
528 soulng::parser::Match* parentMatch1 = &match;
529 {
530 soulng::parser::Match match(false);
531 soulng::parser::Match* parentMatch2 = &match;
532 {
533 soulng::parser::Match match(false);
534 soulng::parser::Match* parentMatch3 = &match;
535 {
536 int64_t pos = lexer.GetPos();
537 soulng::lexer::Span span = lexer.GetSpan();
538 soulng::parser::Match match(false);
539 for (const soulng::parser::Range& range : s2)
540 {
541 if (*lexer >= range.first && *lexer <= range.last)
542 {
543 match.hit = true;
544 ++lexer;
545 break;
546 }
547 }
548 if (match.hit)
549 {
550 s = span;
551 }
552 *parentMatch3 = match;
553 }
554 *parentMatch2 = match;
555 }
556 if (match.hit)
557 {
558 soulng::parser::Match match(false);
559 soulng::parser::Match* parentMatch4 = &match;
560 {
561 soulng::parser::Match match(true);
562 soulng::parser::Match* parentMatch5 = &match;
563 {
564 while (true)
565 {
566 int64_t save = lexer.GetPos();
567 {
568 soulng::parser::Match match(false);
569 soulng::parser::Match* parentMatch6 = &match;
570 {
571 soulng::parser::Match match(false);
572 soulng::parser::Match* parentMatch7 = &match;
573 {
574 int64_t pos = lexer.GetPos();
575 soulng::lexer::Span span = lexer.GetSpan();
576 soulng::parser::Match match(false);
577 for (const soulng::parser::Range& range : s3)
578 {
579 if (*lexer >= range.first && *lexer <= range.last)
580 {
581 match.hit = true;
582 ++lexer;
583 break;
584 }
585 }
586 if (match.hit)
587 {
588 s.end = span.end;
589 }
590 *parentMatch7 = match;
591 }
592 *parentMatch6 = match;
593 }
594 if (match.hit)
595 {
596 *parentMatch5 = match;
597 }
598 else
599 {
600 lexer.SetPos(save);
601 break;
602 }
603 }
604 }
605 }
606 *parentMatch4 = match;
607 }
608 *parentMatch2 = match;
609 }
610 *parentMatch1 = match;
611 }
612 if (match.hit)
613 {
614 {
615 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
616
617 #endif // SOULNG_PARSER_DEBUG_SUPPORT
618 return soulng::parser::Match(true, new soulng::parser::Value<std::u32string>(lexer.GetMatch(s)));
619 }
620 }
621 *parentMatch0 = match;
622 }
623 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
624
625
626
627
628
629 #endif // SOULNG_PARSER_DEBUG_SUPPORT
630 if (!match.hit)
631 {
632 match.value = nullptr;
633 }
634 return match;
635 }
636
637 soulng::parser::Match PatchFileParser::Patch(TrivialLexer& lexer)
638 {
639 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
640
641
642
643
644
645
646
647 #endif // SOULNG_PARSER_DEBUG_SUPPORT
648 std::unique_ptr<cpp2cm::Patch> ins;
649 std::unique_ptr<cpp2cm::Patch> del;
650 std::unique_ptr<cpp2cm::Patch> mod;
651 soulng::parser::Match match(false);
652 soulng::parser::Match* parentMatch0 = &match;
653 {
654 int64_t save = lexer.GetPos();
655 soulng::parser::Match match(false);
656 soulng::parser::Match* parentMatch1 = &match;
657 {
658 int64_t save = lexer.GetPos();
659 soulng::parser::Match match(false);
660 soulng::parser::Match* parentMatch2 = &match;
661 {
662 int64_t pos = lexer.GetPos();
663 soulng::parser::Match match = PatchFileParser::Insert(lexer);
664 ins.reset(static_cast<cpp2cm::Patch*>(match.value));
665 if (match.hit)
666 {
667 {
668 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
669
670 #endif // SOULNG_PARSER_DEBUG_SUPPORT
671 return soulng::parser::Match(true, ins.release());
672 }
673 }
674 *parentMatch2 = match;
675 }
676 *parentMatch1 = match;
677 if (!match.hit)
678 {
679 soulng::parser::Match match(false);
680 soulng::parser::Match* parentMatch3 = &match;
681 lexer.SetPos(save);
682 {
683 soulng::parser::Match match(false);
684 soulng::parser::Match* parentMatch4 = &match;
685 {
686 int64_t pos = lexer.GetPos();
687 soulng::parser::Match match = PatchFileParser::Delete(lexer);
688 del.reset(static_cast<cpp2cm::Patch*>(match.value));
689 if (match.hit)
690 {
691 {
692 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
693
694 #endif // SOULNG_PARSER_DEBUG_SUPPORT
695 return soulng::parser::Match(true, del.release());
696 }
697 }
698 *parentMatch4 = match;
699 }
700 *parentMatch3 = match;
701 }
702 *parentMatch1 = match;
703 }
704 }
705 *parentMatch0 = match;
706 if (!match.hit)
707 {
708 soulng::parser::Match match(false);
709 soulng::parser::Match* parentMatch5 = &match;
710 lexer.SetPos(save);
711 {
712 soulng::parser::Match match(false);
713 soulng::parser::Match* parentMatch6 = &match;
714 {
715 int64_t pos = lexer.GetPos();
716 soulng::parser::Match match = PatchFileParser::Modify(lexer);
717 mod.reset(static_cast<cpp2cm::Patch*>(match.value));
718 if (match.hit)
719 {
720 {
721 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
722
723 #endif // SOULNG_PARSER_DEBUG_SUPPORT
724 return soulng::parser::Match(true, mod.release());
725 }
726 }
727 *parentMatch6 = match;
728 }
729 *parentMatch5 = match;
730 }
731 *parentMatch0 = match;
732 }
733 }
734 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
735
736
737
738
739
740 #endif // SOULNG_PARSER_DEBUG_SUPPORT
741 if (!match.hit)
742 {
743 match.value = nullptr;
744 }
745 return match;
746 }
747
748 soulng::parser::Match PatchFileParser::Insert(TrivialLexer& lexer)
749 {
750 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
751
752
753
754
755
756
757
758 #endif // SOULNG_PARSER_DEBUG_SUPPORT
759 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>text;
760 soulng::parser::Match match(false);
761 soulng::parser::Match* parentMatch0 = &match;
762 {
763 int64_t pos = lexer.GetPos();
764 soulng::parser::Match match(false);
765 soulng::parser::Match* parentMatch1 = &match;
766 {
767 soulng::parser::Match match(false);
768 soulng::parser::Match* parentMatch2 = &match;
769 {
770 soulng::parser::Match match(false);
771 soulng::parser::Match* parentMatch3 = &match;
772 {
773 soulng::parser::Match match(false);
774 soulng::parser::Match* parentMatch4 = &match;
775 {
776 soulng::parser::Match match(false);
777 if (*lexer == 73)
778 {
779 ++lexer;
780 match.hit = true;
781 }
782 *parentMatch4 = match;
783 }
784 if (match.hit)
785 {
786 soulng::parser::Match match(false);
787 soulng::parser::Match* parentMatch5 = &match;
788 {
789 soulng::parser::Match match(false);
790 if (*lexer == 47)
791 {
792 ++lexer;
793 match.hit = true;
794 }
795 *parentMatch5 = match;
796 }
797 *parentMatch4 = match;
798 }
799 *parentMatch3 = match;
800 }
801 if (match.hit)
802 {
803 soulng::parser::Match match(false);
804 soulng::parser::Match* parentMatch6 = &match;
805 {
806 soulng::parser::Match match = PatchFileParser::Text(lexer);
807 text.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
808 *parentMatch6 = match;
809 }
810 *parentMatch3 = match;
811 }
812 *parentMatch2 = match;
813 }
814 if (match.hit)
815 {
816 soulng::parser::Match match(false);
817 soulng::parser::Match* parentMatch7 = &match;
818 {
819 soulng::parser::Match match(false);
820 if (*lexer == 47)
821 {
822 ++lexer;
823 match.hit = true;
824 }
825 *parentMatch7 = match;
826 }
827 *parentMatch2 = match;
828 }
829 *parentMatch1 = match;
830 }
831 if (match.hit)
832 {
833 {
834 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
835
836 #endif // SOULNG_PARSER_DEBUG_SUPPORT
837 return soulng::parser::Match(true, new cpp2cm::InsertPatch(text->value));
838 }
839 }
840 *parentMatch0 = match;
841 }
842 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
843
844
845
846
847
848 #endif // SOULNG_PARSER_DEBUG_SUPPORT
849 if (!match.hit)
850 {
851 match.value = nullptr;
852 }
853 return match;
854 }
855
856 soulng::parser::Match PatchFileParser::Delete(TrivialLexer& lexer)
857 {
858 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
859
860
861
862
863
864
865
866 #endif // SOULNG_PARSER_DEBUG_SUPPORT
867 soulng::parser::Match match(false);
868 soulng::parser::Match* parentMatch0 = &match;
869 {
870 int64_t pos = lexer.GetPos();
871 soulng::parser::Match match(false);
872 soulng::parser::Match* parentMatch1 = &match;
873 {
874 soulng::parser::Match match(false);
875 if (*lexer == 68)
876 {
877 ++lexer;
878 match.hit = true;
879 }
880 *parentMatch1 = match;
881 }
882 if (match.hit)
883 {
884 {
885 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
886
887 #endif // SOULNG_PARSER_DEBUG_SUPPORT
888 return soulng::parser::Match(true, new cpp2cm::DeletePatch());
889 }
890 }
891 *parentMatch0 = match;
892 }
893 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
894
895
896
897
898
899 #endif // SOULNG_PARSER_DEBUG_SUPPORT
900 if (!match.hit)
901 {
902 match.value = nullptr;
903 }
904 return match;
905 }
906
907 soulng::parser::Match PatchFileParser::Modify(TrivialLexer& lexer)
908 {
909 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
910
911
912
913
914
915
916
917 #endif // SOULNG_PARSER_DEBUG_SUPPORT
918 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>oldText;
919 std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>newText;
920 soulng::parser::Match match(false);
921 soulng::parser::Match* parentMatch0 = &match;
922 {
923 int64_t pos = lexer.GetPos();
924 soulng::parser::Match match(false);
925 soulng::parser::Match* parentMatch1 = &match;
926 {
927 soulng::parser::Match match(false);
928 soulng::parser::Match* parentMatch2 = &match;
929 {
930 soulng::parser::Match match(false);
931 soulng::parser::Match* parentMatch3 = &match;
932 {
933 soulng::parser::Match match(false);
934 soulng::parser::Match* parentMatch4 = &match;
935 {
936 soulng::parser::Match match(false);
937 soulng::parser::Match* parentMatch5 = &match;
938 {
939 soulng::parser::Match match(false);
940 soulng::parser::Match* parentMatch6 = &match;
941 {
942 soulng::parser::Match match(false);
943 if (*lexer == 77)
944 {
945 ++lexer;
946 match.hit = true;
947 }
948 *parentMatch6 = match;
949 }
950 if (match.hit)
951 {
952 soulng::parser::Match match(false);
953 soulng::parser::Match* parentMatch7 = &match;
954 {
955 soulng::parser::Match match(false);
956 if (*lexer == 47)
957 {
958 ++lexer;
959 match.hit = true;
960 }
961 *parentMatch7 = match;
962 }
963 *parentMatch6 = match;
964 }
965 *parentMatch5 = match;
966 }
967 if (match.hit)
968 {
969 soulng::parser::Match match(false);
970 soulng::parser::Match* parentMatch8 = &match;
971 {
972 soulng::parser::Match match = PatchFileParser::Text(lexer);
973 oldText.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
974 *parentMatch8 = match;
975 }
976 *parentMatch5 = match;
977 }
978 *parentMatch4 = match;
979 }
980 if (match.hit)
981 {
982 soulng::parser::Match match(false);
983 soulng::parser::Match* parentMatch9 = &match;
984 {
985 soulng::parser::Match match(false);
986 if (*lexer == 47)
987 {
988 ++lexer;
989 match.hit = true;
990 }
991 *parentMatch9 = match;
992 }
993 *parentMatch4 = match;
994 }
995 *parentMatch3 = match;
996 }
997 if (match.hit)
998 {
999 soulng::parser::Match match(false);
1000 soulng::parser::Match* parentMatch10 = &match;
1001 {
1002 soulng::parser::Match match = PatchFileParser::Text(lexer);
1003 newText.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
1004 *parentMatch10 = match;
1005 }
1006 *parentMatch3 = match;
1007 }
1008 *parentMatch2 = match;
1009 }
1010 if (match.hit)
1011 {
1012 soulng::parser::Match match(false);
1013 soulng::parser::Match* parentMatch11 = &match;
1014 {
1015 soulng::parser::Match match(false);
1016 if (*lexer == 47)
1017 {
1018 ++lexer;
1019 match.hit = true;
1020 }
1021 *parentMatch11 = match;
1022 }
1023 *parentMatch2 = match;
1024 }
1025 *parentMatch1 = match;
1026 }
1027 if (match.hit)
1028 {
1029 {
1030 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1031
1032 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1033 return soulng::parser::Match(true, new cpp2cm::ModifyPatch(oldText->value, newText->value));
1034 }
1035 }
1036 *parentMatch0 = match;
1037 }
1038 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1039
1040
1041
1042
1043
1044 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1045 if (!match.hit)
1046 {
1047 match.value = nullptr;
1048 }
1049 return match;
1050 }
1051
1052 soulng::parser::Match PatchFileParser::Text(TrivialLexer& lexer)
1053 {
1054 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1055
1056
1057
1058
1059
1060
1061
1062 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1063 Span s = Span();
1064 soulng::parser::Match match(false);
1065 soulng::parser::Match* parentMatch0 = &match;
1066 {
1067 int64_t pos = lexer.GetPos();
1068 soulng::parser::Match match(false);
1069 soulng::parser::Match* parentMatch1 = &match;
1070 {
1071 soulng::parser::Match match(false);
1072 soulng::parser::Match* parentMatch2 = &match;
1073 {
1074 soulng::parser::Match match(false);
1075 soulng::parser::Match* parentMatch3 = &match;
1076 {
1077 int64_t pos = lexer.GetPos();
1078 soulng::lexer::Span span = lexer.GetSpan();
1079 soulng::parser::Match match(lexer.Pos() != lexer.End());
1080 for (const soulng::parser::Range& range : s4)
1081 {
1082 if (*lexer >= range.first && *lexer <= range.last)
1083 {
1084 match.hit = false;
1085 break;
1086 }
1087 }
1088 if (match.hit)
1089 {
1090 ++lexer;
1091 }
1092 if (match.hit)
1093 {
1094 s = span;
1095 }
1096 *parentMatch3 = match;
1097 }
1098 *parentMatch2 = match;
1099 }
1100 if (match.hit)
1101 {
1102 soulng::parser::Match match(false);
1103 soulng::parser::Match* parentMatch4 = &match;
1104 {
1105 soulng::parser::Match match(true);
1106 soulng::parser::Match* parentMatch5 = &match;
1107 {
1108 while (true)
1109 {
1110 int64_t save = lexer.GetPos();
1111 {
1112 soulng::parser::Match match(false);
1113 soulng::parser::Match* parentMatch6 = &match;
1114 {
1115 soulng::parser::Match match(false);
1116 soulng::parser::Match* parentMatch7 = &match;
1117 {
1118 int64_t pos = lexer.GetPos();
1119 soulng::lexer::Span span = lexer.GetSpan();
1120 soulng::parser::Match match(lexer.Pos() != lexer.End());
1121 for (const soulng::parser::Range& range : s5)
1122 {
1123 if (*lexer >= range.first && *lexer <= range.last)
1124 {
1125 match.hit = false;
1126 break;
1127 }
1128 }
1129 if (match.hit)
1130 {
1131 ++lexer;
1132 }
1133 if (match.hit)
1134 {
1135 s.end = span.end;
1136 }
1137 *parentMatch7 = match;
1138 }
1139 *parentMatch6 = match;
1140 }
1141 if (match.hit)
1142 {
1143 *parentMatch5 = match;
1144 }
1145 else
1146 {
1147 lexer.SetPos(save);
1148 break;
1149 }
1150 }
1151 }
1152 }
1153 *parentMatch4 = match;
1154 }
1155 *parentMatch2 = match;
1156 }
1157 *parentMatch1 = match;
1158 }
1159 if (match.hit)
1160 {
1161 {
1162 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1163
1164 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1165 return soulng::parser::Match(true, new soulng::parser::Value<std::u32string>(lexer.GetMatch(s)));
1166 }
1167 }
1168 *parentMatch0 = match;
1169 }
1170 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1171
1172
1173
1174
1175
1176 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1177 if (!match.hit)
1178 {
1179 match.value = nullptr;
1180 }
1181 return match;
1182 }
1183
1184 soulng::parser::Match PatchFileParser::Newline(TrivialLexer& lexer)
1185 {
1186 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1187
1188
1189
1190
1191
1192
1193
1194 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1195 soulng::parser::Match match(false);
1196 soulng::parser::Match* parentMatch0 = &match;
1197 {
1198 int64_t save = lexer.GetPos();
1199 soulng::parser::Match match(false);
1200 soulng::parser::Match* parentMatch1 = &match;
1201 {
1202 int64_t save = lexer.GetPos();
1203 soulng::parser::Match match(true);
1204 for (int i : s6)
1205 {
1206 if (*lexer == i)
1207 {
1208 ++lexer;
1209 }
1210 else
1211 {
1212 match.hit = false;
1213 break;
1214 }
1215 }
1216 *parentMatch1 = match;
1217 if (!match.hit)
1218 {
1219 soulng::parser::Match match(false);
1220 soulng::parser::Match* parentMatch2 = &match;
1221 lexer.SetPos(save);
1222 {
1223 soulng::parser::Match match(false);
1224 if (*lexer == 10)
1225 {
1226 ++lexer;
1227 match.hit = true;
1228 }
1229 *parentMatch2 = match;
1230 }
1231 *parentMatch1 = match;
1232 }
1233 }
1234 *parentMatch0 = match;
1235 if (!match.hit)
1236 {
1237 soulng::parser::Match match(false);
1238 soulng::parser::Match* parentMatch3 = &match;
1239 lexer.SetPos(save);
1240 {
1241 soulng::parser::Match match(false);
1242 if (*lexer == 13)
1243 {
1244 ++lexer;
1245 match.hit = true;
1246 }
1247 *parentMatch3 = match;
1248 }
1249 *parentMatch0 = match;
1250 }
1251 }
1252 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
1253
1254
1255
1256
1257
1258 #endif // SOULNG_PARSER_DEBUG_SUPPORT
1259 if (!match.hit)
1260 {
1261 match.value = nullptr;
1262 }
1263 return match;
1264 }