1 #include "ArgsParser.hpp"
  2 #include <soulng/util/Unicode.hpp>
  3 #include <soulng/lexer/TrivialLexer.hpp>
  4 #include <soulng/parser/Range.hpp>
  5 
  6 // this file has been automatically generated from 'D:/work/soulng-project/tools/cpp2cm/cpp2cm/ArgsParser.parser' using soulng parser generator spg version 3.0.0
  7 
  8 static const soulng::parser::Range s0[] = {{4857}};
  9 
 10 static const soulng::parser::Range s1[] = {{4857}};
 11 
 12 static const soulng::parser::Range s2[] = {{3232}  {99}};
 13 
 14 using namespace soulng::unicode;
 15 using namespace soulng::lexer;
 16 
 17 void ArgsParser::Parse(TrivialLexer& lexerstd::std::vector<int>*args)
 18 {
 19     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 20 
 21 
 22 
 23 
 24 
 25     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 26     ++lexer;
 27     soulng::lexer::Span span = lexer.GetSpan();
 28     soulng::parser::Match match = ArgsParser::Args(lexerargs);
 29     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 30 
 31 
 32 
 33 
 34 
 35     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 36     if (match.hit)
 37     {
 38         if (*lexer == soulng::lexer::END_TOKEN)
 39         {
 40             return;
 41         }
 42         else
 43         {
 44             lexer.ThrowExpectationFailure(lexer.GetSpan()ToUtf32(soulng::lexer::GetEndTokenInfo()));
 45         }
 46     }
 47     else
 48     {
 49         lexer.ThrowExpectationFailure(spanU"Args");
 50     }
 51     return;
 52 }
 53 
 54 soulng::parser::Match ArgsParser::Args(TrivialLexer& lexerstd::std::vector<int>*args)
 55 {
 56     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 57 
 58 
 59 
 60 
 61 
 62 
 63 
 64     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 65     std::unique_ptr<soulng::parser::soulng::parser::Value<int>>arg;
 66     soulng::parser::Match match(false);
 67     soulng::parser::Match* parentMatch0 = &match;
 68     {
 69         soulng::parser::Match match(false);
 70         soulng::parser::Match* parentMatch1 = &match;
 71         {
 72             soulng::parser::Match match(false);
 73             if (*lexer == 40)
 74             {
 75                 ++lexer;
 76                 match.hit = true;
 77             }
 78             *parentMatch1 = match;
 79         }
 80         if (match.hit)
 81         {
 82             soulng::parser::Match match(false);
 83             soulng::parser::Match* parentMatch2 = &match;
 84             {
 85                 soulng::parser::Match match(false);
 86                 soulng::parser::Match* parentMatch3 = &match;
 87                 {
 88                     soulng::parser::Match match(false);
 89                     soulng::parser::Match* parentMatch4 = &match;
 90                     {
 91                         soulng::parser::Match match(false);
 92                         soulng::parser::Match* parentMatch5 = &match;
 93                         {
 94                             int64_t pos = lexer.GetPos();
 95                             soulng::parser::Match match = ArgsParser::Arg(lexer);
 96                             arg.reset(static_cast<soulng::parser::soulng::parser::Value<int>*>(match.value));
 97                             if (match.hit)
 98                             {
 99                                 args->push_back(arg->value);
100                             }
101                             *parentMatch5 = match;
102                         }
103                         *parentMatch4 = match;
104                     }
105                     if (match.hit)
106                     {
107                         soulng::parser::Match match(false);
108                         soulng::parser::Match* parentMatch6 = &match;
109                         {
110                             soulng::parser::Match match(true);
111                             soulng::parser::Match* parentMatch7 = &match;
112                             {
113                                 while (true)
114                                 {
115                                     int64_t save = lexer.GetPos();
116                                     {
117                                         soulng::parser::Match match(false);
118                                         soulng::parser::Match* parentMatch8 = &match;
119                                         {
120                                             soulng::parser::Match match(false);
121                                             if (*lexer == 44)
122                                             {
123                                                 ++lexer;
124                                                 match.hit = true;
125                                             }
126                                             *parentMatch8 = match;
127                                         }
128                                         if (match.hit)
129                                         {
130                                             soulng::parser::Match match(false);
131                                             soulng::parser::Match* parentMatch9 = &match;
132                                             {
133                                                 soulng::parser::Match match(false);
134                                                 soulng::parser::Match* parentMatch10 = &match;
135                                                 {
136                                                     int64_t pos = lexer.GetPos();
137                                                     soulng::parser::Match match = ArgsParser::Arg(lexer);
138                                                     arg.reset(static_cast<soulng::parser::soulng::parser::Value<int>*>(match.value));
139                                                     if (match.hit)
140                                                     {
141                                                         args->push_back(arg->value);
142                                                     }
143                                                     *parentMatch10 = match;
144                                                 }
145                                                 *parentMatch9 = match;
146                                             }
147                                             *parentMatch8 = match;
148                                         }
149                                         if (match.hit)
150                                         {
151                                             *parentMatch7 = match;
152                                         }
153                                         else
154                                         {
155                                             lexer.SetPos(save);
156                                             break;
157                                         }
158                                     }
159                                 }
160                             }
161                             *parentMatch6 = match;
162                         }
163                         *parentMatch4 = match;
164                     }
165                     *parentMatch3 = match;
166                 }
167                 *parentMatch2 = match;
168             }
169             *parentMatch1 = match;
170         }
171         *parentMatch0 = match;
172     }
173     if (match.hit)
174     {
175         soulng::parser::Match match(false);
176         soulng::parser::Match* parentMatch11 = &match;
177         {
178             soulng::parser::Match match(false);
179             if (*lexer == 41)
180             {
181                 ++lexer;
182                 match.hit = true;
183             }
184             *parentMatch11 = match;
185         }
186         *parentMatch0 = match;
187     }
188     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
189 
190 
191 
192 
193 
194     #endif // SOULNG_PARSER_DEBUG_SUPPORT
195     if (!match.hit)
196     {
197         match.value = nullptr;
198     }
199     return match;
200 }
201 
202 soulng::parser::Match ArgsParser::Arg(TrivialLexer& lexer)
203 {
204     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
205 
206 
207 
208 
209 
210 
211 
212     #endif // SOULNG_PARSER_DEBUG_SUPPORT
213     Span s = Span();
214     soulng::parser::Match match(false);
215     soulng::parser::Match* parentMatch0 = &match;
216     {
217         soulng::parser::Match match(true);
218         int64_t save = lexer.GetPos();
219         soulng::parser::Match* parentMatch1 = &match;
220         {
221             soulng::parser::Match match = ArgsParser::S(lexer);
222             if (match.hit)
223             {
224                 *parentMatch1 = match;
225             }
226             else
227             {
228                 lexer.SetPos(save);
229             }
230         }
231         *parentMatch0 = match;
232     }
233     if (match.hit)
234     {
235         soulng::parser::Match match(false);
236         soulng::parser::Match* parentMatch2 = &match;
237         {
238             soulng::parser::Match match(false);
239             soulng::parser::Match* parentMatch3 = &match;
240             {
241                 int64_t pos = lexer.GetPos();
242                 soulng::parser::Match match(false);
243                 soulng::parser::Match* parentMatch4 = &match;
244                 {
245                     soulng::parser::Match match(false);
246                     soulng::parser::Match* parentMatch5 = &match;
247                     {
248                         soulng::parser::Match match(false);
249                         soulng::parser::Match* parentMatch6 = &match;
250                         {
251                             soulng::parser::Match match(false);
252                             soulng::parser::Match* parentMatch7 = &match;
253                             {
254                                 int64_t pos = lexer.GetPos();
255                                 soulng::lexer::Span span = lexer.GetSpan();
256                                 soulng::parser::Match match(false);
257                                 for (const soulng::parser::Range& range : s0)
258                                 {
259                                     if (*lexer >= range.first && *lexer <= range.last)
260                                     {
261                                         match.hit = true;
262                                         ++lexer;
263                                         break;
264                                     }
265                                 }
266                                 if (match.hit)
267                                 {
268                                     s = span;
269                                 }
270                                 *parentMatch7 = match;
271                             }
272                             *parentMatch6 = match;
273                         }
274                         if (match.hit)
275                         {
276                             soulng::parser::Match match(false);
277                             soulng::parser::Match* parentMatch8 = &match;
278                             {
279                                 soulng::parser::Match match(true);
280                                 soulng::parser::Match* parentMatch9 = &match;
281                                 {
282                                     while (true)
283                                     {
284                                         int64_t save = lexer.GetPos();
285                                         {
286                                             soulng::parser::Match match(false);
287                                             soulng::parser::Match* parentMatch10 = &match;
288                                             {
289                                                 soulng::parser::Match match(false);
290                                                 soulng::parser::Match* parentMatch11 = &match;
291                                                 {
292                                                     int64_t pos = lexer.GetPos();
293                                                     soulng::lexer::Span span = lexer.GetSpan();
294                                                     soulng::parser::Match match(false);
295                                                     for (const soulng::parser::Range& range : s1)
296                                                     {
297                                                         if (*lexer >= range.first && *lexer <= range.last)
298                                                         {
299                                                             match.hit = true;
300                                                             ++lexer;
301                                                             break;
302                                                         }
303                                                     }
304                                                     if (match.hit)
305                                                     {
306                                                         s.end = span.end;
307                                                     }
308                                                     *parentMatch11 = match;
309                                                 }
310                                                 *parentMatch10 = match;
311                                             }
312                                             if (match.hit)
313                                             {
314                                                 *parentMatch9 = match;
315                                             }
316                                             else
317                                             {
318                                                 lexer.SetPos(save);
319                                                 break;
320                                             }
321                                         }
322                                     }
323                                 }
324                                 *parentMatch8 = match;
325                             }
326                             *parentMatch6 = match;
327                         }
328                         *parentMatch5 = match;
329                     }
330                     if (match.hit)
331                     {
332                         soulng::parser::Match match(false);
333                         soulng::parser::Match* parentMatch12 = &match;
334                         {
335                             soulng::parser::Match match(true);
336                             int64_t save = lexer.GetPos();
337                             soulng::parser::Match* parentMatch13 = &match;
338                             {
339                                 soulng::parser::Match match = ArgsParser::S(lexer);
340                                 if (match.hit)
341                                 {
342                                     *parentMatch13 = match;
343                                 }
344                                 else
345                                 {
346                                     lexer.SetPos(save);
347                                 }
348                             }
349                             *parentMatch12 = match;
350                         }
351                         *parentMatch5 = match;
352                     }
353                     *parentMatch4 = match;
354                 }
355                 if (match.hit)
356                 {
357                     {
358                         #ifdef SOULNG_PARSER_DEBUG_SUPPORT
359 
360                         #endif // SOULNG_PARSER_DEBUG_SUPPORT
361                         return soulng::parser::Match(truenew soulng::parser::Value<int>(ParseInt(lexer.GetMatch(s))));
362                     }
363                 }
364                 *parentMatch3 = match;
365             }
366             *parentMatch2 = match;
367         }
368         *parentMatch0 = match;
369     }
370     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
371 
372 
373 
374 
375 
376     #endif // SOULNG_PARSER_DEBUG_SUPPORT
377     if (!match.hit)
378     {
379         match.value = nullptr;
380     }
381     return match;
382 }
383 
384 soulng::parser::Match ArgsParser::S(TrivialLexer& lexer)
385 {
386     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
387 
388 
389 
390 
391 
392 
393 
394     #endif // SOULNG_PARSER_DEBUG_SUPPORT
395     soulng::parser::Match match(false);
396     soulng::parser::Match* parentMatch0 = &match;
397     {
398         soulng::parser::Match match(false);
399         for (const soulng::parser::Range& range : s2)
400         {
401             if (*lexer >= range.first && *lexer <= range.last)
402             {
403                 match.hit = true;
404                 ++lexer;
405                 break;
406             }
407         }
408         *parentMatch0 = match;
409     }
410     if (match.hit)
411     {
412         soulng::parser::Match match(true);
413         soulng::parser::Match* parentMatch1 = &match;
414         while (true)
415         {
416             int64_t save = lexer.GetPos();
417             {
418                 soulng::parser::Match match(false);
419                 for (const soulng::parser::Range& range : s2)
420                 {
421                     if (*lexer >= range.first && *lexer <= range.last)
422                     {
423                         match.hit = true;
424                         ++lexer;
425                         break;
426                     }
427                 }
428                 if (match.hit)
429                 {
430                     *parentMatch1 = match;
431                 }
432                 else
433                 {
434                     lexer.SetPos(save);
435                     break;
436                 }
437             }
438         }
439     }
440     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
441 
442 
443 
444 
445 
446     #endif // SOULNG_PARSER_DEBUG_SUPPORT
447     if (!match.hit)
448     {
449         match.value = nullptr;
450     }
451     return match;
452 }