1 // this file has been generated from 'C:/work/cmajor-mod/cmajor/masm/system/System.Json/Json.parser' using SoulCm parser generator scmpg version 5.0.0
  2 
  3 using System;
  4 using System.Lex;
  5 using System.Parsing;
  6 using JsonTokens;
  7 
  8 public static class JsonParser<LexerT>
  9 {
 10     public static System.Result<System.UniquePtr<System.Json.JsonValue>> Parse(LexerT& lexer)
 11     {
 12         System.UniquePtr<System.Json.JsonValue> value;
 13         #if (DEBUG)
 14         if (lexer.Log() != null)
 15         {
 16             auto result = lexer.Log()->WriteBeginRule(u"parse");
 17             if (result.Error())
 18             {
 19                 return System.Result<System.UniquePtr<System.Json.JsonValue>>(System.ErrorId(result.GetErrorId()));
 20             }
 21             lexer.Log()->IncIndent();
 22         }
 23         #endif
 24         auto incResult0 = ++lexer;
 25         if (incResult0.Error())
 26         {
 27             return System.Result<System.UniquePtr<System.Json.JsonValue>>(System.ErrorId(incResult0.GetErrorId()));
 28         }
 29         System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Value(lexer);
 30         if (matchResult.Error())
 31         {
 32             return System.Result<System.UniquePtr<System.Json.JsonValue>>(System.ErrorId(matchResult.GetErrorId()));
 33         }
 34         System.Parsing.Match match = matchResult.Value();
 35         value.Reset(cast<System.Json.JsonValue*>(match.value));
 36         #if (DEBUG)
 37         if (lexer.Log() != null)
 38         {
 39             lexer.Log()->DecIndent();
 40             auto result = lexer.Log()->WriteEndRule(u"parse");
 41             if (result.Error())
 42             {
 43                 return System.Result<System.UniquePtr<System.Json.JsonValue>>(System.ErrorId(result.GetErrorId()));
 44             }
 45         }
 46         #endif
 47         if (match.hit)
 48         {
 49             if (*lexer == System.Lex.END_TOKEN)
 50             {
 51                 return System.Result<System.UniquePtr<System.Json.JsonValue>>(System.Rvalue(value));
 52             }
 53             else
 54             {
 55                 return System.Result<System.UniquePtr<System.Json.JsonValue>>(lexer.GetFarthestError());
 56             }
 57         }
 58         else
 59         {
 60             return System.Result<System.UniquePtr<System.Json.JsonValue>>(lexer.GetFarthestError());
 61         }
 62     }
 63     public static System.Result<System.Parsing.Match> Value(LexerT& lexer)
 64     {
 65         #if (DEBUG)
 66         long parser_debug_match_pos = 0;
 67         bool parser_debug_write_to_log = lexer.Log() != null;
 68         if (parser_debug_write_to_log)
 69         {
 70             parser_debug_match_pos = lexer.GetPos();
 71             auto result = System.Lex.WriteBeginRuleToLog(lexeru"Value");
 72             if (result.Error())
 73             {
 74                 return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 75             }
 76         }
 77         #endif
 78         System.Lex.RuleGuard<LexerT> ruleGuard(lexer4742808741454282753);
 79         System.UniquePtr<System.Json.JsonObject> o;
 80         System.UniquePtr<System.Json.JsonArray> a;
 81         System.Parsing.Match match(false);
 82         System.Parsing.Match* parentMatch0 = &match;
 83         switch (*lexer)
 84         {
 85             case STRING:
 86             {
 87                 System.Parsing.Match match(false);
 88                 System.Parsing.Match* parentMatch1 = &match;
 89                 {
 90                     long pos = lexer.GetPos();
 91                     System.Parsing.Match match(false);
 92                     if (*lexer == STRING)
 93                     {
 94                         auto incResult0 = ++lexer;
 95                         if (incResult0.Error())
 96                         {
 97                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
 98                         }
 99                         match.hit = true;
100                     }
101                     if (match.hit)
102                     {
103                         #if (DEBUG)
104                             if (parser_debug_write_to_log)
105                             {
106                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
107                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
108                             }
109                         #endif
110                         Token token = lexer.GetToken(pos);
111                         auto stringLiteralResult = System.Json.ParseStringLiteral(token);
112                         if (stringLiteralResult.Error())
113                         {
114                             return System.Result<System.Parsing.Match>(ErrorId(stringLiteralResult.GetErrorId()));
115                         }
116                         return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Json.JsonString(stringLiteralResult.Value())));
117                     }
118                     *parentMatch1 = match;
119                 }
120                 if (match.hit)
121                 {
122                     *parentMatch0 = match;
123                 }
124                 break;
125             }
126             case NUMBER:
127             {
128                 System.Parsing.Match match(false);
129                 System.Parsing.Match* parentMatch2 = &match;
130                 {
131                     long pos = lexer.GetPos();
132                     System.Parsing.Match match(false);
133                     if (*lexer == NUMBER)
134                     {
135                         auto incResult1 = ++lexer;
136                         if (incResult1.Error())
137                         {
138                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
139                         }
140                         match.hit = true;
141                     }
142                     if (match.hit)
143                     {
144                         #if (DEBUG)
145                             if (parser_debug_write_to_log)
146                             {
147                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
148                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
149                             }
150                         #endif
151                         Token token = lexer.GetToken(pos);
152                         auto numberResult = System.Json.ParseNumber(token);
153                         if (numberResult.Error())
154                         {
155                             return System.Result<System.Parsing.Match>(ErrorId(numberResult.GetErrorId()));
156                         }
157                         return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Json.JsonNumber(numberResult.Value())));
158                     }
159                     *parentMatch2 = match;
160                 }
161                 if (match.hit)
162                 {
163                     *parentMatch0 = match;
164                 }
165                 break;
166             }
167             case LBRACE:
168             {
169                 System.Parsing.Match match(false);
170                 System.Parsing.Match* parentMatch3 = &match;
171                 {
172                     long pos = lexer.GetPos();
173                     System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Object(lexer);
174                     if (matchResult.Error())
175                     {
176                         return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
177                     }
178                     System.Parsing.Match match = matchResult.Value();
179                     o.Reset(cast<System.Json.JsonObject*>(match.value));
180                     if (match.hit)
181                     {
182                         #if (DEBUG)
183                             if (parser_debug_write_to_log)
184                             {
185                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
186                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
187                             }
188                         #endif
189                         return System.Result<System.Parsing.Match>(System.Parsing.Match(trueo.Release()));
190                     }
191                     *parentMatch3 = match;
192                 }
193                 if (match.hit)
194                 {
195                     *parentMatch0 = match;
196                 }
197                 break;
198             }
199             case LBRACKET:
200             {
201                 System.Parsing.Match match(false);
202                 System.Parsing.Match* parentMatch4 = &match;
203                 {
204                     long pos = lexer.GetPos();
205                     System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Array(lexer);
206                     if (matchResult.Error())
207                     {
208                         return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
209                     }
210                     System.Parsing.Match match = matchResult.Value();
211                     a.Reset(cast<System.Json.JsonArray*>(match.value));
212                     if (match.hit)
213                     {
214                         #if (DEBUG)
215                             if (parser_debug_write_to_log)
216                             {
217                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
218                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
219                             }
220                         #endif
221                         return System.Result<System.Parsing.Match>(System.Parsing.Match(truea.Release()));
222                     }
223                     *parentMatch4 = match;
224                 }
225                 if (match.hit)
226                 {
227                     *parentMatch0 = match;
228                 }
229                 break;
230             }
231             case TRUE:
232             {
233                 System.Parsing.Match match(false);
234                 System.Parsing.Match* parentMatch5 = &match;
235                 {
236                     long pos = lexer.GetPos();
237                     System.Parsing.Match match(false);
238                     if (*lexer == TRUE)
239                     {
240                         auto incResult2 = ++lexer;
241                         if (incResult2.Error())
242                         {
243                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult2.GetErrorId()));
244                         }
245                         match.hit = true;
246                     }
247                     if (match.hit)
248                     {
249                         #if (DEBUG)
250                             if (parser_debug_write_to_log)
251                             {
252                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
253                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
254                             }
255                         #endif
256                         return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Json.JsonBool(true)));
257                     }
258                     *parentMatch5 = match;
259                 }
260                 if (match.hit)
261                 {
262                     *parentMatch0 = match;
263                 }
264                 break;
265             }
266             case FALSE:
267             {
268                 System.Parsing.Match match(false);
269                 System.Parsing.Match* parentMatch6 = &match;
270                 {
271                     long pos = lexer.GetPos();
272                     System.Parsing.Match match(false);
273                     if (*lexer == FALSE)
274                     {
275                         auto incResult3 = ++lexer;
276                         if (incResult3.Error())
277                         {
278                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult3.GetErrorId()));
279                         }
280                         match.hit = true;
281                     }
282                     if (match.hit)
283                     {
284                         #if (DEBUG)
285                             if (parser_debug_write_to_log)
286                             {
287                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
288                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
289                             }
290                         #endif
291                         return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Json.JsonBool(false)));
292                     }
293                     *parentMatch6 = match;
294                 }
295                 if (match.hit)
296                 {
297                     *parentMatch0 = match;
298                 }
299                 break;
300             }
301             case NULL:
302             {
303                 System.Parsing.Match match(false);
304                 System.Parsing.Match* parentMatch7 = &match;
305                 {
306                     long pos = lexer.GetPos();
307                     System.Parsing.Match match(false);
308                     if (*lexer == NULL)
309                     {
310                         auto incResult4 = ++lexer;
311                         if (incResult4.Error())
312                         {
313                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult4.GetErrorId()));
314                         }
315                         match.hit = true;
316                     }
317                     if (match.hit)
318                     {
319                         #if (DEBUG)
320                             if (parser_debug_write_to_log)
321                             {
322                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
323                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
324                             }
325                         #endif
326                         return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Json.JsonNull()));
327                     }
328                     *parentMatch7 = match;
329                 }
330                 if (match.hit)
331                 {
332                     *parentMatch0 = match;
333                 }
334                 break;
335             }
336         }
337         #if (DEBUG)
338         if (parser_debug_write_to_log)
339         {
340             if (match.hit)
341             {
342                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Value");
343                 if (result.Error())
344                 {
345                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
346                 }
347             }
348             else
349             {
350                 auto result = System.Lex.WriteFailureToLog(lexeru"Value");
351                 if (result.Error())
352                 {
353                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
354                 }
355             }
356         }
357         #endif
358         if (!match.hit)
359         {
360             match.value = null;
361         }
362         return System.Result<System.Parsing.Match>(match);
363     }
364     public static System.Result<System.Parsing.Match> Object(LexerT& lexer)
365     {
366         #if (DEBUG)
367         long parser_debug_match_pos = 0;
368         bool parser_debug_write_to_log = lexer.Log() != null;
369         if (parser_debug_write_to_log)
370         {
371             parser_debug_match_pos = lexer.GetPos();
372             auto result = System.Lex.WriteBeginRuleToLog(lexeru"Object");
373             if (result.Error())
374             {
375                 return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
376             }
377         }
378         #endif
379         System.Lex.RuleGuard<LexerT> ruleGuard(lexer4742808741454282754);
380         UniquePtr<System.Json.JsonObject> o = UniquePtr<System.Json.JsonObject>();
381         System.UniquePtr<System.Parsing.Value<bool>> field;
382         System.Parsing.Match match(false);
383         System.Parsing.Match* parentMatch0 = &match;
384         {
385             System.Parsing.Match match(false);
386             System.Parsing.Match* parentMatch1 = &match;
387             {
388                 System.Parsing.Match match(false);
389                 System.Parsing.Match* parentMatch2 = &match;
390                 {
391                     long pos = lexer.GetPos();
392                     System.Parsing.Match match(false);
393                     if (*lexer == LBRACE)
394                     {
395                         auto incResult0 = ++lexer;
396                         if (incResult0.Error())
397                         {
398                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
399                         }
400                         match.hit = true;
401                     }
402                     if (match.hit)
403                     {
404                         o.Reset(new System.Json.JsonObject());
405                     }
406                     *parentMatch2 = match;
407                 }
408                 *parentMatch1 = match;
409             }
410             if (match.hit)
411             {
412                 System.Parsing.Match match(false);
413                 System.Parsing.Match* parentMatch3 = &match;
414                 {
415                     System.Parsing.Match match(true);
416                     long save = lexer.GetPos();
417                     System.Parsing.Match* parentMatch4 = &match;
418                     {
419                         System.Parsing.Match match(false);
420                         System.Parsing.Match* parentMatch5 = &match;
421                         {
422                             System.Parsing.Match match(false);
423                             System.Parsing.Match* parentMatch6 = &match;
424                             {
425                                 System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Field(lexero.Get());
426                                 if (matchResult.Error())
427                                 {
428                                     return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
429                                 }
430                                 System.Parsing.Match match = matchResult.Value();
431                                 field.Reset(cast<System.Parsing.Value<bool>*>(match.value));
432                                 *parentMatch6 = match;
433                             }
434                             if (match.hit)
435                             {
436                                 System.Parsing.Match match(false);
437                                 System.Parsing.Match* parentMatch7 = &match;
438                                 {
439                                     System.Parsing.Match match(true);
440                                     System.Parsing.Match* parentMatch8 = &match;
441                                     {
442                                         while (true)
443                                         {
444                                             long save = lexer.GetPos();
445                                             {
446                                                 System.Parsing.Match match(false);
447                                                 System.Parsing.Match* parentMatch9 = &match;
448                                                 {
449                                                     System.Parsing.Match match(false);
450                                                     if (*lexer == COMMA)
451                                                     {
452                                                         auto incResult1 = ++lexer;
453                                                         if (incResult1.Error())
454                                                         {
455                                                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
456                                                         }
457                                                         match.hit = true;
458                                                     }
459                                                     *parentMatch9 = match;
460                                                 }
461                                                 if (match.hit)
462                                                 {
463                                                     System.Parsing.Match match(false);
464                                                     System.Parsing.Match* parentMatch10 = &match;
465                                                     {
466                                                         System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Field(lexero.Get());
467                                                         if (matchResult.Error())
468                                                         {
469                                                             return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
470                                                         }
471                                                         System.Parsing.Match match = matchResult.Value();
472                                                         field.Reset(cast<System.Parsing.Value<bool>*>(match.value));
473                                                         *parentMatch10 = match;
474                                                     }
475                                                     *parentMatch9 = match;
476                                                 }
477                                                 if (match.hit)
478                                                 {
479                                                     *parentMatch8 = match;
480                                                 }
481                                                 else
482                                                 {
483                                                     lexer.SetPos(save);
484                                                     break;
485                                                 }
486                                             }
487                                         }
488                                     }
489                                     *parentMatch7 = match;
490                                 }
491                                 *parentMatch6 = match;
492                             }
493                             *parentMatch5 = match;
494                         }
495                         if (match.hit)
496                         {
497                             *parentMatch4 = match;
498                         }
499                         else
500                         {
501                             lexer.SetPos(save);
502                         }
503                     }
504                     *parentMatch3 = match;
505                 }
506                 *parentMatch1 = match;
507             }
508             *parentMatch0 = match;
509         }
510         if (match.hit)
511         {
512             System.Parsing.Match match(false);
513             System.Parsing.Match* parentMatch11 = &match;
514             {
515                 System.Parsing.Match match(false);
516                 System.Parsing.Match* parentMatch12 = &match;
517                 {
518                     long pos = lexer.GetPos();
519                     System.Parsing.Match match(false);
520                     if (*lexer == RBRACE)
521                     {
522                         auto incResult2 = ++lexer;
523                         if (incResult2.Error())
524                         {
525                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult2.GetErrorId()));
526                         }
527                         match.hit = true;
528                     }
529                     if (match.hit)
530                     {
531                         #if (DEBUG)
532                             if (parser_debug_write_to_log)
533                             {
534                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Object");
535                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
536                             }
537                         #endif
538                         return System.Result<System.Parsing.Match>(System.Parsing.Match(trueo.Release()));
539                     }
540                     *parentMatch12 = match;
541                 }
542                 *parentMatch11 = match;
543             }
544             *parentMatch0 = match;
545         }
546         #if (DEBUG)
547         if (parser_debug_write_to_log)
548         {
549             if (match.hit)
550             {
551                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Object");
552                 if (result.Error())
553                 {
554                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
555                 }
556             }
557             else
558             {
559                 auto result = System.Lex.WriteFailureToLog(lexeru"Object");
560                 if (result.Error())
561                 {
562                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
563                 }
564             }
565         }
566         #endif
567         if (!match.hit)
568         {
569             match.value = null;
570         }
571         return System.Result<System.Parsing.Match>(match);
572     }
573     public static System.Result<System.Parsing.Match> Field(LexerT& lexerSystem.Json.JsonObject* o)
574     {
575         #if (DEBUG)
576         long parser_debug_match_pos = 0;
577         bool parser_debug_write_to_log = lexer.Log() != null;
578         if (parser_debug_write_to_log)
579         {
580             parser_debug_match_pos = lexer.GetPos();
581             auto result = System.Lex.WriteBeginRuleToLog(lexeru"Field");
582             if (result.Error())
583             {
584                 return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
585             }
586         }
587         #endif
588         System.Lex.RuleGuard<LexerT> ruleGuard(lexer4742808741454282755);
589         ustring n = ustring();
590         System.UniquePtr<System.Json.JsonValue> v;
591         System.Parsing.Match match(false);
592         System.Parsing.Match* parentMatch0 = &match;
593         {
594             long pos = lexer.GetPos();
595             System.Parsing.Match match(false);
596             System.Parsing.Match* parentMatch1 = &match;
597             {
598                 System.Parsing.Match match(false);
599                 System.Parsing.Match* parentMatch2 = &match;
600                 {
601                     System.Parsing.Match match(false);
602                     System.Parsing.Match* parentMatch3 = &match;
603                     {
604                         System.Parsing.Match match(false);
605                         System.Parsing.Match* parentMatch4 = &match;
606                         {
607                             long pos = lexer.GetPos();
608                             System.Parsing.Match match(false);
609                             if (*lexer == STRING)
610                             {
611                                 auto incResult0 = ++lexer;
612                                 if (incResult0.Error())
613                                 {
614                                     return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
615                                 }
616                                 match.hit = true;
617                             }
618                             if (match.hit)
619                             {
620                                 Token token = lexer.GetToken(pos);
621                                 auto stringLiteralResult = System.Json.ParseStringLiteral(token);
622                                 if (stringLiteralResult.Error())
623                                 {
624                                     return System.Result<System.Parsing.Match>(ErrorId(stringLiteralResult.GetErrorId()));
625                                 }
626                                 n = stringLiteralResult.Value();
627                             }
628                             *parentMatch4 = match;
629                         }
630                         *parentMatch3 = match;
631                     }
632                     if (match.hit)
633                     {
634                         System.Parsing.Match match(false);
635                         System.Parsing.Match* parentMatch5 = &match;
636                         {
637                             System.Parsing.Match match(false);
638                             if (*lexer == COLON)
639                             {
640                                 auto incResult1 = ++lexer;
641                                 if (incResult1.Error())
642                                 {
643                                     return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
644                                 }
645                                 match.hit = true;
646                             }
647                             *parentMatch5 = match;
648                         }
649                         *parentMatch3 = match;
650                     }
651                     *parentMatch2 = match;
652                 }
653                 if (match.hit)
654                 {
655                     System.Parsing.Match match(false);
656                     System.Parsing.Match* parentMatch6 = &match;
657                     {
658                         System.Parsing.Match match(false);
659                         System.Parsing.Match* parentMatch7 = &match;
660                         {
661                             long pos = lexer.GetPos();
662                             System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Value(lexer);
663                             if (matchResult.Error())
664                             {
665                                 return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
666                             }
667                             System.Parsing.Match match = matchResult.Value();
668                             v.Reset(cast<System.Json.JsonValue*>(match.value));
669                             if (match.hit)
670                             {
671                                 o->AddField(nv.Release());
672                             }
673                             *parentMatch7 = match;
674                         }
675                         *parentMatch6 = match;
676                     }
677                     *parentMatch2 = match;
678                 }
679                 *parentMatch1 = match;
680             }
681             if (match.hit)
682             {
683                 #if (DEBUG)
684                     if (parser_debug_write_to_log)
685                     {
686                         auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Field");
687                         if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
688                     }
689                 #endif
690                 return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<bool>(true)));
691             }
692             *parentMatch0 = match;
693         }
694         #if (DEBUG)
695         if (parser_debug_write_to_log)
696         {
697             if (match.hit)
698             {
699                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Field");
700                 if (result.Error())
701                 {
702                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
703                 }
704             }
705             else
706             {
707                 auto result = System.Lex.WriteFailureToLog(lexeru"Field");
708                 if (result.Error())
709                 {
710                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
711                 }
712             }
713         }
714         #endif
715         if (!match.hit)
716         {
717             match.value = null;
718         }
719         return System.Result<System.Parsing.Match>(match);
720     }
721     public static System.Result<System.Parsing.Match> Array(LexerT& lexer)
722     {
723         #if (DEBUG)
724         long parser_debug_match_pos = 0;
725         bool parser_debug_write_to_log = lexer.Log() != null;
726         if (parser_debug_write_to_log)
727         {
728             parser_debug_match_pos = lexer.GetPos();
729             auto result = System.Lex.WriteBeginRuleToLog(lexeru"Array");
730             if (result.Error())
731             {
732                 return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
733             }
734         }
735         #endif
736         System.Lex.RuleGuard<LexerT> ruleGuard(lexer4742808741454282756);
737         UniquePtr<System.Json.JsonArray> a = UniquePtr<System.Json.JsonArray>();
738         System.UniquePtr<System.Json.JsonValue> first;
739         System.UniquePtr<System.Json.JsonValue> next;
740         System.Parsing.Match match(false);
741         System.Parsing.Match* parentMatch0 = &match;
742         {
743             System.Parsing.Match match(false);
744             System.Parsing.Match* parentMatch1 = &match;
745             {
746                 System.Parsing.Match match(false);
747                 System.Parsing.Match* parentMatch2 = &match;
748                 {
749                     long pos = lexer.GetPos();
750                     System.Parsing.Match match(false);
751                     if (*lexer == LBRACKET)
752                     {
753                         auto incResult0 = ++lexer;
754                         if (incResult0.Error())
755                         {
756                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
757                         }
758                         match.hit = true;
759                     }
760                     if (match.hit)
761                     {
762                         a.Reset(new System.Json.JsonArray());
763                     }
764                     *parentMatch2 = match;
765                 }
766                 *parentMatch1 = match;
767             }
768             if (match.hit)
769             {
770                 System.Parsing.Match match(false);
771                 System.Parsing.Match* parentMatch3 = &match;
772                 {
773                     System.Parsing.Match match(true);
774                     long save = lexer.GetPos();
775                     System.Parsing.Match* parentMatch4 = &match;
776                     {
777                         System.Parsing.Match match(false);
778                         System.Parsing.Match* parentMatch5 = &match;
779                         {
780                             System.Parsing.Match match(false);
781                             System.Parsing.Match* parentMatch6 = &match;
782                             {
783                                 System.Parsing.Match match(false);
784                                 System.Parsing.Match* parentMatch7 = &match;
785                                 {
786                                     long pos = lexer.GetPos();
787                                     System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Value(lexer);
788                                     if (matchResult.Error())
789                                     {
790                                         return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
791                                     }
792                                     System.Parsing.Match match = matchResult.Value();
793                                     first.Reset(cast<System.Json.JsonValue*>(match.value));
794                                     if (match.hit)
795                                     {
796                                         a->AddItem(first.Release());
797                                     }
798                                     *parentMatch7 = match;
799                                 }
800                                 *parentMatch6 = match;
801                             }
802                             if (match.hit)
803                             {
804                                 System.Parsing.Match match(false);
805                                 System.Parsing.Match* parentMatch8 = &match;
806                                 {
807                                     System.Parsing.Match match(true);
808                                     System.Parsing.Match* parentMatch9 = &match;
809                                     {
810                                         while (true)
811                                         {
812                                             long save = lexer.GetPos();
813                                             {
814                                                 System.Parsing.Match match(false);
815                                                 System.Parsing.Match* parentMatch10 = &match;
816                                                 {
817                                                     System.Parsing.Match match(false);
818                                                     System.Parsing.Match* parentMatch11 = &match;
819                                                     {
820                                                         System.Parsing.Match match(false);
821                                                         if (*lexer == COMMA)
822                                                         {
823                                                             auto incResult1 = ++lexer;
824                                                             if (incResult1.Error())
825                                                             {
826                                                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
827                                                             }
828                                                             match.hit = true;
829                                                         }
830                                                         *parentMatch11 = match;
831                                                     }
832                                                     if (match.hit)
833                                                     {
834                                                         System.Parsing.Match match(false);
835                                                         System.Parsing.Match* parentMatch12 = &match;
836                                                         {
837                                                             System.Parsing.Match match(false);
838                                                             System.Parsing.Match* parentMatch13 = &match;
839                                                             {
840                                                                 long pos = lexer.GetPos();
841                                                                 System.Result<System.Parsing.Match> matchResult = JsonParser<LexerT>.Value(lexer);
842                                                                 if (matchResult.Error())
843                                                                 {
844                                                                     return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
845                                                                 }
846                                                                 System.Parsing.Match match = matchResult.Value();
847                                                                 next.Reset(cast<System.Json.JsonValue*>(match.value));
848                                                                 if (match.hit)
849                                                                 {
850                                                                     a->AddItem(next.Release());
851                                                                 }
852                                                                 *parentMatch13 = match;
853                                                             }
854                                                             *parentMatch12 = match;
855                                                         }
856                                                         *parentMatch11 = match;
857                                                     }
858                                                     *parentMatch10 = match;
859                                                 }
860                                                 if (match.hit)
861                                                 {
862                                                     *parentMatch9 = match;
863                                                 }
864                                                 else
865                                                 {
866                                                     lexer.SetPos(save);
867                                                     break;
868                                                 }
869                                             }
870                                         }
871                                     }
872                                     *parentMatch8 = match;
873                                 }
874                                 *parentMatch6 = match;
875                             }
876                             *parentMatch5 = match;
877                         }
878                         if (match.hit)
879                         {
880                             *parentMatch4 = match;
881                         }
882                         else
883                         {
884                             lexer.SetPos(save);
885                         }
886                     }
887                     *parentMatch3 = match;
888                 }
889                 *parentMatch1 = match;
890             }
891             *parentMatch0 = match;
892         }
893         if (match.hit)
894         {
895             System.Parsing.Match match(false);
896             System.Parsing.Match* parentMatch14 = &match;
897             {
898                 System.Parsing.Match match(false);
899                 System.Parsing.Match* parentMatch15 = &match;
900                 {
901                     long pos = lexer.GetPos();
902                     System.Parsing.Match match(false);
903                     if (*lexer == RBRACKET)
904                     {
905                         auto incResult2 = ++lexer;
906                         if (incResult2.Error())
907                         {
908                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult2.GetErrorId()));
909                         }
910                         match.hit = true;
911                     }
912                     if (match.hit)
913                     {
914                         #if (DEBUG)
915                             if (parser_debug_write_to_log)
916                             {
917                                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Array");
918                                 if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
919                             }
920                         #endif
921                         return System.Result<System.Parsing.Match>(System.Parsing.Match(truea.Release()));
922                     }
923                     *parentMatch15 = match;
924                 }
925                 *parentMatch14 = match;
926             }
927             *parentMatch0 = match;
928         }
929         #if (DEBUG)
930         if (parser_debug_write_to_log)
931         {
932             if (match.hit)
933             {
934                 auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Array");
935                 if (result.Error())
936                 {
937                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
938                 }
939             }
940             else
941             {
942                 auto result = System.Lex.WriteFailureToLog(lexeru"Array");
943                 if (result.Error())
944                 {
945                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
946                 }
947             }
948         }
949         #endif
950         if (!match.hit)
951         {
952             match.value = null;
953         }
954         return System.Result<System.Parsing.Match>(match);
955     }
956 }
957 
958 new class JsonParser<JsonLexer>;