1 #include "SolutionFile.hpp"
  2 #include <soulng/util/Unicode.hpp>
  3 #include <sngcm/cmlexer/ContainerFileLexer.hpp>
  4 #include <sngcm/cmlexer/ContainerFileTokens.hpp>
  5 
  6 // this file has been automatically generated from 'C:/work/cmajorm/cmajor/sngcm/cmparser/SolutionFile.parser' using soulng parser generator spg version 3.10.0
  7 
  8 using namespace soulng::unicode;
  9 using namespace sngcm::ast;
 10 using namespace ContainerFileTokens;
 11 
 12 std::std::unique_ptr<sngcm::ast::Solution>SolutionFileParser::Parse(ContainerFileLexer&lexer)
 13 {
 14     std::unique_ptr<sngcm::ast::Solution> value;
 15     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 16 
 17 
 18 
 19 
 20 
 21     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 22     ++lexer;
 23     soulng::lexer::Span span = lexer.GetSpan();
 24     soulng::parser::Match match = SolutionFileParser::SolutionFile(lexer);
 25     value.reset(static_cast<sngcm::ast::Solution*>(match.value));
 26     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 27 
 28 
 29 
 30 
 31 
 32     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 33     if (match.hit)
 34     {
 35         if (*lexer == soulng::lexer::END_TOKEN)
 36         {
 37             return value;
 38         }
 39         else
 40         {
 41             lexer.ThrowExpectationFailure(lexer.GetSpan()ToUtf32(soulng::lexer::GetEndTokenInfo()));
 42         }
 43     }
 44     else
 45     {
 46         lexer.ThrowExpectationFailure(spanU"SolutionFile");
 47     }
 48     return value;
 49 }
 50 
 51 soulng::parser::Match SolutionFileParser::SolutionFile(ContainerFileLexer& lexer)
 52 {
 53     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 54 
 55 
 56 
 57 
 58 
 59 
 60 
 61     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 62     std::unique_ptr<sngcm::ast::Solution> solution = std::unique_ptr<sngcm::ast::Solution>();
 63     std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>name;
 64     std::unique_ptr<sngcm::ast::SolutionDeclaration> declaration;
 65     soulng::parser::Match match(false);
 66     soulng::parser::Match* parentMatch0 = &match;
 67     {
 68         int64_t pos = lexer.GetPos();
 69         soulng::parser::Match match(false);
 70         soulng::parser::Match* parentMatch1 = &match;
 71         {
 72             soulng::parser::Match match(false);
 73             soulng::parser::Match* parentMatch2 = &match;
 74             {
 75                 soulng::parser::Match match(false);
 76                 soulng::parser::Match* parentMatch3 = &match;
 77                 {
 78                     soulng::parser::Match match(false);
 79                     soulng::parser::Match* parentMatch4 = &match;
 80                     {
 81                         soulng::parser::Match match(false);
 82                         if (*lexer == SOLUTION)
 83                         {
 84                             ++lexer;
 85                             match.hit = true;
 86                         }
 87                         *parentMatch4 = match;
 88                     }
 89                     if (match.hit)
 90                     {
 91                         soulng::parser::Match match(false);
 92                         soulng::parser::Match* parentMatch5 = &match;
 93                         {
 94                             soulng::parser::Match match(true);
 95                             soulng::parser::Match* parentMatch6 = &match;
 96                             {
 97                                 soulng::lexer::Span span = lexer.GetSpan();
 98                                 soulng::parser::Match match = SolutionFileParser::QualifiedId(lexer);
 99                                 name.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
100                                 if (match.hit)
101                                 {
102                                     *parentMatch6 = match;
103                                 }
104                                 else
105                                 {
106                                     lexer.ThrowExpectationFailure(spanU"QualifiedId");
107                                 }
108                             }
109                             *parentMatch5 = match;
110                         }
111                         *parentMatch4 = match;
112                     }
113                     *parentMatch3 = match;
114                 }
115                 if (match.hit)
116                 {
117                     soulng::parser::Match match(false);
118                     soulng::parser::Match* parentMatch7 = &match;
119                     {
120                         soulng::parser::Match match(false);
121                         soulng::parser::Match* parentMatch8 = &match;
122                         {
123                             int64_t pos = lexer.GetPos();
124                             soulng::parser::Match match(true);
125                             soulng::parser::Match* parentMatch9 = &match;
126                             {
127                                 soulng::lexer::Span span = lexer.GetSpan();
128                                 soulng::parser::Match match(false);
129                                 if (*lexer == SEMICOLON)
130                                 {
131                                     ++lexer;
132                                     match.hit = true;
133                                 }
134                                 if (match.hit)
135                                 {
136                                     *parentMatch9 = match;
137                                 }
138                                 else
139                                 {
140                                     lexer.ThrowExpectationFailure(spanToUtf32(GetTokenInfo(SEMICOLON)));
141                                 }
142                             }
143                             if (match.hit)
144                             {
145                                 solution.reset(new sngcm::ast::Solution(name->valuelexer.FileName()));
146                             }
147                             *parentMatch8 = match;
148                         }
149                         *parentMatch7 = match;
150                     }
151                     *parentMatch3 = match;
152                 }
153                 *parentMatch2 = match;
154             }
155             if (match.hit)
156             {
157                 soulng::parser::Match match(false);
158                 soulng::parser::Match* parentMatch10 = &match;
159                 {
160                     soulng::parser::Match match(true);
161                     soulng::parser::Match* parentMatch11 = &match;
162                     {
163                         while (true)
164                         {
165                             int64_t save = lexer.GetPos();
166                             {
167                                 soulng::parser::Match match(false);
168                                 soulng::parser::Match* parentMatch12 = &match;
169                                 {
170                                     soulng::parser::Match match(false);
171                                     soulng::parser::Match* parentMatch13 = &match;
172                                     {
173                                         int64_t pos = lexer.GetPos();
174                                         soulng::parser::Match match = SolutionFileParser::Declaration(lexer);
175                                         declaration.reset(static_cast<sngcm::ast::SolutionDeclaration*>(match.value));
176                                         if (match.hit)
177                                         {
178                                             solution->AddDeclaration(declaration.release());
179                                         }
180                                         *parentMatch13 = match;
181                                     }
182                                     *parentMatch12 = match;
183                                 }
184                                 if (match.hit)
185                                 {
186                                     *parentMatch11 = match;
187                                 }
188                                 else
189                                 {
190                                     lexer.SetPos(save);
191                                     break;
192                                 }
193                             }
194                         }
195                     }
196                     *parentMatch10 = match;
197                 }
198                 *parentMatch2 = match;
199             }
200             *parentMatch1 = match;
201         }
202         if (match.hit)
203         {
204             {
205                 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
206 
207                 #endif // SOULNG_PARSER_DEBUG_SUPPORT
208                 return soulng::parser::Match(truesolution.release());
209             }
210         }
211         *parentMatch0 = match;
212     }
213     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
214 
215 
216 
217 
218 
219     #endif // SOULNG_PARSER_DEBUG_SUPPORT
220     if (!match.hit)
221     {
222         match.value = nullptr;
223     }
224     return match;
225 }
226 
227 soulng::parser::Match SolutionFileParser::QualifiedId(ContainerFileLexer& lexer)
228 {
229     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
230 
231 
232 
233 
234 
235 
236 
237     #endif // SOULNG_PARSER_DEBUG_SUPPORT
238     Span s = Span();
239     soulng::parser::Match match(false);
240     soulng::parser::Match* parentMatch0 = &match;
241     {
242         int64_t pos = lexer.GetPos();
243         soulng::parser::Match match(false);
244         soulng::parser::Match* parentMatch1 = &match;
245         {
246             soulng::parser::Match match(false);
247             soulng::parser::Match* parentMatch2 = &match;
248             {
249                 soulng::parser::Match match(false);
250                 soulng::parser::Match* parentMatch3 = &match;
251                 {
252                     int64_t pos = lexer.GetPos();
253                     soulng::lexer::Span span = lexer.GetSpan();
254                     soulng::parser::Match match(false);
255                     if (*lexer == ID)
256                     {
257                         ++lexer;
258                         match.hit = true;
259                     }
260                     if (match.hit)
261                     {
262                         s = span;
263                     }
264                     *parentMatch3 = match;
265                 }
266                 *parentMatch2 = match;
267             }
268             if (match.hit)
269             {
270                 soulng::parser::Match match(false);
271                 soulng::parser::Match* parentMatch4 = &match;
272                 {
273                     soulng::parser::Match match(true);
274                     soulng::parser::Match* parentMatch5 = &match;
275                     {
276                         while (true)
277                         {
278                             int64_t save = lexer.GetPos();
279                             {
280                                 soulng::parser::Match match(false);
281                                 soulng::parser::Match* parentMatch6 = &match;
282                                 {
283                                     soulng::parser::Match match(false);
284                                     soulng::parser::Match* parentMatch7 = &match;
285                                     {
286                                         soulng::parser::Match match(false);
287                                         if (*lexer == DOT)
288                                         {
289                                             ++lexer;
290                                             match.hit = true;
291                                         }
292                                         *parentMatch7 = match;
293                                     }
294                                     if (match.hit)
295                                     {
296                                         soulng::parser::Match match(false);
297                                         soulng::parser::Match* parentMatch8 = &match;
298                                         {
299                                             soulng::parser::Match match(false);
300                                             soulng::parser::Match* parentMatch9 = &match;
301                                             {
302                                                 int64_t pos = lexer.GetPos();
303                                                 soulng::lexer::Span span = lexer.GetSpan();
304                                                 soulng::parser::Match match(false);
305                                                 if (*lexer == ID)
306                                                 {
307                                                     ++lexer;
308                                                     match.hit = true;
309                                                 }
310                                                 if (match.hit)
311                                                 {
312                                                     s.end = span.end;
313                                                 }
314                                                 *parentMatch9 = match;
315                                             }
316                                             *parentMatch8 = match;
317                                         }
318                                         *parentMatch7 = match;
319                                     }
320                                     *parentMatch6 = match;
321                                 }
322                                 if (match.hit)
323                                 {
324                                     *parentMatch5 = match;
325                                 }
326                                 else
327                                 {
328                                     lexer.SetPos(save);
329                                     break;
330                                 }
331                             }
332                         }
333                     }
334                     *parentMatch4 = match;
335                 }
336                 *parentMatch2 = match;
337             }
338             *parentMatch1 = match;
339         }
340         if (match.hit)
341         {
342             {
343                 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
344 
345                 #endif // SOULNG_PARSER_DEBUG_SUPPORT
346                 return soulng::parser::Match(truenew soulng::parser::Value<std::u32string>(lexer.GetMatch(s)));
347             }
348         }
349         *parentMatch0 = match;
350     }
351     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
352 
353 
354 
355 
356 
357     #endif // SOULNG_PARSER_DEBUG_SUPPORT
358     if (!match.hit)
359     {
360         match.value = nullptr;
361     }
362     return match;
363 }
364 
365 soulng::parser::Match SolutionFileParser::Declaration(ContainerFileLexer& lexer)
366 {
367     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
368 
369 
370 
371 
372 
373 
374 
375     #endif // SOULNG_PARSER_DEBUG_SUPPORT
376     std::unique_ptr<sngcm::ast::SolutionDeclaration> solutionProjectDeclaration;
377     std::unique_ptr<sngcm::ast::SolutionDeclaration> activeProjectDeclaration;
378     soulng::parser::Match match(false);
379     soulng::parser::Match* parentMatch0 = &match;
380     {
381         int64_t save = lexer.GetPos();
382         soulng::parser::Match match(false);
383         soulng::parser::Match* parentMatch1 = &match;
384         {
385             int64_t pos = lexer.GetPos();
386             soulng::parser::Match match = SolutionFileParser::SolutionProjectDeclaration(lexer);
387             solutionProjectDeclaration.reset(static_cast<sngcm::ast::SolutionDeclaration*>(match.value));
388             if (match.hit)
389             {
390                 {
391                     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
392 
393                     #endif // SOULNG_PARSER_DEBUG_SUPPORT
394                     return soulng::parser::Match(truesolutionProjectDeclaration.release());
395                 }
396             }
397             *parentMatch1 = match;
398         }
399         *parentMatch0 = match;
400         if (!match.hit)
401         {
402             soulng::parser::Match match(false);
403             soulng::parser::Match* parentMatch2 = &match;
404             lexer.SetPos(save);
405             {
406                 soulng::parser::Match match(false);
407                 soulng::parser::Match* parentMatch3 = &match;
408                 {
409                     int64_t pos = lexer.GetPos();
410                     soulng::parser::Match match = SolutionFileParser::ActiveProjectDeclaration(lexer);
411                     activeProjectDeclaration.reset(static_cast<sngcm::ast::SolutionDeclaration*>(match.value));
412                     if (match.hit)
413                     {
414                         {
415                             #ifdef SOULNG_PARSER_DEBUG_SUPPORT
416 
417                             #endif // SOULNG_PARSER_DEBUG_SUPPORT
418                             return soulng::parser::Match(trueactiveProjectDeclaration.release());
419                         }
420                     }
421                     *parentMatch3 = match;
422                 }
423                 *parentMatch2 = match;
424             }
425             *parentMatch0 = match;
426         }
427     }
428     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
429 
430 
431 
432 
433 
434     #endif // SOULNG_PARSER_DEBUG_SUPPORT
435     if (!match.hit)
436     {
437         match.value = nullptr;
438     }
439     return match;
440 }
441 
442 soulng::parser::Match SolutionFileParser::SolutionProjectDeclaration(ContainerFileLexer& lexer)
443 {
444     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
445 
446 
447 
448 
449 
450 
451 
452     #endif // SOULNG_PARSER_DEBUG_SUPPORT
453     std::string filePath = std::string();
454     soulng::parser::Match match(false);
455     soulng::parser::Match* parentMatch0 = &match;
456     {
457         int64_t pos = lexer.GetPos();
458         soulng::parser::Match match(false);
459         soulng::parser::Match* parentMatch1 = &match;
460         {
461             soulng::parser::Match match(false);
462             soulng::parser::Match* parentMatch2 = &match;
463             {
464                 soulng::parser::Match match(false);
465                 soulng::parser::Match* parentMatch3 = &match;
466                 {
467                     soulng::parser::Match match(false);
468                     if (*lexer == PROJECT)
469                     {
470                         ++lexer;
471                         match.hit = true;
472                     }
473                     *parentMatch3 = match;
474                 }
475                 if (match.hit)
476                 {
477                     soulng::parser::Match match(false);
478                     soulng::parser::Match* parentMatch4 = &match;
479                     {
480                         soulng::parser::Match match(false);
481                         soulng::parser::Match* parentMatch5 = &match;
482                         {
483                             int64_t pos = lexer.GetPos();
484                             soulng::parser::Match match(false);
485                             if (*lexer == FILEPATH)
486                             {
487                                 ++lexer;
488                                 match.hit = true;
489                             }
490                             if (match.hit)
491                             {
492                                 filePath = lexer.filePath;
493                             }
494                             *parentMatch5 = match;
495                         }
496                         *parentMatch4 = match;
497                     }
498                     *parentMatch3 = match;
499                 }
500                 *parentMatch2 = match;
501             }
502             if (match.hit)
503             {
504                 soulng::parser::Match match(false);
505                 soulng::parser::Match* parentMatch6 = &match;
506                 {
507                     soulng::parser::Match match(false);
508                     if (*lexer == SEMICOLON)
509                     {
510                         ++lexer;
511                         match.hit = true;
512                     }
513                     *parentMatch6 = match;
514                 }
515                 *parentMatch2 = match;
516             }
517             *parentMatch1 = match;
518         }
519         if (match.hit)
520         {
521             {
522                 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
523 
524                 #endif // SOULNG_PARSER_DEBUG_SUPPORT
525                 return soulng::parser::Match(truenew sngcm::ast::SolutionProjectDeclaration(filePath));
526             }
527         }
528         *parentMatch0 = match;
529     }
530     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
531 
532 
533 
534 
535 
536     #endif // SOULNG_PARSER_DEBUG_SUPPORT
537     if (!match.hit)
538     {
539         match.value = nullptr;
540     }
541     return match;
542 }
543 
544 soulng::parser::Match SolutionFileParser::ActiveProjectDeclaration(ContainerFileLexer& lexer)
545 {
546     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
547 
548 
549 
550 
551 
552 
553 
554     #endif // SOULNG_PARSER_DEBUG_SUPPORT
555     std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>activeProjectName;
556     soulng::parser::Match match(false);
557     soulng::parser::Match* parentMatch0 = &match;
558     {
559         int64_t pos = lexer.GetPos();
560         soulng::parser::Match match(false);
561         soulng::parser::Match* parentMatch1 = &match;
562         {
563             soulng::parser::Match match(false);
564             soulng::parser::Match* parentMatch2 = &match;
565             {
566                 soulng::parser::Match match(false);
567                 soulng::parser::Match* parentMatch3 = &match;
568                 {
569                     soulng::parser::Match match(false);
570                     if (*lexer == ACTIVEPROJECT)
571                     {
572                         ++lexer;
573                         match.hit = true;
574                     }
575                     *parentMatch3 = match;
576                 }
577                 if (match.hit)
578                 {
579                     soulng::parser::Match match(false);
580                     soulng::parser::Match* parentMatch4 = &match;
581                     {
582                         soulng::parser::Match match = SolutionFileParser::QualifiedId(lexer);
583                         activeProjectName.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
584                         *parentMatch4 = match;
585                     }
586                     *parentMatch3 = match;
587                 }
588                 *parentMatch2 = match;
589             }
590             if (match.hit)
591             {
592                 soulng::parser::Match match(false);
593                 soulng::parser::Match* parentMatch5 = &match;
594                 {
595                     soulng::parser::Match match(false);
596                     if (*lexer == SEMICOLON)
597                     {
598                         ++lexer;
599                         match.hit = true;
600                     }
601                     *parentMatch5 = match;
602                 }
603                 *parentMatch2 = match;
604             }
605             *parentMatch1 = match;
606         }
607         if (match.hit)
608         {
609             {
610                 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
611 
612                 #endif // SOULNG_PARSER_DEBUG_SUPPORT
613                 return soulng::parser::Match(truenew sngcm::ast::SolutionActiveProjectDeclaration(activeProjectName->value));
614             }
615         }
616         *parentMatch0 = match;
617     }
618     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
619 
620 
621 
622 
623 
624     #endif // SOULNG_PARSER_DEBUG_SUPPORT
625     if (!match.hit)
626     {
627         match.value = nullptr;
628     }
629     return match;
630 }