1 using System;
   2 using System.Collections;
   3 using System.Lex;
   4 using System.Parsing;
   5 using System;
   6 using MdbTokens;
   7 
   8 // this file has been automatically generated from 'D:/work/cmajorm/cmajor/projects/cmsx/cmsxmdb/Expr.parser' using soulcm parser generator scmpg version 3.0.0
   9 
  10 public static class MdbExprParser
  11 {
  12     public static UniquePtr<cmsx.debug.Node> Parse(MdbLexer& lexer)
  13     {
  14         UniquePtr<cmsx.debug.Node> value;
  15         #if (DEBUG)
  16             if (lexer.Log() != null)
  17             {
  18                 lexer.Log()->WriteBeginRule(u"parse");
  19                 lexer.Log()->IncIndent();
  20             }
  21         #endif
  22         ++lexer;
  23         System.Lex.Span span = lexer.GetSpan();
  24         Match match = Expression(lexer);
  25         value.Reset(cast<cmsx.debug.Node*>(match.value));
  26         #if (DEBUG)
  27             if (lexer.Log() != null)
  28             {
  29                 lexer.Log()->DecIndent();
  30                 lexer.Log()->WriteEndRule(u"parse");
  31             }
  32         #endif
  33         if (match.hit)
  34         {
  35             if (*lexer == System.Lex.END_TOKEN)
  36             {
  37                 return value;
  38             }
  39             else
  40             {
  41                 lexer.ThrowExpectationFailure(lexer.GetSpan()GetEndTokenInfo());
  42             }
  43         }
  44         else
  45         {
  46             lexer.ThrowExpectationFailure(spanu"Expression");
  47         }
  48         return value;
  49     }
  50     public static Match Expression(MdbLexer& lexer)
  51     {
  52         #if (DEBUG)
  53             Span debugSpan;
  54             bool writeToLog = lexer.Log() != null;
  55             if (writeToLog)
  56             {
  57                 debugSpan = lexer.GetSpan();
  58                 System.Lex.WriteBeginRuleToLog(lexeru"Expression");
  59             }
  60         #endif
  61         UniquePtr<cmsx.debug.Node> formatExpr;
  62         Match match(false);
  63         Match* parentMatch0 = &match;
  64         {
  65             long pos = lexer.GetPos();
  66             Match match = MdbExprParser.FormatExpression(lexer);
  67             formatExpr.Reset(cast<cmsx.debug.Node*>(match.value));
  68             if (match.hit)
  69             {
  70                 {
  71                     #if (DEBUG)
  72                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"Expression");
  73                     #endif
  74                     return Match(trueformatExpr.Release());
  75                 }
  76             }
  77             *parentMatch0 = match;
  78         }
  79         #if (DEBUG)
  80             if (writeToLog)
  81             {
  82                 if (match.hit)
  83                 {
  84                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"Expression");
  85                 }
  86                 else
  87                 {
  88                     System.Lex.WriteFailureToLog(lexeru"Expression");
  89                 }
  90             }
  91         #endif
  92         if (!match.hit)
  93         {
  94             match.value = null;
  95         }
  96         return match;
  97     }
  98     public static Match FormatExpression(MdbLexer& lexer)
  99     {
 100         #if (DEBUG)
 101             Span debugSpan;
 102             bool writeToLog = lexer.Log() != null;
 103             if (writeToLog)
 104             {
 105                 debugSpan = lexer.GetSpan();
 106                 System.Lex.WriteBeginRuleToLog(lexeru"FormatExpression");
 107             }
 108         #endif
 109         UniquePtr<cmsx.debug.Node> node;
 110         UniquePtr<cmsx.debug.Node> binaryExpr;
 111         UniquePtr<Value<cmsx.debug.ResultFormat>> f;
 112         Match match(false);
 113         Match* parentMatch0 = &match;
 114         {
 115             long pos = lexer.GetPos();
 116             Match match(false);
 117             Match* parentMatch1 = &match;
 118             {
 119                 Match match(false);
 120                 Match* parentMatch2 = &match;
 121                 {
 122                     Match match(false);
 123                     Match* parentMatch3 = &match;
 124                     {
 125                         long pos = lexer.GetPos();
 126                         Match match = MdbExprParser.BinaryExpression(lexer);
 127                         binaryExpr.Reset(cast<cmsx.debug.Node*>(match.value));
 128                         if (match.hit)
 129                         {
 130                             node.Reset(binaryExpr.Release());
 131                         }
 132                         *parentMatch3 = match;
 133                     }
 134                     *parentMatch2 = match;
 135                 }
 136                 if (match.hit)
 137                 {
 138                     Match match(false);
 139                     Match* parentMatch4 = &match;
 140                     {
 141                         Match match(true);
 142                         long save = lexer.GetPos();
 143                         Match* parentMatch5 = &match;
 144                         {
 145                             Match match(false);
 146                             Match* parentMatch6 = &match;
 147                             {
 148                                 Match match(false);
 149                                 Match* parentMatch7 = &match;
 150                                 {
 151                                     Match match(false);
 152                                     if (*lexer == DOT)
 153                                     {
 154                                         ++lexer;
 155                                         match.hit = true;
 156                                     }
 157                                     *parentMatch7 = match;
 158                                 }
 159                                 if (match.hit)
 160                                 {
 161                                     Match match(false);
 162                                     Match* parentMatch8 = &match;
 163                                     {
 164                                         Match match(false);
 165                                         Match* parentMatch9 = &match;
 166                                         {
 167                                             long pos = lexer.GetPos();
 168                                             Span span = lexer.GetSpan();
 169                                             Match match = MdbExprParser.Format(lexer);
 170                                             f.Reset(cast<Value<cmsx.debug.ResultFormat>*>(match.value));
 171                                             if (match.hit)
 172                                             {
 173                                                 node.Reset(new cmsx.debug.FormatExpressionNode(spannode.Release()f->value));
 174                                             }
 175                                             *parentMatch9 = match;
 176                                         }
 177                                         *parentMatch8 = match;
 178                                     }
 179                                     *parentMatch7 = match;
 180                                 }
 181                                 *parentMatch6 = match;
 182                             }
 183                             if (match.hit)
 184                             {
 185                                 *parentMatch5 = match;
 186                             }
 187                             else
 188                             {
 189                                 lexer.SetPos(save);
 190                             }
 191                         }
 192                         *parentMatch4 = match;
 193                     }
 194                     *parentMatch2 = match;
 195                 }
 196                 *parentMatch1 = match;
 197             }
 198             if (match.hit)
 199             {
 200                 {
 201                     #if (DEBUG)
 202                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"FormatExpression");
 203                     #endif
 204                     return Match(truenode.Release());
 205                 }
 206             }
 207             *parentMatch0 = match;
 208         }
 209         #if (DEBUG)
 210             if (writeToLog)
 211             {
 212                 if (match.hit)
 213                 {
 214                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"FormatExpression");
 215                 }
 216                 else
 217                 {
 218                     System.Lex.WriteFailureToLog(lexeru"FormatExpression");
 219                 }
 220             }
 221         #endif
 222         if (!match.hit)
 223         {
 224             match.value = null;
 225         }
 226         return match;
 227     }
 228     public static Match Format(MdbLexer& lexer)
 229     {
 230         #if (DEBUG)
 231             Span debugSpan;
 232             bool writeToLog = lexer.Log() != null;
 233             if (writeToLog)
 234             {
 235                 debugSpan = lexer.GetSpan();
 236                 System.Lex.WriteBeginRuleToLog(lexeru"Format");
 237             }
 238         #endif
 239         Span s;
 240         Match match(false);
 241         Match* parentMatch0 = &match;
 242         {
 243             long save = lexer.GetPos();
 244             Match match(false);
 245             Match* parentMatch1 = &match;
 246             {
 247                 long pos = lexer.GetPos();
 248                 bool pass = true;
 249                 Match match(false);
 250                 if (*lexer == ID)
 251                 {
 252                     ++lexer;
 253                     match.hit = true;
 254                 }
 255                 if (match.hit)
 256                 {
 257                     pass = true;
 258                     cmsx.debug.ResultFormat format;
 259                     string f = ToUtf8(lexer.GetToken(pos).match.ToString());
 260                     switch (cast<char>(f[0]))
 261                     {
 262                         case 'b': format.type = cmsx.debug.Type.byte_;
 263                         break;
 264                         case 'w': format.type = cmsx.debug.Type.wyde;
 265                         break;
 266                         case 't': format.type = cmsx.debug.Type.tetra;
 267                         break;
 268                         case 'o': format.type = cmsx.debug.Type.octa;
 269                         break;
 270                         case 'c': format.type = cmsx.debug.Type.char_;
 271                         break;
 272                         case 's': format.type = cmsx.debug.Type.string;
 273                         break;
 274                         default: pass = false;
 275                         break;
 276                     }
 277                     if (pass == true)
 278                     {
 279                         if (f.Length() == 2)
 280                         {
 281                             switch (cast<char>(f[1]))
 282                             {
 283                                 case 's': format.modifier = cmsx.debug.Modifier.signed;
 284                                 break;
 285                                 case 'x': format.modifier = cmsx.debug.Modifier.hex;
 286                                 break;
 287                                 default: pass = false;
 288                                 break;
 289                             }
 290                         }
 291                         else if (f.Length() > 2)
 292                         {
 293                             pass = false;
 294                         }
 295                     }
 296                     if (pass)
 297                     {
 298                         {
 299                             #if (DEBUG)
 300                                 if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"Format");
 301                             #endif
 302                             return Match(truenew Value<cmsx.debug.ResultFormat>(format));
 303                         }
 304                     }
 305                 }
 306                 if (match.hit && !pass)
 307                 {
 308                     match = Match(false);
 309                 }
 310                 *parentMatch1 = match;
 311             }
 312             *parentMatch0 = match;
 313             if (!match.hit)
 314             {
 315                 Match match(false);
 316                 Match* parentMatch2 = &match;
 317                 lexer.SetPos(save);
 318                 {
 319                     Match match(false);
 320                     Match* parentMatch3 = &match;
 321                     {
 322                         long pos = lexer.GetPos();
 323                         bool pass = true;
 324                         Match match(false);
 325                         Match* parentMatch4 = &match;
 326                         {
 327                             Match match(false);
 328                             Match* parentMatch5 = &match;
 329                             {
 330                                 Match match(false);
 331                                 Match* parentMatch6 = &match;
 332                                 {
 333                                     long pos = lexer.GetPos();
 334                                     Span span = lexer.GetSpan();
 335                                     Match match(false);
 336                                     if (*lexer == DEC)
 337                                     {
 338                                         ++lexer;
 339                                         match.hit = true;
 340                                     }
 341                                     if (match.hit)
 342                                     {
 343                                         s = span;
 344                                     }
 345                                     *parentMatch6 = match;
 346                                 }
 347                                 *parentMatch5 = match;
 348                             }
 349                             if (match.hit)
 350                             {
 351                                 Match match(false);
 352                                 Match* parentMatch7 = &match;
 353                                 {
 354                                     Match match(true);
 355                                     long save = lexer.GetPos();
 356                                     Match* parentMatch8 = &match;
 357                                     {
 358                                         Match match(false);
 359                                         Match* parentMatch9 = &match;
 360                                         {
 361                                             Match match(false);
 362                                             Match* parentMatch10 = &match;
 363                                             {
 364                                                 long pos = lexer.GetPos();
 365                                                 Span span = lexer.GetSpan();
 366                                                 Match match(false);
 367                                                 if (*lexer == ID)
 368                                                 {
 369                                                     ++lexer;
 370                                                     match.hit = true;
 371                                                 }
 372                                                 if (match.hit)
 373                                                 {
 374                                                     s.end = span.end;
 375                                                 }
 376                                                 *parentMatch10 = match;
 377                                             }
 378                                             *parentMatch9 = match;
 379                                         }
 380                                         if (match.hit)
 381                                         {
 382                                             *parentMatch8 = match;
 383                                         }
 384                                         else
 385                                         {
 386                                             lexer.SetPos(save);
 387                                         }
 388                                     }
 389                                     *parentMatch7 = match;
 390                                 }
 391                                 *parentMatch5 = match;
 392                             }
 393                             *parentMatch4 = match;
 394                         }
 395                         if (match.hit)
 396                         {
 397                             pass = true;
 398                             cmsx.debug.ResultFormat format;
 399                             string f = ToUtf8(lexer.GetMatch(s));
 400                             switch (cast<char>(f[0]))
 401                             {
 402                                 case '1': format.type = cmsx.debug.Type.byte_;
 403                                 break;
 404                                 case '2': format.type = cmsx.debug.Type.wyde;
 405                                 break;
 406                                 case '4': format.type = cmsx.debug.Type.tetra;
 407                                 break;
 408                                 case '8': format.type = cmsx.debug.Type.octa;
 409                                 break;
 410                                 default: pass = false;
 411                                 break;
 412                             }
 413                             if (pass == true)
 414                             {
 415                                 if (f.Length() == 2)
 416                                 {
 417                                     switch (cast<char>(f[1]))
 418                                     {
 419                                         case 's': format.modifier = cmsx.debug.Modifier.signed;
 420                                         break;
 421                                         case 'x': format.modifier = cmsx.debug.Modifier.hex;
 422                                         break;
 423                                         default: pass = false;
 424                                         break;
 425                                     }
 426                                 }
 427                                 else if (f.Length() > 2)
 428                                 {
 429                                     pass = false;
 430                                 }
 431                             }
 432                             if (pass)
 433                             {
 434                                 {
 435                                     #if (DEBUG)
 436                                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"Format");
 437                                     #endif
 438                                     return Match(truenew Value<cmsx.debug.ResultFormat>(format));
 439                                 }
 440                             }
 441                         }
 442                         if (match.hit && !pass)
 443                         {
 444                             match = Match(false);
 445                         }
 446                         *parentMatch3 = match;
 447                     }
 448                     *parentMatch2 = match;
 449                 }
 450                 *parentMatch0 = match;
 451             }
 452         }
 453         #if (DEBUG)
 454             if (writeToLog)
 455             {
 456                 if (match.hit)
 457                 {
 458                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"Format");
 459                 }
 460                 else
 461                 {
 462                     System.Lex.WriteFailureToLog(lexeru"Format");
 463                 }
 464             }
 465         #endif
 466         if (!match.hit)
 467         {
 468             match.value = null;
 469         }
 470         return match;
 471     }
 472     public static Match BinaryExpression(MdbLexer& lexer)
 473     {
 474         #if (DEBUG)
 475             Span debugSpan;
 476             bool writeToLog = lexer.Log() != null;
 477             if (writeToLog)
 478             {
 479                 debugSpan = lexer.GetSpan();
 480                 System.Lex.WriteBeginRuleToLog(lexeru"BinaryExpression");
 481             }
 482         #endif
 483         UniquePtr<cmsx.debug.Node> node;
 484         UniquePtr<cmsx.debug.Node> left;
 485         UniquePtr<Value<cmsx.debug.Operator>> op;
 486         UniquePtr<cmsx.debug.Node> right;
 487         Match match(false);
 488         Match* parentMatch0 = &match;
 489         {
 490             long pos = lexer.GetPos();
 491             Match match(false);
 492             Match* parentMatch1 = &match;
 493             {
 494                 Match match(false);
 495                 Match* parentMatch2 = &match;
 496                 {
 497                     Match match(false);
 498                     Match* parentMatch3 = &match;
 499                     {
 500                         long pos = lexer.GetPos();
 501                         Match match = MdbExprParser.Term(lexer);
 502                         left.Reset(cast<cmsx.debug.Node*>(match.value));
 503                         if (match.hit)
 504                         {
 505                             node.Reset(left.Release());
 506                         }
 507                         *parentMatch3 = match;
 508                     }
 509                     *parentMatch2 = match;
 510                 }
 511                 if (match.hit)
 512                 {
 513                     Match match(false);
 514                     Match* parentMatch4 = &match;
 515                     {
 516                         Match match(true);
 517                         Match* parentMatch5 = &match;
 518                         {
 519                             while (true)
 520                             {
 521                                 long save = lexer.GetPos();
 522                                 {
 523                                     Match match(false);
 524                                     Match* parentMatch6 = &match;
 525                                     {
 526                                         Match match(false);
 527                                         Match* parentMatch7 = &match;
 528                                         {
 529                                             Match match = MdbExprParser.WeakOperator(lexer);
 530                                             op.Reset(cast<Value<cmsx.debug.Operator>*>(match.value));
 531                                             *parentMatch7 = match;
 532                                         }
 533                                         if (match.hit)
 534                                         {
 535                                             Match match(false);
 536                                             Match* parentMatch8 = &match;
 537                                             {
 538                                                 Match match(false);
 539                                                 Match* parentMatch9 = &match;
 540                                                 {
 541                                                     long pos = lexer.GetPos();
 542                                                     Span span = lexer.GetSpan();
 543                                                     Match match = MdbExprParser.Term(lexer);
 544                                                     right.Reset(cast<cmsx.debug.Node*>(match.value));
 545                                                     if (match.hit)
 546                                                     {
 547                                                         node.Reset(new cmsx.debug.BinaryExpressionNode(spannode.Release()right.Release()op->value));
 548                                                     }
 549                                                     *parentMatch9 = match;
 550                                                 }
 551                                                 *parentMatch8 = match;
 552                                             }
 553                                             *parentMatch7 = match;
 554                                         }
 555                                         *parentMatch6 = match;
 556                                     }
 557                                     if (match.hit)
 558                                     {
 559                                         *parentMatch5 = match;
 560                                     }
 561                                     else
 562                                     {
 563                                         lexer.SetPos(save);
 564                                         break;
 565                                     }
 566                                 }
 567                             }
 568                         }
 569                         *parentMatch4 = match;
 570                     }
 571                     *parentMatch2 = match;
 572                 }
 573                 *parentMatch1 = match;
 574             }
 575             if (match.hit)
 576             {
 577                 {
 578                     #if (DEBUG)
 579                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"BinaryExpression");
 580                     #endif
 581                     return Match(truenode.Release());
 582                 }
 583             }
 584             *parentMatch0 = match;
 585         }
 586         #if (DEBUG)
 587             if (writeToLog)
 588             {
 589                 if (match.hit)
 590                 {
 591                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"BinaryExpression");
 592                 }
 593                 else
 594                 {
 595                     System.Lex.WriteFailureToLog(lexeru"BinaryExpression");
 596                 }
 597             }
 598         #endif
 599         if (!match.hit)
 600         {
 601             match.value = null;
 602         }
 603         return match;
 604     }
 605     public static Match WeakOperator(MdbLexer& lexer)
 606     {
 607         #if (DEBUG)
 608             Span debugSpan;
 609             bool writeToLog = lexer.Log() != null;
 610             if (writeToLog)
 611             {
 612                 debugSpan = lexer.GetSpan();
 613                 System.Lex.WriteBeginRuleToLog(lexeru"WeakOperator");
 614             }
 615         #endif
 616         Match match(false);
 617         long pos = lexer.GetPos();
 618         Span span = lexer.GetSpan();
 619         switch (*lexer)
 620         {
 621             case PLUS:
 622             {
 623                 ++lexer;
 624                 {
 625                     #if (DEBUG)
 626                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"WeakOperator");
 627                     #endif
 628                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.add));
 629                 }
 630                 break;
 631             }
 632             case MINUS:
 633             {
 634                 ++lexer;
 635                 {
 636                     #if (DEBUG)
 637                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"WeakOperator");
 638                     #endif
 639                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.sub));
 640                 }
 641                 break;
 642             }
 643             case BAR:
 644             {
 645                 ++lexer;
 646                 {
 647                     #if (DEBUG)
 648                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"WeakOperator");
 649                     #endif
 650                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.or_));
 651                 }
 652                 break;
 653             }
 654             case CARET:
 655             {
 656                 ++lexer;
 657                 {
 658                     #if (DEBUG)
 659                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"WeakOperator");
 660                     #endif
 661                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.xor_));
 662                 }
 663                 break;
 664             }
 665         }
 666         #if (DEBUG)
 667             if (writeToLog)
 668             {
 669                 if (match.hit)
 670                 {
 671                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"WeakOperator");
 672                 }
 673                 else
 674                 {
 675                     System.Lex.WriteFailureToLog(lexeru"WeakOperator");
 676                 }
 677             }
 678         #endif
 679         if (!match.hit)
 680         {
 681             match.value = null;
 682         }
 683         return match;
 684     }
 685     public static Match Term(MdbLexer& lexer)
 686     {
 687         #if (DEBUG)
 688             Span debugSpan;
 689             bool writeToLog = lexer.Log() != null;
 690             if (writeToLog)
 691             {
 692                 debugSpan = lexer.GetSpan();
 693                 System.Lex.WriteBeginRuleToLog(lexeru"Term");
 694             }
 695         #endif
 696         UniquePtr<cmsx.debug.Node> node;
 697         UniquePtr<cmsx.debug.Node> left;
 698         UniquePtr<Value<cmsx.debug.Operator>> op;
 699         UniquePtr<cmsx.debug.Node> right;
 700         Match match(false);
 701         Match* parentMatch0 = &match;
 702         {
 703             long pos = lexer.GetPos();
 704             Match match(false);
 705             Match* parentMatch1 = &match;
 706             {
 707                 Match match(false);
 708                 Match* parentMatch2 = &match;
 709                 {
 710                     Match match(false);
 711                     Match* parentMatch3 = &match;
 712                     {
 713                         long pos = lexer.GetPos();
 714                         Match match = MdbExprParser.UnaryExpression(lexer);
 715                         left.Reset(cast<cmsx.debug.Node*>(match.value));
 716                         if (match.hit)
 717                         {
 718                             node.Reset(left.Release());
 719                         }
 720                         *parentMatch3 = match;
 721                     }
 722                     *parentMatch2 = match;
 723                 }
 724                 if (match.hit)
 725                 {
 726                     Match match(false);
 727                     Match* parentMatch4 = &match;
 728                     {
 729                         Match match(true);
 730                         Match* parentMatch5 = &match;
 731                         {
 732                             while (true)
 733                             {
 734                                 long save = lexer.GetPos();
 735                                 {
 736                                     Match match(false);
 737                                     Match* parentMatch6 = &match;
 738                                     {
 739                                         Match match(false);
 740                                         Match* parentMatch7 = &match;
 741                                         {
 742                                             Match match = MdbExprParser.StrongOperator(lexer);
 743                                             op.Reset(cast<Value<cmsx.debug.Operator>*>(match.value));
 744                                             *parentMatch7 = match;
 745                                         }
 746                                         if (match.hit)
 747                                         {
 748                                             Match match(false);
 749                                             Match* parentMatch8 = &match;
 750                                             {
 751                                                 Match match(false);
 752                                                 Match* parentMatch9 = &match;
 753                                                 {
 754                                                     long pos = lexer.GetPos();
 755                                                     Span span = lexer.GetSpan();
 756                                                     Match match = MdbExprParser.UnaryExpression(lexer);
 757                                                     right.Reset(cast<cmsx.debug.Node*>(match.value));
 758                                                     if (match.hit)
 759                                                     {
 760                                                         node.Reset(new cmsx.debug.BinaryExpressionNode(spannode.Release()right.Release()op->value));
 761                                                     }
 762                                                     *parentMatch9 = match;
 763                                                 }
 764                                                 *parentMatch8 = match;
 765                                             }
 766                                             *parentMatch7 = match;
 767                                         }
 768                                         *parentMatch6 = match;
 769                                     }
 770                                     if (match.hit)
 771                                     {
 772                                         *parentMatch5 = match;
 773                                     }
 774                                     else
 775                                     {
 776                                         lexer.SetPos(save);
 777                                         break;
 778                                     }
 779                                 }
 780                             }
 781                         }
 782                         *parentMatch4 = match;
 783                     }
 784                     *parentMatch2 = match;
 785                 }
 786                 *parentMatch1 = match;
 787             }
 788             if (match.hit)
 789             {
 790                 {
 791                     #if (DEBUG)
 792                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"Term");
 793                     #endif
 794                     return Match(truenode.Release());
 795                 }
 796             }
 797             *parentMatch0 = match;
 798         }
 799         #if (DEBUG)
 800             if (writeToLog)
 801             {
 802                 if (match.hit)
 803                 {
 804                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"Term");
 805                 }
 806                 else
 807                 {
 808                     System.Lex.WriteFailureToLog(lexeru"Term");
 809                 }
 810             }
 811         #endif
 812         if (!match.hit)
 813         {
 814             match.value = null;
 815         }
 816         return match;
 817     }
 818     public static Match StrongOperator(MdbLexer& lexer)
 819     {
 820         #if (DEBUG)
 821             Span debugSpan;
 822             bool writeToLog = lexer.Log() != null;
 823             if (writeToLog)
 824             {
 825                 debugSpan = lexer.GetSpan();
 826                 System.Lex.WriteBeginRuleToLog(lexeru"StrongOperator");
 827             }
 828         #endif
 829         Match match(false);
 830         long pos = lexer.GetPos();
 831         Span span = lexer.GetSpan();
 832         switch (*lexer)
 833         {
 834             case AST:
 835             {
 836                 ++lexer;
 837                 {
 838                     #if (DEBUG)
 839                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"StrongOperator");
 840                     #endif
 841                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.mul));
 842                 }
 843                 break;
 844             }
 845             case SLASH:
 846             {
 847                 ++lexer;
 848                 {
 849                     #if (DEBUG)
 850                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"StrongOperator");
 851                     #endif
 852                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.div));
 853                 }
 854                 break;
 855             }
 856             case PERCENT:
 857             {
 858                 ++lexer;
 859                 {
 860                     #if (DEBUG)
 861                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"StrongOperator");
 862                     #endif
 863                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.mod));
 864                 }
 865                 break;
 866             }
 867             case SHIFT_LEFT:
 868             {
 869                 ++lexer;
 870                 {
 871                     #if (DEBUG)
 872                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"StrongOperator");
 873                     #endif
 874                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.shiftLeft));
 875                 }
 876                 break;
 877             }
 878             case SHIFT_RIGHT:
 879             {
 880                 ++lexer;
 881                 {
 882                     #if (DEBUG)
 883                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"StrongOperator");
 884                     #endif
 885                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.shiftRight));
 886                 }
 887                 break;
 888             }
 889             case AMP:
 890             {
 891                 ++lexer;
 892                 {
 893                     #if (DEBUG)
 894                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"StrongOperator");
 895                     #endif
 896                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.and_));
 897                 }
 898                 break;
 899             }
 900         }
 901         #if (DEBUG)
 902             if (writeToLog)
 903             {
 904                 if (match.hit)
 905                 {
 906                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"StrongOperator");
 907                 }
 908                 else
 909                 {
 910                     System.Lex.WriteFailureToLog(lexeru"StrongOperator");
 911                 }
 912             }
 913         #endif
 914         if (!match.hit)
 915         {
 916             match.value = null;
 917         }
 918         return match;
 919     }
 920     public static Match UnaryExpression(MdbLexer& lexer)
 921     {
 922         #if (DEBUG)
 923             Span debugSpan;
 924             bool writeToLog = lexer.Log() != null;
 925             if (writeToLog)
 926             {
 927                 debugSpan = lexer.GetSpan();
 928                 System.Lex.WriteBeginRuleToLog(lexeru"UnaryExpression");
 929             }
 930         #endif
 931         UniquePtr<cmsx.debug.Node> expr;
 932         UniquePtr<Value<cmsx.debug.Operator>> op;
 933         UniquePtr<cmsx.debug.Node> child;
 934         UniquePtr<cmsx.debug.Node> primary;
 935         Match match(false);
 936         Match* parentMatch0 = &match;
 937         {
 938             long save = lexer.GetPos();
 939             Match match(false);
 940             Match* parentMatch1 = &match;
 941             {
 942                 long save = lexer.GetPos();
 943                 Match match(false);
 944                 Match* parentMatch2 = &match;
 945                 {
 946                     Match match(false);
 947                     Match* parentMatch3 = &match;
 948                     {
 949                         Match match(false);
 950                         if (*lexer == LPAREN)
 951                         {
 952                             ++lexer;
 953                             match.hit = true;
 954                         }
 955                         *parentMatch3 = match;
 956                     }
 957                     if (match.hit)
 958                     {
 959                         Match match(false);
 960                         Match* parentMatch4 = &match;
 961                         {
 962                             Match match = MdbExprParser.Expression(lexer);
 963                             expr.Reset(cast<cmsx.debug.Node*>(match.value));
 964                             *parentMatch4 = match;
 965                         }
 966                         *parentMatch3 = match;
 967                     }
 968                     *parentMatch2 = match;
 969                 }
 970                 if (match.hit)
 971                 {
 972                     Match match(false);
 973                     Match* parentMatch5 = &match;
 974                     {
 975                         Match match(false);
 976                         Match* parentMatch6 = &match;
 977                         {
 978                             long pos = lexer.GetPos();
 979                             Span span = lexer.GetSpan();
 980                             Match match(false);
 981                             if (*lexer == RPAREN)
 982                             {
 983                                 ++lexer;
 984                                 match.hit = true;
 985                             }
 986                             if (match.hit)
 987                             {
 988                                 {
 989                                     #if (DEBUG)
 990                                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryExpression");
 991                                     #endif
 992                                     return Match(truenew cmsx.debug.ParenthesizedExpressionNode(spanexpr.Release()));
 993                                 }
 994                             }
 995                             *parentMatch6 = match;
 996                         }
 997                         *parentMatch5 = match;
 998                     }
 999                     *parentMatch2 = match;
1000                 }
1001                 *parentMatch1 = match;
1002                 if (!match.hit)
1003                 {
1004                     Match match(false);
1005                     Match* parentMatch7 = &match;
1006                     lexer.SetPos(save);
1007                     {
1008                         Match match(false);
1009                         Match* parentMatch8 = &match;
1010                         {
1011                             Match match = MdbExprParser.UnaryOperator(lexer);
1012                             op.Reset(cast<Value<cmsx.debug.Operator>*>(match.value));
1013                             *parentMatch8 = match;
1014                         }
1015                         if (match.hit)
1016                         {
1017                             Match match(false);
1018                             Match* parentMatch9 = &match;
1019                             {
1020                                 Match match(false);
1021                                 Match* parentMatch10 = &match;
1022                                 {
1023                                     long pos = lexer.GetPos();
1024                                     Span span = lexer.GetSpan();
1025                                     Match match = MdbExprParser.UnaryExpression(lexer);
1026                                     child.Reset(cast<cmsx.debug.Node*>(match.value));
1027                                     if (match.hit)
1028                                     {
1029                                         {
1030                                             #if (DEBUG)
1031                                                 if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryExpression");
1032                                             #endif
1033                                             return Match(truenew cmsx.debug.UnaryExpressionNode(spanchild.Release()op->value));
1034                                         }
1035                                     }
1036                                     *parentMatch10 = match;
1037                                 }
1038                                 *parentMatch9 = match;
1039                             }
1040                             *parentMatch8 = match;
1041                         }
1042                         *parentMatch7 = match;
1043                     }
1044                     *parentMatch1 = match;
1045                 }
1046             }
1047             *parentMatch0 = match;
1048             if (!match.hit)
1049             {
1050                 Match match(false);
1051                 Match* parentMatch11 = &match;
1052                 lexer.SetPos(save);
1053                 {
1054                     Match match(false);
1055                     Match* parentMatch12 = &match;
1056                     {
1057                         long pos = lexer.GetPos();
1058                         Match match = MdbExprParser.PrimaryExpression(lexer);
1059                         primary.Reset(cast<cmsx.debug.Node*>(match.value));
1060                         if (match.hit)
1061                         {
1062                             {
1063                                 #if (DEBUG)
1064                                     if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryExpression");
1065                                 #endif
1066                                 return Match(trueprimary.Release());
1067                             }
1068                         }
1069                         *parentMatch12 = match;
1070                     }
1071                     *parentMatch11 = match;
1072                 }
1073                 *parentMatch0 = match;
1074             }
1075         }
1076         #if (DEBUG)
1077             if (writeToLog)
1078             {
1079                 if (match.hit)
1080                 {
1081                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryExpression");
1082                 }
1083                 else
1084                 {
1085                     System.Lex.WriteFailureToLog(lexeru"UnaryExpression");
1086                 }
1087             }
1088         #endif
1089         if (!match.hit)
1090         {
1091             match.value = null;
1092         }
1093         return match;
1094     }
1095     public static Match UnaryOperator(MdbLexer& lexer)
1096     {
1097         #if (DEBUG)
1098             Span debugSpan;
1099             bool writeToLog = lexer.Log() != null;
1100             if (writeToLog)
1101             {
1102                 debugSpan = lexer.GetSpan();
1103                 System.Lex.WriteBeginRuleToLog(lexeru"UnaryOperator");
1104             }
1105         #endif
1106         Match match(false);
1107         long pos = lexer.GetPos();
1108         Span span = lexer.GetSpan();
1109         switch (*lexer)
1110         {
1111             case PLUS:
1112             {
1113                 ++lexer;
1114                 {
1115                     #if (DEBUG)
1116                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryOperator");
1117                     #endif
1118                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.unaryPlus));
1119                 }
1120                 break;
1121             }
1122             case MINUS:
1123             {
1124                 ++lexer;
1125                 {
1126                     #if (DEBUG)
1127                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryOperator");
1128                     #endif
1129                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.unaryMinus));
1130                 }
1131                 break;
1132             }
1133             case TILDE:
1134             {
1135                 ++lexer;
1136                 {
1137                     #if (DEBUG)
1138                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryOperator");
1139                     #endif
1140                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.complement));
1141                 }
1142                 break;
1143             }
1144             case AST:
1145             {
1146                 ++lexer;
1147                 {
1148                     #if (DEBUG)
1149                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryOperator");
1150                     #endif
1151                     return Match(truenew Value<cmsx.debug.Operator>(cmsx.debug.Operator.deref));
1152                 }
1153                 break;
1154             }
1155         }
1156         #if (DEBUG)
1157             if (writeToLog)
1158             {
1159                 if (match.hit)
1160                 {
1161                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"UnaryOperator");
1162                 }
1163                 else
1164                 {
1165                     System.Lex.WriteFailureToLog(lexeru"UnaryOperator");
1166                 }
1167             }
1168         #endif
1169         if (!match.hit)
1170         {
1171             match.value = null;
1172         }
1173         return match;
1174     }
1175     public static Match PrimaryExpression(MdbLexer& lexer)
1176     {
1177         #if (DEBUG)
1178             Span debugSpan;
1179             bool writeToLog = lexer.Log() != null;
1180             if (writeToLog)
1181             {
1182                 debugSpan = lexer.GetSpan();
1183                 System.Lex.WriteBeginRuleToLog(lexeru"PrimaryExpression");
1184             }
1185         #endif
1186         Match match(false);
1187         long pos = lexer.GetPos();
1188         Span span = lexer.GetSpan();
1189         switch (*lexer)
1190         {
1191             case SEG:
1192             {
1193                 ++lexer;
1194                 uchar s = lexer.GetToken(pos).match.ToString()[1];
1195                 switch (s)
1196                 {
1197                     case 't':
1198                     {
1199                         #if (DEBUG)
1200                             if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1201                         #endif
1202                         return Match(truenew cmsx.debug.SegmentNode(spancmsx.machine.textSegmentIndex));
1203                     }
1204                     case 'd':
1205                     {
1206                         #if (DEBUG)
1207                             if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1208                         #endif
1209                         return Match(truenew cmsx.debug.SegmentNode(spancmsx.machine.dataSegmentIndex));
1210                     }
1211                     case 'p':
1212                     {
1213                         #if (DEBUG)
1214                             if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1215                         #endif
1216                         return Match(truenew cmsx.debug.SegmentNode(spancmsx.machine.poolSegmentIndex));
1217                     }
1218                     case 's':
1219                     {
1220                         #if (DEBUG)
1221                             if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1222                         #endif
1223                         return Match(truenew cmsx.debug.SegmentNode(spancmsx.machine.stackSegmentIndex));
1224                     }
1225                     case 'k':
1226                     {
1227                         #if (DEBUG)
1228                             if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1229                         #endif
1230                         return Match(truenew cmsx.debug.SegmentNode(spancmsx.machine.numSegments));
1231                     }
1232                 }
1233                 {
1234                     #if (DEBUG)
1235                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1236                     #endif
1237                     return Match(truenull);
1238                 }
1239                 break;
1240             }
1241             case REG:
1242             {
1243                 ++lexer;
1244                 byte x = ParseByte(ToUtf8(lexer.GetToken(pos).match.ToString().Substring(1)));
1245                 {
1246                     #if (DEBUG)
1247                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1248                     #endif
1249                     return Match(truenew cmsx.debug.RegNumberNode(spanx));
1250                 }
1251                 break;
1252             }
1253             case HEX:
1254             {
1255                 ++lexer;
1256                 ulong x = ParseHexULong(ToUtf8(lexer.GetToken(pos).match.ToString().Substring(1)));
1257                 {
1258                     #if (DEBUG)
1259                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1260                     #endif
1261                     return Match(truenew cmsx.debug.HexNumberNode(spanx));
1262                 }
1263                 break;
1264             }
1265             case DEC:
1266             {
1267                 ++lexer;
1268                 ulong x = ParseULong(ToUtf8(lexer.GetToken(pos).match.ToString()));
1269                 {
1270                     #if (DEBUG)
1271                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1272                     #endif
1273                     return Match(truenew cmsx.debug.DecNumberNode(spanx));
1274                 }
1275                 break;
1276             }
1277             case ID:
1278             {
1279                 ++lexer;
1280                 ustring id = lexer.GetToken(pos).match.ToString();
1281                 {
1282                     #if (DEBUG)
1283                         if (writeToLog) System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1284                     #endif
1285                     return Match(truenew cmsx.debug.SymbolNode(spanid));
1286                 }
1287                 break;
1288             }
1289         }
1290         #if (DEBUG)
1291             if (writeToLog)
1292             {
1293                 if (match.hit)
1294                 {
1295                     System.Lex.WriteSuccessToLog(lexerdebugSpanu"PrimaryExpression");
1296                 }
1297                 else
1298                 {
1299                     System.Lex.WriteFailureToLog(lexeru"PrimaryExpression");
1300                 }
1301             }
1302         #endif
1303         if (!match.hit)
1304         {
1305             match.value = null;
1306         }
1307         return match;
1308     }
1309 }