1 #include "ProjectFileParser.hpp"
  2 #include <soulng/util/Unicode.hpp>
  3 #include <sng2html/sng2html/ProjectFileLexer.hpp>
  4 #include <sng2html/sng2html/ProjectFileTokens.hpp>
  5 
  6 // this file has been automatically generated from 'D:/work/soulng-project/tools/sng2html/sng2html/ProjectFileParser.parser' using soulng parser generator spg version 3.0.0
  7 
  8 using namespace soulng::unicode;
  9 using namespace soulng::lexer;
 10 using namespace ProjectFileTokens;
 11 
 12 std::std::unique_ptr<sng2html::sng2html::ProjectFile>ProjectFileParser::Parse(ProjectFileLexer&lexer)
 13 {
 14     std::unique_ptr<sng2html::sng2html::ProjectFile> 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 = ProjectFileParser::ProjectFile(lexer);
 25     value.reset(static_cast<sng2html::sng2html::ProjectFile*>(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"ProjectFile");
 47     }
 48     return value;
 49 }
 50 
 51 soulng::parser::Match ProjectFileParser::ProjectFile(ProjectFileLexer& 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<sng2html::sng2html::ProjectFile> projectFile = std::unique_ptr<sng2html::sng2html::ProjectFile>();
 63     std::unique_ptr<soulng::parser::soulng::parser::Value<std::u32string>>projectName;
 64     soulng::parser::Match match(false);
 65     soulng::parser::Match* parentMatch0 = &match;
 66     {
 67         soulng::parser::Match match(false);
 68         soulng::parser::Match* parentMatch1 = &match;
 69         {
 70             soulng::parser::Match match(false);
 71             soulng::parser::Match* parentMatch2 = &match;
 72             {
 73                 soulng::parser::Match match(false);
 74                 if (*lexer == PROJECT)
 75                 {
 76                     ++lexer;
 77                     match.hit = true;
 78                 }
 79                 *parentMatch2 = match;
 80             }
 81             if (match.hit)
 82             {
 83                 soulng::parser::Match match(false);
 84                 soulng::parser::Match* parentMatch3 = &match;
 85                 {
 86                     soulng::parser::Match match(true);
 87                     soulng::parser::Match* parentMatch4 = &match;
 88                     {
 89                         soulng::lexer::Span span = lexer.GetSpan();
 90                         soulng::parser::Match match = ProjectFileParser::QualifiedId(lexer);
 91                         projectName.reset(static_cast<soulng::parser::soulng::parser::Value<std::u32string>*>(match.value));
 92                         if (match.hit)
 93                         {
 94                             *parentMatch4 = match;
 95                         }
 96                         else
 97                         {
 98                             lexer.ThrowExpectationFailure(spanU"QualifiedId");
 99                         }
100                     }
101                     *parentMatch3 = match;
102                 }
103                 *parentMatch2 = match;
104             }
105             *parentMatch1 = match;
106         }
107         if (match.hit)
108         {
109             soulng::parser::Match match(false);
110             soulng::parser::Match* parentMatch5 = &match;
111             {
112                 soulng::parser::Match match(false);
113                 soulng::parser::Match* parentMatch6 = &match;
114                 {
115                     int64_t pos = lexer.GetPos();
116                     soulng::parser::Match match(true);
117                     soulng::parser::Match* parentMatch7 = &match;
118                     {
119                         soulng::lexer::Span span = lexer.GetSpan();
120                         soulng::parser::Match match(false);
121                         if (*lexer == SEMICOLON)
122                         {
123                             ++lexer;
124                             match.hit = true;
125                         }
126                         if (match.hit)
127                         {
128                             *parentMatch7 = match;
129                         }
130                         else
131                         {
132                             lexer.ThrowExpectationFailure(spanToUtf32(GetTokenInfo(SEMICOLON)));
133                         }
134                     }
135                     if (match.hit)
136                     {
137                         projectFile.reset(new sng2html::sng2html::ProjectFile(lexer.FileName()projectName->value));
138                     }
139                     *parentMatch6 = match;
140                 }
141                 *parentMatch5 = match;
142             }
143             *parentMatch1 = match;
144         }
145         *parentMatch0 = match;
146     }
147     if (match.hit)
148     {
149         soulng::parser::Match match(false);
150         soulng::parser::Match* parentMatch8 = &match;
151         {
152             soulng::parser::Match match(false);
153             soulng::parser::Match* parentMatch9 = &match;
154             {
155                 int64_t pos = lexer.GetPos();
156                 soulng::parser::Match match = ProjectFileParser::ProjectFileContent(lexerprojectFile.get());
157                 if (match.hit)
158                 {
159                     {
160                         #ifdef SOULNG_PARSER_DEBUG_SUPPORT
161 
162                         #endif // SOULNG_PARSER_DEBUG_SUPPORT
163                         return soulng::parser::Match(trueprojectFile.release());
164                     }
165                 }
166                 *parentMatch9 = match;
167             }
168             *parentMatch8 = match;
169         }
170         *parentMatch0 = match;
171     }
172     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
173 
174 
175 
176 
177 
178     #endif // SOULNG_PARSER_DEBUG_SUPPORT
179     if (!match.hit)
180     {
181         match.value = nullptr;
182     }
183     return match;
184 }
185 
186 soulng::parser::Match ProjectFileParser::ProjectFileContent(ProjectFileLexer& lexersng2html::sng2html::ProjectFile* projectFile)
187 {
188     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
189 
190 
191 
192 
193 
194 
195 
196     #endif // SOULNG_PARSER_DEBUG_SUPPORT
197     soulng::parser::Match match(true);
198     soulng::parser::Match* parentMatch0 = &match;
199     {
200         while (true)
201         {
202             int64_t save = lexer.GetPos();
203             {
204                 soulng::parser::Match match = ProjectFileParser::SourceFile(lexerprojectFile);
205                 if (match.hit)
206                 {
207                     *parentMatch0 = match;
208                 }
209                 else
210                 {
211                     lexer.SetPos(save);
212                     break;
213                 }
214             }
215         }
216     }
217     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
218 
219 
220 
221 
222 
223     #endif // SOULNG_PARSER_DEBUG_SUPPORT
224     if (!match.hit)
225     {
226         match.value = nullptr;
227     }
228     return match;
229 }
230 
231 soulng::parser::Match ProjectFileParser::QualifiedId(ProjectFileLexer& lexer)
232 {
233     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
234 
235 
236 
237 
238 
239 
240 
241     #endif // SOULNG_PARSER_DEBUG_SUPPORT
242     Span s = Span();
243     soulng::parser::Match match(false);
244     soulng::parser::Match* parentMatch0 = &match;
245     {
246         int64_t pos = lexer.GetPos();
247         soulng::parser::Match match(false);
248         soulng::parser::Match* parentMatch1 = &match;
249         {
250             soulng::parser::Match match(false);
251             soulng::parser::Match* parentMatch2 = &match;
252             {
253                 soulng::parser::Match match(false);
254                 soulng::parser::Match* parentMatch3 = &match;
255                 {
256                     int64_t pos = lexer.GetPos();
257                     soulng::lexer::Span span = lexer.GetSpan();
258                     soulng::parser::Match match(false);
259                     if (*lexer == ID)
260                     {
261                         ++lexer;
262                         match.hit = true;
263                     }
264                     if (match.hit)
265                     {
266                         s = span;
267                     }
268                     *parentMatch3 = match;
269                 }
270                 *parentMatch2 = match;
271             }
272             if (match.hit)
273             {
274                 soulng::parser::Match match(false);
275                 soulng::parser::Match* parentMatch4 = &match;
276                 {
277                     soulng::parser::Match match(true);
278                     soulng::parser::Match* parentMatch5 = &match;
279                     {
280                         while (true)
281                         {
282                             int64_t save = lexer.GetPos();
283                             {
284                                 soulng::parser::Match match(false);
285                                 soulng::parser::Match* parentMatch6 = &match;
286                                 {
287                                     soulng::parser::Match match(false);
288                                     soulng::parser::Match* parentMatch7 = &match;
289                                     {
290                                         soulng::parser::Match match(false);
291                                         if (*lexer == DOT)
292                                         {
293                                             ++lexer;
294                                             match.hit = true;
295                                         }
296                                         *parentMatch7 = match;
297                                     }
298                                     if (match.hit)
299                                     {
300                                         soulng::parser::Match match(false);
301                                         soulng::parser::Match* parentMatch8 = &match;
302                                         {
303                                             soulng::parser::Match match(false);
304                                             soulng::parser::Match* parentMatch9 = &match;
305                                             {
306                                                 int64_t pos = lexer.GetPos();
307                                                 soulng::lexer::Span span = lexer.GetSpan();
308                                                 soulng::parser::Match match(false);
309                                                 if (*lexer == ID)
310                                                 {
311                                                     ++lexer;
312                                                     match.hit = true;
313                                                 }
314                                                 if (match.hit)
315                                                 {
316                                                     s.end = span.end;
317                                                 }
318                                                 *parentMatch9 = match;
319                                             }
320                                             *parentMatch8 = match;
321                                         }
322                                         *parentMatch7 = match;
323                                     }
324                                     *parentMatch6 = match;
325                                 }
326                                 if (match.hit)
327                                 {
328                                     *parentMatch5 = match;
329                                 }
330                                 else
331                                 {
332                                     lexer.SetPos(save);
333                                     break;
334                                 }
335                             }
336                         }
337                     }
338                     *parentMatch4 = match;
339                 }
340                 *parentMatch2 = match;
341             }
342             *parentMatch1 = match;
343         }
344         if (match.hit)
345         {
346             {
347                 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
348 
349                 #endif // SOULNG_PARSER_DEBUG_SUPPORT
350                 return soulng::parser::Match(truenew soulng::parser::Value<std::u32string>(lexer.GetMatch(s)));
351             }
352         }
353         *parentMatch0 = match;
354     }
355     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
356 
357 
358 
359 
360 
361     #endif // SOULNG_PARSER_DEBUG_SUPPORT
362     if (!match.hit)
363     {
364         match.value = nullptr;
365     }
366     return match;
367 }
368 
369 soulng::parser::Match ProjectFileParser::SourceFile(ProjectFileLexer& lexersng2html::sng2html::ProjectFile* projectFile)
370 {
371     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
372 
373 
374 
375 
376 
377 
378 
379     #endif // SOULNG_PARSER_DEBUG_SUPPORT
380     soulng::parser::Match match(false);
381     soulng::parser::Match* parentMatch0 = &match;
382     {
383         soulng::parser::Match match(false);
384         soulng::parser::Match* parentMatch1 = &match;
385         {
386             soulng::parser::Match match(false);
387             if (*lexer == SOURCE)
388             {
389                 ++lexer;
390                 match.hit = true;
391             }
392             *parentMatch1 = match;
393         }
394         if (match.hit)
395         {
396             soulng::parser::Match match(false);
397             soulng::parser::Match* parentMatch2 = &match;
398             {
399                 soulng::parser::Match match(false);
400                 soulng::parser::Match* parentMatch3 = &match;
401                 {
402                     int64_t pos = lexer.GetPos();
403                     soulng::parser::Match match(true);
404                     soulng::parser::Match* parentMatch4 = &match;
405                     {
406                         soulng::lexer::Span span = lexer.GetSpan();
407                         soulng::parser::Match match(false);
408                         if (*lexer == FILEPATH)
409                         {
410                             ++lexer;
411                             match.hit = true;
412                         }
413                         if (match.hit)
414                         {
415                             *parentMatch4 = match;
416                         }
417                         else
418                         {
419                             lexer.ThrowExpectationFailure(spanToUtf32(GetTokenInfo(FILEPATH)));
420                         }
421                     }
422                     if (match.hit)
423                     {
424                         projectFile->AddSourceFile(lexer.filePath);
425                     }
426                     *parentMatch3 = match;
427                 }
428                 *parentMatch2 = match;
429             }
430             *parentMatch1 = match;
431         }
432         *parentMatch0 = match;
433     }
434     if (match.hit)
435     {
436         soulng::parser::Match match(false);
437         soulng::parser::Match* parentMatch5 = &match;
438         {
439             soulng::parser::Match match(true);
440             soulng::parser::Match* parentMatch6 = &match;
441             {
442                 soulng::lexer::Span span = lexer.GetSpan();
443                 soulng::parser::Match match(false);
444                 if (*lexer == SEMICOLON)
445                 {
446                     ++lexer;
447                     match.hit = true;
448                 }
449                 if (match.hit)
450                 {
451                     *parentMatch6 = match;
452                 }
453                 else
454                 {
455                     lexer.ThrowExpectationFailure(spanToUtf32(GetTokenInfo(SEMICOLON)));
456                 }
457             }
458             *parentMatch5 = match;
459         }
460         *parentMatch0 = match;
461     }
462     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
463 
464 
465 
466 
467 
468     #endif // SOULNG_PARSER_DEBUG_SUPPORT
469     if (!match.hit)
470     {
471         match.value = nullptr;
472     }
473     return match;
474 }