public static IEnumerable<bool> read_term3(object Input, object Term, object Options)
 {
     Variable SaveInput = new Variable();
     Variable Answer = new Variable();
     Variable Variables = new Variable();
     foreach (bool l1 in read_termOptions(Options, Variables))
     {
         foreach (bool l2 in YP.current_input(SaveInput))
         {
             try
             {
                 YP.see(Input);
                 foreach (bool l3 in portable_read3(Answer, Variables, new Variable()))
                 {
                     foreach (bool l4 in remove_pos(Answer, Term))
                         yield return false;
                 }
             }
             finally
             {
                 YP.see(SaveInput);
             }
         }
     }
 }
 public static IEnumerable<bool> read_term2(object Term, object Options)
 {
     Variable Answer = new Variable();
     Variable Variables = new Variable();
     foreach (bool l1 in read_termOptions(Options, Variables))
     {
         foreach (bool l2 in portable_read3(Answer, Variables, new Variable()))
         {
             foreach (bool l3 in remove_pos(Answer, Term))
                 yield return false;
         }
     }
 }
示例#3
0
 public object makeCopy(Variable.CopyStore copyStore)
 {
     // Atom does not contain variables that need to be copied.
     return this;
 }
示例#4
0
 public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode)
 {
     {
         Variable FirstRule = new Variable();
         Variable x5 = new Variable();
         Variable x6 = new Variable();
         Variable x7 = new Variable();
         Variable Head = new Variable();
         Variable x9 = new Variable();
         Variable ArgAssignments = new Variable();
         Variable Calls = new Variable();
         Variable Rule = new Variable();
         Variable VariableNameSuggestions = new Variable();
         Variable ClauseBag = new Variable();
         Variable Name = new Variable();
         Variable ArgsList = new Variable();
         Variable FunctionArgNames = new Variable();
         Variable MergedArgName = new Variable();
         Variable ArgName = new Variable();
         Variable MergedArgNames = new Variable();
         Variable FunctionArgs = new Variable();
         Variable BodyCode = new Variable();
         Variable ReturnType = new Variable();
         Variable BodyWithReturn = new Variable();
         foreach (bool l2 in YP.unify(new ListPair(new Functor2("f", FirstRule, x5), x6), SamePredicateRuleList))
         {
             foreach (bool l3 in YP.unify(FirstRule, new Functor1(":-", x7)))
             {
                 goto cutIf1;
             }
             foreach (bool l3 in YP.unify(new Functor2(":-", Head, x9), FirstRule))
             {
                 CompilerState.startFunction(State, Head);
                 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
                 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
                 {
                     foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
                     {
                         findallAnswers3.add();
                     }
                 }
                 foreach (bool l4 in findallAnswers3.result(ClauseBag))
                 {
                     foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
                     {
                         foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
                         {
                             FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName);
                             foreach (bool l7 in member(ArgName, FunctionArgNames))
                             {
                                 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
                                 {
                                     findallAnswers4.add();
                                     goto cutIf5;
                                 }
                                 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
                                 {
                                     findallAnswers4.add();
                                 }
                             cutIf5:
                                 { }
                             }
                             foreach (bool l7 in findallAnswers4.result(MergedArgNames))
                             {
                                 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
                                 {
                                     foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
                                     {
                                         if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf7;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf8;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf9;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf9:
                                             cutIf8:
                                             cutIf7:
                                                 { }
                                             }
                                             goto cutIf6;
                                         }
                                         if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf11;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf12;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf13;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf13:
                                             cutIf12:
                                             cutIf11:
                                                 { }
                                             }
                                             goto cutIf10;
                                         }
                                         foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
                                         {
                                             if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                             {
                                                 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf14;
                                             }
                                             if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf15;
                                             }
                                             if (CompilerState.codeUsesYield(State))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf16;
                                             }
                                             foreach (bool l11 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                             {
                                                 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                 {
                                                     yield return false;
                                                 }
                                             }
                                         cutIf16:
                                         cutIf15:
                                         cutIf14:
                                             { }
                                         }
                                     cutIf10:
                                     cutIf6:
                                         { }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 goto cutIf2;
             }
             foreach (bool l3 in YP.unify(Head, FirstRule))
             {
                 CompilerState.startFunction(State, Head);
                 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
                 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
                 {
                     foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
                     {
                         findallAnswers17.add();
                     }
                 }
                 foreach (bool l4 in findallAnswers17.result(ClauseBag))
                 {
                     foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
                     {
                         foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
                         {
                             FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName);
                             foreach (bool l7 in member(ArgName, FunctionArgNames))
                             {
                                 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
                                 {
                                     findallAnswers18.add();
                                     goto cutIf19;
                                 }
                                 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
                                 {
                                     findallAnswers18.add();
                                 }
                             cutIf19:
                                 { }
                             }
                             foreach (bool l7 in findallAnswers18.result(MergedArgNames))
                             {
                                 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
                                 {
                                     foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
                                     {
                                         if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf21;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf22;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf23;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf23:
                                             cutIf22:
                                             cutIf21:
                                                 { }
                                             }
                                             goto cutIf20;
                                         }
                                         if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf25;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf26;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf27;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf27:
                                             cutIf26:
                                             cutIf25:
                                                 { }
                                             }
                                             goto cutIf24;
                                         }
                                         foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
                                         {
                                             if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                             {
                                                 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf28;
                                             }
                                             if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf29;
                                             }
                                             if (CompilerState.codeUsesYield(State))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf30;
                                             }
                                             foreach (bool l11 in append(BodyCode, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                             {
                                                 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                 {
                                                     yield return false;
                                                 }
                                             }
                                         cutIf30:
                                         cutIf29:
                                         cutIf28:
                                             { }
                                         }
                                     cutIf24:
                                     cutIf20:
                                         { }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         cutIf2:
         cutIf1:
             { }
         }
     }
 }
示例#5
0
 public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3)
 {
     {
         object _State = arg1;
         object _Module = arg2;
         foreach (bool l2 in YP.unify(arg3, Atom.NIL))
         {
             yield return true;
             yield break;
         }
     }
     {
         object State = arg1;
         object Module = arg2;
         Variable Name = new Variable();
         Variable Arity = new Variable();
         Variable Rest = new Variable();
         foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2("/", Name, Arity), Rest)))
         {
             CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
             foreach (bool l3 in importPredicateList(State, Module, Rest))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object State = arg1;
         object Module = arg2;
         Variable x3 = new Variable();
         Variable Rest = new Variable();
         foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest)))
         {
             foreach (bool l3 in importPredicateList(State, Module, Rest))
             {
                 yield return true;
                 yield break;
             }
         }
     }
 }
示例#6
0
 public static IEnumerable<bool> append(object arg1, object arg2, object arg3)
 {
     {
         Variable List = new Variable();
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             foreach (bool l3 in YP.unify(arg2, List))
             {
                 foreach (bool l4 in YP.unify(arg3, List))
                 {
                     yield return false;
                 }
             }
         }
     }
     {
         object List2 = arg2;
         Variable X = new Variable();
         Variable List1 = new Variable();
         Variable List12 = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1)))
         {
             foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12)))
             {
                 foreach (bool l4 in append(List1, List2, List12))
                 {
                     yield return false;
                 }
             }
         }
     }
 }
示例#7
0
 public static IEnumerable<bool> putCStringCode(object Code)
 {
     {
         Variable HexDigit = new Variable();
         Variable HexChar = new Variable();
         if (YP.lessThanOrEqual(Code, 31))
         {
             if (YP.lessThanOrEqual(Code, 15))
             {
                 YP.write(Atom.a("\\u000"));
                 foreach (bool l4 in YP.unify(HexDigit, Code))
                 {
                     if (YP.lessThanOrEqual(HexDigit, 9))
                     {
                         foreach (bool l6 in YP.unify(HexChar, YP.add(HexDigit, 48)))
                         {
                             YP.put_code(HexChar);
                             yield return true;
                             yield break;
                         }
                         goto cutIf2;
                     }
                     foreach (bool l5 in YP.unify(HexChar, YP.add(HexDigit, 55)))
                     {
                         YP.put_code(HexChar);
                         yield return true;
                         yield break;
                     }
                 cutIf2:
                     { }
                 }
                 goto cutIf1;
             }
             YP.write(Atom.a("\\u001"));
             foreach (bool l3 in YP.unify(HexDigit, YP.subtract(Code, 16)))
             {
                 if (YP.lessThanOrEqual(HexDigit, 9))
                 {
                     foreach (bool l5 in YP.unify(HexChar, YP.add(HexDigit, 48)))
                     {
                         YP.put_code(HexChar);
                         yield return true;
                         yield break;
                     }
                     goto cutIf3;
                 }
                 foreach (bool l4 in YP.unify(HexChar, YP.add(HexDigit, 55)))
                 {
                     YP.put_code(HexChar);
                     yield return true;
                     yield break;
                 }
             cutIf3:
                 { }
             }
         cutIf1:
             { }
         }
     }
     {
         if (YP.termEqual(Code, 34))
         {
             YP.put_code(92);
             YP.put_code(34);
             yield return true;
             yield break;
         }
     }
     {
         if (YP.termEqual(Code, 92))
         {
             YP.put_code(92);
             YP.put_code(92);
             yield return true;
             yield break;
         }
     }
     {
         YP.put_code(Code);
         yield return true;
         yield break;
     }
 }
示例#8
0
 public static void convertExpressionPython(object arg1)
 {
     {
         Variable X = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
         {
             YP.write(X);
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor2("call", Name, ArgList)))
         {
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable _FunctorArgs = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor3("functorCall", Name, _FunctorArgs, ArgList)))
         {
             convertExpressionPython(new Functor2("call", Name, ArgList));
             return;
         }
     }
     {
         Variable Obj = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor3("callMember", new Functor1("var", Obj), Name, ArgList)))
         {
             YP.write(Obj);
             YP.write(Atom.a("."));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor2("new", Name, ArgList)))
         {
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable Name = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
         {
             YP.write(Name);
             return;
         }
     }
     {
         foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
         {
             YP.write(Atom.a("None"));
             return;
         }
     }
     {
         Variable X = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
         {
             YP.write(Atom.a("not ("));
             convertExpressionPython(X);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable X = new Variable();
         Variable Y = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor2("and", X, Y)))
         {
             YP.write(Atom.a("("));
             convertExpressionPython(X);
             YP.write(Atom.a(") and ("));
             convertExpressionPython(Y);
             YP.write(Atom.a(")"));
             return;
         }
     }
     {
         Variable ArgList = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
         {
             YP.write(Atom.a("["));
             convertArgListPython(ArgList);
             YP.write(Atom.a("]"));
             return;
         }
     }
     {
         Variable X = new Variable();
         Variable Codes = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
         {
             if (YP.atom(X))
             {
                 YP.write(Atom.a("\""));
                 foreach (bool l4 in YP.atom_codes(X, Codes))
                 {
                     convertStringCodesPython(Codes);
                     YP.write(Atom.a("\""));
                     return;
                 }
             }
         }
     }
     {
         Variable X = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor1("object", X)))
         {
             YP.write(X);
             return;
         }
     }
 }
示例#9
0
 public static void convertStatementListJavascript(object arg1, object arg2)
 {
     {
         object x1 = arg2;
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             return;
         }
     }
     {
         object Level = arg2;
         Variable Name = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Name);
             YP.write(Atom.a(":"));
             YP.nl();
             convertIndentationJavascript(Level);
             YP.write(Atom.a("{"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListJavascript(Body, NextLevel);
                 convertIndentationJavascript(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListJavascript(RestStatements, Level);
                 return;
             }
         }
     }
     {
         object Level = arg2;
         Variable _Type = new Variable();
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", _Type, Name, Expression), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("var "));
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionJavascript(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionJavascript(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("yield true;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("yield false;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("return;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("return"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("return;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returntrue"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("return true;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returnfalse"), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("return false;"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable Name = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("breakBlock", Name), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("break "));
             YP.write(Name);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("call", Name, ArgList), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListJavascript(ArgList);
             YP.write(Atom.a(");"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable Name = new Variable();
         Variable _FunctorArgs = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("functorCall", Name, _FunctorArgs, ArgList), RestStatements)))
         {
             convertStatementListJavascript(new ListPair(new Functor2("call", Name, ArgList), RestStatements), Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable Obj = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("callMember", new Functor1("var", Obj), Name, ArgList), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Obj);
             YP.write(Atom.a("."));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListJavascript(ArgList);
             YP.write(Atom.a(");"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
     {
         object Level = arg2;
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("{"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListJavascript(Body, NextLevel);
                 convertIndentationJavascript(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListJavascript(RestStatements, Level);
                 return;
             }
         }
     }
     {
         object Level = arg2;
         Variable Expression = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", Expression, Body), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("if ("));
             convertExpressionJavascript(Expression);
             YP.write(Atom.a(") {"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListJavascript(Body, NextLevel);
                 convertIndentationJavascript(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListJavascript(RestStatements, Level);
                 return;
             }
         }
     }
     {
         object Level = arg2;
         Variable Expression = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", Expression, Body), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("for each (var l"));
             YP.write(Level);
             YP.write(Atom.a(" in "));
             convertExpressionJavascript(Expression);
             YP.write(Atom.a(") {"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListJavascript(Body, NextLevel);
                 convertIndentationJavascript(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListJavascript(RestStatements, Level);
                 return;
             }
         }
     }
     {
         object Level = arg2;
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("throw", Expression), RestStatements)))
         {
             convertIndentationJavascript(Level);
             YP.write(Atom.a("throw "));
             convertExpressionJavascript(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListJavascript(RestStatements, Level);
             return;
         }
     }
 }
示例#10
0
 public static void convertFunctionJavascript(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
         {
             YP.write(Atom.a("function getDeclaringClass() { return null; }"));
             YP.nl();
             YP.nl();
             return;
         }
     }
     {
         Variable x1 = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable Body = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { x1, Name, ArgList, Body })))
         {
             YP.write(Atom.a("function "));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListJavascript(ArgList);
             YP.write(Atom.a(") {"));
             YP.nl();
             convertStatementListJavascript(Body, 1);
             YP.write(Atom.a("}"));
             YP.nl();
             YP.nl();
             return;
         }
     }
 }
示例#11
0
 public static void convertStatementListCSharp(object arg1, object Level)
 {
     {
         Variable Name = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NewStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
         {
             foreach (bool l3 in append(Body, new ListPair(new Functor1("label", Name), RestStatements), NewStatements))
             {
                 convertStatementListCSharp(NewStatements, Level);
                 return;
             }
         }
     }
     {
         Variable Type = new Variable();
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", Type, Name, Expression), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Type);
             YP.write(Atom.a(" "));
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionCSharp(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionCSharp(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("yield return true;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("yield return false;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("yield break;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("return"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("return;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returntrue"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("return true;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returnfalse"), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("return false;"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("label", Name), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Name);
             YP.write(Atom.a(":"));
             YP.nl();
             if (YP.termEqual(RestStatements, Atom.NIL))
             {
                 convertIndentationCSharp(Level);
                 YP.write(Atom.a("{}"));
                 YP.nl();
                 convertStatementListCSharp(RestStatements, Level);
                 return;
                 goto cutIf1;
             }
             convertStatementListCSharp(RestStatements, Level);
             return;
         cutIf1:
             { }
         }
     }
     {
         Variable Name = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("breakBlock", Name), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("goto "));
             YP.write(Name);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("call", Name, ArgList), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListCSharp(ArgList);
             YP.write(Atom.a(");"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable Name = new Variable();
         Variable _FunctorArgs = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("functorCall", Name, _FunctorArgs, ArgList), RestStatements)))
         {
             convertStatementListCSharp(new ListPair(new Functor2("call", Name, ArgList), RestStatements), Level);
             return;
         }
     }
     {
         Variable Obj = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("callMember", new Functor1("var", Obj), Name, ArgList), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Obj);
             YP.write(Atom.a("."));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListCSharp(ArgList);
             YP.write(Atom.a(");"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
     {
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("{"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListCSharp(Body, NextLevel);
                 convertIndentationCSharp(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListCSharp(RestStatements, Level);
                 return;
             }
         }
     }
     {
         Variable Expression = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", Expression, Body), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("if ("));
             convertExpressionCSharp(Expression);
             YP.write(Atom.a(") {"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListCSharp(Body, NextLevel);
                 convertIndentationCSharp(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListCSharp(RestStatements, Level);
                 return;
             }
         }
     }
     {
         Variable Expression = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", Expression, Body), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("foreach (bool l"));
             YP.write(Level);
             YP.write(Atom.a(" in "));
             convertExpressionCSharp(Expression);
             YP.write(Atom.a(") {"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 convertStatementListCSharp(Body, NextLevel);
                 convertIndentationCSharp(Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 convertStatementListCSharp(RestStatements, Level);
                 return;
             }
         }
     }
     {
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("throw", Expression), RestStatements)))
         {
             convertIndentationCSharp(Level);
             YP.write(Atom.a("throw "));
             convertExpressionCSharp(Expression);
             YP.write(Atom.a(";"));
             YP.nl();
             convertStatementListCSharp(RestStatements, Level);
             return;
         }
     }
 }
示例#12
0
 public static void convertFunctionCSharp(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
         {
             YP.write(Atom.a("public class YPInnerClass {}"));
             YP.nl();
             YP.write(Atom.a("public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }"));
             YP.nl();
             YP.nl();
             return;
         }
     }
     {
         Variable ReturnType = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable Body = new Variable();
         Variable Level = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { ReturnType, Name, ArgList, Body })))
         {
             YP.write(Atom.a("public static "));
             YP.write(ReturnType);
             YP.write(Atom.a(" "));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListCSharp(ArgList);
             YP.write(Atom.a(") {"));
             YP.nl();
             foreach (bool l3 in YP.unify(Level, 1))
             {
                 convertStatementListCSharp(Body, Level);
                 YP.write(Atom.a("}"));
                 YP.nl();
                 YP.nl();
                 return;
             }
         }
     }
 }
示例#13
0
        /// <summary>
        /// If the functor with name and args can be called directly as determined by
        ///   functorCallFunctionName, then call it and return its iterator.  If the predicate is
        ///   dynamic and undefined, or if static and the method cannot be found, return
        ///   the result of YP.unknownPredicate.
        /// This returns null if the functor has a special form than needs to be compiled 
        ///   (including ,/2 and ;/2).
        /// </summary>
        /// <param name="name"></param>
        /// <param name="args"></param>
        /// <param name="declaringClass">used to resolve references to the default 
        /// module Atom.a(""). If a declaringClass is needed to resolve the reference but it is
        ///   null, this throws a PrologException for existence_error</param>
        /// <returns></returns>
        public static IEnumerable<bool> getSimpleIterator(Atom name, object[] args, Type declaringClass)
        {
            CompilerState state = new CompilerState();
            Variable FunctionName = new Variable();
            foreach (bool l1 in functorCallFunctionName(state, name, args.Length, FunctionName))
            {
                Atom functionNameAtom = ((Atom)FunctionName.getValue());
                if (functionNameAtom == Atom.NIL)
                    // name is for a dynamic predicate.
                    return YP.matchDynamic(name, args);

                string methodName = functionNameAtom._name;
                // Set the default for the method to call.
                Type methodClass = declaringClass;

                bool checkMode = false;
                if (methodName.StartsWith("YP."))
                {
                    // Assume we only check mode in calls to standard Prolog predicates in YP.
                    checkMode = true;

                    // Use the method in class YP.
                    methodName = methodName.Substring(3);
                    methodClass = typeof(YP);
                }
                if (methodName.Contains("."))
                    // We don't support calling inner classes, etc.
                    return null;

                if (methodClass == null)
                    return YP.unknownPredicate
                        (name, args.Length,
                         "Cannot find predicate function for: " + name + "/" + args.Length + 
                         " because declaringClass is null.  Set declaringClass to the class containing " +
                         methodName);
                try
                {
                    if (checkMode)
                    {
                        assertYPPred(state);
                        object functor = Functor.make(name, args);
                        if (CompilerState.isDetNoneOut(state, functor))
                        {
                            methodClass.InvokeMember
                                (methodName, BindingFlags.InvokeMethod, null, null, args);
                            return YP.succeed();
                        }
                        if (CompilerState.isSemidetNoneOut(state, functor))
                        {
                            if ((bool)methodClass.InvokeMember
                                 (methodName, BindingFlags.InvokeMethod, null, null, args))
                                return YP.succeed();
                            else
                                return YP.fail();
                        }

                    }
                    return (IEnumerable<bool>)methodClass.InvokeMember
                      (methodName, BindingFlags.InvokeMethod, null, null, args);
                }
                catch (TargetInvocationException exception)
                {
                    throw exception.InnerException;
                }
                catch (MissingMethodException)
                {
                    return YP.unknownPredicate
                        (name, args.Length,
                         "Cannot find predicate function " + methodName + " for " + name + "/" + args.Length + 
                         " in " + methodClass.FullName);
                }
            }

            return null;
        }
示例#14
0
 public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
 {
     {
         Variable Name = new Variable();
         Variable TermArgs = new Variable();
         Variable X1 = new Variable();
         Variable FunctionName = new Variable();
         Variable Arg1 = new Variable();
         Variable x9 = new Variable();
         Variable X2 = new Variable();
         Variable Arg2 = new Variable();
         Variable x12 = new Variable();
         Variable Arity = new Variable();
         if (YP.nonvar(Term))
         {
             foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs)))
             {
                 if (YP.atom(Name))
                 {
                     foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
                     {
                         foreach (bool l6 in unaryFunction(Name, FunctionName))
                         {
                             foreach (bool l7 in compileExpression(X1, State, Arg1))
                             {
                                 foreach (bool l8 in YP.unify(Result, new Functor2("call", FunctionName, new ListPair(Arg1, Atom.NIL))))
                                 {
                                     yield return true;
                                     yield break;
                                 }
                             }
                             goto cutIf1;
                         }
                     }
                     foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL)))
                     {
                         foreach (bool l6 in compileTerm(Term, State, Result))
                         {
                             yield return true;
                             yield break;
                         }
                         goto cutIf2;
                     }
                     foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
                     {
                         foreach (bool l6 in binaryFunction(Name, FunctionName))
                         {
                             foreach (bool l7 in compileExpression(X1, State, Arg1))
                             {
                                 foreach (bool l8 in compileExpression(X2, State, Arg2))
                                 {
                                     foreach (bool l9 in YP.unify(Result, new Functor2("call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
                                     {
                                         yield return true;
                                         yield break;
                                     }
                                 }
                             }
                             goto cutIf3;
                         }
                     }
                     foreach (bool l5 in YP.functor(Term, x12, Arity))
                     {
                         YP.throwException(new Functor2("error", new Functor2("type_error", Atom.a("evaluable"), new Functor2("/", Name, Arity)), Atom.a("Not an expression function")));
                         yield return false;
                     }
                 cutIf3:
                 cutIf2:
                 cutIf1:
                     { }
                 }
             }
         }
     }
     {
         foreach (bool l2 in compileTerm(Term, State, Result))
         {
             yield return true;
             yield break;
         }
     }
 }
示例#15
0
 public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3)
 {
     {
         object _State = arg2;
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             foreach (bool l3 in YP.unify(arg3, Atom.NIL))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object State = arg2;
         Variable First = new Variable();
         Variable Rest = new Variable();
         Variable FirstResult = new Variable();
         Variable RestResults = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
         {
             foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
             {
                 if (YP.nonvar(Rest))
                 {
                     foreach (bool l5 in compileTerm(First, State, FirstResult))
                 {
                         foreach (bool l6 in maplist_compileTerm(Rest, State, RestResults))
                     {
                         yield return true;
                         yield break;
                     }
                 }
             }
         }
     }
 }
 }
示例#16
0
 public static void convertIndentationPython(object Level)
 {
     {
         Variable N = new Variable();
         foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
         {
             repeatWrite(Atom.a(" "), N);
             return;
         }
     }
 }
示例#17
0
 public static void convertArgListPython(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             return;
         }
     }
     {
         Variable Head = new Variable();
         Variable Tail = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
         {
             convertExpressionPython(Head);
             if (YP.termNotEqual(Tail, Atom.NIL))
             {
                 YP.write(Atom.a(", "));
                 convertArgListPython(Tail);
                 return;
                 goto cutIf1;
             }
             convertArgListPython(Tail);
             return;
         cutIf1:
             { }
         }
     }
 }
示例#18
0
        /// <summary>
        /// Return true if there is a dynamic or static predicate with name and arity.
        /// This returns false for built-in predicates.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="arity"></param>
        /// <param name="declaringClass">used to resolve references to the default 
        /// module Atom.a(""). If a declaringClass is needed to resolve the reference but it is
        ///   null, return false</param>
        /// <returns></returns>
        public static bool isCurrentPredicate(Atom name, int arity, Type declaringClass)
        {
            CompilerState state = new CompilerState();
            Variable FunctionName = new Variable();
            foreach (bool l1 in functorCallFunctionName(state, name, arity, FunctionName))
            {
                Atom functionNameAtom = ((Atom)FunctionName.getValue());
                if (functionNameAtom == Atom.NIL)
                    // name is for a dynamic predicate.
                    return YP.isDynamicCurrentPredicate(name, arity);

                string methodName = functionNameAtom._name;

                if (methodName.StartsWith("YP."))
                    // current_predicate/1 should fail for built-ins.
                    return false;
                if (methodName.Contains("."))
                    // We don't support calling inner classes, etc.
                    return false;
                if (declaringClass == null)
                    return false;

                foreach (MemberInfo member in declaringClass.GetMember(methodName))
                {
                    MethodInfo method = member as MethodInfo;
                    if (method == null)
                        continue;
                    if ((method.Attributes | MethodAttributes.Static) == 0)
                        // Not a static method.
                        continue;
                    if (method.GetParameters().Length == arity)
                        return true;
                }
            }

            return false;
        }
示例#19
0
 public static void convertStringCodesPython(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             return;
         }
     }
     {
         Variable Code = new Variable();
         Variable RestCodes = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
         {
             if (YP.termEqual(Code, 34))
             {
                 YP.put_code(92);
                 YP.put_code(Code);
                 convertStringCodesPython(RestCodes);
                 return;
                 goto cutIf1;
             }
             if (YP.termEqual(Code, 92))
             {
                 YP.put_code(92);
                 YP.put_code(Code);
                 convertStringCodesPython(RestCodes);
                 return;
                 goto cutIf1;
             }
             YP.put_code(Code);
             convertStringCodesPython(RestCodes);
             return;
         cutIf1:
             { }
         }
     }
 }
示例#20
0
 public static void convertStringCodesJavascript(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             return;
         }
     }
     {
         Variable Code = new Variable();
         Variable RestCodes = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
         {
             foreach (bool l3 in putCStringCode(Code))
             {
                 convertStringCodesJavascript(RestCodes);
                 return;
             }
         }
     }
 }
示例#21
0
 public static IEnumerable<bool> member(object X, object arg2)
 {
     {
         Variable x2 = new Variable();
         foreach (bool l2 in YP.unify(arg2, new ListPair(X, x2)))
         {
             yield return false;
         }
     }
     {
         Variable x2 = new Variable();
         Variable Rest = new Variable();
         foreach (bool l2 in YP.unify(arg2, new ListPair(x2, Rest)))
         {
             foreach (bool l3 in member(X, Rest))
             {
                 yield return false;
             }
         }
     }
 }
示例#22
0
 public static void convertFunctionPython(object arg1)
 {
     {
         foreach (bool l2 in YP.unify(arg1, Atom.a("getDeclaringClass")))
         {
             YP.write(Atom.a("def getDeclaringClass():"));
             YP.nl();
             YP.write(Atom.a("  return None"));
             YP.nl();
             YP.nl();
             return;
         }
     }
     {
         Variable x1 = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable Body = new Variable();
         Variable Level = new Variable();
         Variable HasBreakableBlock = new Variable();
         foreach (bool l2 in YP.unify(arg1, new Functor("function", new object[] { x1, Name, ArgList, Body })))
         {
             YP.write(Atom.a("def "));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a("):"));
             YP.nl();
             foreach (bool l3 in YP.unify(Level, 1))
             {
                 if (hasBreakableBlockPython(Body))
                 {
                     foreach (bool l5 in YP.unify(HasBreakableBlock, 1))
                     {
                         if (YP.termEqual(HasBreakableBlock, 1))
                         {
                             convertIndentationPython(Level);
                             YP.write(Atom.a("doBreak = False"));
                             YP.nl();
                             foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock))
                             {
                                 YP.nl();
                                 return;
                             }
                             goto cutIf2;
                         }
                         foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
                         {
                             YP.nl();
                             return;
                         }
                     cutIf2:
                         { }
                     }
                     goto cutIf1;
                 }
                 foreach (bool l4 in YP.unify(HasBreakableBlock, 0))
                 {
                     if (YP.termEqual(HasBreakableBlock, 1))
                     {
                         convertIndentationPython(Level);
                         YP.write(Atom.a("doBreak = False"));
                         YP.nl();
                         foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
                         {
                             YP.nl();
                             return;
                         }
                         goto cutIf3;
                     }
                     foreach (bool l5 in convertStatementListPython(Body, Level, HasBreakableBlock))
                     {
                         YP.nl();
                         return;
                     }
                 cutIf3:
                     { }
                 }
             cutIf1:
                 { }
             }
         }
     }
 }
示例#23
0
 public static void processCompilerDirectives(object arg1, object arg2)
 {
     {
         object _State = arg2;
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             return;
         }
     }
     {
         object State = arg2;
         Variable Pred = new Variable();
         Variable Determinism = new Variable();
         Variable x3 = new Variable();
         Variable RestRules = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor1(":-", new Functor1("pred", new Functor2("is", Pred, Determinism))), x3), RestRules)))
         {
             CompilerState.assertPred(State, Pred, Determinism);
             processCompilerDirectives(RestRules, State);
             return;
         }
     }
     {
         object State = arg2;
         Variable Module = new Variable();
         Variable PredicateList = new Variable();
         Variable x3 = new Variable();
         Variable RestRules = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor1(":-", new Functor2("import", Module, PredicateList)), x3), RestRules)))
         {
             foreach (bool l3 in importPredicateList(State, Module, PredicateList))
             {
                 processCompilerDirectives(RestRules, State);
                 return;
             }
         }
     }
     {
         object State = arg2;
         Variable x1 = new Variable();
         Variable x2 = new Variable();
         Variable RestRules = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor1(":-", x1), x2), RestRules)))
         {
             processCompilerDirectives(RestRules, State);
             return;
         }
     }
     {
         object State = arg2;
         Variable Head = new Variable();
         Variable _Body = new Variable();
         Variable x3 = new Variable();
         Variable RestRules = new Variable();
         Variable Name = new Variable();
         Variable Arity = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", new Functor2(":-", Head, _Body), x3), RestRules)))
         {
             foreach (bool l3 in YP.functor(Head, Name, Arity))
             {
                 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(""));
                 processCompilerDirectives(RestRules, State);
                 return;
             }
         }
     }
     {
         object State = arg2;
         Variable Fact = new Variable();
         Variable x2 = new Variable();
         Variable RestRules = new Variable();
         Variable Name = new Variable();
         Variable Arity = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("f", Fact, x2), RestRules)))
         {
             foreach (bool l3 in YP.functor(Fact, Name, Arity))
             {
                 CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(""));
                 processCompilerDirectives(RestRules, State);
                 return;
             }
         }
     }
     {
         object State = arg2;
         Variable x1 = new Variable();
         Variable RestRules = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestRules)))
         {
             processCompilerDirectives(RestRules, State);
             return;
         }
     }
 }
示例#24
0
 public static void repeatWrite(object arg1, object N)
 {
     {
         object _Value = arg1;
         if (YP.termEqual(N, 0))
         {
             return;
         }
     }
     {
         object Value = arg1;
         Variable NextN = new Variable();
         YP.write(Value);
         foreach (bool l2 in YP.unify(NextN, YP.subtract(N, 1)))
         {
             repeatWrite(Value, NextN);
             return;
         }
     }
 }
示例#25
0
 public static IEnumerable<bool> makeFunctionPseudoCode3(object RuleList, object State, object FunctionCode)
 {
     {
         Variable SamePredicateRuleList = new Variable();
         Variable RestRules = new Variable();
         foreach (bool l2 in samePredicateRuleList(RuleList, SamePredicateRuleList, RestRules))
         {
             if (YP.termNotEqual(SamePredicateRuleList, Atom.NIL))
             {
                 foreach (bool l4 in compileSamePredicateFunction(SamePredicateRuleList, State, FunctionCode))
                 {
                     yield return false;
                 }
                 foreach (bool l4 in makeFunctionPseudoCode3(RestRules, State, FunctionCode))
                 {
                     yield return false;
                 }
             }
         }
     }
 }
示例#26
0
 public static bool hasBreakableBlockPython(object arg1)
 {
     {
         Variable _Name = new Variable();
         Variable _Body = new Variable();
         Variable _RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", _Name, _Body), _RestStatements)))
         {
             return true;
         }
     }
     {
         Variable Body = new Variable();
         Variable _RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), _RestStatements)))
         {
             if (hasBreakableBlockPython(Body))
             {
                 return true;
             }
         }
     }
     {
         Variable _Expression = new Variable();
         Variable Body = new Variable();
         Variable _RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", _Expression, Body), _RestStatements)))
         {
             if (hasBreakableBlockPython(Body))
             {
                 return true;
             }
         }
     }
     {
         Variable _Expression = new Variable();
         Variable Body = new Variable();
         Variable _RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", _Expression, Body), _RestStatements)))
         {
             if (hasBreakableBlockPython(Body))
             {
                 return true;
             }
         }
     }
     {
         Variable x1 = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestStatements)))
         {
             if (hasBreakableBlockPython(RestStatements))
             {
                 return true;
             }
         }
     }
     return false;
 }
        static string GenCode(string myCode)
        {
            Variable TermList = new Variable();
            Variable FunctionCode = new Variable();

            string CS_code = "";

            int cs_pointer = myCode.IndexOf("\n//cs");
            if (cs_pointer > 0)
            {
                CS_code = myCode.Substring(cs_pointer); // CS code comes after
                myCode = myCode.Substring(0, cs_pointer);
            }
            myCode.Replace("//yp", "%YPCode");

            StringWriter myCS_SW = new StringWriter();
            StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n");

            YP.see(myCode_SR);
            YP.tell(myCS_SW);

            //m_log.Debug("Mycode\n ===================================\n" + myCode+"\n");

            // disable warning: don't see how we can code this differently short
            // of rewriting the whole thing
            #pragma warning disable 0168, 0219
            foreach (bool l1 in Parser.parseInput(TermList))
            {
                foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode))
                {
                    // ListPair VFC = new ListPair(FunctionCode, new Variable());
                    //m_log.Debug("-------------------------")
                    //m_log.Debug(FunctionCode.ToString())
                    //m_log.Debug("-------------------------")
                    YPCompiler.convertFunctionCSharp(FunctionCode);
                    //YPCompiler.convertStringCodesCSharp(VFC);
                }
            }
            #pragma warning restore 0168, 0219
            YP.seen();
            myCS_SW.Close();
            YP.told();
            StringBuilder bu = myCS_SW.GetStringBuilder();
            string finalcode = "//YPEncoded\n" + bu.ToString();
            // FIX script events (we're in the same script)
            // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit('
            finalcode = Regex.Replace(finalcode,
                                        @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,",
                                        @"this.$1(",
                                        RegexOptions.Compiled | RegexOptions.Singleline);
            finalcode = Regex.Replace(finalcode,
                                        @"YP.script_event\(Atom.a\(\""(.*?)""\)\,",
                                        @"this.$1(",
                                        RegexOptions.Compiled | RegexOptions.Singleline);
            finalcode = Regex.Replace(finalcode,
                            @" static ",
                            @" ",
                            RegexOptions.Compiled | RegexOptions.Singleline);

            finalcode = CS_code+"\n\r"+ finalcode;
            finalcode = Regex.Replace(finalcode,
                                        @"PrologCallback",
                                        @"public IEnumerable<bool> ",
                                        RegexOptions.Compiled | RegexOptions.Singleline);
            return finalcode;
        }
示例#28
0
 public static IEnumerable<bool> convertStatementListPython(object arg1, object arg2, object arg3)
 {
     {
         object x1 = arg2;
         object x2 = arg3;
         foreach (bool l2 in YP.unify(arg1, Atom.NIL))
         {
             yield return true;
             yield break;
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Name = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("breakableBlock", Name, Body), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Name);
             YP.write(Atom.a(" = False"));
             YP.nl();
             convertIndentationPython(Level);
             YP.write(Atom.a("for _ in [1]:"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
                 {
                     convertIndentationPython(Level);
                     YP.write(Atom.a("if "));
                     YP.write(Name);
                     YP.write(Atom.a(":"));
                     YP.nl();
                     convertIndentationPython(NextLevel);
                     YP.write(Atom.a("doBreak = False"));
                     YP.nl();
                     convertIndentationPython(Level);
                     YP.write(Atom.a("if doBreak:"));
                     YP.nl();
                     convertIndentationPython(NextLevel);
                     YP.write(Atom.a("break"));
                     YP.nl();
                     foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                     {
                         yield return true;
                         yield break;
                     }
                 }
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable _Type = new Variable();
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("declare", _Type, Name, Expression), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionPython(Expression);
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Name = new Variable();
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("assign", Name, Expression), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Name);
             YP.write(Atom.a(" = "));
             convertExpressionPython(Expression);
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldtrue"), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("yield True"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldfalse"), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("yield False"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("yieldbreak"), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("return"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("return"), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("return"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returntrue"), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("return True"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a("returnfalse"), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("return False"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Name = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("breakBlock", Name), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Name);
             YP.write(Atom.a(" = True"));
             YP.nl();
             convertIndentationPython(Level);
             YP.write(Atom.a("doBreak = True"));
             YP.nl();
             convertIndentationPython(Level);
             YP.write(Atom.a("break"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("call", Name, ArgList), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Name = new Variable();
         Variable _FunctorArgs = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("functorCall", Name, _FunctorArgs, ArgList), RestStatements)))
         {
             foreach (bool l3 in convertStatementListPython(new ListPair(new Functor2("call", Name, ArgList), RestStatements), Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Obj = new Variable();
         Variable Name = new Variable();
         Variable ArgList = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3("callMember", new Functor1("var", Obj), Name, ArgList), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Obj);
             YP.write(Atom.a("."));
             YP.write(Name);
             YP.write(Atom.a("("));
             convertArgListPython(ArgList);
             YP.write(Atom.a(")"));
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("blockScope", Body), RestStatements)))
         {
             if (YP.termEqual(HasBreakableBlock, 1))
             {
                 convertIndentationPython(Level);
                 YP.write(Atom.a("for _ in [1]:"));
                 YP.nl();
                 foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1)))
                 {
                     foreach (bool l5 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
                     {
                         if (YP.termEqual(HasBreakableBlock, 1))
                         {
                             if (YP.greaterThan(Level, 1))
                             {
                                 convertIndentationPython(Level);
                                 YP.write(Atom.a("if doBreak:"));
                                 YP.nl();
                                 convertIndentationPython(NextLevel);
                                 YP.write(Atom.a("break"));
                                 YP.nl();
                                 foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                                 {
                                     yield return true;
                                     yield break;
                                 }
                                 goto cutIf3;
                             }
                             foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                             {
                                 yield return true;
                                 yield break;
                             }
                         cutIf3:
                             goto cutIf2;
                         }
                         foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                         {
                             yield return true;
                             yield break;
                         }
                     cutIf2:
                         { }
                     }
                 }
                 goto cutIf1;
             }
             foreach (bool l3 in YP.unify(NextLevel, Level))
             {
                 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
                 {
                     if (YP.termEqual(HasBreakableBlock, 1))
                     {
                         if (YP.greaterThan(Level, 1))
                         {
                             convertIndentationPython(Level);
                             YP.write(Atom.a("if doBreak:"));
                             YP.nl();
                             convertIndentationPython(NextLevel);
                             YP.write(Atom.a("break"));
                             YP.nl();
                             foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                             {
                                 yield return true;
                                 yield break;
                             }
                             goto cutIf5;
                         }
                         foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                         {
                             yield return true;
                             yield break;
                         }
                     cutIf5:
                         goto cutIf4;
                     }
                     foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                     {
                         yield return true;
                         yield break;
                     }
                 cutIf4:
                     { }
                 }
             }
         cutIf1:
             { }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Expression = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("if", Expression, Body), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("if "));
             convertExpressionPython(Expression);
             YP.write(Atom.a(":"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
                 {
                     foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                     {
                         yield return true;
                         yield break;
                     }
                 }
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Expression = new Variable();
         Variable Body = new Variable();
         Variable RestStatements = new Variable();
         Variable NextLevel = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("foreach", Expression, Body), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("for l"));
             YP.write(Level);
             YP.write(Atom.a(" in "));
             convertExpressionPython(Expression);
             YP.write(Atom.a(":"));
             YP.nl();
             foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
             {
                 foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
                 {
                     if (YP.termEqual(HasBreakableBlock, 1))
                     {
                         convertIndentationPython(Level);
                         YP.write(Atom.a("if doBreak:"));
                         YP.nl();
                         convertIndentationPython(NextLevel);
                         YP.write(Atom.a("break"));
                         YP.nl();
                         foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                         {
                             yield return true;
                             yield break;
                         }
                         goto cutIf6;
                     }
                     foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
                     {
                         yield return true;
                         yield break;
                     }
                 cutIf6:
                     { }
                 }
             }
         }
     }
     {
         object Level = arg2;
         object HasBreakableBlock = arg3;
         Variable Expression = new Variable();
         Variable RestStatements = new Variable();
         foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1("throw", Expression), RestStatements)))
         {
             convertIndentationPython(Level);
             YP.write(Atom.a("raise "));
             convertExpressionPython(Expression);
             YP.nl();
             foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
             {
                 yield return true;
                 yield break;
             }
         }
     }
 }
示例#29
0
 public object makeCopy(Variable.CopyStore copyStore)
 {
     return new Functor3(_name, YP.makeCopy(_arg1, copyStore),
         YP.makeCopy(_arg2, copyStore), YP.makeCopy(_arg3, copyStore));
 }
示例#30
0
 public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode)
 {
     {
         Variable State = new Variable();
         foreach (bool l2 in CompilerState.make(State))
         {
             assertYPPred(State);
             processCompilerDirectives(RuleList, State);
             foreach (bool l3 in YP.unify(FunctionCode, Atom.a("getDeclaringClass")))
             {
                 yield return false;
             }
             foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode))
             {
                 yield return false;
             }
         }
     }
 }