1 // this file has been generated from 'C:/work/cmajor-mod/cmajor/masm/system/System.RegularExpressions/System.RegularExpressions.parser' using SoulCm parser generator scmpg version 5.0.0
   2 
   3 using System;
   4 using System.Lex;
   5 using System.Parsing;
   6 using System.RegularExpressions;
   7 using System.RegularExpressions.token;
   8 
   9 namespace System.RegularExpressions
  10 {
  11     public static class RegExParser<LexerT>
  12     {
  13         public static System.Result<System.RegularExpressions.Nfa> Parse(LexerT& lexerSystem.RegularExpressions.Context* context)
  14         {
  15             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> value;
  16             #if (DEBUG)
  17             if (lexer.Log() != null)
  18             {
  19                 auto result = lexer.Log()->WriteBeginRule(u"parse");
  20                 if (result.Error())
  21                 {
  22                     return System.Result<System.RegularExpressions.Nfa>(System.ErrorId(result.GetErrorId()));
  23                 }
  24                 lexer.Log()->IncIndent();
  25             }
  26             #endif
  27             auto incResult0 = ++lexer;
  28             if (incResult0.Error())
  29             {
  30                 return System.Result<System.RegularExpressions.Nfa>(System.ErrorId(incResult0.GetErrorId()));
  31             }
  32             System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.RegularExpression(lexercontext);
  33             if (matchResult.Error())
  34             {
  35                 return System.Result<System.RegularExpressions.Nfa>(System.ErrorId(matchResult.GetErrorId()));
  36             }
  37             System.Parsing.Match match = matchResult.Value();
  38             value.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
  39             #if (DEBUG)
  40             if (lexer.Log() != null)
  41             {
  42                 lexer.Log()->DecIndent();
  43                 auto result = lexer.Log()->WriteEndRule(u"parse");
  44                 if (result.Error())
  45                 {
  46                     return System.Result<System.RegularExpressions.Nfa>(System.ErrorId(result.GetErrorId()));
  47                 }
  48             }
  49             #endif
  50             if (match.hit)
  51             {
  52                 if (*lexer == System.Lex.END_TOKEN)
  53                 {
  54                     return System.Result<System.RegularExpressions.Nfa>(value->value);
  55                 }
  56                 else
  57                 {
  58                     return System.Result<System.RegularExpressions.Nfa>(lexer.GetFarthestError());
  59                 }
  60             }
  61             else
  62             {
  63                 return System.Result<System.RegularExpressions.Nfa>(lexer.GetFarthestError());
  64             }
  65         }
  66         public static System.Result<System.Parsing.Match> RegularExpression(LexerT& lexerSystem.RegularExpressions.Context* context)
  67         {
  68             #if (DEBUG)
  69             long parser_debug_match_pos = 0;
  70             bool parser_debug_write_to_log = lexer.Log() != null;
  71             if (parser_debug_write_to_log)
  72             {
  73                 parser_debug_match_pos = lexer.GetPos();
  74                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"RegularExpression");
  75                 if (result.Error())
  76                 {
  77                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
  78                 }
  79             }
  80             #endif
  81             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298945);
  82             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> alternative;
  83             System.Parsing.Match match(false);
  84             System.Parsing.Match* parentMatch0 = &match;
  85             {
  86                 long pos = lexer.GetPos();
  87                 System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Alternative(lexercontext);
  88                 if (matchResult.Error())
  89                 {
  90                     return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
  91                 }
  92                 System.Parsing.Match match = matchResult.Value();
  93                 alternative.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
  94                 if (match.hit)
  95                 {
  96                     #if (DEBUG)
  97                         if (parser_debug_write_to_log)
  98                         {
  99                             auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"RegularExpression");
 100                             if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 101                         }
 102                     #endif
 103                     return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<System.RegularExpressions.Nfa>(alternative->value)));
 104                 }
 105                 *parentMatch0 = match;
 106             }
 107             #if (DEBUG)
 108             if (parser_debug_write_to_log)
 109             {
 110                 if (match.hit)
 111                 {
 112                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"RegularExpression");
 113                     if (result.Error())
 114                     {
 115                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 116                     }
 117                 }
 118                 else
 119                 {
 120                     auto result = System.Lex.WriteFailureToLog(lexeru"RegularExpression");
 121                     if (result.Error())
 122                     {
 123                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 124                     }
 125                 }
 126             }
 127             #endif
 128             if (!match.hit)
 129             {
 130                 match.value = null;
 131             }
 132             return System.Result<System.Parsing.Match>(match);
 133         }
 134         public static System.Result<System.Parsing.Match> Alternative(LexerT& lexerSystem.RegularExpressions.Context* context)
 135         {
 136             #if (DEBUG)
 137             long parser_debug_match_pos = 0;
 138             bool parser_debug_write_to_log = lexer.Log() != null;
 139             if (parser_debug_write_to_log)
 140             {
 141                 parser_debug_match_pos = lexer.GetPos();
 142                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"Alternative");
 143                 if (result.Error())
 144                 {
 145                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 146                 }
 147             }
 148             #endif
 149             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298946);
 150             System.RegularExpressions.Nfa value = System.RegularExpressions.Nfa();
 151             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> left;
 152             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> right;
 153             System.Parsing.Match match(false);
 154             System.Parsing.Match* parentMatch0 = &match;
 155             {
 156                 long pos = lexer.GetPos();
 157                 System.Parsing.Match match(false);
 158                 System.Parsing.Match* parentMatch1 = &match;
 159                 {
 160                     System.Parsing.Match match(false);
 161                     System.Parsing.Match* parentMatch2 = &match;
 162                     {
 163                         System.Parsing.Match match(false);
 164                         System.Parsing.Match* parentMatch3 = &match;
 165                         {
 166                             long pos = lexer.GetPos();
 167                             System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Catenation(lexercontext);
 168                             if (matchResult.Error())
 169                             {
 170                                 return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
 171                             }
 172                             System.Parsing.Match match = matchResult.Value();
 173                             left.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
 174                             if (match.hit)
 175                             {
 176                                 value = left->value;
 177                             }
 178                             *parentMatch3 = match;
 179                         }
 180                         *parentMatch2 = match;
 181                     }
 182                     if (match.hit)
 183                     {
 184                         System.Parsing.Match match(false);
 185                         System.Parsing.Match* parentMatch4 = &match;
 186                         {
 187                             System.Parsing.Match match(true);
 188                             System.Parsing.Match* parentMatch5 = &match;
 189                             {
 190                                 while (true)
 191                                 {
 192                                     long save = lexer.GetPos();
 193                                     {
 194                                         System.Parsing.Match match(false);
 195                                         System.Parsing.Match* parentMatch6 = &match;
 196                                         {
 197                                             System.Parsing.Match match(false);
 198                                             System.Parsing.Match* parentMatch7 = &match;
 199                                             {
 200                                                 System.Parsing.Match match(false);
 201                                                 if (*lexer == ALT)
 202                                                 {
 203                                                     auto incResult0 = ++lexer;
 204                                                     if (incResult0.Error())
 205                                                     {
 206                                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
 207                                                     }
 208                                                     match.hit = true;
 209                                                 }
 210                                                 *parentMatch7 = match;
 211                                             }
 212                                             if (match.hit)
 213                                             {
 214                                                 System.Parsing.Match match(false);
 215                                                 System.Parsing.Match* parentMatch8 = &match;
 216                                                 {
 217                                                     System.Parsing.Match match(false);
 218                                                     System.Parsing.Match* parentMatch9 = &match;
 219                                                     {
 220                                                         long pos = lexer.GetPos();
 221                                                         System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Catenation(lexercontext);
 222                                                         if (matchResult.Error())
 223                                                         {
 224                                                             return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
 225                                                         }
 226                                                         System.Parsing.Match match = matchResult.Value();
 227                                                         right.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
 228                                                         if (match.hit)
 229                                                         {
 230                                                             value = System.RegularExpressions.Alt(*contextvalueright->value);
 231                                                         }
 232                                                         *parentMatch9 = match;
 233                                                     }
 234                                                     *parentMatch8 = match;
 235                                                 }
 236                                                 *parentMatch7 = match;
 237                                             }
 238                                             *parentMatch6 = match;
 239                                         }
 240                                         if (match.hit)
 241                                         {
 242                                             *parentMatch5 = match;
 243                                         }
 244                                         else
 245                                         {
 246                                             lexer.SetPos(save);
 247                                             break;
 248                                         }
 249                                     }
 250                                 }
 251                             }
 252                             *parentMatch4 = match;
 253                         }
 254                         *parentMatch2 = match;
 255                     }
 256                     *parentMatch1 = match;
 257                 }
 258                 if (match.hit)
 259                 {
 260                     #if (DEBUG)
 261                         if (parser_debug_write_to_log)
 262                         {
 263                             auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Alternative");
 264                             if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 265                         }
 266                     #endif
 267                     return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<System.RegularExpressions.Nfa>(value)));
 268                 }
 269                 *parentMatch0 = match;
 270             }
 271             #if (DEBUG)
 272             if (parser_debug_write_to_log)
 273             {
 274                 if (match.hit)
 275                 {
 276                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Alternative");
 277                     if (result.Error())
 278                     {
 279                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 280                     }
 281                 }
 282                 else
 283                 {
 284                     auto result = System.Lex.WriteFailureToLog(lexeru"Alternative");
 285                     if (result.Error())
 286                     {
 287                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 288                     }
 289                 }
 290             }
 291             #endif
 292             if (!match.hit)
 293             {
 294                 match.value = null;
 295             }
 296             return System.Result<System.Parsing.Match>(match);
 297         }
 298         public static System.Result<System.Parsing.Match> Catenation(LexerT& lexerSystem.RegularExpressions.Context* context)
 299         {
 300             #if (DEBUG)
 301             long parser_debug_match_pos = 0;
 302             bool parser_debug_write_to_log = lexer.Log() != null;
 303             if (parser_debug_write_to_log)
 304             {
 305                 parser_debug_match_pos = lexer.GetPos();
 306                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"Catenation");
 307                 if (result.Error())
 308                 {
 309                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 310                 }
 311             }
 312             #endif
 313             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298947);
 314             System.RegularExpressions.Nfa value = System.RegularExpressions.Nfa();
 315             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> left;
 316             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> right;
 317             System.Parsing.Match match(false);
 318             System.Parsing.Match* parentMatch0 = &match;
 319             {
 320                 long pos = lexer.GetPos();
 321                 System.Parsing.Match match(false);
 322                 System.Parsing.Match* parentMatch1 = &match;
 323                 {
 324                     System.Parsing.Match match(false);
 325                     System.Parsing.Match* parentMatch2 = &match;
 326                     {
 327                         System.Parsing.Match match(false);
 328                         System.Parsing.Match* parentMatch3 = &match;
 329                         {
 330                             long pos = lexer.GetPos();
 331                             System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Repetition(lexercontext);
 332                             if (matchResult.Error())
 333                             {
 334                                 return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
 335                             }
 336                             System.Parsing.Match match = matchResult.Value();
 337                             left.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
 338                             if (match.hit)
 339                             {
 340                                 value = left->value;
 341                             }
 342                             *parentMatch3 = match;
 343                         }
 344                         *parentMatch2 = match;
 345                     }
 346                     if (match.hit)
 347                     {
 348                         System.Parsing.Match match(false);
 349                         System.Parsing.Match* parentMatch4 = &match;
 350                         {
 351                             System.Parsing.Match match(true);
 352                             System.Parsing.Match* parentMatch5 = &match;
 353                             {
 354                                 while (true)
 355                                 {
 356                                     long save = lexer.GetPos();
 357                                     {
 358                                         System.Parsing.Match match(false);
 359                                         System.Parsing.Match* parentMatch6 = &match;
 360                                         {
 361                                             System.Parsing.Match match(false);
 362                                             System.Parsing.Match* parentMatch7 = &match;
 363                                             {
 364                                                 long pos = lexer.GetPos();
 365                                                 System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Repetition(lexercontext);
 366                                                 if (matchResult.Error())
 367                                                 {
 368                                                     return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
 369                                                 }
 370                                                 System.Parsing.Match match = matchResult.Value();
 371                                                 right.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
 372                                                 if (match.hit)
 373                                                 {
 374                                                     value = System.RegularExpressions.Cat(valueright->value);
 375                                                 }
 376                                                 *parentMatch7 = match;
 377                                             }
 378                                             *parentMatch6 = match;
 379                                         }
 380                                         if (match.hit)
 381                                         {
 382                                             *parentMatch5 = match;
 383                                         }
 384                                         else
 385                                         {
 386                                             lexer.SetPos(save);
 387                                             break;
 388                                         }
 389                                     }
 390                                 }
 391                             }
 392                             *parentMatch4 = match;
 393                         }
 394                         *parentMatch2 = match;
 395                     }
 396                     *parentMatch1 = match;
 397                 }
 398                 if (match.hit)
 399                 {
 400                     #if (DEBUG)
 401                         if (parser_debug_write_to_log)
 402                         {
 403                             auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Catenation");
 404                             if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 405                         }
 406                     #endif
 407                     return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<System.RegularExpressions.Nfa>(value)));
 408                 }
 409                 *parentMatch0 = match;
 410             }
 411             #if (DEBUG)
 412             if (parser_debug_write_to_log)
 413             {
 414                 if (match.hit)
 415                 {
 416                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Catenation");
 417                     if (result.Error())
 418                     {
 419                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 420                     }
 421                 }
 422                 else
 423                 {
 424                     auto result = System.Lex.WriteFailureToLog(lexeru"Catenation");
 425                     if (result.Error())
 426                     {
 427                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 428                     }
 429                 }
 430             }
 431             #endif
 432             if (!match.hit)
 433             {
 434                 match.value = null;
 435             }
 436             return System.Result<System.Parsing.Match>(match);
 437         }
 438         public static System.Result<System.Parsing.Match> Repetition(LexerT& lexerSystem.RegularExpressions.Context* context)
 439         {
 440             #if (DEBUG)
 441             long parser_debug_match_pos = 0;
 442             bool parser_debug_write_to_log = lexer.Log() != null;
 443             if (parser_debug_write_to_log)
 444             {
 445                 parser_debug_match_pos = lexer.GetPos();
 446                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"Repetition");
 447                 if (result.Error())
 448                 {
 449                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 450                 }
 451             }
 452             #endif
 453             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298948);
 454             System.RegularExpressions.Nfa value = System.RegularExpressions.Nfa();
 455             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> left;
 456             System.Parsing.Match match(false);
 457             System.Parsing.Match* parentMatch0 = &match;
 458             {
 459                 long pos = lexer.GetPos();
 460                 System.Parsing.Match match(false);
 461                 System.Parsing.Match* parentMatch1 = &match;
 462                 {
 463                     System.Parsing.Match match(false);
 464                     System.Parsing.Match* parentMatch2 = &match;
 465                     {
 466                         System.Parsing.Match match(false);
 467                         System.Parsing.Match* parentMatch3 = &match;
 468                         {
 469                             long pos = lexer.GetPos();
 470                             System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Primary(lexercontext);
 471                             if (matchResult.Error())
 472                             {
 473                                 return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
 474                             }
 475                             System.Parsing.Match match = matchResult.Value();
 476                             left.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
 477                             if (match.hit)
 478                             {
 479                                 value = left->value;
 480                             }
 481                             *parentMatch3 = match;
 482                         }
 483                         *parentMatch2 = match;
 484                     }
 485                     if (match.hit)
 486                     {
 487                         System.Parsing.Match match(false);
 488                         System.Parsing.Match* parentMatch4 = &match;
 489                         {
 490                             System.Parsing.Match match(true);
 491                             long save = lexer.GetPos();
 492                             System.Parsing.Match* parentMatch5 = &match;
 493                             {
 494                                 System.Parsing.Match match(false);
 495                                 System.Parsing.Match* parentMatch6 = &match;
 496                                 {
 497                                     System.Parsing.Match match(false);
 498                                     System.Parsing.Match* parentMatch7 = &match;
 499                                     switch (*lexer)
 500                                     {
 501                                         case STAR:
 502                                         {
 503                                             System.Parsing.Match match(false);
 504                                             System.Parsing.Match* parentMatch8 = &match;
 505                                             {
 506                                                 long pos = lexer.GetPos();
 507                                                 System.Parsing.Match match(false);
 508                                                 if (*lexer == STAR)
 509                                                 {
 510                                                     auto incResult0 = ++lexer;
 511                                                     if (incResult0.Error())
 512                                                     {
 513                                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
 514                                                     }
 515                                                     match.hit = true;
 516                                                 }
 517                                                 if (match.hit)
 518                                                 {
 519                                                     value = System.RegularExpressions.Kleene(*contextvalue);
 520                                                 }
 521                                                 *parentMatch8 = match;
 522                                             }
 523                                             if (match.hit)
 524                                             {
 525                                                 *parentMatch7 = match;
 526                                             }
 527                                             break;
 528                                         }
 529                                         case PLUS:
 530                                         {
 531                                             System.Parsing.Match match(false);
 532                                             System.Parsing.Match* parentMatch9 = &match;
 533                                             {
 534                                                 long pos = lexer.GetPos();
 535                                                 System.Parsing.Match match(false);
 536                                                 if (*lexer == PLUS)
 537                                                 {
 538                                                     auto incResult1 = ++lexer;
 539                                                     if (incResult1.Error())
 540                                                     {
 541                                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
 542                                                     }
 543                                                     match.hit = true;
 544                                                 }
 545                                                 if (match.hit)
 546                                                 {
 547                                                     value = System.RegularExpressions.Pos(*contextvalue);
 548                                                 }
 549                                                 *parentMatch9 = match;
 550                                             }
 551                                             if (match.hit)
 552                                             {
 553                                                 *parentMatch7 = match;
 554                                             }
 555                                             break;
 556                                         }
 557                                         case QUEST:
 558                                         {
 559                                             System.Parsing.Match match(false);
 560                                             System.Parsing.Match* parentMatch10 = &match;
 561                                             {
 562                                                 long pos = lexer.GetPos();
 563                                                 System.Parsing.Match match(false);
 564                                                 if (*lexer == QUEST)
 565                                                 {
 566                                                     auto incResult2 = ++lexer;
 567                                                     if (incResult2.Error())
 568                                                     {
 569                                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult2.GetErrorId()));
 570                                                     }
 571                                                     match.hit = true;
 572                                                 }
 573                                                 if (match.hit)
 574                                                 {
 575                                                     value = System.RegularExpressions.Opt(*contextvalue);
 576                                                 }
 577                                                 *parentMatch10 = match;
 578                                             }
 579                                             if (match.hit)
 580                                             {
 581                                                 *parentMatch7 = match;
 582                                             }
 583                                             break;
 584                                         }
 585                                     }
 586                                     *parentMatch6 = match;
 587                                 }
 588                                 if (match.hit)
 589                                 {
 590                                     *parentMatch5 = match;
 591                                 }
 592                                 else
 593                                 {
 594                                     lexer.SetPos(save);
 595                                 }
 596                             }
 597                             *parentMatch4 = match;
 598                         }
 599                         *parentMatch2 = match;
 600                     }
 601                     *parentMatch1 = match;
 602                 }
 603                 if (match.hit)
 604                 {
 605                     #if (DEBUG)
 606                         if (parser_debug_write_to_log)
 607                         {
 608                             auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Repetition");
 609                             if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 610                         }
 611                     #endif
 612                     return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<System.RegularExpressions.Nfa>(value)));
 613                 }
 614                 *parentMatch0 = match;
 615             }
 616             #if (DEBUG)
 617             if (parser_debug_write_to_log)
 618             {
 619                 if (match.hit)
 620                 {
 621                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Repetition");
 622                     if (result.Error())
 623                     {
 624                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 625                     }
 626                 }
 627                 else
 628                 {
 629                     auto result = System.Lex.WriteFailureToLog(lexeru"Repetition");
 630                     if (result.Error())
 631                     {
 632                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 633                     }
 634                 }
 635             }
 636             #endif
 637             if (!match.hit)
 638             {
 639                 match.value = null;
 640             }
 641             return System.Result<System.Parsing.Match>(match);
 642         }
 643         public static System.Result<System.Parsing.Match> Primary(LexerT& lexerSystem.RegularExpressions.Context* context)
 644         {
 645             #if (DEBUG)
 646             long parser_debug_match_pos = 0;
 647             bool parser_debug_write_to_log = lexer.Log() != null;
 648             if (parser_debug_write_to_log)
 649             {
 650                 parser_debug_match_pos = lexer.GetPos();
 651                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"Primary");
 652                 if (result.Error())
 653                 {
 654                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 655                 }
 656             }
 657             #endif
 658             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298949);
 659             System.RegularExpressions.Nfa value = System.RegularExpressions.Nfa();
 660             System.UniquePtr<System.Parsing.Value<System.RegularExpressions.Nfa>> alt;
 661             System.UniquePtr<System.RegularExpressions.Class> cls;
 662             System.Parsing.Match match(false);
 663             System.Parsing.Match* parentMatch0 = &match;
 664             {
 665                 long pos = lexer.GetPos();
 666                 System.Parsing.Match match(false);
 667                 System.Parsing.Match* parentMatch1 = &match;
 668                 {
 669                     System.Parsing.Match match(false);
 670                     System.Parsing.Match* parentMatch2 = &match;
 671                     switch (*lexer)
 672                     {
 673                         case LPAREN:
 674                         {
 675                             System.Parsing.Match match(false);
 676                             System.Parsing.Match* parentMatch3 = &match;
 677                             {
 678                                 System.Parsing.Match match(false);
 679                                 System.Parsing.Match* parentMatch4 = &match;
 680                                 {
 681                                     System.Parsing.Match match(false);
 682                                     if (*lexer == LPAREN)
 683                                     {
 684                                         auto incResult0 = ++lexer;
 685                                         if (incResult0.Error())
 686                                         {
 687                                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
 688                                         }
 689                                         match.hit = true;
 690                                     }
 691                                     *parentMatch4 = match;
 692                                 }
 693                                 if (match.hit)
 694                                 {
 695                                     System.Parsing.Match match(false);
 696                                     System.Parsing.Match* parentMatch5 = &match;
 697                                     {
 698                                         System.Parsing.Match match(false);
 699                                         System.Parsing.Match* parentMatch6 = &match;
 700                                         {
 701                                             long pos = lexer.GetPos();
 702                                             System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Alternative(lexercontext);
 703                                             if (matchResult.Error())
 704                                             {
 705                                                 return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
 706                                             }
 707                                             System.Parsing.Match match = matchResult.Value();
 708                                             alt.Reset(cast<System.Parsing.Value<System.RegularExpressions.Nfa>*>(match.value));
 709                                             if (match.hit)
 710                                             {
 711                                                 value = alt->value;
 712                                             }
 713                                             *parentMatch6 = match;
 714                                         }
 715                                         *parentMatch5 = match;
 716                                     }
 717                                     *parentMatch4 = match;
 718                                 }
 719                                 *parentMatch3 = match;
 720                             }
 721                             if (match.hit)
 722                             {
 723                                 System.Parsing.Match match(false);
 724                                 System.Parsing.Match* parentMatch7 = &match;
 725                                 {
 726                                     System.Parsing.Match match(false);
 727                                     if (*lexer == RPAREN)
 728                                     {
 729                                         auto incResult1 = ++lexer;
 730                                         if (incResult1.Error())
 731                                         {
 732                                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
 733                                         }
 734                                         match.hit = true;
 735                                     }
 736                                     *parentMatch7 = match;
 737                                 }
 738                                 *parentMatch3 = match;
 739                             }
 740                             if (match.hit)
 741                             {
 742                                 *parentMatch2 = match;
 743                             }
 744                             break;
 745                         }
 746                         case ESCAPE:
 747                         {
 748                             System.Parsing.Match match(false);
 749                             System.Parsing.Match* parentMatch8 = &match;
 750                             {
 751                                 long pos = lexer.GetPos();
 752                                 System.Parsing.Match match(false);
 753                                 if (*lexer == ESCAPE)
 754                                 {
 755                                     auto incResult2 = ++lexer;
 756                                     if (incResult2.Error())
 757                                     {
 758                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult2.GetErrorId()));
 759                                     }
 760                                     match.hit = true;
 761                                 }
 762                                 if (match.hit)
 763                                 {
 764                                     auto escape = System.RegularExpressions.MakeEscapeValue(lexer.FileName()lexer.GetToken(pos));
 765                                     if (escape.Error())
 766                                     {
 767                                         return System.Result<System.Parsing.Match>(ErrorId(escape.GetErrorId()));
 768                                     }
 769                                     value = System.RegularExpressions.MakeNfa(*contextcontext->MakeChar(escape.Value()));
 770                                 }
 771                                 *parentMatch8 = match;
 772                             }
 773                             if (match.hit)
 774                             {
 775                                 *parentMatch2 = match;
 776                             }
 777                             break;
 778                         }
 779                         case INVERSE:
 780                         {
 781                             System.Parsing.Match match(false);
 782                             System.Parsing.Match* parentMatch9 = &match;
 783                             {
 784                                 long pos = lexer.GetPos();
 785                                 System.Parsing.Match match(false);
 786                                 if (*lexer == INVERSE)
 787                                 {
 788                                     auto incResult3 = ++lexer;
 789                                     if (incResult3.Error())
 790                                     {
 791                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult3.GetErrorId()));
 792                                     }
 793                                     match.hit = true;
 794                                 }
 795                                 if (match.hit)
 796                                 {
 797                                     value = System.RegularExpressions.MakeNfa(*contextcontext->MakeChar('^'));
 798                                 }
 799                                 *parentMatch9 = match;
 800                             }
 801                             if (match.hit)
 802                             {
 803                                 *parentMatch2 = match;
 804                             }
 805                             break;
 806                         }
 807                         case MINUS:
 808                         {
 809                             System.Parsing.Match match(false);
 810                             System.Parsing.Match* parentMatch10 = &match;
 811                             {
 812                                 long pos = lexer.GetPos();
 813                                 System.Parsing.Match match(false);
 814                                 if (*lexer == MINUS)
 815                                 {
 816                                     auto incResult4 = ++lexer;
 817                                     if (incResult4.Error())
 818                                     {
 819                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult4.GetErrorId()));
 820                                     }
 821                                     match.hit = true;
 822                                 }
 823                                 if (match.hit)
 824                                 {
 825                                     value = System.RegularExpressions.MakeNfa(*contextcontext->MakeChar('-'));
 826                                 }
 827                                 *parentMatch10 = match;
 828                             }
 829                             if (match.hit)
 830                             {
 831                                 *parentMatch2 = match;
 832                             }
 833                             break;
 834                         }
 835                         case CHAR:
 836                         {
 837                             System.Parsing.Match match(false);
 838                             System.Parsing.Match* parentMatch11 = &match;
 839                             {
 840                                 long pos = lexer.GetPos();
 841                                 System.Parsing.Match match(false);
 842                                 if (*lexer == CHAR)
 843                                 {
 844                                     auto incResult5 = ++lexer;
 845                                     if (incResult5.Error())
 846                                     {
 847                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult5.GetErrorId()));
 848                                     }
 849                                     match.hit = true;
 850                                 }
 851                                 if (match.hit)
 852                                 {
 853                                     ustring match = lexer.GetToken(pos).ToString();
 854                                     value = System.RegularExpressions.MakeNfa(*contextcontext->MakeChar(match[0]));
 855                                 }
 856                                 *parentMatch11 = match;
 857                             }
 858                             if (match.hit)
 859                             {
 860                                 *parentMatch2 = match;
 861                             }
 862                             break;
 863                         }
 864                         case DOT:
 865                         {
 866                             System.Parsing.Match match(false);
 867                             System.Parsing.Match* parentMatch12 = &match;
 868                             {
 869                                 long pos = lexer.GetPos();
 870                                 System.Parsing.Match match(false);
 871                                 if (*lexer == DOT)
 872                                 {
 873                                     auto incResult6 = ++lexer;
 874                                     if (incResult6.Error())
 875                                     {
 876                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult6.GetErrorId()));
 877                                     }
 878                                     match.hit = true;
 879                                 }
 880                                 if (match.hit)
 881                                 {
 882                                     value = System.RegularExpressions.MakeNfa(*contextcontext->MakeAny());
 883                                 }
 884                                 *parentMatch12 = match;
 885                             }
 886                             if (match.hit)
 887                             {
 888                                 *parentMatch2 = match;
 889                             }
 890                             break;
 891                         }
 892                         case LBRACKET:
 893                         {
 894                             System.Parsing.Match match(false);
 895                             System.Parsing.Match* parentMatch13 = &match;
 896                             {
 897                                 long pos = lexer.GetPos();
 898                                 System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Class(lexercontext);
 899                                 if (matchResult.Error())
 900                                 {
 901                                     return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
 902                                 }
 903                                 System.Parsing.Match match = matchResult.Value();
 904                                 cls.Reset(cast<System.RegularExpressions.Class*>(match.value));
 905                                 if (match.hit)
 906                                 {
 907                                     value = System.RegularExpressions.MakeNfa(*contextcls.Release());
 908                                 }
 909                                 *parentMatch13 = match;
 910                             }
 911                             if (match.hit)
 912                             {
 913                                 *parentMatch2 = match;
 914                             }
 915                             break;
 916                         }
 917                     }
 918                     *parentMatch1 = match;
 919                 }
 920                 if (match.hit)
 921                 {
 922                     #if (DEBUG)
 923                         if (parser_debug_write_to_log)
 924                         {
 925                             auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Primary");
 926                             if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 927                         }
 928                     #endif
 929                     return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<System.RegularExpressions.Nfa>(value)));
 930                 }
 931                 *parentMatch0 = match;
 932             }
 933             #if (DEBUG)
 934             if (parser_debug_write_to_log)
 935             {
 936                 if (match.hit)
 937                 {
 938                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Primary");
 939                     if (result.Error())
 940                     {
 941                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 942                     }
 943                 }
 944                 else
 945                 {
 946                     auto result = System.Lex.WriteFailureToLog(lexeru"Primary");
 947                     if (result.Error())
 948                     {
 949                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 950                     }
 951                 }
 952             }
 953             #endif
 954             if (!match.hit)
 955             {
 956                 match.value = null;
 957             }
 958             return System.Result<System.Parsing.Match>(match);
 959         }
 960         public static System.Result<System.Parsing.Match> Class(LexerT& lexerSystem.RegularExpressions.Context* context)
 961         {
 962             #if (DEBUG)
 963             long parser_debug_match_pos = 0;
 964             bool parser_debug_write_to_log = lexer.Log() != null;
 965             if (parser_debug_write_to_log)
 966             {
 967                 parser_debug_match_pos = lexer.GetPos();
 968                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"Class");
 969                 if (result.Error())
 970                 {
 971                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
 972                 }
 973             }
 974             #endif
 975             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298950);
 976             System.RegularExpressions.Class* cls = null;
 977             System.UniquePtr<System.RegularExpressions.Symbol> r;
 978             System.Parsing.Match match(false);
 979             System.Parsing.Match* parentMatch0 = &match;
 980             {
 981                 long pos = lexer.GetPos();
 982                 System.Parsing.Match match(false);
 983                 System.Parsing.Match* parentMatch1 = &match;
 984                 {
 985                     System.Parsing.Match match(false);
 986                     System.Parsing.Match* parentMatch2 = &match;
 987                     {
 988                         System.Parsing.Match match(false);
 989                         System.Parsing.Match* parentMatch3 = &match;
 990                         {
 991                             System.Parsing.Match match(false);
 992                             System.Parsing.Match* parentMatch4 = &match;
 993                             {
 994                                 long pos = lexer.GetPos();
 995                                 System.Parsing.Match match(false);
 996                                 if (*lexer == LBRACKET)
 997                                 {
 998                                     auto incResult0 = ++lexer;
 999                                     if (incResult0.Error())
1000                                     {
1001                                         return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
1002                                     }
1003                                     match.hit = true;
1004                                 }
1005                                 if (match.hit)
1006                                 {
1007                                     cls = context->MakeClass();
1008                                 }
1009                                 *parentMatch4 = match;
1010                             }
1011                             *parentMatch3 = match;
1012                         }
1013                         if (match.hit)
1014                         {
1015                             System.Parsing.Match match(false);
1016                             System.Parsing.Match* parentMatch5 = &match;
1017                             {
1018                                 System.Parsing.Match match(false);
1019                                 System.Parsing.Match* parentMatch6 = &match;
1020                                 {
1021                                     System.Parsing.Match match(false);
1022                                     System.Parsing.Match* parentMatch7 = &match;
1023                                     {
1024                                         System.Parsing.Match match(true);
1025                                         long save = lexer.GetPos();
1026                                         System.Parsing.Match* parentMatch8 = &match;
1027                                         {
1028                                             System.Parsing.Match match(false);
1029                                             System.Parsing.Match* parentMatch9 = &match;
1030                                             {
1031                                                 System.Parsing.Match match(false);
1032                                                 System.Parsing.Match* parentMatch10 = &match;
1033                                                 {
1034                                                     long pos = lexer.GetPos();
1035                                                     System.Parsing.Match match(false);
1036                                                     if (*lexer == INVERSE)
1037                                                     {
1038                                                         auto incResult1 = ++lexer;
1039                                                         if (incResult1.Error())
1040                                                         {
1041                                                             return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
1042                                                         }
1043                                                         match.hit = true;
1044                                                     }
1045                                                     if (match.hit)
1046                                                     {
1047                                                         cls->SetInverse();
1048                                                     }
1049                                                     *parentMatch10 = match;
1050                                                 }
1051                                                 *parentMatch9 = match;
1052                                             }
1053                                             if (match.hit)
1054                                             {
1055                                                 *parentMatch8 = match;
1056                                             }
1057                                             else
1058                                             {
1059                                                 lexer.SetPos(save);
1060                                             }
1061                                         }
1062                                         *parentMatch7 = match;
1063                                     }
1064                                     if (match.hit)
1065                                     {
1066                                         System.Parsing.Match match(false);
1067                                         System.Parsing.Match* parentMatch11 = &match;
1068                                         {
1069                                             System.Parsing.Match match(true);
1070                                             System.Parsing.Match* parentMatch12 = &match;
1071                                             {
1072                                                 while (true)
1073                                                 {
1074                                                     long save = lexer.GetPos();
1075                                                     {
1076                                                         System.Parsing.Match match(false);
1077                                                         System.Parsing.Match* parentMatch13 = &match;
1078                                                         {
1079                                                             System.Parsing.Match match(false);
1080                                                             System.Parsing.Match* parentMatch14 = &match;
1081                                                             {
1082                                                                 long pos = lexer.GetPos();
1083                                                                 System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Range(lexercontext);
1084                                                                 if (matchResult.Error())
1085                                                                 {
1086                                                                     return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
1087                                                                 }
1088                                                                 System.Parsing.Match match = matchResult.Value();
1089                                                                 r.Reset(cast<System.RegularExpressions.Symbol*>(match.value));
1090                                                                 if (match.hit)
1091                                                                 {
1092                                                                     cls->AddSymbol(r.Release());
1093                                                                 }
1094                                                                 *parentMatch14 = match;
1095                                                             }
1096                                                             *parentMatch13 = match;
1097                                                         }
1098                                                         if (match.hit)
1099                                                         {
1100                                                             *parentMatch12 = match;
1101                                                         }
1102                                                         else
1103                                                         {
1104                                                             lexer.SetPos(save);
1105                                                             break;
1106                                                         }
1107                                                     }
1108                                                 }
1109                                             }
1110                                             *parentMatch11 = match;
1111                                         }
1112                                         *parentMatch7 = match;
1113                                     }
1114                                     *parentMatch6 = match;
1115                                 }
1116                                 *parentMatch5 = match;
1117                             }
1118                             *parentMatch3 = match;
1119                         }
1120                         *parentMatch2 = match;
1121                     }
1122                     if (match.hit)
1123                     {
1124                         System.Parsing.Match match(false);
1125                         System.Parsing.Match* parentMatch15 = &match;
1126                         {
1127                             System.Parsing.Match match(false);
1128                             if (*lexer == RBRACKET)
1129                             {
1130                                 auto incResult2 = ++lexer;
1131                                 if (incResult2.Error())
1132                                 {
1133                                     return System.Result<System.Parsing.Match>(System.ErrorId(incResult2.GetErrorId()));
1134                                 }
1135                                 match.hit = true;
1136                             }
1137                             *parentMatch15 = match;
1138                         }
1139                         *parentMatch2 = match;
1140                     }
1141                     *parentMatch1 = match;
1142                 }
1143                 if (match.hit)
1144                 {
1145                     #if (DEBUG)
1146                         if (parser_debug_write_to_log)
1147                         {
1148                             auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Class");
1149                             if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1150                         }
1151                     #endif
1152                     return System.Result<System.Parsing.Match>(System.Parsing.Match(truecls));
1153                 }
1154                 *parentMatch0 = match;
1155             }
1156             #if (DEBUG)
1157             if (parser_debug_write_to_log)
1158             {
1159                 if (match.hit)
1160                 {
1161                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Class");
1162                     if (result.Error())
1163                     {
1164                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1165                     }
1166                 }
1167                 else
1168                 {
1169                     auto result = System.Lex.WriteFailureToLog(lexeru"Class");
1170                     if (result.Error())
1171                     {
1172                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1173                     }
1174                 }
1175             }
1176             #endif
1177             if (!match.hit)
1178             {
1179                 match.value = null;
1180             }
1181             return System.Result<System.Parsing.Match>(match);
1182         }
1183         public static System.Result<System.Parsing.Match> Range(LexerT& lexerSystem.RegularExpressions.Context* context)
1184         {
1185             #if (DEBUG)
1186             long parser_debug_match_pos = 0;
1187             bool parser_debug_write_to_log = lexer.Log() != null;
1188             if (parser_debug_write_to_log)
1189             {
1190                 parser_debug_match_pos = lexer.GetPos();
1191                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"Range");
1192                 if (result.Error())
1193                 {
1194                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1195                 }
1196             }
1197             #endif
1198             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298951);
1199             System.RegularExpressions.Symbol* symbol = null;
1200             System.UniquePtr<System.Parsing.Value<uchar>> s;
1201             System.UniquePtr<System.Parsing.Value<uchar>> e;
1202             System.Parsing.Match match(false);
1203             System.Parsing.Match* parentMatch0 = &match;
1204             {
1205                 long pos = lexer.GetPos();
1206                 System.Parsing.Match match(false);
1207                 System.Parsing.Match* parentMatch1 = &match;
1208                 {
1209                     System.Parsing.Match match(false);
1210                     System.Parsing.Match* parentMatch2 = &match;
1211                     {
1212                         System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Char(lexer);
1213                         if (matchResult.Error())
1214                         {
1215                             return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
1216                         }
1217                         System.Parsing.Match match = matchResult.Value();
1218                         s.Reset(cast<System.Parsing.Value<uchar>*>(match.value));
1219                         *parentMatch2 = match;
1220                     }
1221                     if (match.hit)
1222                     {
1223                         System.Parsing.Match match(false);
1224                         System.Parsing.Match* parentMatch3 = &match;
1225                         {
1226                             System.Parsing.Match match(false);
1227                             System.Parsing.Match* parentMatch4 = &match;
1228                             {
1229                                 System.Parsing.Match match(false);
1230                                 System.Parsing.Match* parentMatch5 = &match;
1231                                 {
1232                                     long save = lexer.GetPos();
1233                                     System.Parsing.Match match(false);
1234                                     System.Parsing.Match* parentMatch6 = &match;
1235                                     {
1236                                         System.Parsing.Match match(false);
1237                                         if (*lexer == MINUS)
1238                                         {
1239                                             auto incResult0 = ++lexer;
1240                                             if (incResult0.Error())
1241                                             {
1242                                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
1243                                             }
1244                                             match.hit = true;
1245                                         }
1246                                         *parentMatch6 = match;
1247                                     }
1248                                     if (match.hit)
1249                                     {
1250                                         System.Parsing.Match match(false);
1251                                         System.Parsing.Match* parentMatch7 = &match;
1252                                         {
1253                                             System.Parsing.Match match(false);
1254                                             System.Parsing.Match* parentMatch8 = &match;
1255                                             {
1256                                                 long pos = lexer.GetPos();
1257                                                 System.Result<System.Parsing.Match> matchResult = System.RegularExpressions.RegExParser<LexerT>.Char(lexer);
1258                                                 if (matchResult.Error())
1259                                                 {
1260                                                     return System.Result<System.Parsing.Match>(System.ErrorId(matchResult.GetErrorId()));
1261                                                 }
1262                                                 System.Parsing.Match match = matchResult.Value();
1263                                                 e.Reset(cast<System.Parsing.Value<uchar>*>(match.value));
1264                                                 if (match.hit)
1265                                                 {
1266                                                     symbol = context->MakeRange(s->valuee->value);
1267                                                 }
1268                                                 *parentMatch8 = match;
1269                                             }
1270                                             *parentMatch7 = match;
1271                                         }
1272                                         *parentMatch6 = match;
1273                                     }
1274                                     *parentMatch5 = match;
1275                                     if (!match.hit)
1276                                     {
1277                                         System.Parsing.Match match(false);
1278                                         System.Parsing.Match* parentMatch9 = &match;
1279                                         lexer.SetPos(save);
1280                                         {
1281                                             System.Parsing.Match match(false);
1282                                             System.Parsing.Match* parentMatch10 = &match;
1283                                             {
1284                                                 long pos = lexer.GetPos();
1285                                                 System.Parsing.Match match(true);
1286                                                 if (match.hit)
1287                                                 {
1288                                                     symbol = context->MakeChar(s->value);
1289                                                 }
1290                                                 *parentMatch10 = match;
1291                                             }
1292                                             *parentMatch9 = match;
1293                                         }
1294                                         *parentMatch5 = match;
1295                                     }
1296                                 }
1297                                 *parentMatch4 = match;
1298                             }
1299                             *parentMatch3 = match;
1300                         }
1301                         *parentMatch2 = match;
1302                     }
1303                     *parentMatch1 = match;
1304                 }
1305                 if (match.hit)
1306                 {
1307                     #if (DEBUG)
1308                         if (parser_debug_write_to_log)
1309                         {
1310                             auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Range");
1311                             if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1312                         }
1313                     #endif
1314                     return System.Result<System.Parsing.Match>(System.Parsing.Match(truesymbol));
1315                 }
1316                 *parentMatch0 = match;
1317             }
1318             #if (DEBUG)
1319             if (parser_debug_write_to_log)
1320             {
1321                 if (match.hit)
1322                 {
1323                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Range");
1324                     if (result.Error())
1325                     {
1326                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1327                     }
1328                 }
1329                 else
1330                 {
1331                     auto result = System.Lex.WriteFailureToLog(lexeru"Range");
1332                     if (result.Error())
1333                     {
1334                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1335                     }
1336                 }
1337             }
1338             #endif
1339             if (!match.hit)
1340             {
1341                 match.value = null;
1342             }
1343             return System.Result<System.Parsing.Match>(match);
1344         }
1345         public static System.Result<System.Parsing.Match> Char(LexerT& lexer)
1346         {
1347             #if (DEBUG)
1348             long parser_debug_match_pos = 0;
1349             bool parser_debug_write_to_log = lexer.Log() != null;
1350             if (parser_debug_write_to_log)
1351             {
1352                 parser_debug_match_pos = lexer.GetPos();
1353                 auto result = System.Lex.WriteBeginRuleToLog(lexeru"Char");
1354                 if (result.Error())
1355                 {
1356                     return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1357                 }
1358             }
1359             #endif
1360             System.Lex.RuleGuard<LexerT> ruleGuard(lexer6105989386489298952);
1361             System.Parsing.Match match(false);
1362             System.Parsing.Match* parentMatch0 = &match;
1363             switch (*lexer)
1364             {
1365                 case LPAREN:
1366                 {
1367                     System.Parsing.Match match(false);
1368                     System.Parsing.Match* parentMatch1 = &match;
1369                     {
1370                         long pos = lexer.GetPos();
1371                         System.Parsing.Match match(false);
1372                         if (*lexer == LPAREN)
1373                         {
1374                             auto incResult0 = ++lexer;
1375                             if (incResult0.Error())
1376                             {
1377                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult0.GetErrorId()));
1378                             }
1379                             match.hit = true;
1380                         }
1381                         if (match.hit)
1382                         {
1383                             #if (DEBUG)
1384                                 if (parser_debug_write_to_log)
1385                                 {
1386                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1387                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1388                                 }
1389                             #endif
1390                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('(')));
1391                         }
1392                         *parentMatch1 = match;
1393                     }
1394                     if (match.hit)
1395                     {
1396                         *parentMatch0 = match;
1397                     }
1398                     break;
1399                 }
1400                 case RPAREN:
1401                 {
1402                     System.Parsing.Match match(false);
1403                     System.Parsing.Match* parentMatch2 = &match;
1404                     {
1405                         long pos = lexer.GetPos();
1406                         System.Parsing.Match match(false);
1407                         if (*lexer == RPAREN)
1408                         {
1409                             auto incResult1 = ++lexer;
1410                             if (incResult1.Error())
1411                             {
1412                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult1.GetErrorId()));
1413                             }
1414                             match.hit = true;
1415                         }
1416                         if (match.hit)
1417                         {
1418                             #if (DEBUG)
1419                                 if (parser_debug_write_to_log)
1420                                 {
1421                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1422                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1423                                 }
1424                             #endif
1425                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>(')')));
1426                         }
1427                         *parentMatch2 = match;
1428                     }
1429                     if (match.hit)
1430                     {
1431                         *parentMatch0 = match;
1432                     }
1433                     break;
1434                 }
1435                 case LBRACKET:
1436                 {
1437                     System.Parsing.Match match(false);
1438                     System.Parsing.Match* parentMatch3 = &match;
1439                     {
1440                         long pos = lexer.GetPos();
1441                         System.Parsing.Match match(false);
1442                         if (*lexer == LBRACKET)
1443                         {
1444                             auto incResult2 = ++lexer;
1445                             if (incResult2.Error())
1446                             {
1447                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult2.GetErrorId()));
1448                             }
1449                             match.hit = true;
1450                         }
1451                         if (match.hit)
1452                         {
1453                             #if (DEBUG)
1454                                 if (parser_debug_write_to_log)
1455                                 {
1456                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1457                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1458                                 }
1459                             #endif
1460                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('[')));
1461                         }
1462                         *parentMatch3 = match;
1463                     }
1464                     if (match.hit)
1465                     {
1466                         *parentMatch0 = match;
1467                     }
1468                     break;
1469                 }
1470                 case ALT:
1471                 {
1472                     System.Parsing.Match match(false);
1473                     System.Parsing.Match* parentMatch4 = &match;
1474                     {
1475                         long pos = lexer.GetPos();
1476                         System.Parsing.Match match(false);
1477                         if (*lexer == ALT)
1478                         {
1479                             auto incResult3 = ++lexer;
1480                             if (incResult3.Error())
1481                             {
1482                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult3.GetErrorId()));
1483                             }
1484                             match.hit = true;
1485                         }
1486                         if (match.hit)
1487                         {
1488                             #if (DEBUG)
1489                                 if (parser_debug_write_to_log)
1490                                 {
1491                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1492                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1493                                 }
1494                             #endif
1495                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('|')));
1496                         }
1497                         *parentMatch4 = match;
1498                     }
1499                     if (match.hit)
1500                     {
1501                         *parentMatch0 = match;
1502                     }
1503                     break;
1504                 }
1505                 case STAR:
1506                 {
1507                     System.Parsing.Match match(false);
1508                     System.Parsing.Match* parentMatch5 = &match;
1509                     {
1510                         long pos = lexer.GetPos();
1511                         System.Parsing.Match match(false);
1512                         if (*lexer == STAR)
1513                         {
1514                             auto incResult4 = ++lexer;
1515                             if (incResult4.Error())
1516                             {
1517                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult4.GetErrorId()));
1518                             }
1519                             match.hit = true;
1520                         }
1521                         if (match.hit)
1522                         {
1523                             #if (DEBUG)
1524                                 if (parser_debug_write_to_log)
1525                                 {
1526                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1527                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1528                                 }
1529                             #endif
1530                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('*')));
1531                         }
1532                         *parentMatch5 = match;
1533                     }
1534                     if (match.hit)
1535                     {
1536                         *parentMatch0 = match;
1537                     }
1538                     break;
1539                 }
1540                 case PLUS:
1541                 {
1542                     System.Parsing.Match match(false);
1543                     System.Parsing.Match* parentMatch6 = &match;
1544                     {
1545                         long pos = lexer.GetPos();
1546                         System.Parsing.Match match(false);
1547                         if (*lexer == PLUS)
1548                         {
1549                             auto incResult5 = ++lexer;
1550                             if (incResult5.Error())
1551                             {
1552                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult5.GetErrorId()));
1553                             }
1554                             match.hit = true;
1555                         }
1556                         if (match.hit)
1557                         {
1558                             #if (DEBUG)
1559                                 if (parser_debug_write_to_log)
1560                                 {
1561                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1562                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1563                                 }
1564                             #endif
1565                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('+')));
1566                         }
1567                         *parentMatch6 = match;
1568                     }
1569                     if (match.hit)
1570                     {
1571                         *parentMatch0 = match;
1572                     }
1573                     break;
1574                 }
1575                 case QUEST:
1576                 {
1577                     System.Parsing.Match match(false);
1578                     System.Parsing.Match* parentMatch7 = &match;
1579                     {
1580                         long pos = lexer.GetPos();
1581                         System.Parsing.Match match(false);
1582                         if (*lexer == QUEST)
1583                         {
1584                             auto incResult6 = ++lexer;
1585                             if (incResult6.Error())
1586                             {
1587                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult6.GetErrorId()));
1588                             }
1589                             match.hit = true;
1590                         }
1591                         if (match.hit)
1592                         {
1593                             #if (DEBUG)
1594                                 if (parser_debug_write_to_log)
1595                                 {
1596                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1597                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1598                                 }
1599                             #endif
1600                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('?')));
1601                         }
1602                         *parentMatch7 = match;
1603                     }
1604                     if (match.hit)
1605                     {
1606                         *parentMatch0 = match;
1607                     }
1608                     break;
1609                 }
1610                 case DOT:
1611                 {
1612                     System.Parsing.Match match(false);
1613                     System.Parsing.Match* parentMatch8 = &match;
1614                     {
1615                         long pos = lexer.GetPos();
1616                         System.Parsing.Match match(false);
1617                         if (*lexer == DOT)
1618                         {
1619                             auto incResult7 = ++lexer;
1620                             if (incResult7.Error())
1621                             {
1622                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult7.GetErrorId()));
1623                             }
1624                             match.hit = true;
1625                         }
1626                         if (match.hit)
1627                         {
1628                             #if (DEBUG)
1629                                 if (parser_debug_write_to_log)
1630                                 {
1631                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1632                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1633                                 }
1634                             #endif
1635                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('.')));
1636                         }
1637                         *parentMatch8 = match;
1638                     }
1639                     if (match.hit)
1640                     {
1641                         *parentMatch0 = match;
1642                     }
1643                     break;
1644                 }
1645                 case ESCAPE:
1646                 {
1647                     System.Parsing.Match match(false);
1648                     System.Parsing.Match* parentMatch9 = &match;
1649                     {
1650                         long pos = lexer.GetPos();
1651                         System.Parsing.Match match(false);
1652                         if (*lexer == ESCAPE)
1653                         {
1654                             auto incResult8 = ++lexer;
1655                             if (incResult8.Error())
1656                             {
1657                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult8.GetErrorId()));
1658                             }
1659                             match.hit = true;
1660                         }
1661                         if (match.hit)
1662                         {
1663                             #if (DEBUG)
1664                                 if (parser_debug_write_to_log)
1665                                 {
1666                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1667                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1668                                 }
1669                             #endif
1670                             auto escape = System.RegularExpressions.MakeEscapeValue(lexer.FileName()lexer.GetToken(pos));
1671                             if (escape.Error())
1672                             {
1673                                 return System.Result<System.Parsing.Match>(ErrorId(escape.GetErrorId()));
1674                             }
1675                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>(escape.Value())));
1676                         }
1677                         *parentMatch9 = match;
1678                     }
1679                     if (match.hit)
1680                     {
1681                         *parentMatch0 = match;
1682                     }
1683                     break;
1684                 }
1685                 case INVERSE:
1686                 {
1687                     System.Parsing.Match match(false);
1688                     System.Parsing.Match* parentMatch10 = &match;
1689                     {
1690                         long pos = lexer.GetPos();
1691                         System.Parsing.Match match(false);
1692                         if (*lexer == INVERSE)
1693                         {
1694                             auto incResult9 = ++lexer;
1695                             if (incResult9.Error())
1696                             {
1697                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult9.GetErrorId()));
1698                             }
1699                             match.hit = true;
1700                         }
1701                         if (match.hit)
1702                         {
1703                             #if (DEBUG)
1704                                 if (parser_debug_write_to_log)
1705                                 {
1706                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1707                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1708                                 }
1709                             #endif
1710                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('^')));
1711                         }
1712                         *parentMatch10 = match;
1713                     }
1714                     if (match.hit)
1715                     {
1716                         *parentMatch0 = match;
1717                     }
1718                     break;
1719                 }
1720                 case MINUS:
1721                 {
1722                     System.Parsing.Match match(false);
1723                     System.Parsing.Match* parentMatch11 = &match;
1724                     {
1725                         long pos = lexer.GetPos();
1726                         System.Parsing.Match match(false);
1727                         if (*lexer == MINUS)
1728                         {
1729                             auto incResult10 = ++lexer;
1730                             if (incResult10.Error())
1731                             {
1732                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult10.GetErrorId()));
1733                             }
1734                             match.hit = true;
1735                         }
1736                         if (match.hit)
1737                         {
1738                             #if (DEBUG)
1739                                 if (parser_debug_write_to_log)
1740                                 {
1741                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1742                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1743                                 }
1744                             #endif
1745                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>('-')));
1746                         }
1747                         *parentMatch11 = match;
1748                     }
1749                     if (match.hit)
1750                     {
1751                         *parentMatch0 = match;
1752                     }
1753                     break;
1754                 }
1755                 case CHAR:
1756                 {
1757                     System.Parsing.Match match(false);
1758                     System.Parsing.Match* parentMatch12 = &match;
1759                     {
1760                         long pos = lexer.GetPos();
1761                         System.Parsing.Match match(false);
1762                         if (*lexer == CHAR)
1763                         {
1764                             auto incResult11 = ++lexer;
1765                             if (incResult11.Error())
1766                             {
1767                                 return System.Result<System.Parsing.Match>(System.ErrorId(incResult11.GetErrorId()));
1768                             }
1769                             match.hit = true;
1770                         }
1771                         if (match.hit)
1772                         {
1773                             #if (DEBUG)
1774                                 if (parser_debug_write_to_log)
1775                                 {
1776                                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1777                                     if (result.Error()) return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1778                                 }
1779                             #endif
1780                             ustring match = lexer.GetToken(pos).ToString();
1781                             return System.Result<System.Parsing.Match>(System.Parsing.Match(truenew System.Parsing.Value<uchar>(match[0])));
1782                         }
1783                         *parentMatch12 = match;
1784                     }
1785                     if (match.hit)
1786                     {
1787                         *parentMatch0 = match;
1788                     }
1789                     break;
1790                 }
1791             }
1792             #if (DEBUG)
1793             if (parser_debug_write_to_log)
1794             {
1795                 if (match.hit)
1796                 {
1797                     auto result = System.Lex.WriteSuccessToLog(lexerparser_debug_match_posu"Char");
1798                     if (result.Error())
1799                     {
1800                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1801                     }
1802                 }
1803                 else
1804                 {
1805                     auto result = System.Lex.WriteFailureToLog(lexeru"Char");
1806                     if (result.Error())
1807                     {
1808                         return System.Result<System.Parsing.Match>(System.ErrorId(result.GetErrorId()));
1809                     }
1810                 }
1811             }
1812             #endif
1813             if (!match.hit)
1814             {
1815                 match.value = null;
1816             }
1817             return System.Result<System.Parsing.Match>(match);
1818         }
1819     }
1820 }
1821 
1822 new class System.RegularExpressions.RegExParser<System.RegularExpressions.RegExLexer>;