PageRenderTime 59ms CodeModel.GetById 5ms app.highlight 42ms RepoModel.GetById 1ms app.codeStats 1ms

/YieldProlog/Modules/Parser.cs

https://bitbucket.org/VirtualReality/optional-modules
C# | 4572 lines | 4458 code | 73 blank | 41 comment | 123 complexity | ce5d678426367e726ae3f51595df23f5 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*
   2 * Copyright (c) Contributors, http://aurora-sim.org/
   3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
   4 *
   5 * Redistribution and use in source and binary forms, with or without
   6 * modification, are permitted provided that the following conditions are met:
   7 *     * Redistributions of source code must retain the above copyright
   8 *       notice, this list of conditions and the following disclaimer.
   9 *     * Redistributions in binary form must reproduce the above copyright
  10 *       notice, this list of conditions and the following disclaimer in the
  11 *       documentation and/or other materials provided with the distribution.
  12 *     * Neither the name of the Aurora-Sim Project nor the
  13 *       names of its contributors may be used to endorse or promote products
  14 *       derived from this software without specific prior written permission.
  15 *
  16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26 */
  27
  28using System;
  29using System.Collections.Generic;
  30
  31        // disable warning on l1, don't see how we can
  32        // code this differently
  33        #pragma warning disable 0168, 0219, 0162
  34
  35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
  36{
  37    public class Parser
  38    {
  39        public static IEnumerable<bool> read_term2(object Term, object Options)
  40        {
  41            Variable Answer = new Variable();
  42            Variable Variables = new Variable();
  43            foreach (bool l1 in read_termOptions(Options, Variables))
  44            {
  45                foreach (bool l2 in portable_read3(Answer, Variables, new Variable()))
  46                {
  47                    foreach (bool l3 in remove_pos(Answer, Term))
  48                        yield return false;
  49                }
  50            }
  51        }
  52
  53        public static IEnumerable<bool> read_term3(object Input, object Term, object Options)
  54        {
  55            Variable SaveInput = new Variable();
  56            Variable Answer = new Variable();
  57            Variable Variables = new Variable();
  58            foreach (bool l1 in read_termOptions(Options, Variables))
  59            {
  60                foreach (bool l2 in YP.current_input(SaveInput))
  61                {
  62                    try
  63                    {
  64                        YP.see(Input);
  65                        foreach (bool l3 in portable_read3(Answer, Variables, new Variable()))
  66                        {
  67                            foreach (bool l4 in remove_pos(Answer, Term))
  68                                yield return false;
  69                        }
  70                    }
  71                    finally
  72                    {
  73                        YP.see(SaveInput);
  74                    }
  75                }
  76            }
  77        }
  78
  79        /// <summary>
  80        /// For read_term, check if Options has variable_names(Variables).
  81        /// Otherwise, ignore Options.
  82        /// </summary>
  83        /// <param name="Options"></param>
  84        /// <param name="Variables"></param>
  85        /// <returns></returns>
  86        private static IEnumerable<bool> read_termOptions(object Options, object Variables)
  87        {
  88            Options = YP.getValue(Options);
  89            if (Options is Variable)
  90                throw new PrologException(Atom.a("instantiation_error"), "Options is an unbound variable");
  91            // First try to match Options = [variable_names(Variables)]
  92            foreach (bool l1 in YP.unify(Options, ListPair.make(new Functor1("variable_names", Variables))))
  93            {
  94                yield return false;
  95                yield break;
  96            }
  97            // Default: Ignore Options.
  98            yield return false;
  99        }
 100
 101        public static IEnumerable<bool> read1(object Term)
 102        {
 103            return read_term2(Term, Atom.NIL);
 104        }
 105
 106        public static IEnumerable<bool> read2(object Input, object Term)
 107        {
 108            return read_term3(Input, Term, Atom.NIL);
 109        }
 110
 111        public static IEnumerable<bool> formatError(object Output, object Format, object Arguments)
 112        {
 113            // Debug: Simple implementation for now.
 114            YP.write(Format);
 115            YP.write(Arguments);
 116            YP.nl();
 117            yield return false;
 118        }
 119
 120
 121        // Debug: Hand-modify this central predicate to do tail recursion.
 122        public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3)
 123        {
 124            bool repeat = true;
 125            while (repeat)
 126            {
 127                repeat = false;
 128                {
 129                    object C1 = arg1;
 130                    object Dict = arg2;
 131                    object Tokens = arg3;
 132                    Variable C2 = new Variable();
 133                    if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL)))
 134                    {
 135                        if (YP.greaterThanOrEqual(C1, 0))
 136                        {
 137                            foreach (bool l4 in YP.get_code(C2))
 138                            {
 139#if false
 140                                foreach (bool l5 in read_tokens(C2, Dict, Tokens))
 141                                {
 142                                    yield return false;
 143                                }
 144#endif
 145                                arg1 = YP.getValue(C2);
 146                                arg2 = YP.getValue(Dict);
 147                                arg3 = YP.getValue(Tokens);
 148                                repeat = true;
 149                            }
 150                        }
 151                        goto cutIf1;
 152                    }
 153                    if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL)))
 154                    {
 155                        if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL)))
 156                        {
 157                            foreach (bool l4 in read_identifier(C1, Dict, Tokens))
 158                            {
 159                                yield return false;
 160                            }
 161                            goto cutIf2;
 162                        }
 163                    }
 164                    if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL)))
 165                    {
 166                        if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL)))
 167                        {
 168                            foreach (bool l4 in read_variable(C1, Dict, Tokens))
 169                            {
 170                                yield return false;
 171                            }
 172                            goto cutIf3;
 173                        }
 174                    }
 175                    if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL)))
 176                    {
 177                        if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL)))
 178                        {
 179                            foreach (bool l4 in read_number(C1, Dict, Tokens))
 180                            {
 181                                yield return false;
 182                            }
 183                            goto cutIf4;
 184                        }
 185                    }
 186                    if (YP.lessThan(C1, 127))
 187                    {
 188                        foreach (bool l3 in read_special(C1, Dict, Tokens))
 189                        {
 190                            yield return false;
 191                        }
 192                        goto cutIf5;
 193                    }
 194                    if (YP.lessThanOrEqual(C1, 160))
 195                    {
 196                        foreach (bool l3 in YP.get_code(C2))
 197                        {
 198#if false
 199                            foreach (bool l4 in read_tokens(C2, Dict, Tokens))
 200                            {
 201                                yield return false;
 202                            }
 203#endif
 204                            arg1 = YP.getValue(C2);
 205                            arg2 = YP.getValue(Dict);
 206                            arg3 = YP.getValue(Tokens);
 207                            repeat = true;
 208                        }
 209                        goto cutIf6;
 210                    }
 211                    if (YP.greaterThanOrEqual(C1, 223))
 212                    {
 213                        if (YP.notEqual(C1, 247))
 214                        {
 215                            foreach (bool l4 in read_identifier(C1, Dict, Tokens))
 216                            {
 217                                yield return false;
 218                            }
 219                            goto cutIf7;
 220                        }
 221                    }
 222                    if (YP.greaterThanOrEqual(C1, 192))
 223                    {
 224                        if (YP.notEqual(C1, 215))
 225                        {
 226                            foreach (bool l4 in read_variable(C1, Dict, Tokens))
 227                            {
 228                                yield return false;
 229                            }
 230                            goto cutIf8;
 231                        }
 232                    }
 233                    if (YP.notEqual(C1, 170))
 234                    {
 235                        if (YP.notEqual(C1, 186))
 236                        {
 237                            foreach (bool l4 in read_symbol(C1, Dict, Tokens))
 238                            {
 239                                yield return false;
 240                            }
 241                            goto cutIf9;
 242                        }
 243                    }
 244                    foreach (bool l2 in read_identifier(C1, Dict, Tokens))
 245                    {
 246                        yield return false;
 247                    }
 248                cutIf9:
 249                cutIf8:
 250                cutIf7:
 251                cutIf6:
 252                cutIf5:
 253                cutIf4:
 254                cutIf3:
 255                cutIf2:
 256                cutIf1:
 257                    { }
 258                }
 259            }
 260        }
 261
 262        // Compiler output follows.
 263
 264        class YPInnerClass { }
 265        // static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
 266
 267        public static IEnumerable<bool> parseInput(object TermList)
 268        {
 269            {
 270                Variable TermAndVariables = new Variable();
 271                FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables);
 272                foreach (bool l2 in parseInputHelper(TermAndVariables))
 273                {
 274                    findallAnswers1.add();
 275                }
 276                foreach (bool l2 in findallAnswers1.result(TermList))
 277                {
 278                    yield return false;
 279                }
 280            }
 281        }
 282
 283        public static IEnumerable<bool> parseInputHelper(object arg1)
 284        {
 285            {
 286                Variable Term = new Variable();
 287                Variable Variables = new Variable();
 288                Variable Answer = new Variable();
 289                Variable x4 = new Variable();
 290                foreach (bool l2 in YP.unify(arg1, new Functor2("f", Term, Variables)))
 291                {
 292                    foreach (bool l3 in YP.repeat())
 293                    {
 294                        foreach (bool l4 in portable_read3(Answer, Variables, x4))
 295                        {
 296                            foreach (bool l5 in remove_pos(Answer, Term))
 297                            {
 298                                if (YP.termEqual(Term, Atom.a("end_of_file")))
 299                                {
 300                                    yield break;
 301                                    goto cutIf1;
 302                                }
 303                                yield return false;
 304                            cutIf1:
 305                                { }
 306                            }
 307                        }
 308                    }
 309                }
 310            }
 311        }
 312
 313        public static IEnumerable<bool> clear_errors()
 314        {
 315            {
 316                yield return false;
 317            }
 318        }
 319
 320        public static IEnumerable<bool> remove_pos(object arg1, object arg2)
 321        {
 322            {
 323                Variable X = new Variable();
 324                foreach (bool l2 in YP.unify(arg1, X))
 325                {
 326                    foreach (bool l3 in YP.unify(arg2, X))
 327                    {
 328                        if (YP.var(X))
 329                        {
 330                            yield return true;
 331                            yield break;
 332                        }
 333                    }
 334                }
 335            }
 336            {
 337                object X = arg2;
 338                Variable _Pos = new Variable();
 339                Variable _Name = new Variable();
 340                foreach (bool l2 in YP.unify(arg1, new Functor3("$VAR", _Pos, _Name, X)))
 341                {
 342                    if (YP.var(X))
 343                    {
 344                        yield return true;
 345                        yield break;
 346                    }
 347                }
 348            }
 349            {
 350                foreach (bool l2 in YP.unify(arg1, Atom.NIL))
 351                {
 352                    foreach (bool l3 in YP.unify(arg2, Atom.NIL))
 353                    {
 354                        yield return true;
 355                        yield break;
 356                    }
 357                }
 358            }
 359            {
 360                Variable H = new Variable();
 361                Variable T = new Variable();
 362                Variable NH = new Variable();
 363                Variable NT = new Variable();
 364                foreach (bool l2 in YP.unify(arg1, new ListPair(H, T)))
 365                {
 366                    foreach (bool l3 in YP.unify(arg2, new ListPair(NH, NT)))
 367                    {
 368                        foreach (bool l4 in remove_pos(H, NH))
 369                        {
 370                            foreach (bool l5 in remove_pos(T, NT))
 371                            {
 372                                yield return false;
 373                            }
 374                        }
 375                        yield break;
 376                    }
 377                }
 378            }
 379            {
 380                Variable A = new Variable();
 381                Variable B = new Variable();
 382                Variable NA = new Variable();
 383                Variable NB = new Variable();
 384                foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
 385                {
 386                    foreach (bool l3 in YP.unify(arg2, new Functor2(",", NA, NB)))
 387                    {
 388                        foreach (bool l4 in remove_pos(A, NA))
 389                        {
 390                            foreach (bool l5 in remove_pos(B, NB))
 391                            {
 392                                yield return false;
 393                            }
 394                        }
 395                        yield break;
 396                    }
 397                }
 398            }
 399            {
 400                Variable Atom_1 = new Variable();
 401                Variable _F = new Variable();
 402                foreach (bool l2 in YP.unify(arg1, Atom_1))
 403                {
 404                    foreach (bool l3 in YP.unify(arg2, Atom_1))
 405                    {
 406                        foreach (bool l4 in YP.functor(Atom_1, _F, 0))
 407                        {
 408                            yield return false;
 409                        }
 410                    }
 411                }
 412            }
 413            {
 414                object Term = arg1;
 415                object NewTerm = arg2;
 416                Variable Func = new Variable();
 417                Variable _Pos = new Variable();
 418                Variable Args = new Variable();
 419                Variable NArgs = new Variable();
 420                if (YP.nonvar(Term))
 421                {
 422                    foreach (bool l3 in YP.univ(Term, new ListPair(Func, new ListPair(_Pos, Args))))
 423                    {
 424                        foreach (bool l4 in remove_pos(Args, NArgs))
 425                        {
 426                            foreach (bool l5 in YP.univ(NewTerm, new ListPair(Func, NArgs)))
 427                            {
 428                                yield return false;
 429                            }
 430                        }
 431                    }
 432                }
 433            }
 434        }
 435
 436        public static IEnumerable<bool> portable_read_position(object Term, object PosTerm, object Syntax)
 437        {
 438            {
 439                foreach (bool l2 in portable_read(PosTerm, Syntax))
 440                {
 441                    foreach (bool l3 in remove_pos(PosTerm, Term))
 442                    {
 443                        yield return false;
 444                    }
 445                }
 446            }
 447        }
 448
 449        public static IEnumerable<bool> portable_read(object Answer, object Syntax)
 450        {
 451            {
 452                Variable Tokens = new Variable();
 453                Variable ParseTokens = new Variable();
 454                foreach (bool l2 in read_tokens1(Tokens))
 455                {
 456                    foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
 457                    {
 458                        foreach (bool l4 in parse2(ParseTokens, Answer))
 459                        {
 460                            yield return false;
 461                        }
 462                    }
 463                }
 464            }
 465        }
 466
 467        public static IEnumerable<bool> portable_read3(object Answer, object Variables, object Syntax)
 468        {
 469            {
 470                Variable Tokens = new Variable();
 471                Variable ParseTokens = new Variable();
 472                foreach (bool l2 in read_tokens2(Tokens, Variables))
 473                {
 474                    foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax))
 475                    {
 476                        foreach (bool l4 in parse2(ParseTokens, Answer))
 477                        {
 478                            yield return false;
 479                        }
 480                    }
 481                }
 482            }
 483        }
 484
 485        public static IEnumerable<bool> remove_comments(object arg1, object arg2, object arg3)
 486        {
 487            {
 488                foreach (bool l2 in YP.unify(arg1, Atom.NIL))
 489                {
 490                    foreach (bool l3 in YP.unify(arg2, Atom.NIL))
 491                    {
 492                        foreach (bool l4 in YP.unify(arg3, Atom.NIL))
 493                        {
 494                            yield return false;
 495                        }
 496                    }
 497                }
 498            }
 499            {
 500                object Ys = arg2;
 501                Variable S = new Variable();
 502                Variable E = new Variable();
 503                Variable Xs = new Variable();
 504                Variable Zs = new Variable();
 505                foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("comment", S, E), Xs)))
 506                {
 507                    foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("comment", S, E), Zs)))
 508                    {
 509                        foreach (bool l4 in remove_comments(Xs, Ys, Zs))
 510                        {
 511                            yield return false;
 512                        }
 513                        yield break;
 514                    }
 515                }
 516            }
 517            {
 518                Variable Pos = new Variable();
 519                Variable Xs = new Variable();
 520                Variable Ys = new Variable();
 521                Variable Pos2 = new Variable();
 522                Variable Zs = new Variable();
 523                foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("["), Pos), Xs)))
 524                {
 525                    foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("["), Ys)))
 526                    {
 527                        foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
 528                        {
 529                            foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
 530                            {
 531                                foreach (bool l6 in remove_comments(Xs, Ys, Zs))
 532                                {
 533                                    yield return false;
 534                                }
 535                            }
 536                            yield break;
 537                        }
 538                    }
 539                }
 540            }
 541            {
 542                Variable Pos = new Variable();
 543                Variable Xs = new Variable();
 544                Variable Ys = new Variable();
 545                Variable Pos2 = new Variable();
 546                Variable Zs = new Variable();
 547                foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("]"), Pos), Xs)))
 548                {
 549                    foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), Ys)))
 550                    {
 551                        foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
 552                        {
 553                            foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
 554                            {
 555                                foreach (bool l6 in remove_comments(Xs, Ys, Zs))
 556                                {
 557                                    yield return false;
 558                                }
 559                            }
 560                            yield break;
 561                        }
 562                    }
 563                }
 564            }
 565            {
 566                object Zs = arg3;
 567                Variable Token = new Variable();
 568                Variable Xs = new Variable();
 569                Variable Ys = new Variable();
 570                foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Xs)))
 571                {
 572                    foreach (bool l3 in YP.unify(arg2, new ListPair(Token, Ys)))
 573                    {
 574                        foreach (bool l4 in remove_comments(Xs, Ys, Zs))
 575                        {
 576                            yield return false;
 577                        }
 578                    }
 579                }
 580            }
 581        }
 582
 583        public static IEnumerable<bool> expect(object Token, object arg2, object arg3)
 584        {
 585            {
 586                object Rest = arg3;
 587                foreach (bool l2 in YP.unify(arg2, new ListPair(Token, Rest)))
 588                {
 589                    yield return true;
 590                    yield break;
 591                }
 592            }
 593            {
 594                object S0 = arg2;
 595                object x3 = arg3;
 596                foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("or"), Atom.a("operator"), Atom.a("expected") }), S0))
 597                {
 598                    yield return false;
 599                }
 600            }
 601        }
 602
 603        public static IEnumerable<bool> parse2(object Tokens, object Answer)
 604        {
 605            {
 606                Variable Term = new Variable();
 607                Variable LeftOver = new Variable();
 608                foreach (bool l2 in clear_errors())
 609                {
 610                    foreach (bool l3 in parse(Tokens, 1200, Term, LeftOver))
 611                    {
 612                        foreach (bool l4 in all_read(LeftOver))
 613                        {
 614                            foreach (bool l5 in YP.unify(Answer, Term))
 615                            {
 616                                yield return false;
 617                            }
 618                            yield break;
 619                        }
 620                    }
 621                    foreach (bool l3 in syntax_error(Tokens))
 622                    {
 623                        yield return false;
 624                    }
 625                }
 626            }
 627        }
 628
 629        public static IEnumerable<bool> all_read(object arg1)
 630        {
 631            {
 632                foreach (bool l2 in YP.unify(arg1, Atom.NIL))
 633                {
 634                    yield return false;
 635                }
 636            }
 637            {
 638                Variable Token = new Variable();
 639                Variable S = new Variable();
 640                foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S)))
 641                {
 642                    foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a("operator"), Atom.a("expected"), Atom.a("after"), Atom.a("expression") }), new ListPair(Token, S)))
 643                    {
 644                        yield return false;
 645                    }
 646                }
 647            }
 648        }
 649
 650        public static IEnumerable<bool> parse(object arg1, object arg2, object arg3, object arg4)
 651        {
 652            {
 653                object x1 = arg2;
 654                object x2 = arg3;
 655                object x3 = arg4;
 656                foreach (bool l2 in YP.unify(arg1, Atom.NIL))
 657                {
 658                    foreach (bool l3 in syntax_error(new ListPair(Atom.a("expression"), new ListPair(Atom.a("expected"), Atom.NIL)), Atom.NIL))
 659                    {
 660                        yield return false;
 661                    }
 662                }
 663            }
 664            {
 665                object Precedence = arg2;
 666                object Term = arg3;
 667                object LeftOver = arg4;
 668                Variable Token = new Variable();
 669                Variable RestTokens = new Variable();
 670                foreach (bool l2 in YP.unify(arg1, new ListPair(Token, RestTokens)))
 671                {
 672                    foreach (bool l3 in parse5(Token, RestTokens, Precedence, Term, LeftOver))
 673                    {
 674                        yield return false;
 675                    }
 676                }
 677            }
 678        }
 679
 680        public static IEnumerable<bool> parse5(object arg1, object arg2, object arg3, object arg4, object arg5)
 681        {
 682            {
 683                object S0 = arg2;
 684                object x2 = arg3;
 685                object x3 = arg4;
 686                object x4 = arg5;
 687                foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
 688                {
 689                    foreach (bool l3 in cannot_start(Atom.a("}"), S0))
 690                    {
 691                        yield return false;
 692                    }
 693                }
 694            }
 695            {
 696                object S0 = arg2;
 697                object x2 = arg3;
 698                object x3 = arg4;
 699                object x4 = arg5;
 700                foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
 701                {
 702                    foreach (bool l3 in cannot_start(Atom.a("]"), S0))
 703                    {
 704                        yield return false;
 705                    }
 706                }
 707            }
 708            {
 709                object S0 = arg2;
 710                object x2 = arg3;
 711                object x3 = arg4;
 712                object x4 = arg5;
 713                foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
 714                {
 715                    foreach (bool l3 in cannot_start(Atom.a(")"), S0))
 716                    {
 717                        yield return false;
 718                    }
 719                }
 720            }
 721            {
 722                object S0 = arg2;
 723                object x2 = arg3;
 724                object x3 = arg4;
 725                object x4 = arg5;
 726                foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
 727                {
 728                    foreach (bool l3 in cannot_start(Atom.a(","), S0))
 729                    {
 730                        yield return false;
 731                    }
 732                }
 733            }
 734            {
 735                object S0 = arg2;
 736                object x2 = arg3;
 737                object x3 = arg4;
 738                object x4 = arg5;
 739                foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
 740                {
 741                    foreach (bool l3 in cannot_start(Atom.a("|"), S0))
 742                    {
 743                        yield return false;
 744                    }
 745                }
 746            }
 747            {
 748                object S0 = arg2;
 749                object Precedence = arg3;
 750                object Answer = arg4;
 751                object S = arg5;
 752                Variable Codes = new Variable();
 753                Variable Term = new Variable();
 754                Variable A = new Variable();
 755                foreach (bool l2 in YP.unify(arg1, new Functor1("string", Codes)))
 756                {
 757                    foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("atom")))
 758                    {
 759                        foreach (bool l4 in YP.atom_codes(Term, Codes))
 760                        {
 761                            foreach (bool l5 in exprtl0(S0, Term, Precedence, Answer, S))
 762                            {
 763                                yield return false;
 764                            }
 765                        }
 766                        goto cutIf1;
 767                    }
 768                    foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("chars")))
 769                    {
 770                        foreach (bool l4 in YP.atom_codes(A, Codes))
 771                        {
 772                            foreach (bool l5 in YP.atom_chars(A, Term))
 773                {
 774                                foreach (bool l6 in exprtl0(S0, Term, Precedence, Answer, S))
 775                    {
 776                        yield return false;
 777                    }
 778                }
 779            }
 780                        goto cutIf2;
 781                    }
 782                    foreach (bool l3 in YP.unify(Term, Codes))
 783                {
 784                        foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
 785                    {
 786                        yield return false;
 787                    }
 788                }
 789                cutIf2:
 790                cutIf1:
 791                    { }
 792                }
 793            }
 794            {
 795                object S0 = arg2;
 796                object Precedence = arg3;
 797                object Answer = arg4;
 798                object S = arg5;
 799                Variable Number = new Variable();
 800                foreach (bool l2 in YP.unify(arg1, new Functor1("number", Number)))
 801                {
 802                    foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S))
 803                    {
 804                        yield return false;
 805                    }
 806                }
 807            }
 808            {
 809                object Precedence = arg3;
 810                object Answer = arg4;
 811                object S = arg5;
 812                Variable S1 = new Variable();
 813                foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
 814                {
 815                    foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), S1)))
 816                    {
 817                        foreach (bool l4 in read_atom(new Functor2("/", Atom.NIL, 0), S1, Precedence, Answer, S))
 818                        {
 819                            yield return false;
 820                        }
 821                        yield break;
 822                    }
 823                }
 824            }
 825            {
 826                object S1 = arg2;
 827                object Precedence = arg3;
 828                object Answer = arg4;
 829                object S = arg5;
 830                Variable Arg1 = new Variable();
 831                Variable S2 = new Variable();
 832                Variable RestArgs = new Variable();
 833                Variable S3 = new Variable();
 834                foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
 835                {
 836                    foreach (bool l3 in parse(S1, 999, Arg1, S2))
 837                    {
 838                        foreach (bool l4 in read_list(S2, RestArgs, S3))
 839                        {
 840                            foreach (bool l5 in exprtl0(S3, new ListPair(Arg1, RestArgs), Precedence, Answer, S))
 841                            {
 842                                yield return false;
 843                            }
 844                            yield break;
 845                        }
 846                    }
 847                }
 848            }
 849            {
 850                object S1 = arg2;
 851                object Precedence = arg3;
 852                object Answer = arg4;
 853                object S = arg5;
 854                Variable Term = new Variable();
 855                Variable S2 = new Variable();
 856                Variable S3 = new Variable();
 857                foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
 858                {
 859                    foreach (bool l3 in parse(S1, 1200, Term, S2))
 860                    {
 861                        foreach (bool l4 in expect(Atom.a(")"), S2, S3))
 862                        {
 863                            foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
 864                            {
 865                                yield return false;
 866                            }
 867                            yield break;
 868                        }
 869                    }
 870                }
 871            }
 872            {
 873                object S1 = arg2;
 874                object Precedence = arg3;
 875                object Answer = arg4;
 876                object S = arg5;
 877                Variable Term = new Variable();
 878                Variable S2 = new Variable();
 879                Variable S3 = new Variable();
 880                foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
 881                {
 882                    foreach (bool l3 in parse(S1, 1200, Term, S2))
 883                    {
 884                        foreach (bool l4 in expect(Atom.a(")"), S2, S3))
 885                        {
 886                            foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
 887                            {
 888                                yield return false;
 889                            }
 890                            yield break;
 891                        }
 892                    }
 893                }
 894            }
 895            {
 896                object Precedence = arg3;
 897                object Answer = arg4;
 898                object S = arg5;
 899                Variable _Pos = new Variable();
 900                Variable S1 = new Variable();
 901                foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), _Pos)))
 902                {
 903                    foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("}"), S1)))
 904                    {
 905                        foreach (bool l4 in read_atom(Atom.a("{}"), S1, Precedence, Answer, S))
 906                        {
 907                            yield return false;
 908                        }
 909                        yield break;
 910                    }
 911                }
 912            }
 913            {
 914                object S1 = arg2;
 915                object Precedence = arg3;
 916                object Answer = arg4;
 917                object S = arg5;
 918                Variable Pos = new Variable();
 919                Variable Term = new Variable();
 920                Variable S2 = new Variable();
 921                Variable S3 = new Variable();
 922                foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), Pos)))
 923                {
 924                    foreach (bool l3 in parse(S1, 1200, Term, S2))
 925                    {
 926                        foreach (bool l4 in expect(Atom.a("}"), S2, S3))
 927                        {
 928                            foreach (bool l5 in exprtl0(S3, new Functor2("{}", Pos, Term), Precedence, Answer, S))
 929                            {
 930                                yield return false;
 931                            }
 932                            yield break;
 933                        }
 934                    }
 935                }
 936            }
 937            {
 938                object Precedence = arg3;
 939                object Answer = arg4;
 940                object S = arg5;
 941                Variable Variable_1 = new Variable();
 942                Variable Name = new Variable();
 943                Variable Pos = new Variable();
 944                Variable S1 = new Variable();
 945                Variable Arg1 = new Variable();
 946                Variable S2 = new Variable();
 947                Variable RestArgs = new Variable();
 948                Variable S3 = new Variable();
 949                Variable Term = new Variable();
 950                foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
 951                {
 952                    foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
 953                    {
 954                        foreach (bool l4 in parse(S1, 999, Arg1, S2))
 955                        {
 956                            foreach (bool l5 in read_args(S2, RestArgs, S3))
 957                            {
 958                                foreach (bool l6 in YP.univ(Term, new ListPair(Atom.a("call"), new ListPair(new Functor3("$VAR", Pos, Name, Variable_1), new ListPair(Arg1, RestArgs)))))
 959                                {
 960                                    foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
 961                                    {
 962                                        yield return false;
 963                                    }
 964                                }
 965                                yield break;
 966                            }
 967                        }
 968                        yield break;
 969                    }
 970                }
 971            }
 972            {
 973                object S0 = arg2;
 974                object Precedence = arg3;
 975                object Answer = arg4;
 976                object S = arg5;
 977                Variable Variable_1 = new Variable();
 978                Variable Name = new Variable();
 979                Variable Pos = new Variable();
 980                foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
 981                {
 982                    foreach (bool l3 in exprtl0(S0, new Functor3("$VAR", Pos, Name, Variable_1), Precedence, Answer, S))
 983                    {
 984                        yield return false;
 985                    }
 986                }
 987            }
 988            {
 989                object S0 = arg2;
 990                object Precedence = arg3;
 991                object Answer = arg4;
 992                object S = arg5;
 993                Variable Atom_1 = new Variable();
 994                Variable P = new Variable();
 995                foreach (bool l2 in YP.unify(arg1, new Functor2("atom", Atom_1, P)))
 996                {
 997                    foreach (bool l3 in read_atom(new Functor2("/", Atom_1, P), S0, Precedence, Answer, S))
 998                    {
 999                        yield return false;
1000                    }
1001                }
1002            }
1003        }
1004
1005        public static IEnumerable<bool> read_atom(object arg1, object arg2, object Precedence, object Answer, object S)
1006        {
1007            {
1008                Variable _Pos = new Variable();
1009                Variable Number = new Variable();
1010                Variable S1 = new Variable();
1011                Variable Negative = new Variable();
1012                foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("-"), _Pos)))
1013                {
1014                    foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1("number", Number), S1)))
1015                    {
1016                        foreach (bool l4 in YP.unify(Negative, YP.negate(Number)))
1017                        {
1018                            foreach (bool l5 in exprtl0(S1, Negative, Precedence, Answer, S))
1019                            {
1020                                yield return false;
1021                            }
1022                        }
1023                        yield break;
1024                    }
1025                }
1026            }
1027            {
1028                Variable Functor_1 = new Variable();
1029                Variable Pos = new Variable();
1030                Variable S1 = new Variable();
1031                Variable Arg1 = new Variable();
1032                Variable S2 = new Variable();
1033                Variable RestArgs = new Variable();
1034                Variable S3 = new Variable();
1035                Variable Term = new Variable();
1036                foreach (bool l2 in YP.unify(arg1, new Functor2("/", Functor_1, Pos)))
1037                {
1038                    foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
1039                    {
1040                        foreach (bool l4 in parse(S1, 999, Arg1, S2))
1041                        {
1042                            foreach (bool l5 in read_args(S2, RestArgs, S3))
1043                            {
1044                                foreach (bool l6 in YP.univ(Term, new ListPair(Functor_1, new ListPair(Pos, new ListPair(Arg1, RestArgs)))))
1045                                {
1046                                    foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
1047                                    {
1048                                        yield return false;
1049                                    }
1050                                }
1051                                yield break;
1052                            }
1053                        }
1054                        yield break;
1055                    }
1056                }
1057            }
1058            {
1059                object S0 = arg2;
1060                Variable Op = new Variable();
1061                Variable Pos = new Variable();
1062                Variable Oprec = new Variable();
1063                Variable Aprec = new Variable();
1064                Variable Flag = new Variable();
1065                Variable Term = new Variable();
1066                Variable Arg = new Variable();
1067                Variable S1 = new Variable();
1068                foreach (bool l2 in YP.unify(arg1, new Functor2("/", Op, Pos)))
1069                {
1070                    foreach (bool l3 in prefixop(Op, Oprec, Aprec))
1071                    {
1072                        foreach (bool l4 in possible_right_operand(S0, Flag))
1073                        {
1074                            if (YP.lessThan(Flag, 0))
1075                            {
1076                                foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, Atom.NIL))))
1077                                {
1078                                    foreach (bool l7 in exprtl0(S0, Term, Precedence, Answer, S))
1079                                    {
1080                                        yield return false;
1081                                    }
1082                                }
1083                                goto cutIf1;
1084                            }
1085                            if (YP.greaterThan(Oprec, Precedence))
1086                            {
1087                                foreach (bool l6 in syntax_error(ListPair.make(new object[] { Atom.a("prefix"), Atom.a("operator"), Op, Atom.a("in"), Atom.a("context"), Atom.a("with"), Atom.a("precedence"), Precedence }), S0))
1088                                {
1089                                    yield return false;
1090                                }
1091                                goto cutIf2;
1092                            }
1093                            if (YP.greaterThan(Flag, 0))
1094                            {
1095                                foreach (bool l6 in parse(S0, Aprec, Arg, S1))
1096                                {
1097                                    foreach (bool l7 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
1098                                    {
1099                                        foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
1100                                        {
1101                                            yield return false;
1102                                        }
1103                                    }
1104                                    yield break;
1105                                }
1106                                goto cutIf3;
1107                            }
1108                            foreach (bool l5 in peepop(S0, S1))
1109                            {
1110                                foreach (bool l6 in prefix_is_atom(S1, Oprec))
1111                                {
1112                                    foreach (bool l7 in exprtl(S1, Oprec, new Functor2("/", Op, Pos), Precedence, Answer, S))
1113                                    {
1114                                        yield return false;
1115                                    }
1116                                }
1117                            }
1118                            foreach (bool l5 in parse(S0, Aprec, Arg, S1))
1119                            {
1120                                foreach (bool l6 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
1121                                {
1122                                    foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
1123                                    {
1124                                        yield return false;
1125                                    }
1126                                }
1127                                yield break;
1128                            }
1129                        cutIf3:
1130                        cutIf2:
1131                        cutIf1:
1132                            { }
1133                        }
1134                        yield break;
1135                    }
1136                }
1137            }
1138            {
1139                object S0 = arg2;
1140                Variable Atom_1 = new Variable();
1141                Variable Pos = new Variable();
1142                Variable Term = new Variable();
1143                foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom_1, Pos)))
1144                {
1145                    foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL))))
1146                    {
1147                        foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
1148                        {
1149                            yield return false;
1150                        }
1151                    }
1152                }
1153            }
1154        }
1155
1156        public static IEnumerable<bool> cannot_start(object Token, object S0)
1157        {
1158            {
1159                foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("cannot"), Atom.a("start"), Atom.a("an"), Atom.a("expression") }), S0))
1160                {
1161                    yield return false;
1162                }
1163            }
1164        }
1165
1166        public static IEnumerable<bool> read_args(object arg1, object arg2, object arg3)
1167        {
1168            {
1169                object S = arg3;
1170                Variable S1 = new Variable();
1171                Variable Term = new Variable();
1172                Variable Rest = new Variable();
1173                Variable S2 = new Variable();
1174                foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(","), S1)))
1175                {
1176                    foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest)))
1177                    {
1178                        foreach (bool l4 in parse(S1, 999, Term, S2))
1179                        {
1180                            foreach (bool l5 in read_args(S2, Rest, S))
1181                            {
1182                                yield return false;
1183                            }
1184                            yield break;
1185                        }
1186                        yield break;
1187                    }
1188                }
1189            }
1190            {
1191                object S = arg3;
1192                foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(")"), S)))
1193                {
1194                    foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1195                    {
1196                        yield return true;
1197                        yield break;
1198                    }
1199                }
1200            }
1201            {
1202                object S = arg1;
1203                object x2 = arg2;
1204                object x3 = arg3;
1205                foreach (bool l2 in syntax_error(ListPair.make(new object[] { Atom.a(", or )"), Atom.a("expected"), Atom.a("in"), Atom.a("arguments") }), S))
1206                {
1207                    yield return false;
1208                }
1209            }
1210        }
1211
1212        public static IEnumerable<bool> read_list(object arg1, object arg2, object arg3)
1213        {
1214            {
1215                object x1 = arg2;
1216                object x2 = arg3;
1217                foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1218                {
1219                    foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a(", | or ]"), Atom.a("expected"), Atom.a("in"), Atom.a("list") }), Atom.NIL))
1220                    {
1221                        yield return false;
1222                    }
1223                }
1224            }
1225            {
1226                object Rest = arg2;
1227                object S = arg3;
1228                Variable Token = new Variable();
1229                Variable S1 = new Variable();
1230                foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1)))
1231                {
1232                    foreach (bool l3 in read_list4(Token, S1, Rest, S))
1233                    {
1234                        yield return false;
1235                    }
1236                }

Large files files are truncated, but you can click here to view the full file