1 #include "BuildLangOptionParser.hpp"
  2 #include <soulng/util/Unicode.hpp>
  3 #include <cmajor/build/BuildLangLexer.hpp>
  4 #include <cmajor/build/BuildLangTokens.hpp>
  5 
  6 // this file has been automatically generated from 'D:/work/cmajorm/cmajor/build/BuildLangOptionParser.parser' using soulng parser generator spg version 3.0.0
  7 
  8 using namespace soulng::unicode;
  9 using namespace BuildLangTokens;
 10 
 11 soulng::parser::Match BuildLangOptionParser::Options(BuildLangLexer& lexercmajor::build::BuildOptionSetter* optionSetter)
 12 {
 13     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 22     soulng::parser::Match match(false);
 23     soulng::parser::Match* parentMatch0 = &match;
 24     {
 25         soulng::parser::Match match(false);
 26         soulng::parser::Match* parentMatch1 = &match;
 27         {
 28             soulng::parser::Match match(false);
 29             if (*lexer == LBRACKET)
 30             {
 31                 ++lexer;
 32                 match.hit = true;
 33             }
 34             *parentMatch1 = match;
 35         }
 36         if (match.hit)
 37         {
 38             soulng::parser::Match match(false);
 39             soulng::parser::Match* parentMatch2 = &match;
 40             {
 41                 soulng::parser::Match match(true);
 42                 soulng::parser::Match* parentMatch3 = &match;
 43                 {
 44                     soulng::lexer::Span span = lexer.GetSpan();
 45                     soulng::parser::Match match = BuildLangOptionParser::OptionsWithinBrackets(lexeroptionSetter);
 46                     if (match.hit)
 47                     {
 48                         *parentMatch3 = match;
 49                     }
 50                     else
 51                     {
 52                         lexer.ThrowExpectationFailure(spanU"OptionsWithinBrackets");
 53                     }
 54                 }
 55                 *parentMatch2 = match;
 56             }
 57             *parentMatch1 = match;
 58         }
 59         *parentMatch0 = match;
 60     }
 61     if (match.hit)
 62     {
 63         soulng::parser::Match match(false);
 64         soulng::parser::Match* parentMatch4 = &match;
 65         {
 66             soulng::parser::Match match(true);
 67             soulng::parser::Match* parentMatch5 = &match;
 68             {
 69                 soulng::lexer::Span span = lexer.GetSpan();
 70                 soulng::parser::Match match(false);
 71                 if (*lexer == RBRACKET)
 72                 {
 73                     ++lexer;
 74                     match.hit = true;
 75                 }
 76                 if (match.hit)
 77                 {
 78                     *parentMatch5 = match;
 79                 }
 80                 else
 81                 {
 82                     lexer.ThrowExpectationFailure(spanToUtf32(GetTokenInfo(RBRACKET)));
 83                 }
 84             }
 85             *parentMatch4 = match;
 86         }
 87         *parentMatch0 = match;
 88     }
 89     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 90 
 91 
 92 
 93 
 94 
 95     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 96     if (!match.hit)
 97     {
 98         match.value = nullptr;
 99     }
100     return match;
101 }
102 
103 soulng::parser::Match BuildLangOptionParser::OptionsWithinBrackets(BuildLangLexer& lexercmajor::build::BuildOptionSetter* optionSetter)
104 {
105     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
106 
107 
108 
109 
110 
111 
112 
113     #endif // SOULNG_PARSER_DEBUG_SUPPORT
114     soulng::parser::Match match(true);
115     soulng::parser::Match* parentMatch0 = &match;
116     {
117         while (true)
118         {
119             int64_t save = lexer.GetPos();
120             {
121                 soulng::parser::Match match = BuildLangOptionParser::Option(lexeroptionSetter);
122                 if (match.hit)
123                 {
124                     *parentMatch0 = match;
125                 }
126                 else
127                 {
128                     lexer.SetPos(save);
129                     break;
130                 }
131             }
132         }
133     }
134     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
135 
136 
137 
138 
139 
140     #endif // SOULNG_PARSER_DEBUG_SUPPORT
141     if (!match.hit)
142     {
143         match.value = nullptr;
144     }
145     return match;
146 }
147 
148 soulng::parser::Match BuildLangOptionParser::Option(BuildLangLexer& lexercmajor::build::BuildOptionSetter* optionSetter)
149 {
150     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
151 
152 
153 
154 
155 
156 
157 
158     #endif // SOULNG_PARSER_DEBUG_SUPPORT
159     std::unique_ptr<soulng::parser::soulng::parser::Value<std::string>>config;
160     std::unique_ptr<soulng::parser::soulng::parser::Value<std::string>>toolChain;
161     soulng::parser::Match match(false);
162     soulng::parser::Match* parentMatch0 = &match;
163     {
164         int64_t save = lexer.GetPos();
165         soulng::parser::Match match(false);
166         soulng::parser::Match* parentMatch1 = &match;
167         {
168             int64_t save = lexer.GetPos();
169             soulng::parser::Match match(false);
170             soulng::parser::Match* parentMatch2 = &match;
171             {
172                 int64_t save = lexer.GetPos();
173                 soulng::parser::Match match(false);
174                 soulng::parser::Match* parentMatch3 = &match;
175                 {
176                     int64_t save = lexer.GetPos();
177                     soulng::parser::Match match(false);
178                     soulng::parser::Match* parentMatch4 = &match;
179                     {
180                         int64_t save = lexer.GetPos();
181                         soulng::parser::Match match(false);
182                         soulng::parser::Match* parentMatch5 = &match;
183                         {
184                             int64_t save = lexer.GetPos();
185                             soulng::parser::Match match(false);
186                             soulng::parser::Match* parentMatch6 = &match;
187                             {
188                                 int64_t save = lexer.GetPos();
189                                 soulng::parser::Match match(false);
190                                 soulng::parser::Match* parentMatch7 = &match;
191                                 {
192                                     int64_t save = lexer.GetPos();
193                                     soulng::parser::Match match(false);
194                                     soulng::parser::Match* parentMatch8 = &match;
195                                     {
196                                         int64_t save = lexer.GetPos();
197                                         soulng::parser::Match match(false);
198                                         soulng::parser::Match* parentMatch9 = &match;
199                                         {
200                                             int64_t save = lexer.GetPos();
201                                             soulng::parser::Match match(false);
202                                             soulng::parser::Match* parentMatch10 = &match;
203                                             {
204                                                 int64_t pos = lexer.GetPos();
205                                                 soulng::parser::Match match(false);
206                                                 if (*lexer == VERBOSE)
207                                                 {
208                                                     ++lexer;
209                                                     match.hit = true;
210                                                 }
211                                                 if (match.hit)
212                                                 {
213                                                     optionSetter->SetOption(cmajor::build::BuildOptions::verbose);
214                                                 }
215                                                 *parentMatch10 = match;
216                                             }
217                                             *parentMatch9 = match;
218                                             if (!match.hit)
219                                             {
220                                                 soulng::parser::Match match(false);
221                                                 soulng::parser::Match* parentMatch11 = &match;
222                                                 lexer.SetPos(save);
223                                                 {
224                                                     soulng::parser::Match match(false);
225                                                     soulng::parser::Match* parentMatch12 = &match;
226                                                     {
227                                                         int64_t pos = lexer.GetPos();
228                                                         soulng::parser::Match match(false);
229                                                         if (*lexer == MESSAGES)
230                                                         {
231                                                             ++lexer;
232                                                             match.hit = true;
233                                                         }
234                                                         if (match.hit)
235                                                         {
236                                                             optionSetter->SetOption(cmajor::build::BuildOptions::messages);
237                                                         }
238                                                         *parentMatch12 = match;
239                                                     }
240                                                     *parentMatch11 = match;
241                                                 }
242                                                 *parentMatch9 = match;
243                                             }
244                                         }
245                                         *parentMatch8 = match;
246                                         if (!match.hit)
247                                         {
248                                             soulng::parser::Match match(false);
249                                             soulng::parser::Match* parentMatch13 = &match;
250                                             lexer.SetPos(save);
251                                             {
252                                                 soulng::parser::Match match(false);
253                                                 soulng::parser::Match* parentMatch14 = &match;
254                                                 {
255                                                     int64_t pos = lexer.GetPos();
256                                                     soulng::parser::Match match(false);
257                                                     if (*lexer == DEBUG)
258                                                     {
259                                                         ++lexer;
260                                                         match.hit = true;
261                                                     }
262                                                     if (match.hit)
263                                                     {
264                                                         optionSetter->SetOption(cmajor::build::BuildOptions::debug);
265                                                     }
266                                                     *parentMatch14 = match;
267                                                 }
268                                                 *parentMatch13 = match;
269                                             }
270                                             *parentMatch8 = match;
271                                         }
272                                     }
273                                     *parentMatch7 = match;
274                                     if (!match.hit)
275                                     {
276                                         soulng::parser::Match match(false);
277                                         soulng::parser::Match* parentMatch15 = &match;
278                                         lexer.SetPos(save);
279                                         {
280                                             soulng::parser::Match match(false);
281                                             soulng::parser::Match* parentMatch16 = &match;
282                                             {
283                                                 int64_t pos = lexer.GetPos();
284                                                 soulng::parser::Match match(false);
285                                                 if (*lexer == FORCE)
286                                                 {
287                                                     ++lexer;
288                                                     match.hit = true;
289                                                 }
290                                                 if (match.hit)
291                                                 {
292                                                     optionSetter->SetOption(cmajor::build::BuildOptions::force);
293                                                 }
294                                                 *parentMatch16 = match;
295                                             }
296                                             *parentMatch15 = match;
297                                         }
298                                         *parentMatch7 = match;
299                                     }
300                                 }
301                                 *parentMatch6 = match;
302                                 if (!match.hit)
303                                 {
304                                     soulng::parser::Match match(false);
305                                     soulng::parser::Match* parentMatch17 = &match;
306                                     lexer.SetPos(save);
307                                     {
308                                         soulng::parser::Match match(false);
309                                         soulng::parser::Match* parentMatch18 = &match;
310                                         {
311                                             int64_t pos = lexer.GetPos();
312                                             soulng::parser::Match match(false);
313                                             if (*lexer == ONLY)
314                                             {
315                                                 ++lexer;
316                                                 match.hit = true;
317                                             }
318                                             if (match.hit)
319                                             {
320                                                 optionSetter->SetOption(cmajor::build::BuildOptions::only);
321                                             }
322                                             *parentMatch18 = match;
323                                         }
324                                         *parentMatch17 = match;
325                                     }
326                                     *parentMatch6 = match;
327                                 }
328                             }
329                             *parentMatch5 = match;
330                             if (!match.hit)
331                             {
332                                 soulng::parser::Match match(false);
333                                 soulng::parser::Match* parentMatch19 = &match;
334                                 lexer.SetPos(save);
335                                 {
336                                     soulng::parser::Match match(false);
337                                     soulng::parser::Match* parentMatch20 = &match;
338                                     {
339                                         int64_t pos = lexer.GetPos();
340                                         soulng::parser::Match match(false);
341                                         if (*lexer == REBUILD)
342                                         {
343                                             ++lexer;
344                                             match.hit = true;
345                                         }
346                                         if (match.hit)
347                                         {
348                                             optionSetter->SetOption(cmajor::build::BuildOptions::rebuild);
349                                         }
350                                         *parentMatch20 = match;
351                                     }
352                                     *parentMatch19 = match;
353                                 }
354                                 *parentMatch5 = match;
355                             }
356                         }
357                         *parentMatch4 = match;
358                         if (!match.hit)
359                         {
360                             soulng::parser::Match match(false);
361                             soulng::parser::Match* parentMatch21 = &match;
362                             lexer.SetPos(save);
363                             {
364                                 soulng::parser::Match match(false);
365                                 soulng::parser::Match* parentMatch22 = &match;
366                                 {
367                                     int64_t pos = lexer.GetPos();
368                                     soulng::parser::Match match(false);
369                                     if (*lexer == ALL)
370                                     {
371                                         ++lexer;
372                                         match.hit = true;
373                                     }
374                                     if (match.hit)
375                                     {
376                                         optionSetter->SetOption(cmajor::build::BuildOptions::all);
377                                     }
378                                     *parentMatch22 = match;
379                                 }
380                                 *parentMatch21 = match;
381                             }
382                             *parentMatch4 = match;
383                         }
384                     }
385                     *parentMatch3 = match;
386                     if (!match.hit)
387                     {
388                         soulng::parser::Match match(false);
389                         soulng::parser::Match* parentMatch23 = &match;
390                         lexer.SetPos(save);
391                         {
392                             soulng::parser::Match match(false);
393                             soulng::parser::Match* parentMatch24 = &match;
394                             {
395                                 int64_t pos = lexer.GetPos();
396                                 soulng::parser::Match match(false);
397                                 if (*lexer == PUSH)
398                                 {
399                                     ++lexer;
400                                     match.hit = true;
401                                 }
402                                 if (match.hit)
403                                 {
404                                     optionSetter->SetOption(cmajor::build::BuildOptions::push);
405                                 }
406                                 *parentMatch24 = match;
407                             }
408                             *parentMatch23 = match;
409                         }
410                         *parentMatch3 = match;
411                     }
412                 }
413                 *parentMatch2 = match;
414                 if (!match.hit)
415                 {
416                     soulng::parser::Match match(false);
417                     soulng::parser::Match* parentMatch25 = &match;
418                     lexer.SetPos(save);
419                     {
420                         soulng::parser::Match match(false);
421                         soulng::parser::Match* parentMatch26 = &match;
422                         {
423                             int64_t pos = lexer.GetPos();
424                             soulng::parser::Match match(false);
425                             if (*lexer == BUILD)
426                             {
427                                 ++lexer;
428                                 match.hit = true;
429                             }
430                             if (match.hit)
431                             {
432                                 optionSetter->SetOption(cmajor::build::BuildOptions::build);
433                             }
434                             *parentMatch26 = match;
435                         }
436                         *parentMatch25 = match;
437                     }
438                     *parentMatch2 = match;
439                 }
440             }
441             *parentMatch1 = match;
442             if (!match.hit)
443             {
444                 soulng::parser::Match match(false);
445                 soulng::parser::Match* parentMatch27 = &match;
446                 lexer.SetPos(save);
447                 {
448                     soulng::parser::Match match(false);
449                     soulng::parser::Match* parentMatch28 = &match;
450                     {
451                         soulng::parser::Match match(false);
452                         soulng::parser::Match* parentMatch29 = &match;
453                         {
454                             soulng::parser::Match match(false);
455                             if (*lexer == CONFIG)
456                             {
457                                 ++lexer;
458                                 match.hit = true;
459                             }
460                             *parentMatch29 = match;
461                         }
462                         if (match.hit)
463                         {
464                             soulng::parser::Match match(false);
465                             soulng::parser::Match* parentMatch30 = &match;
466                             {
467                                 soulng::parser::Match match(true);
468                                 soulng::parser::Match* parentMatch31 = &match;
469                                 {
470                                     soulng::lexer::Span span = lexer.GetSpan();
471                                     soulng::parser::Match match(false);
472                                     if (*lexer == EQ)
473                                     {
474                                         ++lexer;
475                                         match.hit = true;
476                                     }
477                                     if (match.hit)
478                                     {
479                                         *parentMatch31 = match;
480                                     }
481                                     else
482                                     {
483                                         lexer.ThrowExpectationFailure(spanToUtf32(GetTokenInfo(EQ)));
484                                     }
485                                 }
486                                 *parentMatch30 = match;
487                             }
488                             *parentMatch29 = match;
489                         }
490                         *parentMatch28 = match;
491                     }
492                     if (match.hit)
493                     {
494                         soulng::parser::Match match(false);
495                         soulng::parser::Match* parentMatch32 = &match;
496                         {
497                             soulng::parser::Match match(false);
498                             soulng::parser::Match* parentMatch33 = &match;
499                             {
500                                 int64_t pos = lexer.GetPos();
501                                 soulng::parser::Match match(true);
502                                 soulng::parser::Match* parentMatch34 = &match;
503                                 {
504                                     soulng::lexer::Span span = lexer.GetSpan();
505                                     soulng::parser::Match match = BuildLangOptionParser::Config(lexer);
506                                     config.reset(static_cast<soulng::parser::soulng::parser::Value<std::string>*>(match.value));
507                                     if (match.hit)
508                                     {
509                                         *parentMatch34 = match;
510                                     }
511                                     else
512                                     {
513                                         lexer.ThrowExpectationFailure(spanU"Config");
514                                     }
515                                 }
516                                 if (match.hit)
517                                 {
518                                     optionSetter->SetConfigOption(config->value);
519                                 }
520                                 *parentMatch33 = match;
521                             }
522                             *parentMatch32 = match;
523                         }
524                         *parentMatch28 = match;
525                     }
526                     *parentMatch27 = match;
527                 }
528                 *parentMatch1 = match;
529             }
530         }
531         *parentMatch0 = match;
532         if (!match.hit)
533         {
534             soulng::parser::Match match(false);
535             soulng::parser::Match* parentMatch35 = &match;
536             lexer.SetPos(save);
537             {
538                 soulng::parser::Match match(false);
539                 soulng::parser::Match* parentMatch36 = &match;
540                 {
541                     soulng::parser::Match match(false);
542                     soulng::parser::Match* parentMatch37 = &match;
543                     {
544                         soulng::parser::Match match(false);
545                         if (*lexer == TOOLCHAIN)
546                         {
547                             ++lexer;
548                             match.hit = true;
549                         }
550                         *parentMatch37 = match;
551                     }
552                     if (match.hit)
553                     {
554                         soulng::parser::Match match(false);
555                         soulng::parser::Match* parentMatch38 = &match;
556                         {
557                             soulng::parser::Match match(true);
558                             soulng::parser::Match* parentMatch39 = &match;
559                             {
560                                 soulng::lexer::Span span = lexer.GetSpan();
561                                 soulng::parser::Match match(false);
562                                 if (*lexer == EQ)
563                                 {
564                                     ++lexer;
565                                     match.hit = true;
566                                 }
567                                 if (match.hit)
568                                 {
569                                     *parentMatch39 = match;
570                                 }
571                                 else
572                                 {
573                                     lexer.ThrowExpectationFailure(spanToUtf32(GetTokenInfo(EQ)));
574                                 }
575                             }
576                             *parentMatch38 = match;
577                         }
578                         *parentMatch37 = match;
579                     }
580                     *parentMatch36 = match;
581                 }
582                 if (match.hit)
583                 {
584                     soulng::parser::Match match(false);
585                     soulng::parser::Match* parentMatch40 = &match;
586                     {
587                         soulng::parser::Match match(false);
588                         soulng::parser::Match* parentMatch41 = &match;
589                         {
590                             int64_t pos = lexer.GetPos();
591                             soulng::parser::Match match(true);
592                             soulng::parser::Match* parentMatch42 = &match;
593                             {
594                                 soulng::lexer::Span span = lexer.GetSpan();
595                                 soulng::parser::Match match = BuildLangOptionParser::ToolChain(lexer);
596                                 toolChain.reset(static_cast<soulng::parser::soulng::parser::Value<std::string>*>(match.value));
597                                 if (match.hit)
598                                 {
599                                     *parentMatch42 = match;
600                                 }
601                                 else
602                                 {
603                                     lexer.ThrowExpectationFailure(spanU"ToolChain");
604                                 }
605                             }
606                             if (match.hit)
607                             {
608                                 optionSetter->SetToolChainOption(toolChain->value);
609                             }
610                             *parentMatch41 = match;
611                         }
612                         *parentMatch40 = match;
613                     }
614                     *parentMatch36 = match;
615                 }
616                 *parentMatch35 = match;
617             }
618             *parentMatch0 = match;
619         }
620     }
621     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
622 
623 
624 
625 
626 
627     #endif // SOULNG_PARSER_DEBUG_SUPPORT
628     if (!match.hit)
629     {
630         match.value = nullptr;
631     }
632     return match;
633 }
634 
635 soulng::parser::Match BuildLangOptionParser::Config(BuildLangLexer& lexer)
636 {
637     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
638 
639 
640 
641 
642 
643 
644 
645     #endif // SOULNG_PARSER_DEBUG_SUPPORT
646     soulng::parser::Match match(false);
647     int64_t pos = lexer.GetPos();
648     soulng::lexer::Span span = lexer.GetSpan();
649     switch (*lexer)
650     {
651         case DEBUG:
652         {
653             ++lexer;
654             {
655                 {
656                     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
657 
658                     #endif // SOULNG_PARSER_DEBUG_SUPPORT
659                     return soulng::parser::Match(truenew soulng::parser::Value<std::string>("debug"));
660                 }
661             }
662             break;
663         }
664         case RELEASE:
665         {
666             ++lexer;
667             {
668                 {
669                     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
670 
671                     #endif // SOULNG_PARSER_DEBUG_SUPPORT
672                     return soulng::parser::Match(truenew soulng::parser::Value<std::string>("release"));
673                 }
674             }
675             break;
676         }
677     }
678     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
679 
680 
681 
682 
683 
684     #endif // SOULNG_PARSER_DEBUG_SUPPORT
685     if (!match.hit)
686     {
687         match.value = nullptr;
688     }
689     return match;
690 }
691 
692 soulng::parser::Match BuildLangOptionParser::ToolChain(BuildLangLexer& lexer)
693 {
694     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
695 
696 
697 
698 
699 
700 
701 
702     #endif // SOULNG_PARSER_DEBUG_SUPPORT
703     soulng::parser::Match match(false);
704     int64_t pos = lexer.GetPos();
705     soulng::lexer::Span span = lexer.GetSpan();
706     switch (*lexer)
707     {
708         case CLANG:
709         {
710             ++lexer;
711             {
712                 {
713                     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
714 
715                     #endif // SOULNG_PARSER_DEBUG_SUPPORT
716                     return soulng::parser::Match(truenew soulng::parser::Value<std::string>("clang"));
717                 }
718             }
719             break;
720         }
721         case GCC:
722         {
723             ++lexer;
724             {
725                 {
726                     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
727 
728                     #endif // SOULNG_PARSER_DEBUG_SUPPORT
729                     return soulng::parser::Match(truenew soulng::parser::Value<std::string>("gcc"));
730                 }
731             }
732             break;
733         }
734         case VS:
735         {
736             ++lexer;
737             {
738                 {
739                     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
740 
741                     #endif // SOULNG_PARSER_DEBUG_SUPPORT
742                     return soulng::parser::Match(truenew soulng::parser::Value<std::string>("vs"));
743                 }
744             }
745             break;
746         }
747         case ID:
748         {
749             ++lexer;
750             {
751                 {
752                     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
753 
754                     #endif // SOULNG_PARSER_DEBUG_SUPPORT
755                     return soulng::parser::Match(truenew soulng::parser::Value<std::string>(ToUtf8(lexer.GetToken(pos).match.ToString())));
756                 }
757             }
758             break;
759         }
760     }
761     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
762 
763 
764 
765 
766 
767     #endif // SOULNG_PARSER_DEBUG_SUPPORT
768     if (!match.hit)
769     {
770         match.value = nullptr;
771     }
772     return match;
773 }