diff options
author | Jeff Ames | 2008-06-01 03:01:33 +0000 |
---|---|---|
committer | Jeff Ames | 2008-06-01 03:01:33 +0000 |
commit | d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5 (patch) | |
tree | 2311b4c6ad2617cc71b975460c48e723a7e027ee /OpenSim/Region | |
parent | * Committing some stuff I'm working to make it so I can commit an upcoming pa... (diff) | |
download | opensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.zip opensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.tar.gz opensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.tar.bz2 opensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.tar.xz |
Update svn properties.
Diffstat (limited to 'OpenSim/Region')
18 files changed, 13588 insertions, 13593 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs index d98814b..faffa2b 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | namespace OpenSim.Region.Environment.Modules.World.Archiver | 28 | namespace OpenSim.Region.Environment.Modules.World.Archiver |
29 | { | 29 | { |
30 | /// <summary> | 30 | /// <summary> |
31 | /// Constants for the archiving module | 31 | /// Constants for the archiving module |
32 | /// </summary> | 32 | /// </summary> |
33 | public class ArchiveConstants | 33 | public class ArchiveConstants |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// Path for the assets held in an archive | 36 | /// Path for the assets held in an archive |
37 | /// </summary> | 37 | /// </summary> |
38 | public static readonly string ASSETS_PATH = "assets/"; | 38 | public static readonly string ASSETS_PATH = "assets/"; |
39 | 39 | ||
40 | /// <summary> | 40 | /// <summary> |
41 | /// Extension used for texture assets in archive | 41 | /// Extension used for texture assets in archive |
42 | /// </summary> | 42 | /// </summary> |
43 | public static readonly string TEXTURE_EXTENSION = ".jp2"; | 43 | public static readonly string TEXTURE_EXTENSION = ".jp2"; |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Path for the prims file | 46 | /// Path for the prims file |
47 | /// </summary> | 47 | /// </summary> |
48 | public static readonly string PRIMS_PATH = "prims.xml"; | 48 | public static readonly string PRIMS_PATH = "prims.xml"; |
49 | } | 49 | } |
50 | } | 50 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs index 3fc9e00..557c1c9 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/YP2CSConverter.cs | |||
@@ -26,88 +26,83 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; | 34 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; |
35 | 35 | ||
36 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | 36 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL |
37 | { | 37 | { |
38 | public class YP2CSConverter | 38 | public class YP2CSConverter |
39 | { | 39 | { |
40 | public YP2CSConverter() | 40 | public YP2CSConverter() |
41 | { | 41 | { |
42 | } | 42 | } |
43 | 43 | ||
44 | public string Convert(string Script) | 44 | public string Convert(string Script) |
45 | { | 45 | { |
46 | string CS_code = GenCode(Script); | 46 | string CS_code = GenCode(Script); |
47 | return CS_code; | 47 | return CS_code; |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | static string GenCode(string myCode) | |
51 | static string GenCode(string myCode) | 51 | { |
52 | { | 52 | Variable TermList = new Variable(); |
53 | Variable TermList = new Variable(); | 53 | Variable FunctionCode = new Variable(); |
54 | Variable FunctionCode = new Variable(); | 54 | |
55 | 55 | string CS_code = ""; | |
56 | string CS_code = ""; | 56 | |
57 | 57 | int cs_pointer = myCode.IndexOf("\n//cs"); | |
58 | int cs_pointer = myCode.IndexOf("\n//cs"); | 58 | if (cs_pointer > 0) |
59 | if (cs_pointer > 0) | 59 | { |
60 | { | 60 | CS_code = myCode.Substring(cs_pointer); // CS code comes after |
61 | CS_code = myCode.Substring(cs_pointer); // CS code comes after | 61 | myCode = myCode.Substring(0, cs_pointer); |
62 | myCode = myCode.Substring(0, cs_pointer); | 62 | } |
63 | } | 63 | myCode.Replace("//yp", "%YPCode"); |
64 | myCode.Replace("//yp", "%YPCode"); | 64 | |
65 | 65 | StringWriter myCS_SW = new StringWriter(); | |
66 | 66 | StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n"); | |
67 | StringWriter myCS_SW = new StringWriter(); | 67 | |
68 | StringReader myCode_SR = new StringReader(" yp_nop_header_nop. \n "+myCode + "\n"); | 68 | YP.see(myCode_SR); |
69 | 69 | YP.tell(myCS_SW); | |
70 | YP.see(myCode_SR); | 70 | |
71 | YP.tell(myCS_SW); | 71 | //Console.WriteLine("Mycode\n ===================================\n" + myCode+"\n"); |
72 | 72 | foreach (bool l1 in Parser.parseInput(TermList)) | |
73 | //Console.WriteLine("Mycode\n ===================================\n" + myCode+"\n"); | 73 | { |
74 | foreach (bool l1 in Parser.parseInput(TermList)) | 74 | foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode)) |
75 | { | 75 | { |
76 | foreach (bool l2 in YPCompiler.makeFunctionPseudoCode(TermList, FunctionCode)) | 76 | ListPair VFC = new ListPair(FunctionCode, new Variable()); |
77 | { | 77 | //Console.WriteLine("-------------------------") |
78 | ListPair VFC = new ListPair(FunctionCode, new Variable()); | 78 | //Console.WriteLine( FunctionCode.ToString()) |
79 | //Console.WriteLine("-------------------------") | 79 | //Console.WriteLine("-------------------------") |
80 | //Console.WriteLine( FunctionCode.ToString()) | 80 | YPCompiler.convertFunctionCSharp(FunctionCode); |
81 | //Console.WriteLine("-------------------------") | 81 | //YPCompiler.convertStringCodesCSharp(VFC); |
82 | YPCompiler.convertFunctionCSharp(FunctionCode); | 82 | } |
83 | //YPCompiler.convertStringCodesCSharp(VFC); | 83 | } |
84 | 84 | YP.seen(); | |
85 | } | 85 | myCS_SW.Close(); |
86 | } | 86 | YP.told(); |
87 | YP.seen(); | 87 | StringBuilder bu = myCS_SW.GetStringBuilder(); |
88 | myCS_SW.Close(); | 88 | string finalcode = "//YPEncoded\n" + bu.ToString(); |
89 | YP.told(); | 89 | // FIX script events (we're in the same script) |
90 | StringBuilder bu = myCS_SW.GetStringBuilder(); | 90 | // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit(' |
91 | string finalcode = "//YPEncoded\n" + bu.ToString(); | 91 | finalcode = Regex.Replace(finalcode, |
92 | // FIX script events (we're in the same script) | 92 | @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,", |
93 | // 'YP.script_event(Atom.a(@"sayit"),' ==> 'sayit(' | 93 | @"this.$1(", |
94 | finalcode = Regex.Replace(finalcode, | 94 | RegexOptions.Compiled | RegexOptions.Singleline); |
95 | @"YP.script_event\(Atom.a\(\@\""(.*?)""\)\,", | 95 | finalcode = Regex.Replace(finalcode, |
96 | @"this.$1(", | 96 | @" static ", |
97 | RegexOptions.Compiled | RegexOptions.Singleline); | 97 | @" ", |
98 | finalcode = Regex.Replace(finalcode, | 98 | RegexOptions.Compiled | RegexOptions.Singleline); |
99 | @" static ", | 99 | |
100 | @" ", | 100 | finalcode = CS_code+"\n\r"+ finalcode; |
101 | RegexOptions.Compiled | RegexOptions.Singleline); | 101 | finalcode = Regex.Replace(finalcode, |
102 | 102 | @"PrologCallback", | |
103 | finalcode = CS_code+"\n\r"+ finalcode; | 103 | @"public IEnumerable<bool> ", |
104 | finalcode = Regex.Replace(finalcode, | 104 | RegexOptions.Compiled | RegexOptions.Singleline); |
105 | @"PrologCallback", | 105 | return finalcode; |
106 | @"public IEnumerable<bool> ", | 106 | } |
107 | RegexOptions.Compiled | RegexOptions.Singleline); | 107 | } |
108 | return finalcode; | 108 | } |
109 | } | ||
110 | |||
111 | |||
112 | } | ||
113 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Atom.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Atom.cs index 9b4ca6a..7387ef4 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Atom.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Atom.cs | |||
@@ -1,218 +1,218 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Text; | 33 | using System.Text; |
34 | 34 | ||
35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
36 | { | 36 | { |
37 | public class Atom : IUnifiable | 37 | public class Atom : IUnifiable |
38 | { | 38 | { |
39 | private static Dictionary<string, Atom> _atomStore = new Dictionary<string, Atom>(); | 39 | private static Dictionary<string, Atom> _atomStore = new Dictionary<string, Atom>(); |
40 | public readonly string _name; | 40 | public readonly string _name; |
41 | public readonly Atom _module; | 41 | public readonly Atom _module; |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// You should not call this constructor, but use Atom.a instead. | 44 | /// You should not call this constructor, but use Atom.a instead. |
45 | /// </summary> | 45 | /// </summary> |
46 | /// <param name="name"></param> | 46 | /// <param name="name"></param> |
47 | /// <param name="module"></param> | 47 | /// <param name="module"></param> |
48 | private Atom(string name, Atom module) | 48 | private Atom(string name, Atom module) |
49 | { | 49 | { |
50 | _name = name; | 50 | _name = name; |
51 | _module = module; | 51 | _module = module; |
52 | } | 52 | } |
53 | 53 | ||
54 | /// <summary> | 54 | /// <summary> |
55 | /// Return the unique Atom object for name where module is null. You should use this to create | 55 | /// Return the unique Atom object for name where module is null. You should use this to create |
56 | /// an Atom instead of calling the Atom constructor. | 56 | /// an Atom instead of calling the Atom constructor. |
57 | /// </summary> | 57 | /// </summary> |
58 | /// <param name="name"></param> | 58 | /// <param name="name"></param> |
59 | /// <returns></returns> | 59 | /// <returns></returns> |
60 | public static Atom a(string name) | 60 | public static Atom a(string name) |
61 | { | 61 | { |
62 | Atom atom; | 62 | Atom atom; |
63 | if (!_atomStore.TryGetValue(name, out atom)) | 63 | if (!_atomStore.TryGetValue(name, out atom)) |
64 | { | 64 | { |
65 | atom = new Atom(name, null); | 65 | atom = new Atom(name, null); |
66 | _atomStore[name] = atom; | 66 | _atomStore[name] = atom; |
67 | } | 67 | } |
68 | return atom; | 68 | return atom; |
69 | } | 69 | } |
70 | 70 | ||
71 | /// <summary> | 71 | /// <summary> |
72 | /// Return an Atom object with the name and module. If module is null or Atom.NIL, | 72 | /// Return an Atom object with the name and module. If module is null or Atom.NIL, |
73 | /// this behaves like Atom.a(name) and returns the unique object where the module is null. | 73 | /// this behaves like Atom.a(name) and returns the unique object where the module is null. |
74 | /// If module is not null or Atom.NIL, this may or may not be the same object as another Atom | 74 | /// If module is not null or Atom.NIL, this may or may not be the same object as another Atom |
75 | /// with the same name and module. | 75 | /// with the same name and module. |
76 | /// </summary> | 76 | /// </summary> |
77 | /// <param name="name"></param> | 77 | /// <param name="name"></param> |
78 | /// <param name="module"></param> | 78 | /// <param name="module"></param> |
79 | /// <returns></returns> | 79 | /// <returns></returns> |
80 | public static Atom a(string name, Atom module) | 80 | public static Atom a(string name, Atom module) |
81 | { | 81 | { |
82 | if (module == null || module == Atom.NIL) | 82 | if (module == null || module == Atom.NIL) |
83 | return a(name); | 83 | return a(name); |
84 | return new Atom(name, module); | 84 | return new Atom(name, module); |
85 | } | 85 | } |
86 | 86 | ||
87 | /// <summary> | 87 | /// <summary> |
88 | /// If Obj is an Atom unify its _module with Module. If the Atom's _module is null, use Atom.NIL. | 88 | /// If Obj is an Atom unify its _module with Module. If the Atom's _module is null, use Atom.NIL. |
89 | /// </summary> | 89 | /// </summary> |
90 | /// <param name="Atom"></param> | 90 | /// <param name="Atom"></param> |
91 | /// <param name="Module"></param> | 91 | /// <param name="Module"></param> |
92 | /// <returns></returns> | 92 | /// <returns></returns> |
93 | public static IEnumerable<bool> module(object Obj, object Module) | 93 | public static IEnumerable<bool> module(object Obj, object Module) |
94 | { | 94 | { |
95 | Obj = YP.getValue(Obj); | 95 | Obj = YP.getValue(Obj); |
96 | if (Obj is Atom) | 96 | if (Obj is Atom) |
97 | { | 97 | { |
98 | if (((Atom)Obj)._module == null) | 98 | if (((Atom)Obj)._module == null) |
99 | return YP.unify(Module, Atom.NIL); | 99 | return YP.unify(Module, Atom.NIL); |
100 | else | 100 | else |
101 | return YP.unify(Module, ((Atom)Obj)._module); | 101 | return YP.unify(Module, ((Atom)Obj)._module); |
102 | } | 102 | } |
103 | return YP.fail(); | 103 | return YP.fail(); |
104 | } | 104 | } |
105 | 105 | ||
106 | public static readonly Atom NIL = Atom.a("[]"); | 106 | public static readonly Atom NIL = Atom.a("[]"); |
107 | public static readonly Atom DOT = Atom.a("."); | 107 | public static readonly Atom DOT = Atom.a("."); |
108 | public static readonly Atom F = Atom.a("f"); | 108 | public static readonly Atom F = Atom.a("f"); |
109 | public static readonly Atom SLASH = Atom.a("/"); | 109 | public static readonly Atom SLASH = Atom.a("/"); |
110 | public static readonly Atom HAT = Atom.a("^"); | 110 | public static readonly Atom HAT = Atom.a("^"); |
111 | public static readonly Atom RULE = Atom.a(":-"); | 111 | public static readonly Atom RULE = Atom.a(":-"); |
112 | 112 | ||
113 | public IEnumerable<bool> unify(object arg) | 113 | public IEnumerable<bool> unify(object arg) |
114 | { | 114 | { |
115 | arg = YP.getValue(arg); | 115 | arg = YP.getValue(arg); |
116 | if (arg is Atom) | 116 | if (arg is Atom) |
117 | return Equals(arg) ? YP.succeed() : YP.fail(); | 117 | return Equals(arg) ? YP.succeed() : YP.fail(); |
118 | else if (arg is Variable) | 118 | else if (arg is Variable) |
119 | return ((Variable)arg).unify(this); | 119 | return ((Variable)arg).unify(this); |
120 | else | 120 | else |
121 | return YP.fail(); | 121 | return YP.fail(); |
122 | } | 122 | } |
123 | 123 | ||
124 | public void addUniqueVariables(List<Variable> variableSet) | 124 | public void addUniqueVariables(List<Variable> variableSet) |
125 | { | 125 | { |
126 | // Atom does not contain variables. | 126 | // Atom does not contain variables. |
127 | } | 127 | } |
128 | 128 | ||
129 | public object makeCopy(Variable.CopyStore copyStore) | 129 | public object makeCopy(Variable.CopyStore copyStore) |
130 | { | 130 | { |
131 | // Atom does not contain variables that need to be copied. | 131 | // Atom does not contain variables that need to be copied. |
132 | return this; | 132 | return this; |
133 | } | 133 | } |
134 | 134 | ||
135 | public bool termEqual(object term) | 135 | public bool termEqual(object term) |
136 | { | 136 | { |
137 | return Equals(YP.getValue(term)); | 137 | return Equals(YP.getValue(term)); |
138 | } | 138 | } |
139 | 139 | ||
140 | public bool ground() | 140 | public bool ground() |
141 | { | 141 | { |
142 | // Atom is always ground. | 142 | // Atom is always ground. |
143 | return true; | 143 | return true; |
144 | } | 144 | } |
145 | 145 | ||
146 | public override bool Equals(object obj) | 146 | public override bool Equals(object obj) |
147 | { | 147 | { |
148 | if (obj is Atom) | 148 | if (obj is Atom) |
149 | { | 149 | { |
150 | if (_module == null && ((Atom)obj)._module == null) | 150 | if (_module == null && ((Atom)obj)._module == null) |
151 | // When _declaringClass is null, we always use an identical object from _atomStore. | 151 | // When _declaringClass is null, we always use an identical object from _atomStore. |
152 | return this == obj; | 152 | return this == obj; |
153 | // Otherwise, ignore _declaringClass and do a normal string compare on the _name. | 153 | // Otherwise, ignore _declaringClass and do a normal string compare on the _name. |
154 | return _name == ((Atom)obj)._name; | 154 | return _name == ((Atom)obj)._name; |
155 | } | 155 | } |
156 | return false; | 156 | return false; |
157 | } | 157 | } |
158 | 158 | ||
159 | public override string ToString() | 159 | public override string ToString() |
160 | { | 160 | { |
161 | return _name; | 161 | return _name; |
162 | } | 162 | } |
163 | 163 | ||
164 | public override int GetHashCode() | 164 | public override int GetHashCode() |
165 | { | 165 | { |
166 | // Debug: need to check _declaringClass. | 166 | // Debug: need to check _declaringClass. |
167 | return _name.GetHashCode(); | 167 | return _name.GetHashCode(); |
168 | } | 168 | } |
169 | 169 | ||
170 | public string toQuotedString() | 170 | public string toQuotedString() |
171 | { | 171 | { |
172 | if (_name.Length == 0) | 172 | if (_name.Length == 0) |
173 | return "''"; | 173 | return "''"; |
174 | else if (this == Atom.NIL) | 174 | else if (this == Atom.NIL) |
175 | return "[]"; | 175 | return "[]"; |
176 | 176 | ||
177 | StringBuilder result = new StringBuilder(_name.Length); | 177 | StringBuilder result = new StringBuilder(_name.Length); |
178 | bool useQuotes = false; | 178 | bool useQuotes = false; |
179 | foreach (char c in _name) | 179 | foreach (char c in _name) |
180 | { | 180 | { |
181 | int cInt = (int)c; | 181 | int cInt = (int)c; |
182 | if (c == '\'') | 182 | if (c == '\'') |
183 | { | 183 | { |
184 | result.Append("''"); | 184 | result.Append("''"); |
185 | useQuotes = true; | 185 | useQuotes = true; |
186 | } | 186 | } |
187 | else if (c == '_' || cInt >= (int)'a' && cInt <= (int)'z' || | 187 | else if (c == '_' || cInt >= (int)'a' && cInt <= (int)'z' || |
188 | cInt >= (int)'A' && cInt <= (int)'Z' || cInt >= (int)'0' && cInt <= (int)'9') | 188 | cInt >= (int)'A' && cInt <= (int)'Z' || cInt >= (int)'0' && cInt <= (int)'9') |
189 | result.Append(c); | 189 | result.Append(c); |
190 | else | 190 | else |
191 | { | 191 | { |
192 | // Debug: Need to handle non-printable chars. | 192 | // Debug: Need to handle non-printable chars. |
193 | result.Append(c); | 193 | result.Append(c); |
194 | useQuotes = true; | 194 | useQuotes = true; |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | if (!useQuotes && (int)_name[0] >= (int)'a' && (int)_name[0] <= (int)'z') | 198 | if (!useQuotes && (int)_name[0] >= (int)'a' && (int)_name[0] <= (int)'z') |
199 | return result.ToString(); | 199 | return result.ToString(); |
200 | else | 200 | else |
201 | { | 201 | { |
202 | // Surround in single quotes. | 202 | // Surround in single quotes. |
203 | result.Append('\''); | 203 | result.Append('\''); |
204 | return "'" + result; | 204 | return "'" + result; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | /// <summary> | 208 | /// <summary> |
209 | /// Return true if _name is lexicographically less than atom._name. | 209 | /// Return true if _name is lexicographically less than atom._name. |
210 | /// </summary> | 210 | /// </summary> |
211 | /// <param name="atom"></param> | 211 | /// <param name="atom"></param> |
212 | /// <returns></returns> | 212 | /// <returns></returns> |
213 | public bool lessThan(Atom atom) | 213 | public bool lessThan(Atom atom) |
214 | { | 214 | { |
215 | return _name.CompareTo(atom._name) < 0; | 215 | return _name.CompareTo(atom._name) < 0; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/BagofAnswers.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/BagofAnswers.cs index 6aea6f7..88ffdb7 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/BagofAnswers.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/BagofAnswers.cs | |||
@@ -1,234 +1,234 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections; | 32 | using System.Collections; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | 34 | ||
35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// A BagofAnswers holds answers for bagof and setof. | 38 | /// A BagofAnswers holds answers for bagof and setof. |
39 | /// </summary> | 39 | /// </summary> |
40 | public class BagofAnswers | 40 | public class BagofAnswers |
41 | { | 41 | { |
42 | private object _template; | 42 | private object _template; |
43 | private Variable[] _freeVariables; | 43 | private Variable[] _freeVariables; |
44 | private Dictionary<object[], List<object>> _bagForFreeVariables; | 44 | private Dictionary<object[], List<object>> _bagForFreeVariables; |
45 | private List<object> _findallBagArray; | 45 | private List<object> _findallBagArray; |
46 | private static TermArrayEqualityComparer _termArrayEqualityComparer = | 46 | private static TermArrayEqualityComparer _termArrayEqualityComparer = |
47 | new TermArrayEqualityComparer(); | 47 | new TermArrayEqualityComparer(); |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// To get the free variables, split off any existential qualifiers from Goal such as the X in | 50 | /// To get the free variables, split off any existential qualifiers from Goal such as the X in |
51 | /// "X ^ f(Y)", get the set of unbound variables in Goal that are not qualifiers, then remove | 51 | /// "X ^ f(Y)", get the set of unbound variables in Goal that are not qualifiers, then remove |
52 | /// the unbound variables that are qualifiers as well as the unbound variables in Template. | 52 | /// the unbound variables that are qualifiers as well as the unbound variables in Template. |
53 | /// </summary> | 53 | /// </summary> |
54 | /// <param name="Template"></param> | 54 | /// <param name="Template"></param> |
55 | /// <param name="Goal"></param> | 55 | /// <param name="Goal"></param> |
56 | public BagofAnswers(object Template, object Goal) | 56 | public BagofAnswers(object Template, object Goal) |
57 | { | 57 | { |
58 | _template = Template; | 58 | _template = Template; |
59 | 59 | ||
60 | // First get the set of variables that are not free variables. | 60 | // First get the set of variables that are not free variables. |
61 | List<Variable> variableSet = new List<Variable>(); | 61 | List<Variable> variableSet = new List<Variable>(); |
62 | YP.addUniqueVariables(Template, variableSet); | 62 | YP.addUniqueVariables(Template, variableSet); |
63 | object UnqualifiedGoal = YP.getValue(Goal); | 63 | object UnqualifiedGoal = YP.getValue(Goal); |
64 | while (UnqualifiedGoal is Functor2 && ((Functor2)UnqualifiedGoal)._name == Atom.HAT) | 64 | while (UnqualifiedGoal is Functor2 && ((Functor2)UnqualifiedGoal)._name == Atom.HAT) |
65 | { | 65 | { |
66 | YP.addUniqueVariables(((Functor2)UnqualifiedGoal)._arg1, variableSet); | 66 | YP.addUniqueVariables(((Functor2)UnqualifiedGoal)._arg1, variableSet); |
67 | UnqualifiedGoal = YP.getValue(((Functor2)UnqualifiedGoal)._arg2); | 67 | UnqualifiedGoal = YP.getValue(((Functor2)UnqualifiedGoal)._arg2); |
68 | } | 68 | } |
69 | 69 | ||
70 | // Remember how many non-free variables there are so we can find the unique free variables | 70 | // Remember how many non-free variables there are so we can find the unique free variables |
71 | // that are added. | 71 | // that are added. |
72 | int nNonFreeVariables = variableSet.Count; | 72 | int nNonFreeVariables = variableSet.Count; |
73 | YP.addUniqueVariables(UnqualifiedGoal, variableSet); | 73 | YP.addUniqueVariables(UnqualifiedGoal, variableSet); |
74 | int nFreeVariables = variableSet.Count - nNonFreeVariables; | 74 | int nFreeVariables = variableSet.Count - nNonFreeVariables; |
75 | if (nFreeVariables == 0) | 75 | if (nFreeVariables == 0) |
76 | { | 76 | { |
77 | // There were no free variables added, so we won't waste time with _bagForFreeVariables. | 77 | // There were no free variables added, so we won't waste time with _bagForFreeVariables. |
78 | _freeVariables = null; | 78 | _freeVariables = null; |
79 | _findallBagArray = new List<object>(); | 79 | _findallBagArray = new List<object>(); |
80 | } | 80 | } |
81 | else | 81 | else |
82 | { | 82 | { |
83 | // Copy the free variables. | 83 | // Copy the free variables. |
84 | _freeVariables = new Variable[nFreeVariables]; | 84 | _freeVariables = new Variable[nFreeVariables]; |
85 | for (int i = 0; i < nFreeVariables; ++i) | 85 | for (int i = 0; i < nFreeVariables; ++i) |
86 | _freeVariables[i] = variableSet[i + nNonFreeVariables]; | 86 | _freeVariables[i] = variableSet[i + nNonFreeVariables]; |
87 | 87 | ||
88 | _bagForFreeVariables = new Dictionary<object[], List<object>>(_termArrayEqualityComparer); | 88 | _bagForFreeVariables = new Dictionary<object[], List<object>>(_termArrayEqualityComparer); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | public void add() | 92 | public void add() |
93 | { | 93 | { |
94 | if (_freeVariables == null) | 94 | if (_freeVariables == null) |
95 | // The goal has bound the values in _template but we don't bother with _freeVariables. | 95 | // The goal has bound the values in _template but we don't bother with _freeVariables. |
96 | _findallBagArray.Add(YP.makeCopy(_template, new Variable.CopyStore())); | 96 | _findallBagArray.Add(YP.makeCopy(_template, new Variable.CopyStore())); |
97 | else | 97 | else |
98 | { | 98 | { |
99 | // The goal has bound the values in _template and _freeVariables. | 99 | // The goal has bound the values in _template and _freeVariables. |
100 | // Find the entry for this set of _freeVariables values. | 100 | // Find the entry for this set of _freeVariables values. |
101 | object[] freeVariableValues = new object[_freeVariables.Length]; | 101 | object[] freeVariableValues = new object[_freeVariables.Length]; |
102 | for (int i = 0; i < _freeVariables.Length; ++i) | 102 | for (int i = 0; i < _freeVariables.Length; ++i) |
103 | freeVariableValues[i] = YP.getValue(_freeVariables[i]); | 103 | freeVariableValues[i] = YP.getValue(_freeVariables[i]); |
104 | List<object> bagArray; | 104 | List<object> bagArray; |
105 | if (!_bagForFreeVariables.TryGetValue(freeVariableValues, out bagArray)) | 105 | if (!_bagForFreeVariables.TryGetValue(freeVariableValues, out bagArray)) |
106 | { | 106 | { |
107 | bagArray = new List<object>(); | 107 | bagArray = new List<object>(); |
108 | _bagForFreeVariables[freeVariableValues] = bagArray; | 108 | _bagForFreeVariables[freeVariableValues] = bagArray; |
109 | } | 109 | } |
110 | 110 | ||
111 | // Now copy the template and add to the bag for the freeVariables values. | 111 | // Now copy the template and add to the bag for the freeVariables values. |
112 | bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore())); | 112 | bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore())); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | /// <summary> | 116 | /// <summary> |
117 | /// For each result, unify the _freeVariables and unify bagArrayVariable with the associated bag. | 117 | /// For each result, unify the _freeVariables and unify bagArrayVariable with the associated bag. |
118 | /// </summary> | 118 | /// </summary> |
119 | /// <param name="bagArrayVariable">this is unified with the List<object> of matches for template that | 119 | /// <param name="bagArrayVariable">this is unified with the List<object> of matches for template that |
120 | /// corresponds to the bindings for freeVariables. Be very careful: this does not unify with a Prolog | 120 | /// corresponds to the bindings for freeVariables. Be very careful: this does not unify with a Prolog |
121 | /// list.</param> | 121 | /// list.</param> |
122 | /// <returns></returns> | 122 | /// <returns></returns> |
123 | public IEnumerable<bool> resultArray(Variable bagArrayVariable) | 123 | public IEnumerable<bool> resultArray(Variable bagArrayVariable) |
124 | { | 124 | { |
125 | if (_freeVariables == null) | 125 | if (_freeVariables == null) |
126 | { | 126 | { |
127 | // No unbound free variables, so we only filled one bag. If empty, bagof fails. | 127 | // No unbound free variables, so we only filled one bag. If empty, bagof fails. |
128 | if (_findallBagArray.Count > 0) | 128 | if (_findallBagArray.Count > 0) |
129 | { | 129 | { |
130 | foreach (bool l1 in bagArrayVariable.unify(_findallBagArray)) | 130 | foreach (bool l1 in bagArrayVariable.unify(_findallBagArray)) |
131 | yield return false; | 131 | yield return false; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | else | 134 | else |
135 | { | 135 | { |
136 | foreach (KeyValuePair<object[], List<object>> valuesAndBag in _bagForFreeVariables) | 136 | foreach (KeyValuePair<object[], List<object>> valuesAndBag in _bagForFreeVariables) |
137 | { | 137 | { |
138 | foreach (bool l1 in YP.unifyArrays(_freeVariables, valuesAndBag.Key)) | 138 | foreach (bool l1 in YP.unifyArrays(_freeVariables, valuesAndBag.Key)) |
139 | { | 139 | { |
140 | foreach (bool l2 in bagArrayVariable.unify(valuesAndBag.Value)) | 140 | foreach (bool l2 in bagArrayVariable.unify(valuesAndBag.Value)) |
141 | yield return false; | 141 | yield return false; |
142 | } | 142 | } |
143 | // Debug: Should we free memory of the answers already returned? | 143 | // Debug: Should we free memory of the answers already returned? |
144 | } | 144 | } |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | /// <summary> | 148 | /// <summary> |
149 | /// For each result, unify the _freeVariables and unify Bag with the associated bag. | 149 | /// For each result, unify the _freeVariables and unify Bag with the associated bag. |
150 | /// </summary> | 150 | /// </summary> |
151 | /// <param name="Bag"></param> | 151 | /// <param name="Bag"></param> |
152 | /// <returns></returns> | 152 | /// <returns></returns> |
153 | public IEnumerable<bool> result(object Bag) | 153 | public IEnumerable<bool> result(object Bag) |
154 | { | 154 | { |
155 | Variable bagArrayVariable = new Variable(); | 155 | Variable bagArrayVariable = new Variable(); |
156 | foreach (bool l1 in resultArray(bagArrayVariable)) | 156 | foreach (bool l1 in resultArray(bagArrayVariable)) |
157 | { | 157 | { |
158 | foreach (bool l2 in YP.unify(Bag, ListPair.make((List<object>)bagArrayVariable.getValue()))) | 158 | foreach (bool l2 in YP.unify(Bag, ListPair.make((List<object>)bagArrayVariable.getValue()))) |
159 | yield return false; | 159 | yield return false; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | /// <summary> | 163 | /// <summary> |
164 | /// For each result, unify the _freeVariables and unify Bag with the associated bag which is sorted | 164 | /// For each result, unify the _freeVariables and unify Bag with the associated bag which is sorted |
165 | /// with duplicates removed, as in setof. | 165 | /// with duplicates removed, as in setof. |
166 | /// </summary> | 166 | /// </summary> |
167 | /// <param name="Bag"></param> | 167 | /// <param name="Bag"></param> |
168 | /// <returns></returns> | 168 | /// <returns></returns> |
169 | public IEnumerable<bool> resultSet(object Bag) | 169 | public IEnumerable<bool> resultSet(object Bag) |
170 | { | 170 | { |
171 | Variable bagArrayVariable = new Variable(); | 171 | Variable bagArrayVariable = new Variable(); |
172 | foreach (bool l1 in resultArray(bagArrayVariable)) | 172 | foreach (bool l1 in resultArray(bagArrayVariable)) |
173 | { | 173 | { |
174 | List<object> bagArray = (List<object>)bagArrayVariable.getValue(); | 174 | List<object> bagArray = (List<object>)bagArrayVariable.getValue(); |
175 | YP.sortArray(bagArray); | 175 | YP.sortArray(bagArray); |
176 | foreach (bool l2 in YP.unify(Bag, ListPair.makeWithoutRepeatedTerms(bagArray))) | 176 | foreach (bool l2 in YP.unify(Bag, ListPair.makeWithoutRepeatedTerms(bagArray))) |
177 | yield return false; | 177 | yield return false; |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | public static IEnumerable<bool> bagofArray | 181 | public static IEnumerable<bool> bagofArray |
182 | (object Template, object Goal, IEnumerable<bool> goalIterator, Variable bagArrayVariable) | 182 | (object Template, object Goal, IEnumerable<bool> goalIterator, Variable bagArrayVariable) |
183 | { | 183 | { |
184 | BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); | 184 | BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); |
185 | foreach (bool l1 in goalIterator) | 185 | foreach (bool l1 in goalIterator) |
186 | bagOfAnswers.add(); | 186 | bagOfAnswers.add(); |
187 | return bagOfAnswers.resultArray(bagArrayVariable); | 187 | return bagOfAnswers.resultArray(bagArrayVariable); |
188 | } | 188 | } |
189 | 189 | ||
190 | public static IEnumerable<bool> bagof | 190 | public static IEnumerable<bool> bagof |
191 | (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag) | 191 | (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag) |
192 | { | 192 | { |
193 | BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); | 193 | BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); |
194 | foreach (bool l1 in goalIterator) | 194 | foreach (bool l1 in goalIterator) |
195 | bagOfAnswers.add(); | 195 | bagOfAnswers.add(); |
196 | return bagOfAnswers.result(Bag); | 196 | return bagOfAnswers.result(Bag); |
197 | } | 197 | } |
198 | 198 | ||
199 | public static IEnumerable<bool> setof | 199 | public static IEnumerable<bool> setof |
200 | (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag) | 200 | (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag) |
201 | { | 201 | { |
202 | BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); | 202 | BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); |
203 | foreach (bool l1 in goalIterator) | 203 | foreach (bool l1 in goalIterator) |
204 | bagOfAnswers.add(); | 204 | bagOfAnswers.add(); |
205 | return bagOfAnswers.resultSet(Bag); | 205 | return bagOfAnswers.resultSet(Bag); |
206 | } | 206 | } |
207 | 207 | ||
208 | /// <summary> | 208 | /// <summary> |
209 | /// A TermArrayEqualityComparer implements IEqualityComparer to compare two object arrays using YP.termEqual. | 209 | /// A TermArrayEqualityComparer implements IEqualityComparer to compare two object arrays using YP.termEqual. |
210 | /// </summary> | 210 | /// </summary> |
211 | private class TermArrayEqualityComparer : IEqualityComparer<object[]> | 211 | private class TermArrayEqualityComparer : IEqualityComparer<object[]> |
212 | { | 212 | { |
213 | public bool Equals(object[] array1, object[] array2) | 213 | public bool Equals(object[] array1, object[] array2) |
214 | { | 214 | { |
215 | if (array1.Length != array2.Length) | 215 | if (array1.Length != array2.Length) |
216 | return false; | 216 | return false; |
217 | for (int i = 0; i < array1.Length; ++i) | 217 | for (int i = 0; i < array1.Length; ++i) |
218 | { | 218 | { |
219 | if (!YP.termEqual(array1[i], array2[i])) | 219 | if (!YP.termEqual(array1[i], array2[i])) |
220 | return false; | 220 | return false; |
221 | } | 221 | } |
222 | return true; | 222 | return true; |
223 | } | 223 | } |
224 | 224 | ||
225 | public int GetHashCode(object[] array) | 225 | public int GetHashCode(object[] array) |
226 | { | 226 | { |
227 | int hashCode = 0; | 227 | int hashCode = 0; |
228 | for (int i = 0; i < array.Length; ++i) | 228 | for (int i = 0; i < array.Length; ++i) |
229 | hashCode ^= array[i].GetHashCode(); | 229 | hashCode ^= array[i].GetHashCode(); |
230 | return hashCode; | 230 | return hashCode; |
231 | } | 231 | } |
232 | } | 232 | } |
233 | } | 233 | } |
234 | } | 234 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs index 2978cee..dcd4250 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs | |||
@@ -1,103 +1,103 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections; | 32 | using System.Collections; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | 34 | ||
35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// A FindallAnswers holds answers for findall. | 38 | /// A FindallAnswers holds answers for findall. |
39 | /// </summary> | 39 | /// </summary> |
40 | public class FindallAnswers | 40 | public class FindallAnswers |
41 | { | 41 | { |
42 | private object _template; | 42 | private object _template; |
43 | private List<object> _bagArray; | 43 | private List<object> _bagArray; |
44 | 44 | ||
45 | public FindallAnswers(object Template) | 45 | public FindallAnswers(object Template) |
46 | { | 46 | { |
47 | _template = Template; | 47 | _template = Template; |
48 | _bagArray = new List<object>(); | 48 | _bagArray = new List<object>(); |
49 | } | 49 | } |
50 | 50 | ||
51 | public void add() | 51 | public void add() |
52 | { | 52 | { |
53 | _bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore())); | 53 | _bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore())); |
54 | } | 54 | } |
55 | 55 | ||
56 | public List<object> resultArray() | 56 | public List<object> resultArray() |
57 | { | 57 | { |
58 | return _bagArray; | 58 | return _bagArray; |
59 | } | 59 | } |
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// Unify Bag with the result. This frees the internal answers, so you can only call this once. | 62 | /// Unify Bag with the result. This frees the internal answers, so you can only call this once. |
63 | /// </summary> | 63 | /// </summary> |
64 | /// <param name="Bag"></param> | 64 | /// <param name="Bag"></param> |
65 | /// <returns></returns> | 65 | /// <returns></returns> |
66 | public IEnumerable<bool> result(object Bag) | 66 | public IEnumerable<bool> result(object Bag) |
67 | { | 67 | { |
68 | object result = ListPair.make(_bagArray); | 68 | object result = ListPair.make(_bagArray); |
69 | // Try to free the memory. | 69 | // Try to free the memory. |
70 | _bagArray = null; | 70 | _bagArray = null; |
71 | return YP.unify(Bag, result); | 71 | return YP.unify(Bag, result); |
72 | } | 72 | } |
73 | 73 | ||
74 | /// <summary> | 74 | /// <summary> |
75 | /// This is a simplified findall when the goal is a single call. | 75 | /// This is a simplified findall when the goal is a single call. |
76 | /// </summary> | 76 | /// </summary> |
77 | /// <param name="Template"></param> | 77 | /// <param name="Template"></param> |
78 | /// <param name="goal"></param> | 78 | /// <param name="goal"></param> |
79 | /// <param name="Bag"></param> | 79 | /// <param name="Bag"></param> |
80 | /// <returns></returns> | 80 | /// <returns></returns> |
81 | public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag) | 81 | public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag) |
82 | { | 82 | { |
83 | FindallAnswers findallAnswers = new FindallAnswers(Template); | 83 | FindallAnswers findallAnswers = new FindallAnswers(Template); |
84 | foreach (bool l1 in goal) | 84 | foreach (bool l1 in goal) |
85 | findallAnswers.add(); | 85 | findallAnswers.add(); |
86 | return findallAnswers.result(Bag); | 86 | return findallAnswers.result(Bag); |
87 | } | 87 | } |
88 | 88 | ||
89 | /// <summary> | 89 | /// <summary> |
90 | /// Like findall, except return an array of the results. | 90 | /// Like findall, except return an array of the results. |
91 | /// </summary> | 91 | /// </summary> |
92 | /// <param name="template"></param> | 92 | /// <param name="template"></param> |
93 | /// <param name="goal"></param> | 93 | /// <param name="goal"></param> |
94 | /// <returns></returns> | 94 | /// <returns></returns> |
95 | public static List<object> findallArray(object Template, IEnumerable<bool> goal) | 95 | public static List<object> findallArray(object Template, IEnumerable<bool> goal) |
96 | { | 96 | { |
97 | FindallAnswers findallAnswers = new FindallAnswers(Template); | 97 | FindallAnswers findallAnswers = new FindallAnswers(Template); |
98 | foreach (bool l1 in goal) | 98 | foreach (bool l1 in goal) |
99 | findallAnswers.add(); | 99 | findallAnswers.add(); |
100 | return findallAnswers.resultArray(); | 100 | return findallAnswers.resultArray(); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs index 3ba1021..58c0e4b 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs | |||
@@ -1,188 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
35 | { | 35 | { |
36 | public class Functor : IUnifiable | 36 | public class Functor : IUnifiable |
37 | { | 37 | { |
38 | public readonly Atom _name; | 38 | public readonly Atom _name; |
39 | public readonly object[] _args; | 39 | public readonly object[] _args; |
40 | 40 | ||
41 | public Functor(Atom name, object[] args) | 41 | public Functor(Atom name, object[] args) |
42 | { | 42 | { |
43 | if (args.Length <= 3) | 43 | if (args.Length <= 3) |
44 | { | 44 | { |
45 | if (args.Length == 0) | 45 | if (args.Length == 0) |
46 | throw new Exception("For arity 0 functor, just use name as an Atom"); | 46 | throw new Exception("For arity 0 functor, just use name as an Atom"); |
47 | else if (args.Length == 1) | 47 | else if (args.Length == 1) |
48 | throw new Exception("For arity 1 functor, use Functor1"); | 48 | throw new Exception("For arity 1 functor, use Functor1"); |
49 | else if (args.Length == 2) | 49 | else if (args.Length == 2) |
50 | throw new Exception("For arity 2 functor, use Functor2"); | 50 | throw new Exception("For arity 2 functor, use Functor2"); |
51 | else if (args.Length == 3) | 51 | else if (args.Length == 3) |
52 | throw new Exception("For arity 3 functor, use Functor3"); | 52 | throw new Exception("For arity 3 functor, use Functor3"); |
53 | else | 53 | else |
54 | // (This shouldn't happen, but include it for completeness. | 54 | // (This shouldn't happen, but include it for completeness. |
55 | throw new Exception("Cannot create a Functor of arity " + args.Length); | 55 | throw new Exception("Cannot create a Functor of arity " + args.Length); |
56 | } | 56 | } |
57 | 57 | ||
58 | _name = name; | 58 | _name = name; |
59 | _args = args; | 59 | _args = args; |
60 | } | 60 | } |
61 | 61 | ||
62 | public Functor(string name, object[] args) | 62 | public Functor(string name, object[] args) |
63 | : this(Atom.a(name), args) | 63 | : this(Atom.a(name), args) |
64 | { | 64 | { |
65 | } | 65 | } |
66 | 66 | ||
67 | /// <summary> | 67 | /// <summary> |
68 | /// Return an Atom, Functor1, Functor2, Functor3 or Functor depending on the | 68 | /// Return an Atom, Functor1, Functor2, Functor3 or Functor depending on the |
69 | /// length of args. | 69 | /// length of args. |
70 | /// Note that this is different than the Functor constructor which requires | 70 | /// Note that this is different than the Functor constructor which requires |
71 | /// the length of args to be greater than 3. | 71 | /// the length of args to be greater than 3. |
72 | /// </summary> | 72 | /// </summary> |
73 | /// <param name="name"></param> | 73 | /// <param name="name"></param> |
74 | /// <param name="args"></param> | 74 | /// <param name="args"></param> |
75 | /// <returns></returns> | 75 | /// <returns></returns> |
76 | public static object make(Atom name, object[] args) | 76 | public static object make(Atom name, object[] args) |
77 | { | 77 | { |
78 | if (args.Length <= 0) | 78 | if (args.Length <= 0) |
79 | return name; | 79 | return name; |
80 | else if (args.Length == 1) | 80 | else if (args.Length == 1) |
81 | return new Functor1(name, args[0]); | 81 | return new Functor1(name, args[0]); |
82 | else if (args.Length == 2) | 82 | else if (args.Length == 2) |
83 | return new Functor2(name, args[0], args[1]); | 83 | return new Functor2(name, args[0], args[1]); |
84 | else if (args.Length == 3) | 84 | else if (args.Length == 3) |
85 | return new Functor3(name, args[0], args[1], args[2]); | 85 | return new Functor3(name, args[0], args[1], args[2]); |
86 | else | 86 | else |
87 | return new Functor(name, args); | 87 | return new Functor(name, args); |
88 | } | 88 | } |
89 | 89 | ||
90 | /// <summary> | 90 | /// <summary> |
91 | /// Call the main make, first converting name to an Atom. | 91 | /// Call the main make, first converting name to an Atom. |
92 | /// </summary> | 92 | /// </summary> |
93 | /// <param name="name"></param> | 93 | /// <param name="name"></param> |
94 | /// <param name="args"></param> | 94 | /// <param name="args"></param> |
95 | /// <returns></returns> | 95 | /// <returns></returns> |
96 | public static object make(string name, object[] args) | 96 | public static object make(string name, object[] args) |
97 | { | 97 | { |
98 | return make(Atom.a(name), args); | 98 | return make(Atom.a(name), args); |
99 | } | 99 | } |
100 | 100 | ||
101 | public IEnumerable<bool> unify(object arg) | 101 | public IEnumerable<bool> unify(object arg) |
102 | { | 102 | { |
103 | arg = YP.getValue(arg); | 103 | arg = YP.getValue(arg); |
104 | if (arg is Functor) | 104 | if (arg is Functor) |
105 | { | 105 | { |
106 | Functor argFunctor = (Functor)arg; | 106 | Functor argFunctor = (Functor)arg; |
107 | if (_name.Equals(argFunctor._name)) | 107 | if (_name.Equals(argFunctor._name)) |
108 | return YP.unifyArrays(_args, argFunctor._args); | 108 | return YP.unifyArrays(_args, argFunctor._args); |
109 | else | 109 | else |
110 | return YP.fail(); | 110 | return YP.fail(); |
111 | } | 111 | } |
112 | else if (arg is Variable) | 112 | else if (arg is Variable) |
113 | return ((Variable)arg).unify(this); | 113 | return ((Variable)arg).unify(this); |
114 | else | 114 | else |
115 | return YP.fail(); | 115 | return YP.fail(); |
116 | } | 116 | } |
117 | 117 | ||
118 | public override string ToString() | 118 | public override string ToString() |
119 | { | 119 | { |
120 | string result = _name + "(" + YP.getValue(_args[0]); | 120 | string result = _name + "(" + YP.getValue(_args[0]); |
121 | for (int i = 1; i < _args.Length; ++i) | 121 | for (int i = 1; i < _args.Length; ++i) |
122 | result += ", " + YP.getValue(_args[i]); | 122 | result += ", " + YP.getValue(_args[i]); |
123 | result += ")"; | 123 | result += ")"; |
124 | return result; | 124 | return result; |
125 | } | 125 | } |
126 | 126 | ||
127 | public bool termEqual(object term) | 127 | public bool termEqual(object term) |
128 | { | 128 | { |
129 | term = YP.getValue(term); | 129 | term = YP.getValue(term); |
130 | if (term is Functor) | 130 | if (term is Functor) |
131 | { | 131 | { |
132 | Functor termFunctor = (Functor)term; | 132 | Functor termFunctor = (Functor)term; |
133 | if (_name.Equals(termFunctor._name) && _args.Length == termFunctor._args.Length) | 133 | if (_name.Equals(termFunctor._name) && _args.Length == termFunctor._args.Length) |
134 | { | 134 | { |
135 | for (int i = 0; i < _args.Length; ++i) | 135 | for (int i = 0; i < _args.Length; ++i) |
136 | { | 136 | { |
137 | if (!YP.termEqual(_args[i], termFunctor._args[i])) | 137 | if (!YP.termEqual(_args[i], termFunctor._args[i])) |
138 | return false; | 138 | return false; |
139 | } | 139 | } |
140 | return true; | 140 | return true; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | return false; | 143 | return false; |
144 | } | 144 | } |
145 | 145 | ||
146 | public bool lessThan(Functor functor) | 146 | public bool lessThan(Functor functor) |
147 | { | 147 | { |
148 | // Do the equal check first since it is faster. | 148 | // Do the equal check first since it is faster. |
149 | if (!_name.Equals(functor._name)) | 149 | if (!_name.Equals(functor._name)) |
150 | return _name.lessThan(functor._name); | 150 | return _name.lessThan(functor._name); |
151 | 151 | ||
152 | if (_args.Length != functor._args.Length) | 152 | if (_args.Length != functor._args.Length) |
153 | return _args.Length < functor._args.Length; | 153 | return _args.Length < functor._args.Length; |
154 | 154 | ||
155 | for (int i = 0; i < _args.Length; ++i) | 155 | for (int i = 0; i < _args.Length; ++i) |
156 | { | 156 | { |
157 | if (!YP.termEqual(_args[i], functor._args[i])) | 157 | if (!YP.termEqual(_args[i], functor._args[i])) |
158 | return YP.termLessThan(_args[i], functor._args[i]); | 158 | return YP.termLessThan(_args[i], functor._args[i]); |
159 | } | 159 | } |
160 | 160 | ||
161 | return false; | 161 | return false; |
162 | } | 162 | } |
163 | 163 | ||
164 | public bool ground() | 164 | public bool ground() |
165 | { | 165 | { |
166 | for (int i = 0; i < _args.Length; ++i) | 166 | for (int i = 0; i < _args.Length; ++i) |
167 | { | 167 | { |
168 | if (!YP.ground(_args[i])) | 168 | if (!YP.ground(_args[i])) |
169 | return false; | 169 | return false; |
170 | } | 170 | } |
171 | return true; | 171 | return true; |
172 | } | 172 | } |
173 | 173 | ||
174 | public void addUniqueVariables(List<Variable> variableSet) | 174 | public void addUniqueVariables(List<Variable> variableSet) |
175 | { | 175 | { |
176 | for (int i = 0; i < _args.Length; ++i) | 176 | for (int i = 0; i < _args.Length; ++i) |
177 | YP.addUniqueVariables(_args[i], variableSet); | 177 | YP.addUniqueVariables(_args[i], variableSet); |
178 | } | 178 | } |
179 | 179 | ||
180 | public object makeCopy(Variable.CopyStore copyStore) | 180 | public object makeCopy(Variable.CopyStore copyStore) |
181 | { | 181 | { |
182 | object[] argsCopy = new object[_args.Length]; | 182 | object[] argsCopy = new object[_args.Length]; |
183 | for (int i = 0; i < _args.Length; ++i) | 183 | for (int i = 0; i < _args.Length; ++i) |
184 | argsCopy[i] = YP.makeCopy(_args[i], copyStore); | 184 | argsCopy[i] = YP.makeCopy(_args[i], copyStore); |
185 | return new Functor(_name, argsCopy); | 185 | return new Functor(_name, argsCopy); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | } | 188 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs index 33e2a32..582cd20 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs | |||
@@ -1,111 +1,111 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
35 | { | 35 | { |
36 | public class Functor1 : IUnifiable | 36 | public class Functor1 : IUnifiable |
37 | { | 37 | { |
38 | public readonly Atom _name; | 38 | public readonly Atom _name; |
39 | public readonly object _arg1; | 39 | public readonly object _arg1; |
40 | 40 | ||
41 | public Functor1(Atom name, object arg1) | 41 | public Functor1(Atom name, object arg1) |
42 | { | 42 | { |
43 | _name = name; | 43 | _name = name; |
44 | _arg1 = arg1; | 44 | _arg1 = arg1; |
45 | } | 45 | } |
46 | 46 | ||
47 | public Functor1(string name, object arg1) | 47 | public Functor1(string name, object arg1) |
48 | : this(Atom.a(name), arg1) | 48 | : this(Atom.a(name), arg1) |
49 | { | 49 | { |
50 | } | 50 | } |
51 | 51 | ||
52 | public IEnumerable<bool> unify(object arg) | 52 | public IEnumerable<bool> unify(object arg) |
53 | { | 53 | { |
54 | arg = YP.getValue(arg); | 54 | arg = YP.getValue(arg); |
55 | if (arg is Functor1) | 55 | if (arg is Functor1) |
56 | { | 56 | { |
57 | Functor1 argFunctor = (Functor1)arg; | 57 | Functor1 argFunctor = (Functor1)arg; |
58 | if (_name.Equals(argFunctor._name)) | 58 | if (_name.Equals(argFunctor._name)) |
59 | { | 59 | { |
60 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) | 60 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) |
61 | yield return false; | 61 | yield return false; |
62 | } | 62 | } |
63 | } | 63 | } |
64 | else if (arg is Variable) | 64 | else if (arg is Variable) |
65 | { | 65 | { |
66 | foreach (bool l1 in ((Variable)arg).unify(this)) | 66 | foreach (bool l1 in ((Variable)arg).unify(this)) |
67 | yield return false; | 67 | yield return false; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | public override string ToString() | 71 | public override string ToString() |
72 | { | 72 | { |
73 | return _name + "(" + YP.getValue(_arg1) + ")"; | 73 | return _name + "(" + YP.getValue(_arg1) + ")"; |
74 | } | 74 | } |
75 | 75 | ||
76 | public bool termEqual(object term) | 76 | public bool termEqual(object term) |
77 | { | 77 | { |
78 | term = YP.getValue(term); | 78 | term = YP.getValue(term); |
79 | if (term is Functor1) | 79 | if (term is Functor1) |
80 | { | 80 | { |
81 | Functor1 termFunctor = (Functor1)term; | 81 | Functor1 termFunctor = (Functor1)term; |
82 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1); | 82 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1); |
83 | } | 83 | } |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | 86 | ||
87 | public bool lessThan(Functor1 functor) | 87 | public bool lessThan(Functor1 functor) |
88 | { | 88 | { |
89 | // Do the equal check first since it is faster. | 89 | // Do the equal check first since it is faster. |
90 | if (!_name.Equals(functor._name)) | 90 | if (!_name.Equals(functor._name)) |
91 | return _name.lessThan(functor._name); | 91 | return _name.lessThan(functor._name); |
92 | 92 | ||
93 | return YP.termLessThan(_arg1, functor._arg1); | 93 | return YP.termLessThan(_arg1, functor._arg1); |
94 | } | 94 | } |
95 | 95 | ||
96 | public bool ground() | 96 | public bool ground() |
97 | { | 97 | { |
98 | return YP.ground(_arg1); | 98 | return YP.ground(_arg1); |
99 | } | 99 | } |
100 | 100 | ||
101 | public void addUniqueVariables(List<Variable> variableSet) | 101 | public void addUniqueVariables(List<Variable> variableSet) |
102 | { | 102 | { |
103 | YP.addUniqueVariables(_arg1, variableSet); | 103 | YP.addUniqueVariables(_arg1, variableSet); |
104 | } | 104 | } |
105 | 105 | ||
106 | public object makeCopy(Variable.CopyStore copyStore) | 106 | public object makeCopy(Variable.CopyStore copyStore) |
107 | { | 107 | { |
108 | return new Functor1(_name, YP.makeCopy(_arg1, copyStore)); | 108 | return new Functor1(_name, YP.makeCopy(_arg1, copyStore)); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | } | 111 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs index 87c5f1b..138a44c 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs | |||
@@ -1,154 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
35 | { | 35 | { |
36 | public class Functor2 : IUnifiable | 36 | public class Functor2 : IUnifiable |
37 | { | 37 | { |
38 | public readonly Atom _name; | 38 | public readonly Atom _name; |
39 | public readonly object _arg1; | 39 | public readonly object _arg1; |
40 | public readonly object _arg2; | 40 | public readonly object _arg2; |
41 | 41 | ||
42 | public Functor2(Atom name, object arg1, object arg2) | 42 | public Functor2(Atom name, object arg1, object arg2) |
43 | { | 43 | { |
44 | _name = name; | 44 | _name = name; |
45 | _arg1 = arg1; | 45 | _arg1 = arg1; |
46 | _arg2 = arg2; | 46 | _arg2 = arg2; |
47 | } | 47 | } |
48 | 48 | ||
49 | public Functor2(string name, object arg1, object arg2) | 49 | public Functor2(string name, object arg1, object arg2) |
50 | : this(Atom.a(name), arg1, arg2) | 50 | : this(Atom.a(name), arg1, arg2) |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | public IEnumerable<bool> unify(object arg) | 54 | public IEnumerable<bool> unify(object arg) |
55 | { | 55 | { |
56 | arg = YP.getValue(arg); | 56 | arg = YP.getValue(arg); |
57 | if (arg is Functor2) | 57 | if (arg is Functor2) |
58 | { | 58 | { |
59 | Functor2 argFunctor = (Functor2)arg; | 59 | Functor2 argFunctor = (Functor2)arg; |
60 | if (_name.Equals(argFunctor._name)) | 60 | if (_name.Equals(argFunctor._name)) |
61 | { | 61 | { |
62 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) | 62 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) |
63 | { | 63 | { |
64 | foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) | 64 | foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) |
65 | yield return false; | 65 | yield return false; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | } | 68 | } |
69 | else if (arg is Variable) | 69 | else if (arg is Variable) |
70 | { | 70 | { |
71 | foreach (bool l1 in ((Variable)arg).unify(this)) | 71 | foreach (bool l1 in ((Variable)arg).unify(this)) |
72 | yield return false; | 72 | yield return false; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | public override string ToString() | 76 | public override string ToString() |
77 | { | 77 | { |
78 | if (_name == Atom.DOT) | 78 | if (_name == Atom.DOT) |
79 | return listPairToString(this); | 79 | return listPairToString(this); |
80 | else | 80 | else |
81 | return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ")"; | 81 | return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ")"; |
82 | } | 82 | } |
83 | 83 | ||
84 | public bool termEqual(object term) | 84 | public bool termEqual(object term) |
85 | { | 85 | { |
86 | term = YP.getValue(term); | 86 | term = YP.getValue(term); |
87 | if (term is Functor2) | 87 | if (term is Functor2) |
88 | { | 88 | { |
89 | Functor2 termFunctor = (Functor2)term; | 89 | Functor2 termFunctor = (Functor2)term; |
90 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1) | 90 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1) |
91 | && YP.termEqual(_arg2, termFunctor._arg2); | 91 | && YP.termEqual(_arg2, termFunctor._arg2); |
92 | } | 92 | } |
93 | return false; | 93 | return false; |
94 | } | 94 | } |
95 | 95 | ||
96 | public bool lessThan(Functor2 functor) | 96 | public bool lessThan(Functor2 functor) |
97 | { | 97 | { |
98 | // Do the equal check first since it is faster. | 98 | // Do the equal check first since it is faster. |
99 | if (!_name.Equals(functor._name)) | 99 | if (!_name.Equals(functor._name)) |
100 | return _name.lessThan(functor._name); | 100 | return _name.lessThan(functor._name); |
101 | 101 | ||
102 | if (!YP.termEqual(_arg1, functor._arg1)) | 102 | if (!YP.termEqual(_arg1, functor._arg1)) |
103 | return YP.termLessThan(_arg1, functor._arg1); | 103 | return YP.termLessThan(_arg1, functor._arg1); |
104 | 104 | ||
105 | return YP.termLessThan(_arg2, functor._arg2); | 105 | return YP.termLessThan(_arg2, functor._arg2); |
106 | } | 106 | } |
107 | 107 | ||
108 | public bool ground() | 108 | public bool ground() |
109 | { | 109 | { |
110 | return YP.ground(_arg1) && YP.ground(_arg2); | 110 | return YP.ground(_arg1) && YP.ground(_arg2); |
111 | } | 111 | } |
112 | 112 | ||
113 | public void addUniqueVariables(List<Variable> variableSet) | 113 | public void addUniqueVariables(List<Variable> variableSet) |
114 | { | 114 | { |
115 | YP.addUniqueVariables(_arg1, variableSet); | 115 | YP.addUniqueVariables(_arg1, variableSet); |
116 | YP.addUniqueVariables(_arg2, variableSet); | 116 | YP.addUniqueVariables(_arg2, variableSet); |
117 | } | 117 | } |
118 | 118 | ||
119 | public object makeCopy(Variable.CopyStore copyStore) | 119 | public object makeCopy(Variable.CopyStore copyStore) |
120 | { | 120 | { |
121 | return new Functor2(_name, YP.makeCopy(_arg1, copyStore), | 121 | return new Functor2(_name, YP.makeCopy(_arg1, copyStore), |
122 | YP.makeCopy(_arg2, copyStore)); | 122 | YP.makeCopy(_arg2, copyStore)); |
123 | } | 123 | } |
124 | 124 | ||
125 | private static string listPairToString(Functor2 listPair) | 125 | private static string listPairToString(Functor2 listPair) |
126 | { | 126 | { |
127 | string result = "["; | 127 | string result = "["; |
128 | while (true) | 128 | while (true) |
129 | { | 129 | { |
130 | object head = YP.getValue(listPair._arg1); | 130 | object head = YP.getValue(listPair._arg1); |
131 | object tail = YP.getValue(listPair._arg2); | 131 | object tail = YP.getValue(listPair._arg2); |
132 | if (tail == (object)Atom.NIL) | 132 | if (tail == (object)Atom.NIL) |
133 | { | 133 | { |
134 | result += head; | 134 | result += head; |
135 | break; | 135 | break; |
136 | } | 136 | } |
137 | else if (tail is Functor2 && ((Functor2)tail)._name == Atom.DOT) | 137 | else if (tail is Functor2 && ((Functor2)tail)._name == Atom.DOT) |
138 | { | 138 | { |
139 | result += head + ", "; | 139 | result += head + ", "; |
140 | listPair = (Functor2)tail; | 140 | listPair = (Functor2)tail; |
141 | // Loop again. | 141 | // Loop again. |
142 | } | 142 | } |
143 | else | 143 | else |
144 | { | 144 | { |
145 | // The list is not terminated with NIL. | 145 | // The list is not terminated with NIL. |
146 | result += head + "|" + tail; | 146 | result += head + "|" + tail; |
147 | break; | 147 | break; |
148 | } | 148 | } |
149 | } | 149 | } |
150 | result += "]"; | 150 | result += "]"; |
151 | return result; | 151 | return result; |
152 | } | 152 | } |
153 | } | 153 | } |
154 | } | 154 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs index 74418c4..b52fdf3 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs | |||
@@ -1,133 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
35 | { | 35 | { |
36 | public class Functor3 : IUnifiable | 36 | public class Functor3 : IUnifiable |
37 | { | 37 | { |
38 | public readonly Atom _name; | 38 | public readonly Atom _name; |
39 | public readonly object _arg1; | 39 | public readonly object _arg1; |
40 | public readonly object _arg2; | 40 | public readonly object _arg2; |
41 | public readonly object _arg3; | 41 | public readonly object _arg3; |
42 | 42 | ||
43 | public Functor3(Atom name, object arg1, object arg2, object arg3) | 43 | public Functor3(Atom name, object arg1, object arg2, object arg3) |
44 | { | 44 | { |
45 | _name = name; | 45 | _name = name; |
46 | _arg1 = arg1; | 46 | _arg1 = arg1; |
47 | _arg2 = arg2; | 47 | _arg2 = arg2; |
48 | _arg3 = arg3; | 48 | _arg3 = arg3; |
49 | } | 49 | } |
50 | 50 | ||
51 | public Functor3(string name, object arg1, object arg2, object arg3) | 51 | public Functor3(string name, object arg1, object arg2, object arg3) |
52 | : this(Atom.a(name), arg1, arg2, arg3) | 52 | : this(Atom.a(name), arg1, arg2, arg3) |
53 | { | 53 | { |
54 | } | 54 | } |
55 | 55 | ||
56 | public IEnumerable<bool> unify(object arg) | 56 | public IEnumerable<bool> unify(object arg) |
57 | { | 57 | { |
58 | arg = YP.getValue(arg); | 58 | arg = YP.getValue(arg); |
59 | if (arg is Functor3) | 59 | if (arg is Functor3) |
60 | { | 60 | { |
61 | Functor3 argFunctor = (Functor3)arg; | 61 | Functor3 argFunctor = (Functor3)arg; |
62 | if (_name.Equals(argFunctor._name)) | 62 | if (_name.Equals(argFunctor._name)) |
63 | { | 63 | { |
64 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) | 64 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) |
65 | { | 65 | { |
66 | foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) | 66 | foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) |
67 | { | 67 | { |
68 | foreach (bool l3 in YP.unify(_arg3, argFunctor._arg3)) | 68 | foreach (bool l3 in YP.unify(_arg3, argFunctor._arg3)) |
69 | yield return false; | 69 | yield return false; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | } | 72 | } |
73 | } | 73 | } |
74 | else if (arg is Variable) | 74 | else if (arg is Variable) |
75 | { | 75 | { |
76 | foreach (bool l1 in ((Variable)arg).unify(this)) | 76 | foreach (bool l1 in ((Variable)arg).unify(this)) |
77 | yield return false; | 77 | yield return false; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | public override string ToString() | 81 | public override string ToString() |
82 | { | 82 | { |
83 | return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ", " + | 83 | return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ", " + |
84 | YP.getValue(_arg3) + ")"; | 84 | YP.getValue(_arg3) + ")"; |
85 | } | 85 | } |
86 | 86 | ||
87 | public bool termEqual(object term) | 87 | public bool termEqual(object term) |
88 | { | 88 | { |
89 | term = YP.getValue(term); | 89 | term = YP.getValue(term); |
90 | if (term is Functor3) | 90 | if (term is Functor3) |
91 | { | 91 | { |
92 | Functor3 termFunctor = (Functor3)term; | 92 | Functor3 termFunctor = (Functor3)term; |
93 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1) | 93 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1) |
94 | && YP.termEqual(_arg2, termFunctor._arg2) | 94 | && YP.termEqual(_arg2, termFunctor._arg2) |
95 | && YP.termEqual(_arg3, termFunctor._arg3); | 95 | && YP.termEqual(_arg3, termFunctor._arg3); |
96 | } | 96 | } |
97 | return false; | 97 | return false; |
98 | } | 98 | } |
99 | 99 | ||
100 | public bool lessThan(Functor3 functor) | 100 | public bool lessThan(Functor3 functor) |
101 | { | 101 | { |
102 | // Do the equal check first since it is faster. | 102 | // Do the equal check first since it is faster. |
103 | if (!_name.Equals(functor._name)) | 103 | if (!_name.Equals(functor._name)) |
104 | return _name.lessThan(functor._name); | 104 | return _name.lessThan(functor._name); |
105 | 105 | ||
106 | if (!YP.termEqual(_arg1, functor._arg1)) | 106 | if (!YP.termEqual(_arg1, functor._arg1)) |
107 | return YP.termLessThan(_arg1, functor._arg1); | 107 | return YP.termLessThan(_arg1, functor._arg1); |
108 | 108 | ||
109 | if (!YP.termEqual(_arg2, functor._arg2)) | 109 | if (!YP.termEqual(_arg2, functor._arg2)) |
110 | return YP.termLessThan(_arg2, functor._arg2); | 110 | return YP.termLessThan(_arg2, functor._arg2); |
111 | 111 | ||
112 | return YP.termLessThan(_arg3, functor._arg3); | 112 | return YP.termLessThan(_arg3, functor._arg3); |
113 | } | 113 | } |
114 | 114 | ||
115 | public bool ground() | 115 | public bool ground() |
116 | { | 116 | { |
117 | return YP.ground(_arg1) && YP.ground(_arg2) && YP.ground(_arg3); | 117 | return YP.ground(_arg1) && YP.ground(_arg2) && YP.ground(_arg3); |
118 | } | 118 | } |
119 | 119 | ||
120 | public void addUniqueVariables(List<Variable> variableSet) | 120 | public void addUniqueVariables(List<Variable> variableSet) |
121 | { | 121 | { |
122 | YP.addUniqueVariables(_arg1, variableSet); | 122 | YP.addUniqueVariables(_arg1, variableSet); |
123 | YP.addUniqueVariables(_arg2, variableSet); | 123 | YP.addUniqueVariables(_arg2, variableSet); |
124 | YP.addUniqueVariables(_arg3, variableSet); | 124 | YP.addUniqueVariables(_arg3, variableSet); |
125 | } | 125 | } |
126 | 126 | ||
127 | public object makeCopy(Variable.CopyStore copyStore) | 127 | public object makeCopy(Variable.CopyStore copyStore) |
128 | { | 128 | { |
129 | return new Functor3(_name, YP.makeCopy(_arg1, copyStore), | 129 | return new Functor3(_name, YP.makeCopy(_arg1, copyStore), |
130 | YP.makeCopy(_arg2, copyStore), YP.makeCopy(_arg3, copyStore)); | 130 | YP.makeCopy(_arg2, copyStore), YP.makeCopy(_arg3, copyStore)); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | } | 133 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs index 3eac5fa..05b0a01 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs | |||
@@ -1,288 +1,288 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections; | 32 | using System.Collections; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | 34 | ||
35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// An IndexedAnswers holds answers to a query based on the values of index arguments. | 38 | /// An IndexedAnswers holds answers to a query based on the values of index arguments. |
39 | /// </summary> | 39 | /// </summary> |
40 | public class IndexedAnswers : YP.IClause | 40 | public class IndexedAnswers : YP.IClause |
41 | { | 41 | { |
42 | // addAnswer adds the answer here and indexes it later. | 42 | // addAnswer adds the answer here and indexes it later. |
43 | private List<object[]> _allAnswers = new List<object[]>(); | 43 | private List<object[]> _allAnswers = new List<object[]>(); |
44 | // The key has the arity of answers with non-null values for each indexed arg. The value | 44 | // The key has the arity of answers with non-null values for each indexed arg. The value |
45 | // is a list of the matching answers. The signature is implicit in the pattern on non-null index args. | 45 | // is a list of the matching answers. The signature is implicit in the pattern on non-null index args. |
46 | private Dictionary<HashedList, List<object[]>> _indexedAnswers = | 46 | private Dictionary<HashedList, List<object[]>> _indexedAnswers = |
47 | new Dictionary<HashedList, List<object[]>>(); | 47 | new Dictionary<HashedList, List<object[]>>(); |
48 | // Keeps track of whether we have started adding entries to _indexedAnswers for the signature. | 48 | // Keeps track of whether we have started adding entries to _indexedAnswers for the signature. |
49 | private Dictionary<int, object> _gotAnswersForSignature = new Dictionary<int, object>(); | 49 | private Dictionary<int, object> _gotAnswersForSignature = new Dictionary<int, object>(); |
50 | private const int MAX_INDEX_ARGS = 31; | 50 | private const int MAX_INDEX_ARGS = 31; |
51 | 51 | ||
52 | public IndexedAnswers() | 52 | public IndexedAnswers() |
53 | { | 53 | { |
54 | } | 54 | } |
55 | 55 | ||
56 | /// <summary> | 56 | /// <summary> |
57 | /// Elements of answer must be ground, since arguments with unbound variables make this | 57 | /// Elements of answer must be ground, since arguments with unbound variables make this |
58 | /// into a dynamic rule which we don't index. | 58 | /// into a dynamic rule which we don't index. |
59 | /// </summary> | 59 | /// </summary> |
60 | /// <param name="answer"></param> | 60 | /// <param name="answer"></param> |
61 | public void addAnswer(object[] answer) | 61 | public void addAnswer(object[] answer) |
62 | { | 62 | { |
63 | // Store a copy of the answer array. | 63 | // Store a copy of the answer array. |
64 | object[] answerCopy = new object[answer.Length]; | 64 | object[] answerCopy = new object[answer.Length]; |
65 | Variable.CopyStore copyStore = new Variable.CopyStore(); | 65 | Variable.CopyStore copyStore = new Variable.CopyStore(); |
66 | for (int i = 0; i < answer.Length; ++i) | 66 | for (int i = 0; i < answer.Length; ++i) |
67 | answerCopy[i] = YP.makeCopy(answer[i], copyStore); | 67 | answerCopy[i] = YP.makeCopy(answer[i], copyStore); |
68 | if (copyStore.getNUniqueVariables() > 0) | 68 | if (copyStore.getNUniqueVariables() > 0) |
69 | throw new InvalidOperationException | 69 | throw new InvalidOperationException |
70 | ("Elements of answer must be ground, but found " + copyStore.getNUniqueVariables() + | 70 | ("Elements of answer must be ground, but found " + copyStore.getNUniqueVariables() + |
71 | " unbound variables"); | 71 | " unbound variables"); |
72 | _allAnswers.Add(answerCopy); | 72 | _allAnswers.Add(answerCopy); |
73 | 73 | ||
74 | // If match has already indexed answers for a signature, we need to add | 74 | // If match has already indexed answers for a signature, we need to add |
75 | // this to the existing indexed answers. | 75 | // this to the existing indexed answers. |
76 | foreach(int signature in _gotAnswersForSignature.Keys) | 76 | foreach(int signature in _gotAnswersForSignature.Keys) |
77 | indexAnswerForSignature(answerCopy, signature); | 77 | indexAnswerForSignature(answerCopy, signature); |
78 | } | 78 | } |
79 | 79 | ||
80 | private void indexAnswerForSignature(object[] answer, int signature) | 80 | private void indexAnswerForSignature(object[] answer, int signature) |
81 | { | 81 | { |
82 | // First find out which of the answer values can be used as an index. | 82 | // First find out which of the answer values can be used as an index. |
83 | object[] indexValues = new object[answer.Length]; | 83 | object[] indexValues = new object[answer.Length]; |
84 | for (int i = 0; i < answer.Length; ++i) | 84 | for (int i = 0; i < answer.Length; ++i) |
85 | { | 85 | { |
86 | // We limit the number of indexed args in a 32-bit signature. | 86 | // We limit the number of indexed args in a 32-bit signature. |
87 | if (i >= MAX_INDEX_ARGS) | 87 | if (i >= MAX_INDEX_ARGS) |
88 | indexValues[i] = null; | 88 | indexValues[i] = null; |
89 | else | 89 | else |
90 | indexValues[i] = getIndexValue(YP.getValue(answer[i])); | 90 | indexValues[i] = getIndexValue(YP.getValue(answer[i])); |
91 | } | 91 | } |
92 | 92 | ||
93 | // We need an entry in indexArgs from indexValues for each 1 bit in signature. | 93 | // We need an entry in indexArgs from indexValues for each 1 bit in signature. |
94 | HashedList indexArgs = new HashedList(indexValues.Length); | 94 | HashedList indexArgs = new HashedList(indexValues.Length); |
95 | for (int i = 0; i < indexValues.Length; ++i) | 95 | for (int i = 0; i < indexValues.Length; ++i) |
96 | { | 96 | { |
97 | if ((signature & (1 << i)) == 0) | 97 | if ((signature & (1 << i)) == 0) |
98 | indexArgs.Add(null); | 98 | indexArgs.Add(null); |
99 | else | 99 | else |
100 | { | 100 | { |
101 | if (indexValues[i] == null) | 101 | if (indexValues[i] == null) |
102 | // The signature wants an index value here, but we don't have one so | 102 | // The signature wants an index value here, but we don't have one so |
103 | // we can't add it as an answer for this signature. | 103 | // we can't add it as an answer for this signature. |
104 | return; | 104 | return; |
105 | else | 105 | else |
106 | indexArgs.Add(indexValues[i]); | 106 | indexArgs.Add(indexValues[i]); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | // Add the answer to the answers list for indexArgs, creating the entry if needed. | 110 | // Add the answer to the answers list for indexArgs, creating the entry if needed. |
111 | List<object[]> answers; | 111 | List<object[]> answers; |
112 | if (!_indexedAnswers.TryGetValue(indexArgs, out answers)) | 112 | if (!_indexedAnswers.TryGetValue(indexArgs, out answers)) |
113 | { | 113 | { |
114 | answers = new List<object[]>(); | 114 | answers = new List<object[]>(); |
115 | _indexedAnswers[indexArgs] = answers; | 115 | _indexedAnswers[indexArgs] = answers; |
116 | } | 116 | } |
117 | answers.Add(answer); | 117 | answers.Add(answer); |
118 | } | 118 | } |
119 | 119 | ||
120 | public IEnumerable<bool> match(object[] arguments) | 120 | public IEnumerable<bool> match(object[] arguments) |
121 | { | 121 | { |
122 | // Set up indexArgs, up to arg position MAX_INDEX_ARGS. The signature has a 1 bit for | 122 | // Set up indexArgs, up to arg position MAX_INDEX_ARGS. The signature has a 1 bit for |
123 | // each non-null index arg. | 123 | // each non-null index arg. |
124 | HashedList indexArgs = new HashedList(arguments.Length); | 124 | HashedList indexArgs = new HashedList(arguments.Length); |
125 | bool gotAllIndexArgs = true; | 125 | bool gotAllIndexArgs = true; |
126 | int signature = 0; | 126 | int signature = 0; |
127 | for (int i = 0; i < arguments.Length; ++i) | 127 | for (int i = 0; i < arguments.Length; ++i) |
128 | { | 128 | { |
129 | object indexValue = null; | 129 | object indexValue = null; |
130 | if (i < MAX_INDEX_ARGS) | 130 | if (i < MAX_INDEX_ARGS) |
131 | { | 131 | { |
132 | // We limit the number of args in a 32-bit signature. | 132 | // We limit the number of args in a 32-bit signature. |
133 | indexValue = getIndexValue(YP.getValue(arguments[i])); | 133 | indexValue = getIndexValue(YP.getValue(arguments[i])); |
134 | if (indexValue != null) | 134 | if (indexValue != null) |
135 | signature += (1 << i); | 135 | signature += (1 << i); |
136 | } | 136 | } |
137 | if (indexValue == null) | 137 | if (indexValue == null) |
138 | gotAllIndexArgs = false; | 138 | gotAllIndexArgs = false; |
139 | indexArgs.Add(indexValue); | 139 | indexArgs.Add(indexValue); |
140 | } | 140 | } |
141 | 141 | ||
142 | List<object[]> answers; | 142 | List<object[]> answers; |
143 | if (signature == 0) | 143 | if (signature == 0) |
144 | // No index args, so we have to match from _allAnswers. | 144 | // No index args, so we have to match from _allAnswers. |
145 | answers = _allAnswers; | 145 | answers = _allAnswers; |
146 | else | 146 | else |
147 | { | 147 | { |
148 | if (!_gotAnswersForSignature.ContainsKey(signature)) | 148 | if (!_gotAnswersForSignature.ContainsKey(signature)) |
149 | { | 149 | { |
150 | // We need to create the entry in _indexedAnswers. | 150 | // We need to create the entry in _indexedAnswers. |
151 | foreach (object[] answer in _allAnswers) | 151 | foreach (object[] answer in _allAnswers) |
152 | indexAnswerForSignature(answer, signature); | 152 | indexAnswerForSignature(answer, signature); |
153 | // Mark that we did this signature. | 153 | // Mark that we did this signature. |
154 | _gotAnswersForSignature[signature] = null; | 154 | _gotAnswersForSignature[signature] = null; |
155 | } | 155 | } |
156 | if (!_indexedAnswers.TryGetValue(indexArgs, out answers)) | 156 | if (!_indexedAnswers.TryGetValue(indexArgs, out answers)) |
157 | yield break; | 157 | yield break; |
158 | } | 158 | } |
159 | 159 | ||
160 | if (gotAllIndexArgs) | 160 | if (gotAllIndexArgs) |
161 | { | 161 | { |
162 | // All the arguments were already bound, so we don't need to do bindings. | 162 | // All the arguments were already bound, so we don't need to do bindings. |
163 | yield return false; | 163 | yield return false; |
164 | yield break; | 164 | yield break; |
165 | } | 165 | } |
166 | 166 | ||
167 | // Find matches in answers. | 167 | // Find matches in answers. |
168 | IEnumerator<bool>[] iterators = new IEnumerator<bool>[arguments.Length]; | 168 | IEnumerator<bool>[] iterators = new IEnumerator<bool>[arguments.Length]; |
169 | foreach (object[] answer in answers) | 169 | foreach (object[] answer in answers) |
170 | { | 170 | { |
171 | bool gotMatch = true; | 171 | bool gotMatch = true; |
172 | int nIterators = 0; | 172 | int nIterators = 0; |
173 | // Try to bind all the arguments. | 173 | // Try to bind all the arguments. |
174 | for (int i = 0; i < arguments.Length; ++i) | 174 | for (int i = 0; i < arguments.Length; ++i) |
175 | { | 175 | { |
176 | if (indexArgs[i] != null) | 176 | if (indexArgs[i] != null) |
177 | // We already matched this argument by looking up _indexedAnswers. | 177 | // We already matched this argument by looking up _indexedAnswers. |
178 | continue; | 178 | continue; |
179 | 179 | ||
180 | IEnumerator<bool> iterator = YP.unify(arguments[i], answer[i]).GetEnumerator(); | 180 | IEnumerator<bool> iterator = YP.unify(arguments[i], answer[i]).GetEnumerator(); |
181 | iterators[nIterators++] = iterator; | 181 | iterators[nIterators++] = iterator; |
182 | // MoveNext() is true if YP.unify succeeds. | 182 | // MoveNext() is true if YP.unify succeeds. |
183 | if (!iterator.MoveNext()) | 183 | if (!iterator.MoveNext()) |
184 | { | 184 | { |
185 | gotMatch = false; | 185 | gotMatch = false; |
186 | break; | 186 | break; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | try | 190 | try |
191 | { | 191 | { |
192 | if (gotMatch) | 192 | if (gotMatch) |
193 | yield return false; | 193 | yield return false; |
194 | } | 194 | } |
195 | finally | 195 | finally |
196 | { | 196 | { |
197 | // Manually finalize all the iterators. | 197 | // Manually finalize all the iterators. |
198 | for (int i = 0; i < nIterators; ++i) | 198 | for (int i = 0; i < nIterators; ++i) |
199 | iterators[i].Dispose(); | 199 | iterators[i].Dispose(); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | /// <summary> | 204 | /// <summary> |
205 | /// A HashedList extends an ArrayList with methods to get a hash and to check equality | 205 | /// A HashedList extends an ArrayList with methods to get a hash and to check equality |
206 | /// based on the elements of the list. | 206 | /// based on the elements of the list. |
207 | /// </summary> | 207 | /// </summary> |
208 | public class HashedList : ArrayList | 208 | public class HashedList : ArrayList |
209 | { | 209 | { |
210 | private bool _gotHashCode = false; | 210 | private bool _gotHashCode = false; |
211 | private int _hashCode; | 211 | private int _hashCode; |
212 | 212 | ||
213 | public HashedList() | 213 | public HashedList() |
214 | : base() | 214 | : base() |
215 | { | 215 | { |
216 | } | 216 | } |
217 | 217 | ||
218 | public HashedList(int capacity) | 218 | public HashedList(int capacity) |
219 | : base(capacity) | 219 | : base(capacity) |
220 | { | 220 | { |
221 | } | 221 | } |
222 | 222 | ||
223 | public HashedList(ICollection c) | 223 | public HashedList(ICollection c) |
224 | : base(c) | 224 | : base(c) |
225 | { | 225 | { |
226 | } | 226 | } |
227 | 227 | ||
228 | // Debug: Should override all the other methods that change this. | 228 | // Debug: Should override all the other methods that change this. |
229 | public override int Add(object value) | 229 | public override int Add(object value) |
230 | { | 230 | { |
231 | _gotHashCode = false; | 231 | _gotHashCode = false; |
232 | return base.Add(value); | 232 | return base.Add(value); |
233 | } | 233 | } |
234 | 234 | ||
235 | public override int GetHashCode() | 235 | public override int GetHashCode() |
236 | { | 236 | { |
237 | if (!_gotHashCode) | 237 | if (!_gotHashCode) |
238 | { | 238 | { |
239 | int hashCode = 1; | 239 | int hashCode = 1; |
240 | foreach (object obj in this) | 240 | foreach (object obj in this) |
241 | hashCode = 31 * hashCode + (obj == null ? 0 : obj.GetHashCode()); | 241 | hashCode = 31 * hashCode + (obj == null ? 0 : obj.GetHashCode()); |
242 | _hashCode = hashCode; | 242 | _hashCode = hashCode; |
243 | _gotHashCode = true; | 243 | _gotHashCode = true; |
244 | } | 244 | } |
245 | return _hashCode; | 245 | return _hashCode; |
246 | } | 246 | } |
247 | 247 | ||
248 | public override bool Equals(object obj) | 248 | public override bool Equals(object obj) |
249 | { | 249 | { |
250 | if (!(obj is ArrayList)) | 250 | if (!(obj is ArrayList)) |
251 | return false; | 251 | return false; |
252 | 252 | ||
253 | ArrayList objList = (ArrayList)obj; | 253 | ArrayList objList = (ArrayList)obj; |
254 | if (objList.Count != Count) | 254 | if (objList.Count != Count) |
255 | return false; | 255 | return false; |
256 | 256 | ||
257 | for (int i = 0; i < Count; ++i) | 257 | for (int i = 0; i < Count; ++i) |
258 | { | 258 | { |
259 | object value = objList[i]; | 259 | object value = objList[i]; |
260 | if (value == null) | 260 | if (value == null) |
261 | { | 261 | { |
262 | if (this[i] != null) | 262 | if (this[i] != null) |
263 | return false; | 263 | return false; |
264 | } | 264 | } |
265 | else | 265 | else |
266 | { | 266 | { |
267 | if (!value.Equals(this[i])) | 267 | if (!value.Equals(this[i])) |
268 | return false; | 268 | return false; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | return true; | 271 | return true; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | /// <summary> | 275 | /// <summary> |
276 | /// If we keep an index on value, return the value, or null if we don't index it. | 276 | /// If we keep an index on value, return the value, or null if we don't index it. |
277 | /// </summary> | 277 | /// </summary> |
278 | /// <param name="value">the term to examine. Assume you already called YP.getValue(value)</param> | 278 | /// <param name="value">the term to examine. Assume you already called YP.getValue(value)</param> |
279 | /// <returns></returns> | 279 | /// <returns></returns> |
280 | public static object getIndexValue(object value) | 280 | public static object getIndexValue(object value) |
281 | { | 281 | { |
282 | if (value is Atom || value is string || value is Int32 || value is DateTime) | 282 | if (value is Atom || value is string || value is Int32 || value is DateTime) |
283 | return value; | 283 | return value; |
284 | else | 284 | else |
285 | return null; | 285 | return null; |
286 | } | 286 | } |
287 | } | 287 | } |
288 | } | 288 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs index b16e8a4..681c445 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs | |||
@@ -1,156 +1,156 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
35 | { | 35 | { |
36 | public class ListPair : Functor2 | 36 | public class ListPair : Functor2 |
37 | { | 37 | { |
38 | public ListPair(object head, object tail) : base(Atom.DOT, head, tail) | 38 | public ListPair(object head, object tail) : base(Atom.DOT, head, tail) |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | public static object make(List<object> list) | 42 | public static object make(List<object> list) |
43 | { | 43 | { |
44 | if (list.Count <= 0) | 44 | if (list.Count <= 0) |
45 | return Atom.NIL; | 45 | return Atom.NIL; |
46 | 46 | ||
47 | object result = Atom.NIL; | 47 | object result = Atom.NIL; |
48 | // Start from the end. | 48 | // Start from the end. |
49 | for (int i = list.Count - 1; i >= 0; --i) | 49 | for (int i = list.Count - 1; i >= 0; --i) |
50 | result = new ListPair(list[i], result); | 50 | result = new ListPair(list[i], result); |
51 | return result; | 51 | return result; |
52 | } | 52 | } |
53 | 53 | ||
54 | public static object make(object[] array) | 54 | public static object make(object[] array) |
55 | { | 55 | { |
56 | if (array.Length <= 0) | 56 | if (array.Length <= 0) |
57 | return Atom.NIL; | 57 | return Atom.NIL; |
58 | 58 | ||
59 | object result = Atom.NIL; | 59 | object result = Atom.NIL; |
60 | // Start from the end. | 60 | // Start from the end. |
61 | for (int i = array.Length - 1; i >= 0; --i) | 61 | for (int i = array.Length - 1; i >= 0; --i) |
62 | result = new ListPair(array[i], result); | 62 | result = new ListPair(array[i], result); |
63 | return result; | 63 | return result; |
64 | } | 64 | } |
65 | 65 | ||
66 | /// <summary> | 66 | /// <summary> |
67 | /// Return a ListPair version of array, where repeated elements | 67 | /// Return a ListPair version of array, where repeated elements |
68 | /// (according to YP.termEqual) are removed. | 68 | /// (according to YP.termEqual) are removed. |
69 | /// </summary> | 69 | /// </summary> |
70 | /// <param name="array"></param> | 70 | /// <param name="array"></param> |
71 | /// <returns></returns> | 71 | /// <returns></returns> |
72 | public static object makeWithoutRepeatedTerms(object[] array) | 72 | public static object makeWithoutRepeatedTerms(object[] array) |
73 | { | 73 | { |
74 | if (array.Length <= 0) | 74 | if (array.Length <= 0) |
75 | return Atom.NIL; | 75 | return Atom.NIL; |
76 | 76 | ||
77 | // Start from the end. | 77 | // Start from the end. |
78 | object previousTerm = array[array.Length - 1]; | 78 | object previousTerm = array[array.Length - 1]; |
79 | object result = new ListPair(previousTerm, Atom.NIL); | 79 | object result = new ListPair(previousTerm, Atom.NIL); |
80 | for (int i = array.Length - 2; i >= 0; --i) | 80 | for (int i = array.Length - 2; i >= 0; --i) |
81 | { | 81 | { |
82 | object term = array[i]; | 82 | object term = array[i]; |
83 | if (YP.termEqual(term, previousTerm)) | 83 | if (YP.termEqual(term, previousTerm)) |
84 | continue; | 84 | continue; |
85 | result = new ListPair(term, result); | 85 | result = new ListPair(term, result); |
86 | previousTerm = term; | 86 | previousTerm = term; |
87 | } | 87 | } |
88 | return result; | 88 | return result; |
89 | } | 89 | } |
90 | 90 | ||
91 | /// <summary> | 91 | /// <summary> |
92 | /// Return a ListPair version of array, where repeated elements | 92 | /// Return a ListPair version of array, where repeated elements |
93 | /// (according to YP.termEqual) are removed. | 93 | /// (according to YP.termEqual) are removed. |
94 | /// </summary> | 94 | /// </summary> |
95 | /// <param name="array"></param> | 95 | /// <param name="array"></param> |
96 | /// <returns></returns> | 96 | /// <returns></returns> |
97 | public static object makeWithoutRepeatedTerms(List<object> array) | 97 | public static object makeWithoutRepeatedTerms(List<object> array) |
98 | { | 98 | { |
99 | if (array.Count <= 0) | 99 | if (array.Count <= 0) |
100 | return Atom.NIL; | 100 | return Atom.NIL; |
101 | 101 | ||
102 | // Start from the end. | 102 | // Start from the end. |
103 | object previousTerm = array[array.Count - 1]; | 103 | object previousTerm = array[array.Count - 1]; |
104 | object result = new ListPair(previousTerm, Atom.NIL); | 104 | object result = new ListPair(previousTerm, Atom.NIL); |
105 | for (int i = array.Count - 2; i >= 0; --i) | 105 | for (int i = array.Count - 2; i >= 0; --i) |
106 | { | 106 | { |
107 | object term = array[i]; | 107 | object term = array[i]; |
108 | if (YP.termEqual(term, previousTerm)) | 108 | if (YP.termEqual(term, previousTerm)) |
109 | continue; | 109 | continue; |
110 | result = new ListPair(term, result); | 110 | result = new ListPair(term, result); |
111 | previousTerm = term; | 111 | previousTerm = term; |
112 | } | 112 | } |
113 | return result; | 113 | return result; |
114 | } | 114 | } |
115 | 115 | ||
116 | public static object make(object element1) | 116 | public static object make(object element1) |
117 | { | 117 | { |
118 | return new ListPair(element1, Atom.NIL); | 118 | return new ListPair(element1, Atom.NIL); |
119 | } | 119 | } |
120 | 120 | ||
121 | public static object make(object element1, object element2) | 121 | public static object make(object element1, object element2) |
122 | { | 122 | { |
123 | return new ListPair(element1, new ListPair(element2, Atom.NIL)); | 123 | return new ListPair(element1, new ListPair(element2, Atom.NIL)); |
124 | } | 124 | } |
125 | 125 | ||
126 | public static object make(object element1, object element2, object element3) | 126 | public static object make(object element1, object element2, object element3) |
127 | { | 127 | { |
128 | return new ListPair(element1, | 128 | return new ListPair(element1, |
129 | new ListPair(element2, new ListPair(element3, Atom.NIL))); | 129 | new ListPair(element2, new ListPair(element3, Atom.NIL))); |
130 | } | 130 | } |
131 | 131 | ||
132 | /// <summary> | 132 | /// <summary> |
133 | /// Return an array of the elements in list or null if it is not | 133 | /// Return an array of the elements in list or null if it is not |
134 | /// a proper list. If list is Atom.NIL, return an array of zero elements. | 134 | /// a proper list. If list is Atom.NIL, return an array of zero elements. |
135 | /// This does not call YP.getValue on each element. | 135 | /// This does not call YP.getValue on each element. |
136 | /// </summary> | 136 | /// </summary> |
137 | /// <param name="list"></param> | 137 | /// <param name="list"></param> |
138 | /// <returns></returns> | 138 | /// <returns></returns> |
139 | public static object[] toArray(object list) | 139 | public static object[] toArray(object list) |
140 | { | 140 | { |
141 | list = YP.getValue(list); | 141 | list = YP.getValue(list); |
142 | if (list.Equals(Atom.NIL)) | 142 | if (list.Equals(Atom.NIL)) |
143 | return new object[0]; | 143 | return new object[0]; |
144 | 144 | ||
145 | List<object> result = new List<object>(); | 145 | List<object> result = new List<object>(); |
146 | for (object element = list; | 146 | for (object element = list; |
147 | element is Functor2 && ((Functor2)element)._name == Atom.DOT; | 147 | element is Functor2 && ((Functor2)element)._name == Atom.DOT; |
148 | element = YP.getValue(((Functor2)element)._arg2)) | 148 | element = YP.getValue(((Functor2)element)._arg2)) |
149 | result.Add(((Functor2)element)._arg1); | 149 | result.Add(((Functor2)element)._arg1); |
150 | 150 | ||
151 | if (result.Count <= 0) | 151 | if (result.Count <= 0) |
152 | return null; | 152 | return null; |
153 | return result.ToArray(); | 153 | return result.ToArray(); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs index 7ef5c51..a21a471 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs | |||
@@ -1,4457 +1,4457 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
35 | { | 35 | { |
36 | public class Parser | 36 | public class Parser |
37 | { | 37 | { |
38 | public static IEnumerable<bool> formatError(object Output, object Format, object Arguments) | 38 | public static IEnumerable<bool> formatError(object Output, object Format, object Arguments) |
39 | { | 39 | { |
40 | // Debug: Simple implementation for now. | 40 | // Debug: Simple implementation for now. |
41 | YP.write(Format); | 41 | YP.write(Format); |
42 | YP.write(Arguments); | 42 | YP.write(Arguments); |
43 | YP.nl(); | 43 | YP.nl(); |
44 | yield return false; | 44 | yield return false; |
45 | } | 45 | } |
46 | 46 | ||
47 | // Debug: Hand-modify this central predicate to do tail recursion. | 47 | // Debug: Hand-modify this central predicate to do tail recursion. |
48 | public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3) | 48 | public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3) |
49 | { | 49 | { |
50 | bool repeat = true; | 50 | bool repeat = true; |
51 | while (repeat) | 51 | while (repeat) |
52 | { | 52 | { |
53 | repeat = false; | 53 | repeat = false; |
54 | { | 54 | { |
55 | object C1 = arg1; | 55 | object C1 = arg1; |
56 | object Dict = arg2; | 56 | object Dict = arg2; |
57 | object Tokens = arg3; | 57 | object Tokens = arg3; |
58 | Variable C2 = new Variable(); | 58 | Variable C2 = new Variable(); |
59 | if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL))) | 59 | if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL))) |
60 | { | 60 | { |
61 | if (YP.greaterThanOrEqual(C1, 0)) | 61 | if (YP.greaterThanOrEqual(C1, 0)) |
62 | { | 62 | { |
63 | foreach (bool l4 in YP.get_code(C2)) | 63 | foreach (bool l4 in YP.get_code(C2)) |
64 | { | 64 | { |
65 | #if false | 65 | #if false |
66 | foreach (bool l5 in read_tokens(C2, Dict, Tokens)) | 66 | foreach (bool l5 in read_tokens(C2, Dict, Tokens)) |
67 | { | 67 | { |
68 | yield return false; | 68 | yield return false; |
69 | } | 69 | } |
70 | #endif | 70 | #endif |
71 | arg1 = YP.getValue(C2); | 71 | arg1 = YP.getValue(C2); |
72 | arg2 = YP.getValue(Dict); | 72 | arg2 = YP.getValue(Dict); |
73 | arg3 = YP.getValue(Tokens); | 73 | arg3 = YP.getValue(Tokens); |
74 | repeat = true; | 74 | repeat = true; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | goto cutIf1; | 77 | goto cutIf1; |
78 | } | 78 | } |
79 | if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL))) | 79 | if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL))) |
80 | { | 80 | { |
81 | if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL))) | 81 | if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL))) |
82 | { | 82 | { |
83 | foreach (bool l4 in read_identifier(C1, Dict, Tokens)) | 83 | foreach (bool l4 in read_identifier(C1, Dict, Tokens)) |
84 | { | 84 | { |
85 | yield return false; | 85 | yield return false; |
86 | } | 86 | } |
87 | goto cutIf2; | 87 | goto cutIf2; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL))) | 90 | if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL))) |
91 | { | 91 | { |
92 | if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL))) | 92 | if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL))) |
93 | { | 93 | { |
94 | foreach (bool l4 in read_variable(C1, Dict, Tokens)) | 94 | foreach (bool l4 in read_variable(C1, Dict, Tokens)) |
95 | { | 95 | { |
96 | yield return false; | 96 | yield return false; |
97 | } | 97 | } |
98 | goto cutIf3; | 98 | goto cutIf3; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL))) | 101 | if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL))) |
102 | { | 102 | { |
103 | if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL))) | 103 | if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL))) |
104 | { | 104 | { |
105 | foreach (bool l4 in read_number(C1, Dict, Tokens)) | 105 | foreach (bool l4 in read_number(C1, Dict, Tokens)) |
106 | { | 106 | { |
107 | yield return false; | 107 | yield return false; |
108 | } | 108 | } |
109 | goto cutIf4; | 109 | goto cutIf4; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | if (YP.lessThan(C1, 127)) | 112 | if (YP.lessThan(C1, 127)) |
113 | { | 113 | { |
114 | foreach (bool l3 in read_special(C1, Dict, Tokens)) | 114 | foreach (bool l3 in read_special(C1, Dict, Tokens)) |
115 | { | 115 | { |
116 | yield return false; | 116 | yield return false; |
117 | } | 117 | } |
118 | goto cutIf5; | 118 | goto cutIf5; |
119 | } | 119 | } |
120 | if (YP.lessThanOrEqual(C1, 160)) | 120 | if (YP.lessThanOrEqual(C1, 160)) |
121 | { | 121 | { |
122 | foreach (bool l3 in YP.get_code(C2)) | 122 | foreach (bool l3 in YP.get_code(C2)) |
123 | { | 123 | { |
124 | #if false | 124 | #if false |
125 | foreach (bool l4 in read_tokens(C2, Dict, Tokens)) | 125 | foreach (bool l4 in read_tokens(C2, Dict, Tokens)) |
126 | { | 126 | { |
127 | yield return false; | 127 | yield return false; |
128 | } | 128 | } |
129 | #endif | 129 | #endif |
130 | arg1 = YP.getValue(C2); | 130 | arg1 = YP.getValue(C2); |
131 | arg2 = YP.getValue(Dict); | 131 | arg2 = YP.getValue(Dict); |
132 | arg3 = YP.getValue(Tokens); | 132 | arg3 = YP.getValue(Tokens); |
133 | repeat = true; | 133 | repeat = true; |
134 | } | 134 | } |
135 | goto cutIf6; | 135 | goto cutIf6; |
136 | } | 136 | } |
137 | if (YP.greaterThanOrEqual(C1, 223)) | 137 | if (YP.greaterThanOrEqual(C1, 223)) |
138 | { | 138 | { |
139 | if (YP.notEqual(C1, 247)) | 139 | if (YP.notEqual(C1, 247)) |
140 | { | 140 | { |
141 | foreach (bool l4 in read_identifier(C1, Dict, Tokens)) | 141 | foreach (bool l4 in read_identifier(C1, Dict, Tokens)) |
142 | { | 142 | { |
143 | yield return false; | 143 | yield return false; |
144 | } | 144 | } |
145 | goto cutIf7; | 145 | goto cutIf7; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | if (YP.greaterThanOrEqual(C1, 192)) | 148 | if (YP.greaterThanOrEqual(C1, 192)) |
149 | { | 149 | { |
150 | if (YP.notEqual(C1, 215)) | 150 | if (YP.notEqual(C1, 215)) |
151 | { | 151 | { |
152 | foreach (bool l4 in read_variable(C1, Dict, Tokens)) | 152 | foreach (bool l4 in read_variable(C1, Dict, Tokens)) |
153 | { | 153 | { |
154 | yield return false; | 154 | yield return false; |
155 | } | 155 | } |
156 | goto cutIf8; | 156 | goto cutIf8; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | if (YP.notEqual(C1, 170)) | 159 | if (YP.notEqual(C1, 170)) |
160 | { | 160 | { |
161 | if (YP.notEqual(C1, 186)) | 161 | if (YP.notEqual(C1, 186)) |
162 | { | 162 | { |
163 | foreach (bool l4 in read_symbol(C1, Dict, Tokens)) | 163 | foreach (bool l4 in read_symbol(C1, Dict, Tokens)) |
164 | { | 164 | { |
165 | yield return false; | 165 | yield return false; |
166 | } | 166 | } |
167 | goto cutIf9; | 167 | goto cutIf9; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | foreach (bool l2 in read_identifier(C1, Dict, Tokens)) | 170 | foreach (bool l2 in read_identifier(C1, Dict, Tokens)) |
171 | { | 171 | { |
172 | yield return false; | 172 | yield return false; |
173 | } | 173 | } |
174 | cutIf9: | 174 | cutIf9: |
175 | cutIf8: | 175 | cutIf8: |
176 | cutIf7: | 176 | cutIf7: |
177 | cutIf6: | 177 | cutIf6: |
178 | cutIf5: | 178 | cutIf5: |
179 | cutIf4: | 179 | cutIf4: |
180 | cutIf3: | 180 | cutIf3: |
181 | cutIf2: | 181 | cutIf2: |
182 | cutIf1: | 182 | cutIf1: |
183 | { } | 183 | { } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | // Compiler output follows. | 188 | // Compiler output follows. |
189 | 189 | ||
190 | class YPInnerClass { } | 190 | class YPInnerClass { } |
191 | static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; } | 191 | static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; } |
192 | 192 | ||
193 | public static IEnumerable<bool> parseInput(object TermList) | 193 | public static IEnumerable<bool> parseInput(object TermList) |
194 | { | 194 | { |
195 | { | 195 | { |
196 | Variable TermAndVariables = new Variable(); | 196 | Variable TermAndVariables = new Variable(); |
197 | FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables); | 197 | FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables); |
198 | foreach (bool l2 in parseInputHelper(TermAndVariables)) | 198 | foreach (bool l2 in parseInputHelper(TermAndVariables)) |
199 | { | 199 | { |
200 | findallAnswers1.add(); | 200 | findallAnswers1.add(); |
201 | } | 201 | } |
202 | foreach (bool l2 in findallAnswers1.result(TermList)) | 202 | foreach (bool l2 in findallAnswers1.result(TermList)) |
203 | { | 203 | { |
204 | yield return false; | 204 | yield return false; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | public static IEnumerable<bool> parseInputHelper(object arg1) | 209 | public static IEnumerable<bool> parseInputHelper(object arg1) |
210 | { | 210 | { |
211 | { | 211 | { |
212 | Variable Term = new Variable(); | 212 | Variable Term = new Variable(); |
213 | Variable Variables = new Variable(); | 213 | Variable Variables = new Variable(); |
214 | Variable Answer = new Variable(); | 214 | Variable Answer = new Variable(); |
215 | Variable x4 = new Variable(); | 215 | Variable x4 = new Variable(); |
216 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"f", Term, Variables))) | 216 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"f", Term, Variables))) |
217 | { | 217 | { |
218 | foreach (bool l3 in YP.repeat()) | 218 | foreach (bool l3 in YP.repeat()) |
219 | { | 219 | { |
220 | foreach (bool l4 in portable_read3(Answer, Variables, x4)) | 220 | foreach (bool l4 in portable_read3(Answer, Variables, x4)) |
221 | { | 221 | { |
222 | foreach (bool l5 in remove_pos(Answer, Term)) | 222 | foreach (bool l5 in remove_pos(Answer, Term)) |
223 | { | 223 | { |
224 | if (YP.termEqual(Term, Atom.a(@"end_of_file"))) | 224 | if (YP.termEqual(Term, Atom.a(@"end_of_file"))) |
225 | { | 225 | { |
226 | yield break; | 226 | yield break; |
227 | goto cutIf1; | 227 | goto cutIf1; |
228 | } | 228 | } |
229 | yield return false; | 229 | yield return false; |
230 | cutIf1: | 230 | cutIf1: |
231 | { } | 231 | { } |
232 | } | 232 | } |
233 | } | 233 | } |
234 | } | 234 | } |
235 | } | 235 | } |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | public static IEnumerable<bool> clear_errors() | 239 | public static IEnumerable<bool> clear_errors() |
240 | { | 240 | { |
241 | { | 241 | { |
242 | yield return false; | 242 | yield return false; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | public static IEnumerable<bool> remove_pos(object arg1, object arg2) | 246 | public static IEnumerable<bool> remove_pos(object arg1, object arg2) |
247 | { | 247 | { |
248 | { | 248 | { |
249 | Variable X = new Variable(); | 249 | Variable X = new Variable(); |
250 | foreach (bool l2 in YP.unify(arg1, X)) | 250 | foreach (bool l2 in YP.unify(arg1, X)) |
251 | { | 251 | { |
252 | foreach (bool l3 in YP.unify(arg2, X)) | 252 | foreach (bool l3 in YP.unify(arg2, X)) |
253 | { | 253 | { |
254 | if (YP.var(X)) | 254 | if (YP.var(X)) |
255 | { | 255 | { |
256 | yield return true; | 256 | yield return true; |
257 | yield break; | 257 | yield break; |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | } | 261 | } |
262 | { | 262 | { |
263 | object X = arg2; | 263 | object X = arg2; |
264 | Variable _Pos = new Variable(); | 264 | Variable _Pos = new Variable(); |
265 | Variable _Name = new Variable(); | 265 | Variable _Name = new Variable(); |
266 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"$VAR", _Pos, _Name, X))) | 266 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"$VAR", _Pos, _Name, X))) |
267 | { | 267 | { |
268 | if (YP.var(X)) | 268 | if (YP.var(X)) |
269 | { | 269 | { |
270 | yield return true; | 270 | yield return true; |
271 | yield break; | 271 | yield break; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | } | 274 | } |
275 | { | 275 | { |
276 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 276 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
277 | { | 277 | { |
278 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) | 278 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) |
279 | { | 279 | { |
280 | yield return true; | 280 | yield return true; |
281 | yield break; | 281 | yield break; |
282 | } | 282 | } |
283 | } | 283 | } |
284 | } | 284 | } |
285 | { | 285 | { |
286 | Variable H = new Variable(); | 286 | Variable H = new Variable(); |
287 | Variable T = new Variable(); | 287 | Variable T = new Variable(); |
288 | Variable NH = new Variable(); | 288 | Variable NH = new Variable(); |
289 | Variable NT = new Variable(); | 289 | Variable NT = new Variable(); |
290 | foreach (bool l2 in YP.unify(arg1, new ListPair(H, T))) | 290 | foreach (bool l2 in YP.unify(arg1, new ListPair(H, T))) |
291 | { | 291 | { |
292 | foreach (bool l3 in YP.unify(arg2, new ListPair(NH, NT))) | 292 | foreach (bool l3 in YP.unify(arg2, new ListPair(NH, NT))) |
293 | { | 293 | { |
294 | foreach (bool l4 in remove_pos(H, NH)) | 294 | foreach (bool l4 in remove_pos(H, NH)) |
295 | { | 295 | { |
296 | foreach (bool l5 in remove_pos(T, NT)) | 296 | foreach (bool l5 in remove_pos(T, NT)) |
297 | { | 297 | { |
298 | yield return false; | 298 | yield return false; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | yield break; | 301 | yield break; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | } | 304 | } |
305 | { | 305 | { |
306 | Variable A = new Variable(); | 306 | Variable A = new Variable(); |
307 | Variable B = new Variable(); | 307 | Variable B = new Variable(); |
308 | Variable NA = new Variable(); | 308 | Variable NA = new Variable(); |
309 | Variable NB = new Variable(); | 309 | Variable NB = new Variable(); |
310 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) | 310 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) |
311 | { | 311 | { |
312 | foreach (bool l3 in YP.unify(arg2, new Functor2(@",", NA, NB))) | 312 | foreach (bool l3 in YP.unify(arg2, new Functor2(@",", NA, NB))) |
313 | { | 313 | { |
314 | foreach (bool l4 in remove_pos(A, NA)) | 314 | foreach (bool l4 in remove_pos(A, NA)) |
315 | { | 315 | { |
316 | foreach (bool l5 in remove_pos(B, NB)) | 316 | foreach (bool l5 in remove_pos(B, NB)) |
317 | { | 317 | { |
318 | yield return false; | 318 | yield return false; |
319 | } | 319 | } |
320 | } | 320 | } |
321 | yield break; | 321 | yield break; |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } | 324 | } |
325 | { | 325 | { |
326 | Variable Atom_1 = new Variable(); | 326 | Variable Atom_1 = new Variable(); |
327 | Variable _F = new Variable(); | 327 | Variable _F = new Variable(); |
328 | foreach (bool l2 in YP.unify(arg1, Atom_1)) | 328 | foreach (bool l2 in YP.unify(arg1, Atom_1)) |
329 | { | 329 | { |
330 | foreach (bool l3 in YP.unify(arg2, Atom_1)) | 330 | foreach (bool l3 in YP.unify(arg2, Atom_1)) |
331 | { | 331 | { |
332 | foreach (bool l4 in YP.functor(Atom_1, _F, 0)) | 332 | foreach (bool l4 in YP.functor(Atom_1, _F, 0)) |
333 | { | 333 | { |
334 | yield return false; | 334 | yield return false; |
335 | } | 335 | } |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | { | 339 | { |
340 | object Term = arg1; | 340 | object Term = arg1; |
341 | object NewTerm = arg2; | 341 | object NewTerm = arg2; |
342 | Variable Func = new Variable(); | 342 | Variable Func = new Variable(); |
343 | Variable _Pos = new Variable(); | 343 | Variable _Pos = new Variable(); |
344 | Variable Args = new Variable(); | 344 | Variable Args = new Variable(); |
345 | Variable NArgs = new Variable(); | 345 | Variable NArgs = new Variable(); |
346 | if (YP.nonvar(Term)) | 346 | if (YP.nonvar(Term)) |
347 | { | 347 | { |
348 | foreach (bool l3 in YP.univ(Term, new ListPair(Func, new ListPair(_Pos, Args)))) | 348 | foreach (bool l3 in YP.univ(Term, new ListPair(Func, new ListPair(_Pos, Args)))) |
349 | { | 349 | { |
350 | foreach (bool l4 in remove_pos(Args, NArgs)) | 350 | foreach (bool l4 in remove_pos(Args, NArgs)) |
351 | { | 351 | { |
352 | foreach (bool l5 in YP.univ(NewTerm, new ListPair(Func, NArgs))) | 352 | foreach (bool l5 in YP.univ(NewTerm, new ListPair(Func, NArgs))) |
353 | { | 353 | { |
354 | yield return false; | 354 | yield return false; |
355 | } | 355 | } |
356 | } | 356 | } |
357 | } | 357 | } |
358 | } | 358 | } |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | public static IEnumerable<bool> portable_read_position(object Term, object PosTerm, object Syntax) | 362 | public static IEnumerable<bool> portable_read_position(object Term, object PosTerm, object Syntax) |
363 | { | 363 | { |
364 | { | 364 | { |
365 | foreach (bool l2 in portable_read(PosTerm, Syntax)) | 365 | foreach (bool l2 in portable_read(PosTerm, Syntax)) |
366 | { | 366 | { |
367 | foreach (bool l3 in remove_pos(PosTerm, Term)) | 367 | foreach (bool l3 in remove_pos(PosTerm, Term)) |
368 | { | 368 | { |
369 | yield return false; | 369 | yield return false; |
370 | } | 370 | } |
371 | } | 371 | } |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | public static IEnumerable<bool> portable_read(object Answer, object Syntax) | 375 | public static IEnumerable<bool> portable_read(object Answer, object Syntax) |
376 | { | 376 | { |
377 | { | 377 | { |
378 | Variable Tokens = new Variable(); | 378 | Variable Tokens = new Variable(); |
379 | Variable ParseTokens = new Variable(); | 379 | Variable ParseTokens = new Variable(); |
380 | foreach (bool l2 in read_tokens1(Tokens)) | 380 | foreach (bool l2 in read_tokens1(Tokens)) |
381 | { | 381 | { |
382 | foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax)) | 382 | foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax)) |
383 | { | 383 | { |
384 | foreach (bool l4 in parse2(ParseTokens, Answer)) | 384 | foreach (bool l4 in parse2(ParseTokens, Answer)) |
385 | { | 385 | { |
386 | yield return false; | 386 | yield return false; |
387 | } | 387 | } |
388 | } | 388 | } |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | public static IEnumerable<bool> portable_read3(object Answer, object Variables, object Syntax) | 393 | public static IEnumerable<bool> portable_read3(object Answer, object Variables, object Syntax) |
394 | { | 394 | { |
395 | { | 395 | { |
396 | Variable Tokens = new Variable(); | 396 | Variable Tokens = new Variable(); |
397 | Variable ParseTokens = new Variable(); | 397 | Variable ParseTokens = new Variable(); |
398 | foreach (bool l2 in read_tokens2(Tokens, Variables)) | 398 | foreach (bool l2 in read_tokens2(Tokens, Variables)) |
399 | { | 399 | { |
400 | foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax)) | 400 | foreach (bool l3 in remove_comments(Tokens, ParseTokens, Syntax)) |
401 | { | 401 | { |
402 | foreach (bool l4 in parse2(ParseTokens, Answer)) | 402 | foreach (bool l4 in parse2(ParseTokens, Answer)) |
403 | { | 403 | { |
404 | yield return false; | 404 | yield return false; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | } | 407 | } |
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
411 | public static IEnumerable<bool> remove_comments(object arg1, object arg2, object arg3) | 411 | public static IEnumerable<bool> remove_comments(object arg1, object arg2, object arg3) |
412 | { | 412 | { |
413 | { | 413 | { |
414 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 414 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
415 | { | 415 | { |
416 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) | 416 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) |
417 | { | 417 | { |
418 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) | 418 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) |
419 | { | 419 | { |
420 | yield return false; | 420 | yield return false; |
421 | } | 421 | } |
422 | } | 422 | } |
423 | } | 423 | } |
424 | } | 424 | } |
425 | { | 425 | { |
426 | object Ys = arg2; | 426 | object Ys = arg2; |
427 | Variable S = new Variable(); | 427 | Variable S = new Variable(); |
428 | Variable E = new Variable(); | 428 | Variable E = new Variable(); |
429 | Variable Xs = new Variable(); | 429 | Variable Xs = new Variable(); |
430 | Variable Zs = new Variable(); | 430 | Variable Zs = new Variable(); |
431 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"comment", S, E), Xs))) | 431 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"comment", S, E), Xs))) |
432 | { | 432 | { |
433 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", S, E), Zs))) | 433 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", S, E), Zs))) |
434 | { | 434 | { |
435 | foreach (bool l4 in remove_comments(Xs, Ys, Zs)) | 435 | foreach (bool l4 in remove_comments(Xs, Ys, Zs)) |
436 | { | 436 | { |
437 | yield return false; | 437 | yield return false; |
438 | } | 438 | } |
439 | yield break; | 439 | yield break; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | } | 442 | } |
443 | { | 443 | { |
444 | Variable Pos = new Variable(); | 444 | Variable Pos = new Variable(); |
445 | Variable Xs = new Variable(); | 445 | Variable Xs = new Variable(); |
446 | Variable Ys = new Variable(); | 446 | Variable Ys = new Variable(); |
447 | Variable Pos2 = new Variable(); | 447 | Variable Pos2 = new Variable(); |
448 | Variable Zs = new Variable(); | 448 | Variable Zs = new Variable(); |
449 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Xs))) | 449 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Xs))) |
450 | { | 450 | { |
451 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"["), Ys))) | 451 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"["), Ys))) |
452 | { | 452 | { |
453 | foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) | 453 | foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) |
454 | { | 454 | { |
455 | foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) | 455 | foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) |
456 | { | 456 | { |
457 | foreach (bool l6 in remove_comments(Xs, Ys, Zs)) | 457 | foreach (bool l6 in remove_comments(Xs, Ys, Zs)) |
458 | { | 458 | { |
459 | yield return false; | 459 | yield return false; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | yield break; | 462 | yield break; |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | } | 466 | } |
467 | { | 467 | { |
468 | Variable Pos = new Variable(); | 468 | Variable Pos = new Variable(); |
469 | Variable Xs = new Variable(); | 469 | Variable Xs = new Variable(); |
470 | Variable Ys = new Variable(); | 470 | Variable Ys = new Variable(); |
471 | Variable Pos2 = new Variable(); | 471 | Variable Pos2 = new Variable(); |
472 | Variable Zs = new Variable(); | 472 | Variable Zs = new Variable(); |
473 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Xs))) | 473 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Xs))) |
474 | { | 474 | { |
475 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), Ys))) | 475 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), Ys))) |
476 | { | 476 | { |
477 | foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) | 477 | foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) |
478 | { | 478 | { |
479 | foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) | 479 | foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) |
480 | { | 480 | { |
481 | foreach (bool l6 in remove_comments(Xs, Ys, Zs)) | 481 | foreach (bool l6 in remove_comments(Xs, Ys, Zs)) |
482 | { | 482 | { |
483 | yield return false; | 483 | yield return false; |
484 | } | 484 | } |
485 | } | 485 | } |
486 | yield break; | 486 | yield break; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | { | 491 | { |
492 | object Zs = arg3; | 492 | object Zs = arg3; |
493 | Variable Token = new Variable(); | 493 | Variable Token = new Variable(); |
494 | Variable Xs = new Variable(); | 494 | Variable Xs = new Variable(); |
495 | Variable Ys = new Variable(); | 495 | Variable Ys = new Variable(); |
496 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Xs))) | 496 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Xs))) |
497 | { | 497 | { |
498 | foreach (bool l3 in YP.unify(arg2, new ListPair(Token, Ys))) | 498 | foreach (bool l3 in YP.unify(arg2, new ListPair(Token, Ys))) |
499 | { | 499 | { |
500 | foreach (bool l4 in remove_comments(Xs, Ys, Zs)) | 500 | foreach (bool l4 in remove_comments(Xs, Ys, Zs)) |
501 | { | 501 | { |
502 | yield return false; | 502 | yield return false; |
503 | } | 503 | } |
504 | } | 504 | } |
505 | } | 505 | } |
506 | } | 506 | } |
507 | } | 507 | } |
508 | 508 | ||
509 | public static IEnumerable<bool> expect(object Token, object arg2, object arg3) | 509 | public static IEnumerable<bool> expect(object Token, object arg2, object arg3) |
510 | { | 510 | { |
511 | { | 511 | { |
512 | object Rest = arg3; | 512 | object Rest = arg3; |
513 | foreach (bool l2 in YP.unify(arg2, new ListPair(Token, Rest))) | 513 | foreach (bool l2 in YP.unify(arg2, new ListPair(Token, Rest))) |
514 | { | 514 | { |
515 | yield return true; | 515 | yield return true; |
516 | yield break; | 516 | yield break; |
517 | } | 517 | } |
518 | } | 518 | } |
519 | { | 519 | { |
520 | object S0 = arg2; | 520 | object S0 = arg2; |
521 | object x3 = arg3; | 521 | object x3 = arg3; |
522 | foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"or"), new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), Atom.NIL)))), S0)) | 522 | foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"or"), new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), Atom.NIL)))), S0)) |
523 | { | 523 | { |
524 | yield return false; | 524 | yield return false; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | } | 527 | } |
528 | 528 | ||
529 | public static IEnumerable<bool> parse2(object Tokens, object Answer) | 529 | public static IEnumerable<bool> parse2(object Tokens, object Answer) |
530 | { | 530 | { |
531 | { | 531 | { |
532 | Variable Term = new Variable(); | 532 | Variable Term = new Variable(); |
533 | Variable LeftOver = new Variable(); | 533 | Variable LeftOver = new Variable(); |
534 | foreach (bool l2 in clear_errors()) | 534 | foreach (bool l2 in clear_errors()) |
535 | { | 535 | { |
536 | foreach (bool l3 in parse(Tokens, 1200, Term, LeftOver)) | 536 | foreach (bool l3 in parse(Tokens, 1200, Term, LeftOver)) |
537 | { | 537 | { |
538 | foreach (bool l4 in all_read(LeftOver)) | 538 | foreach (bool l4 in all_read(LeftOver)) |
539 | { | 539 | { |
540 | foreach (bool l5 in YP.unify(Answer, Term)) | 540 | foreach (bool l5 in YP.unify(Answer, Term)) |
541 | { | 541 | { |
542 | yield return false; | 542 | yield return false; |
543 | } | 543 | } |
544 | yield break; | 544 | yield break; |
545 | } | 545 | } |
546 | } | 546 | } |
547 | foreach (bool l3 in syntax_error(Tokens)) | 547 | foreach (bool l3 in syntax_error(Tokens)) |
548 | { | 548 | { |
549 | yield return false; | 549 | yield return false; |
550 | } | 550 | } |
551 | } | 551 | } |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | public static IEnumerable<bool> all_read(object arg1) | 555 | public static IEnumerable<bool> all_read(object arg1) |
556 | { | 556 | { |
557 | { | 557 | { |
558 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 558 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
559 | { | 559 | { |
560 | yield return false; | 560 | yield return false; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | { | 563 | { |
564 | Variable Token = new Variable(); | 564 | Variable Token = new Variable(); |
565 | Variable S = new Variable(); | 565 | Variable S = new Variable(); |
566 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S))) | 566 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S))) |
567 | { | 567 | { |
568 | foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"after"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(Token, S))) | 568 | foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"operator"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"after"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(Token, S))) |
569 | { | 569 | { |
570 | yield return false; | 570 | yield return false; |
571 | } | 571 | } |
572 | } | 572 | } |
573 | } | 573 | } |
574 | } | 574 | } |
575 | 575 | ||
576 | public static IEnumerable<bool> parse(object arg1, object arg2, object arg3, object arg4) | 576 | public static IEnumerable<bool> parse(object arg1, object arg2, object arg3, object arg4) |
577 | { | 577 | { |
578 | { | 578 | { |
579 | object x1 = arg2; | 579 | object x1 = arg2; |
580 | object x2 = arg3; | 580 | object x2 = arg3; |
581 | object x3 = arg4; | 581 | object x3 = arg4; |
582 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 582 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
583 | { | 583 | { |
584 | foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"expression"), new ListPair(Atom.a(@"expected"), Atom.NIL)), Atom.NIL)) | 584 | foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"expression"), new ListPair(Atom.a(@"expected"), Atom.NIL)), Atom.NIL)) |
585 | { | 585 | { |
586 | yield return false; | 586 | yield return false; |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } | 589 | } |
590 | { | 590 | { |
591 | object Precedence = arg2; | 591 | object Precedence = arg2; |
592 | object Term = arg3; | 592 | object Term = arg3; |
593 | object LeftOver = arg4; | 593 | object LeftOver = arg4; |
594 | Variable Token = new Variable(); | 594 | Variable Token = new Variable(); |
595 | Variable RestTokens = new Variable(); | 595 | Variable RestTokens = new Variable(); |
596 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, RestTokens))) | 596 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, RestTokens))) |
597 | { | 597 | { |
598 | foreach (bool l3 in parse5(Token, RestTokens, Precedence, Term, LeftOver)) | 598 | foreach (bool l3 in parse5(Token, RestTokens, Precedence, Term, LeftOver)) |
599 | { | 599 | { |
600 | yield return false; | 600 | yield return false; |
601 | } | 601 | } |
602 | } | 602 | } |
603 | } | 603 | } |
604 | } | 604 | } |
605 | 605 | ||
606 | public static IEnumerable<bool> parse5(object arg1, object arg2, object arg3, object arg4, object arg5) | 606 | public static IEnumerable<bool> parse5(object arg1, object arg2, object arg3, object arg4, object arg5) |
607 | { | 607 | { |
608 | { | 608 | { |
609 | object S0 = arg2; | 609 | object S0 = arg2; |
610 | object x2 = arg3; | 610 | object x2 = arg3; |
611 | object x3 = arg4; | 611 | object x3 = arg4; |
612 | object x4 = arg5; | 612 | object x4 = arg5; |
613 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) | 613 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) |
614 | { | 614 | { |
615 | foreach (bool l3 in cannot_start(Atom.a(@"}"), S0)) | 615 | foreach (bool l3 in cannot_start(Atom.a(@"}"), S0)) |
616 | { | 616 | { |
617 | yield return false; | 617 | yield return false; |
618 | } | 618 | } |
619 | } | 619 | } |
620 | } | 620 | } |
621 | { | 621 | { |
622 | object S0 = arg2; | 622 | object S0 = arg2; |
623 | object x2 = arg3; | 623 | object x2 = arg3; |
624 | object x3 = arg4; | 624 | object x3 = arg4; |
625 | object x4 = arg5; | 625 | object x4 = arg5; |
626 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) | 626 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) |
627 | { | 627 | { |
628 | foreach (bool l3 in cannot_start(Atom.a(@"]"), S0)) | 628 | foreach (bool l3 in cannot_start(Atom.a(@"]"), S0)) |
629 | { | 629 | { |
630 | yield return false; | 630 | yield return false; |
631 | } | 631 | } |
632 | } | 632 | } |
633 | } | 633 | } |
634 | { | 634 | { |
635 | object S0 = arg2; | 635 | object S0 = arg2; |
636 | object x2 = arg3; | 636 | object x2 = arg3; |
637 | object x3 = arg4; | 637 | object x3 = arg4; |
638 | object x4 = arg5; | 638 | object x4 = arg5; |
639 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) | 639 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) |
640 | { | 640 | { |
641 | foreach (bool l3 in cannot_start(Atom.a(@")"), S0)) | 641 | foreach (bool l3 in cannot_start(Atom.a(@")"), S0)) |
642 | { | 642 | { |
643 | yield return false; | 643 | yield return false; |
644 | } | 644 | } |
645 | } | 645 | } |
646 | } | 646 | } |
647 | { | 647 | { |
648 | object S0 = arg2; | 648 | object S0 = arg2; |
649 | object x2 = arg3; | 649 | object x2 = arg3; |
650 | object x3 = arg4; | 650 | object x3 = arg4; |
651 | object x4 = arg5; | 651 | object x4 = arg5; |
652 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) | 652 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) |
653 | { | 653 | { |
654 | foreach (bool l3 in cannot_start(Atom.a(@","), S0)) | 654 | foreach (bool l3 in cannot_start(Atom.a(@","), S0)) |
655 | { | 655 | { |
656 | yield return false; | 656 | yield return false; |
657 | } | 657 | } |
658 | } | 658 | } |
659 | } | 659 | } |
660 | { | 660 | { |
661 | object S0 = arg2; | 661 | object S0 = arg2; |
662 | object x2 = arg3; | 662 | object x2 = arg3; |
663 | object x3 = arg4; | 663 | object x3 = arg4; |
664 | object x4 = arg5; | 664 | object x4 = arg5; |
665 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) | 665 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) |
666 | { | 666 | { |
667 | foreach (bool l3 in cannot_start(Atom.a(@"|"), S0)) | 667 | foreach (bool l3 in cannot_start(Atom.a(@"|"), S0)) |
668 | { | 668 | { |
669 | yield return false; | 669 | yield return false; |
670 | } | 670 | } |
671 | } | 671 | } |
672 | } | 672 | } |
673 | { | 673 | { |
674 | object S0 = arg2; | 674 | object S0 = arg2; |
675 | object Precedence = arg3; | 675 | object Precedence = arg3; |
676 | object Answer = arg4; | 676 | object Answer = arg4; |
677 | object S = arg5; | 677 | object S = arg5; |
678 | Variable Chars = new Variable(); | 678 | Variable Chars = new Variable(); |
679 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", Chars))) | 679 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", Chars))) |
680 | { | 680 | { |
681 | foreach (bool l3 in exprtl0(S0, Chars, Precedence, Answer, S)) | 681 | foreach (bool l3 in exprtl0(S0, Chars, Precedence, Answer, S)) |
682 | { | 682 | { |
683 | yield return false; | 683 | yield return false; |
684 | } | 684 | } |
685 | } | 685 | } |
686 | } | 686 | } |
687 | { | 687 | { |
688 | object S0 = arg2; | 688 | object S0 = arg2; |
689 | object Precedence = arg3; | 689 | object Precedence = arg3; |
690 | object Answer = arg4; | 690 | object Answer = arg4; |
691 | object S = arg5; | 691 | object S = arg5; |
692 | Variable Number = new Variable(); | 692 | Variable Number = new Variable(); |
693 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", Number))) | 693 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", Number))) |
694 | { | 694 | { |
695 | foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S)) | 695 | foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S)) |
696 | { | 696 | { |
697 | yield return false; | 697 | yield return false; |
698 | } | 698 | } |
699 | } | 699 | } |
700 | } | 700 | } |
701 | { | 701 | { |
702 | object Precedence = arg3; | 702 | object Precedence = arg3; |
703 | object Answer = arg4; | 703 | object Answer = arg4; |
704 | object S = arg5; | 704 | object S = arg5; |
705 | Variable S1 = new Variable(); | 705 | Variable S1 = new Variable(); |
706 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) | 706 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) |
707 | { | 707 | { |
708 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), S1))) | 708 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), S1))) |
709 | { | 709 | { |
710 | foreach (bool l4 in read_atom(new Functor2(@"/", Atom.NIL, 0), S1, Precedence, Answer, S)) | 710 | foreach (bool l4 in read_atom(new Functor2(@"/", Atom.NIL, 0), S1, Precedence, Answer, S)) |
711 | { | 711 | { |
712 | yield return false; | 712 | yield return false; |
713 | } | 713 | } |
714 | yield break; | 714 | yield break; |
715 | } | 715 | } |
716 | } | 716 | } |
717 | } | 717 | } |
718 | { | 718 | { |
719 | object S1 = arg2; | 719 | object S1 = arg2; |
720 | object Precedence = arg3; | 720 | object Precedence = arg3; |
721 | object Answer = arg4; | 721 | object Answer = arg4; |
722 | object S = arg5; | 722 | object S = arg5; |
723 | Variable Arg1 = new Variable(); | 723 | Variable Arg1 = new Variable(); |
724 | Variable S2 = new Variable(); | 724 | Variable S2 = new Variable(); |
725 | Variable RestArgs = new Variable(); | 725 | Variable RestArgs = new Variable(); |
726 | Variable S3 = new Variable(); | 726 | Variable S3 = new Variable(); |
727 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) | 727 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) |
728 | { | 728 | { |
729 | foreach (bool l3 in parse(S1, 999, Arg1, S2)) | 729 | foreach (bool l3 in parse(S1, 999, Arg1, S2)) |
730 | { | 730 | { |
731 | foreach (bool l4 in read_list(S2, RestArgs, S3)) | 731 | foreach (bool l4 in read_list(S2, RestArgs, S3)) |
732 | { | 732 | { |
733 | foreach (bool l5 in exprtl0(S3, new ListPair(Arg1, RestArgs), Precedence, Answer, S)) | 733 | foreach (bool l5 in exprtl0(S3, new ListPair(Arg1, RestArgs), Precedence, Answer, S)) |
734 | { | 734 | { |
735 | yield return false; | 735 | yield return false; |
736 | } | 736 | } |
737 | yield break; | 737 | yield break; |
738 | } | 738 | } |
739 | } | 739 | } |
740 | } | 740 | } |
741 | } | 741 | } |
742 | { | 742 | { |
743 | object S1 = arg2; | 743 | object S1 = arg2; |
744 | object Precedence = arg3; | 744 | object Precedence = arg3; |
745 | object Answer = arg4; | 745 | object Answer = arg4; |
746 | object S = arg5; | 746 | object S = arg5; |
747 | Variable Term = new Variable(); | 747 | Variable Term = new Variable(); |
748 | Variable S2 = new Variable(); | 748 | Variable S2 = new Variable(); |
749 | Variable S3 = new Variable(); | 749 | Variable S3 = new Variable(); |
750 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) | 750 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) |
751 | { | 751 | { |
752 | foreach (bool l3 in parse(S1, 1200, Term, S2)) | 752 | foreach (bool l3 in parse(S1, 1200, Term, S2)) |
753 | { | 753 | { |
754 | foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) | 754 | foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) |
755 | { | 755 | { |
756 | foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) | 756 | foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) |
757 | { | 757 | { |
758 | yield return false; | 758 | yield return false; |
759 | } | 759 | } |
760 | yield break; | 760 | yield break; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | } | 763 | } |
764 | } | 764 | } |
765 | { | 765 | { |
766 | object S1 = arg2; | 766 | object S1 = arg2; |
767 | object Precedence = arg3; | 767 | object Precedence = arg3; |
768 | object Answer = arg4; | 768 | object Answer = arg4; |
769 | object S = arg5; | 769 | object S = arg5; |
770 | Variable Term = new Variable(); | 770 | Variable Term = new Variable(); |
771 | Variable S2 = new Variable(); | 771 | Variable S2 = new Variable(); |
772 | Variable S3 = new Variable(); | 772 | Variable S3 = new Variable(); |
773 | foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) | 773 | foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) |
774 | { | 774 | { |
775 | foreach (bool l3 in parse(S1, 1200, Term, S2)) | 775 | foreach (bool l3 in parse(S1, 1200, Term, S2)) |
776 | { | 776 | { |
777 | foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) | 777 | foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) |
778 | { | 778 | { |
779 | foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) | 779 | foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) |
780 | { | 780 | { |
781 | yield return false; | 781 | yield return false; |
782 | } | 782 | } |
783 | yield break; | 783 | yield break; |
784 | } | 784 | } |
785 | } | 785 | } |
786 | } | 786 | } |
787 | } | 787 | } |
788 | { | 788 | { |
789 | object Precedence = arg3; | 789 | object Precedence = arg3; |
790 | object Answer = arg4; | 790 | object Answer = arg4; |
791 | object S = arg5; | 791 | object S = arg5; |
792 | Variable _Pos = new Variable(); | 792 | Variable _Pos = new Variable(); |
793 | Variable S1 = new Variable(); | 793 | Variable S1 = new Variable(); |
794 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), _Pos))) | 794 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), _Pos))) |
795 | { | 795 | { |
796 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"}"), S1))) | 796 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"}"), S1))) |
797 | { | 797 | { |
798 | foreach (bool l4 in read_atom(Atom.a(@"{}"), S1, Precedence, Answer, S)) | 798 | foreach (bool l4 in read_atom(Atom.a(@"{}"), S1, Precedence, Answer, S)) |
799 | { | 799 | { |
800 | yield return false; | 800 | yield return false; |
801 | } | 801 | } |
802 | yield break; | 802 | yield break; |
803 | } | 803 | } |
804 | } | 804 | } |
805 | } | 805 | } |
806 | { | 806 | { |
807 | object S1 = arg2; | 807 | object S1 = arg2; |
808 | object Precedence = arg3; | 808 | object Precedence = arg3; |
809 | object Answer = arg4; | 809 | object Answer = arg4; |
810 | object S = arg5; | 810 | object S = arg5; |
811 | Variable Pos = new Variable(); | 811 | Variable Pos = new Variable(); |
812 | Variable Term = new Variable(); | 812 | Variable Term = new Variable(); |
813 | Variable S2 = new Variable(); | 813 | Variable S2 = new Variable(); |
814 | Variable S3 = new Variable(); | 814 | Variable S3 = new Variable(); |
815 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), Pos))) | 815 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), Pos))) |
816 | { | 816 | { |
817 | foreach (bool l3 in parse(S1, 1200, Term, S2)) | 817 | foreach (bool l3 in parse(S1, 1200, Term, S2)) |
818 | { | 818 | { |
819 | foreach (bool l4 in expect(Atom.a(@"}"), S2, S3)) | 819 | foreach (bool l4 in expect(Atom.a(@"}"), S2, S3)) |
820 | { | 820 | { |
821 | foreach (bool l5 in exprtl0(S3, new Functor2(@"{}", Pos, Term), Precedence, Answer, S)) | 821 | foreach (bool l5 in exprtl0(S3, new Functor2(@"{}", Pos, Term), Precedence, Answer, S)) |
822 | { | 822 | { |
823 | yield return false; | 823 | yield return false; |
824 | } | 824 | } |
825 | yield break; | 825 | yield break; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | } | 828 | } |
829 | } | 829 | } |
830 | { | 830 | { |
831 | object Precedence = arg3; | 831 | object Precedence = arg3; |
832 | object Answer = arg4; | 832 | object Answer = arg4; |
833 | object S = arg5; | 833 | object S = arg5; |
834 | Variable Variable_1 = new Variable(); | 834 | Variable Variable_1 = new Variable(); |
835 | Variable Name = new Variable(); | 835 | Variable Name = new Variable(); |
836 | Variable Pos = new Variable(); | 836 | Variable Pos = new Variable(); |
837 | Variable S1 = new Variable(); | 837 | Variable S1 = new Variable(); |
838 | Variable Arg1 = new Variable(); | 838 | Variable Arg1 = new Variable(); |
839 | Variable S2 = new Variable(); | 839 | Variable S2 = new Variable(); |
840 | Variable RestArgs = new Variable(); | 840 | Variable RestArgs = new Variable(); |
841 | Variable S3 = new Variable(); | 841 | Variable S3 = new Variable(); |
842 | Variable Term = new Variable(); | 842 | Variable Term = new Variable(); |
843 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) | 843 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) |
844 | { | 844 | { |
845 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) | 845 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) |
846 | { | 846 | { |
847 | foreach (bool l4 in parse(S1, 999, Arg1, S2)) | 847 | foreach (bool l4 in parse(S1, 999, Arg1, S2)) |
848 | { | 848 | { |
849 | foreach (bool l5 in read_args(S2, RestArgs, S3)) | 849 | foreach (bool l5 in read_args(S2, RestArgs, S3)) |
850 | { | 850 | { |
851 | foreach (bool l6 in YP.univ(Term, new ListPair(Atom.a(@"call"), new ListPair(new Functor3(@"$VAR", Pos, Name, Variable_1), new ListPair(Arg1, RestArgs))))) | 851 | foreach (bool l6 in YP.univ(Term, new ListPair(Atom.a(@"call"), new ListPair(new Functor3(@"$VAR", Pos, Name, Variable_1), new ListPair(Arg1, RestArgs))))) |
852 | { | 852 | { |
853 | foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S)) | 853 | foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S)) |
854 | { | 854 | { |
855 | yield return false; | 855 | yield return false; |
856 | } | 856 | } |
857 | } | 857 | } |
858 | yield break; | 858 | yield break; |
859 | } | 859 | } |
860 | } | 860 | } |
861 | yield break; | 861 | yield break; |
862 | } | 862 | } |
863 | } | 863 | } |
864 | } | 864 | } |
865 | { | 865 | { |
866 | object S0 = arg2; | 866 | object S0 = arg2; |
867 | object Precedence = arg3; | 867 | object Precedence = arg3; |
868 | object Answer = arg4; | 868 | object Answer = arg4; |
869 | object S = arg5; | 869 | object S = arg5; |
870 | Variable Variable_1 = new Variable(); | 870 | Variable Variable_1 = new Variable(); |
871 | Variable Name = new Variable(); | 871 | Variable Name = new Variable(); |
872 | Variable Pos = new Variable(); | 872 | Variable Pos = new Variable(); |
873 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) | 873 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) |
874 | { | 874 | { |
875 | foreach (bool l3 in exprtl0(S0, new Functor3(@"$VAR", Pos, Name, Variable_1), Precedence, Answer, S)) | 875 | foreach (bool l3 in exprtl0(S0, new Functor3(@"$VAR", Pos, Name, Variable_1), Precedence, Answer, S)) |
876 | { | 876 | { |
877 | yield return false; | 877 | yield return false; |
878 | } | 878 | } |
879 | } | 879 | } |
880 | } | 880 | } |
881 | { | 881 | { |
882 | object S0 = arg2; | 882 | object S0 = arg2; |
883 | object Precedence = arg3; | 883 | object Precedence = arg3; |
884 | object Answer = arg4; | 884 | object Answer = arg4; |
885 | object S = arg5; | 885 | object S = arg5; |
886 | Variable Atom_1 = new Variable(); | 886 | Variable Atom_1 = new Variable(); |
887 | Variable P = new Variable(); | 887 | Variable P = new Variable(); |
888 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", Atom_1, P))) | 888 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", Atom_1, P))) |
889 | { | 889 | { |
890 | foreach (bool l3 in read_atom(new Functor2(@"/", Atom_1, P), S0, Precedence, Answer, S)) | 890 | foreach (bool l3 in read_atom(new Functor2(@"/", Atom_1, P), S0, Precedence, Answer, S)) |
891 | { | 891 | { |
892 | yield return false; | 892 | yield return false; |
893 | } | 893 | } |
894 | } | 894 | } |
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | public static IEnumerable<bool> read_atom(object arg1, object arg2, object Precedence, object Answer, object S) | 898 | public static IEnumerable<bool> read_atom(object arg1, object arg2, object Precedence, object Answer, object S) |
899 | { | 899 | { |
900 | { | 900 | { |
901 | Variable _Pos = new Variable(); | 901 | Variable _Pos = new Variable(); |
902 | Variable Number = new Variable(); | 902 | Variable Number = new Variable(); |
903 | Variable S1 = new Variable(); | 903 | Variable S1 = new Variable(); |
904 | Variable Negative = new Variable(); | 904 | Variable Negative = new Variable(); |
905 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"-"), _Pos))) | 905 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"-"), _Pos))) |
906 | { | 906 | { |
907 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"number", Number), S1))) | 907 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"number", Number), S1))) |
908 | { | 908 | { |
909 | foreach (bool l4 in YP.unify(Negative, YP.negate(Number))) | 909 | foreach (bool l4 in YP.unify(Negative, YP.negate(Number))) |
910 | { | 910 | { |
911 | foreach (bool l5 in exprtl0(S1, Negative, Precedence, Answer, S)) | 911 | foreach (bool l5 in exprtl0(S1, Negative, Precedence, Answer, S)) |
912 | { | 912 | { |
913 | yield return false; | 913 | yield return false; |
914 | } | 914 | } |
915 | } | 915 | } |
916 | yield break; | 916 | yield break; |
917 | } | 917 | } |
918 | } | 918 | } |
919 | } | 919 | } |
920 | { | 920 | { |
921 | Variable Functor_1 = new Variable(); | 921 | Variable Functor_1 = new Variable(); |
922 | Variable Pos = new Variable(); | 922 | Variable Pos = new Variable(); |
923 | Variable S1 = new Variable(); | 923 | Variable S1 = new Variable(); |
924 | Variable Arg1 = new Variable(); | 924 | Variable Arg1 = new Variable(); |
925 | Variable S2 = new Variable(); | 925 | Variable S2 = new Variable(); |
926 | Variable RestArgs = new Variable(); | 926 | Variable RestArgs = new Variable(); |
927 | Variable S3 = new Variable(); | 927 | Variable S3 = new Variable(); |
928 | Variable Term = new Variable(); | 928 | Variable Term = new Variable(); |
929 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Functor_1, Pos))) | 929 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Functor_1, Pos))) |
930 | { | 930 | { |
931 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) | 931 | foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) |
932 | { | 932 | { |
933 | foreach (bool l4 in parse(S1, 999, Arg1, S2)) | 933 | foreach (bool l4 in parse(S1, 999, Arg1, S2)) |
934 | { | 934 | { |
935 | foreach (bool l5 in read_args(S2, RestArgs, S3)) | 935 | foreach (bool l5 in read_args(S2, RestArgs, S3)) |
936 | { | 936 | { |
937 | foreach (bool l6 in YP.univ(Term, new ListPair(Functor_1, new ListPair(Pos, new ListPair(Arg1, RestArgs))))) | 937 | foreach (bool l6 in YP.univ(Term, new ListPair(Functor_1, new ListPair(Pos, new ListPair(Arg1, RestArgs))))) |
938 | { | 938 | { |
939 | foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S)) | 939 | foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S)) |
940 | { | 940 | { |
941 | yield return false; | 941 | yield return false; |
942 | } | 942 | } |
943 | } | 943 | } |
944 | yield break; | 944 | yield break; |
945 | } | 945 | } |
946 | } | 946 | } |
947 | yield break; | 947 | yield break; |
948 | } | 948 | } |
949 | } | 949 | } |
950 | } | 950 | } |
951 | { | 951 | { |
952 | object S0 = arg2; | 952 | object S0 = arg2; |
953 | Variable Op = new Variable(); | 953 | Variable Op = new Variable(); |
954 | Variable Pos = new Variable(); | 954 | Variable Pos = new Variable(); |
955 | Variable Oprec = new Variable(); | 955 | Variable Oprec = new Variable(); |
956 | Variable Aprec = new Variable(); | 956 | Variable Aprec = new Variable(); |
957 | Variable Flag = new Variable(); | 957 | Variable Flag = new Variable(); |
958 | Variable Term = new Variable(); | 958 | Variable Term = new Variable(); |
959 | Variable Arg = new Variable(); | 959 | Variable Arg = new Variable(); |
960 | Variable S1 = new Variable(); | 960 | Variable S1 = new Variable(); |
961 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Op, Pos))) | 961 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Op, Pos))) |
962 | { | 962 | { |
963 | foreach (bool l3 in prefixop(Op, Oprec, Aprec)) | 963 | foreach (bool l3 in prefixop(Op, Oprec, Aprec)) |
964 | { | 964 | { |
965 | foreach (bool l4 in possible_right_operand(S0, Flag)) | 965 | foreach (bool l4 in possible_right_operand(S0, Flag)) |
966 | { | 966 | { |
967 | if (YP.lessThan(Flag, 0)) | 967 | if (YP.lessThan(Flag, 0)) |
968 | { | 968 | { |
969 | foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, Atom.NIL)))) | 969 | foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, Atom.NIL)))) |
970 | { | 970 | { |
971 | foreach (bool l7 in exprtl0(S0, Term, Precedence, Answer, S)) | 971 | foreach (bool l7 in exprtl0(S0, Term, Precedence, Answer, S)) |
972 | { | 972 | { |
973 | yield return false; | 973 | yield return false; |
974 | } | 974 | } |
975 | } | 975 | } |
976 | goto cutIf1; | 976 | goto cutIf1; |
977 | } | 977 | } |
978 | if (YP.greaterThan(Oprec, Precedence)) | 978 | if (YP.greaterThan(Oprec, Precedence)) |
979 | { | 979 | { |
980 | foreach (bool l6 in syntax_error(new ListPair(Atom.a(@"prefix"), new ListPair(Atom.a(@"operator"), new ListPair(Op, new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"context"), new ListPair(Atom.a(@"with"), new ListPair(Atom.a(@"precedence"), new ListPair(Precedence, Atom.NIL)))))))), S0)) | 980 | foreach (bool l6 in syntax_error(new ListPair(Atom.a(@"prefix"), new ListPair(Atom.a(@"operator"), new ListPair(Op, new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"context"), new ListPair(Atom.a(@"with"), new ListPair(Atom.a(@"precedence"), new ListPair(Precedence, Atom.NIL)))))))), S0)) |
981 | { | 981 | { |
982 | yield return false; | 982 | yield return false; |
983 | } | 983 | } |
984 | goto cutIf2; | 984 | goto cutIf2; |
985 | } | 985 | } |
986 | if (YP.greaterThan(Flag, 0)) | 986 | if (YP.greaterThan(Flag, 0)) |
987 | { | 987 | { |
988 | foreach (bool l6 in parse(S0, Aprec, Arg, S1)) | 988 | foreach (bool l6 in parse(S0, Aprec, Arg, S1)) |
989 | { | 989 | { |
990 | foreach (bool l7 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) | 990 | foreach (bool l7 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) |
991 | { | 991 | { |
992 | foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) | 992 | foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) |
993 | { | 993 | { |
994 | yield return false; | 994 | yield return false; |
995 | } | 995 | } |
996 | } | 996 | } |
997 | yield break; | 997 | yield break; |
998 | } | 998 | } |
999 | goto cutIf3; | 999 | goto cutIf3; |
1000 | } | 1000 | } |
1001 | foreach (bool l5 in peepop(S0, S1)) | 1001 | foreach (bool l5 in peepop(S0, S1)) |
1002 | { | 1002 | { |
1003 | foreach (bool l6 in prefix_is_atom(S1, Oprec)) | 1003 | foreach (bool l6 in prefix_is_atom(S1, Oprec)) |
1004 | { | 1004 | { |
1005 | foreach (bool l7 in exprtl(S1, Oprec, new Functor2(@"/", Op, Pos), Precedence, Answer, S)) | 1005 | foreach (bool l7 in exprtl(S1, Oprec, new Functor2(@"/", Op, Pos), Precedence, Answer, S)) |
1006 | { | 1006 | { |
1007 | yield return false; | 1007 | yield return false; |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | } | 1010 | } |
1011 | foreach (bool l5 in parse(S0, Aprec, Arg, S1)) | 1011 | foreach (bool l5 in parse(S0, Aprec, Arg, S1)) |
1012 | { | 1012 | { |
1013 | foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) | 1013 | foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) |
1014 | { | 1014 | { |
1015 | foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) | 1015 | foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) |
1016 | { | 1016 | { |
1017 | yield return false; | 1017 | yield return false; |
1018 | } | 1018 | } |
1019 | } | 1019 | } |
1020 | yield break; | 1020 | yield break; |
1021 | } | 1021 | } |
1022 | cutIf3: | 1022 | cutIf3: |
1023 | cutIf2: | 1023 | cutIf2: |
1024 | cutIf1: | 1024 | cutIf1: |
1025 | { } | 1025 | { } |
1026 | } | 1026 | } |
1027 | yield break; | 1027 | yield break; |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | { | 1031 | { |
1032 | object S0 = arg2; | 1032 | object S0 = arg2; |
1033 | Variable Atom_1 = new Variable(); | 1033 | Variable Atom_1 = new Variable(); |
1034 | Variable Pos = new Variable(); | 1034 | Variable Pos = new Variable(); |
1035 | Variable Term = new Variable(); | 1035 | Variable Term = new Variable(); |
1036 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom_1, Pos))) | 1036 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom_1, Pos))) |
1037 | { | 1037 | { |
1038 | foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL)))) | 1038 | foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL)))) |
1039 | { | 1039 | { |
1040 | foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S)) | 1040 | foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S)) |
1041 | { | 1041 | { |
1042 | yield return false; | 1042 | yield return false; |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | } | 1045 | } |
1046 | } | 1046 | } |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | public static IEnumerable<bool> cannot_start(object Token, object S0) | 1049 | public static IEnumerable<bool> cannot_start(object Token, object S0) |
1050 | { | 1050 | { |
1051 | { | 1051 | { |
1052 | foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"cannot"), new ListPair(Atom.a(@"start"), new ListPair(Atom.a(@"an"), new ListPair(Atom.a(@"expression"), Atom.NIL))))), S0)) | 1052 | foreach (bool l2 in syntax_error(new ListPair(Token, new ListPair(Atom.a(@"cannot"), new ListPair(Atom.a(@"start"), new ListPair(Atom.a(@"an"), new ListPair(Atom.a(@"expression"), Atom.NIL))))), S0)) |
1053 | { | 1053 | { |
1054 | yield return false; | 1054 | yield return false; |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | public static IEnumerable<bool> read_args(object arg1, object arg2, object arg3) | 1059 | public static IEnumerable<bool> read_args(object arg1, object arg2, object arg3) |
1060 | { | 1060 | { |
1061 | { | 1061 | { |
1062 | object S = arg3; | 1062 | object S = arg3; |
1063 | Variable S1 = new Variable(); | 1063 | Variable S1 = new Variable(); |
1064 | Variable Term = new Variable(); | 1064 | Variable Term = new Variable(); |
1065 | Variable Rest = new Variable(); | 1065 | Variable Rest = new Variable(); |
1066 | Variable S2 = new Variable(); | 1066 | Variable S2 = new Variable(); |
1067 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@","), S1))) | 1067 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@","), S1))) |
1068 | { | 1068 | { |
1069 | foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest))) | 1069 | foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest))) |
1070 | { | 1070 | { |
1071 | foreach (bool l4 in parse(S1, 999, Term, S2)) | 1071 | foreach (bool l4 in parse(S1, 999, Term, S2)) |
1072 | { | 1072 | { |
1073 | foreach (bool l5 in read_args(S2, Rest, S)) | 1073 | foreach (bool l5 in read_args(S2, Rest, S)) |
1074 | { | 1074 | { |
1075 | yield return false; | 1075 | yield return false; |
1076 | } | 1076 | } |
1077 | yield break; | 1077 | yield break; |
1078 | } | 1078 | } |
1079 | yield break; | 1079 | yield break; |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | { | 1083 | { |
1084 | object S = arg3; | 1084 | object S = arg3; |
1085 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@")"), S))) | 1085 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@")"), S))) |
1086 | { | 1086 | { |
1087 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) | 1087 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) |
1088 | { | 1088 | { |
1089 | yield return true; | 1089 | yield return true; |
1090 | yield break; | 1090 | yield break; |
1091 | } | 1091 | } |
1092 | } | 1092 | } |
1093 | } | 1093 | } |
1094 | { | 1094 | { |
1095 | object S = arg1; | 1095 | object S = arg1; |
1096 | object x2 = arg2; | 1096 | object x2 = arg2; |
1097 | object x3 = arg3; | 1097 | object x3 = arg3; |
1098 | foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", or )"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"arguments"), Atom.NIL)))), S)) | 1098 | foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", or )"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"arguments"), Atom.NIL)))), S)) |
1099 | { | 1099 | { |
1100 | yield return false; | 1100 | yield return false; |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | public static IEnumerable<bool> read_list(object arg1, object arg2, object arg3) | 1105 | public static IEnumerable<bool> read_list(object arg1, object arg2, object arg3) |
1106 | { | 1106 | { |
1107 | { | 1107 | { |
1108 | object x1 = arg2; | 1108 | object x1 = arg2; |
1109 | object x2 = arg3; | 1109 | object x2 = arg3; |
1110 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1110 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1111 | { | 1111 | { |
1112 | foreach (bool l3 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), Atom.NIL)) | 1112 | foreach (bool l3 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), Atom.NIL)) |
1113 | { | 1113 | { |
1114 | yield return false; | 1114 | yield return false; |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | { | 1118 | { |
1119 | object Rest = arg2; | 1119 | object Rest = arg2; |
1120 | object S = arg3; | 1120 | object S = arg3; |
1121 | Variable Token = new Variable(); | 1121 | Variable Token = new Variable(); |
1122 | Variable S1 = new Variable(); | 1122 | Variable S1 = new Variable(); |
1123 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1))) | 1123 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1))) |
1124 | { | 1124 | { |
1125 | foreach (bool l3 in read_list4(Token, S1, Rest, S)) | 1125 | foreach (bool l3 in read_list4(Token, S1, Rest, S)) |
1126 | { | 1126 | { |
1127 | yield return false; | 1127 | yield return false; |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | public static IEnumerable<bool> read_list4(object arg1, object arg2, object arg3, object arg4) | 1133 | public static IEnumerable<bool> read_list4(object arg1, object arg2, object arg3, object arg4) |
1134 | { | 1134 | { |
1135 | { | 1135 | { |
1136 | object S1 = arg2; | 1136 | object S1 = arg2; |
1137 | object S = arg4; | 1137 | object S = arg4; |
1138 | Variable Term = new Variable(); | 1138 | Variable Term = new Variable(); |
1139 | Variable Rest = new Variable(); | 1139 | Variable Rest = new Variable(); |
1140 | Variable S2 = new Variable(); | 1140 | Variable S2 = new Variable(); |
1141 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) | 1141 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) |
1142 | { | 1142 | { |
1143 | foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest))) | 1143 | foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest))) |
1144 | { | 1144 | { |
1145 | foreach (bool l4 in parse(S1, 999, Term, S2)) | 1145 | foreach (bool l4 in parse(S1, 999, Term, S2)) |
1146 | { | 1146 | { |
1147 | foreach (bool l5 in read_list(S2, Rest, S)) | 1147 | foreach (bool l5 in read_list(S2, Rest, S)) |
1148 | { | 1148 | { |
1149 | yield return false; | 1149 | yield return false; |
1150 | } | 1150 | } |
1151 | yield break; | 1151 | yield break; |
1152 | } | 1152 | } |
1153 | yield break; | 1153 | yield break; |
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | } | 1156 | } |
1157 | { | 1157 | { |
1158 | object S1 = arg2; | 1158 | object S1 = arg2; |
1159 | object Rest = arg3; | 1159 | object Rest = arg3; |
1160 | object S = arg4; | 1160 | object S = arg4; |
1161 | Variable S2 = new Variable(); | 1161 | Variable S2 = new Variable(); |
1162 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) | 1162 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) |
1163 | { | 1163 | { |
1164 | foreach (bool l3 in parse(S1, 999, Rest, S2)) | 1164 | foreach (bool l3 in parse(S1, 999, Rest, S2)) |
1165 | { | 1165 | { |
1166 | foreach (bool l4 in expect(Atom.a(@"]"), S2, S)) | 1166 | foreach (bool l4 in expect(Atom.a(@"]"), S2, S)) |
1167 | { | 1167 | { |
1168 | yield return false; | 1168 | yield return false; |
1169 | } | 1169 | } |
1170 | yield break; | 1170 | yield break; |
1171 | } | 1171 | } |
1172 | yield break; | 1172 | yield break; |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | { | 1175 | { |
1176 | Variable S1 = new Variable(); | 1176 | Variable S1 = new Variable(); |
1177 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) | 1177 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) |
1178 | { | 1178 | { |
1179 | foreach (bool l3 in YP.unify(arg2, S1)) | 1179 | foreach (bool l3 in YP.unify(arg2, S1)) |
1180 | { | 1180 | { |
1181 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) | 1181 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) |
1182 | { | 1182 | { |
1183 | foreach (bool l5 in YP.unify(arg4, S1)) | 1183 | foreach (bool l5 in YP.unify(arg4, S1)) |
1184 | { | 1184 | { |
1185 | yield return true; | 1185 | yield return true; |
1186 | yield break; | 1186 | yield break; |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | } | 1190 | } |
1191 | } | 1191 | } |
1192 | { | 1192 | { |
1193 | object Token = arg1; | 1193 | object Token = arg1; |
1194 | object S1 = arg2; | 1194 | object S1 = arg2; |
1195 | object x3 = arg3; | 1195 | object x3 = arg3; |
1196 | object x4 = arg4; | 1196 | object x4 = arg4; |
1197 | foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), new ListPair(Token, S1))) | 1197 | foreach (bool l2 in syntax_error(new ListPair(Atom.a(@", | or ]"), new ListPair(Atom.a(@"expected"), new ListPair(Atom.a(@"in"), new ListPair(Atom.a(@"list"), Atom.NIL)))), new ListPair(Token, S1))) |
1198 | { | 1198 | { |
1199 | yield return false; | 1199 | yield return false; |
1200 | } | 1200 | } |
1201 | } | 1201 | } |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | public static IEnumerable<bool> possible_right_operand(object arg1, object arg2) | 1204 | public static IEnumerable<bool> possible_right_operand(object arg1, object arg2) |
1205 | { | 1205 | { |
1206 | { | 1206 | { |
1207 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1207 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1208 | { | 1208 | { |
1209 | foreach (bool l3 in YP.unify(arg2, -1)) | 1209 | foreach (bool l3 in YP.unify(arg2, -1)) |
1210 | { | 1210 | { |
1211 | yield return false; | 1211 | yield return false; |
1212 | } | 1212 | } |
1213 | } | 1213 | } |
1214 | } | 1214 | } |
1215 | { | 1215 | { |
1216 | object Flag = arg2; | 1216 | object Flag = arg2; |
1217 | Variable H = new Variable(); | 1217 | Variable H = new Variable(); |
1218 | Variable T = new Variable(); | 1218 | Variable T = new Variable(); |
1219 | foreach (bool l2 in YP.unify(arg1, new ListPair(H, T))) | 1219 | foreach (bool l2 in YP.unify(arg1, new ListPair(H, T))) |
1220 | { | 1220 | { |
1221 | foreach (bool l3 in possible_right_operand3(H, Flag, T)) | 1221 | foreach (bool l3 in possible_right_operand3(H, Flag, T)) |
1222 | { | 1222 | { |
1223 | yield return false; | 1223 | yield return false; |
1224 | } | 1224 | } |
1225 | } | 1225 | } |
1226 | } | 1226 | } |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | public static IEnumerable<bool> possible_right_operand3(object arg1, object arg2, object arg3) | 1229 | public static IEnumerable<bool> possible_right_operand3(object arg1, object arg2, object arg3) |
1230 | { | 1230 | { |
1231 | { | 1231 | { |
1232 | object x4 = arg3; | 1232 | object x4 = arg3; |
1233 | Variable x1 = new Variable(); | 1233 | Variable x1 = new Variable(); |
1234 | Variable x2 = new Variable(); | 1234 | Variable x2 = new Variable(); |
1235 | Variable x3 = new Variable(); | 1235 | Variable x3 = new Variable(); |
1236 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", x1, x2, x3))) | 1236 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", x1, x2, x3))) |
1237 | { | 1237 | { |
1238 | foreach (bool l3 in YP.unify(arg2, 1)) | 1238 | foreach (bool l3 in YP.unify(arg2, 1)) |
1239 | { | 1239 | { |
1240 | yield return false; | 1240 | yield return false; |
1241 | } | 1241 | } |
1242 | } | 1242 | } |
1243 | } | 1243 | } |
1244 | { | 1244 | { |
1245 | object x2 = arg3; | 1245 | object x2 = arg3; |
1246 | Variable x1 = new Variable(); | 1246 | Variable x1 = new Variable(); |
1247 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", x1))) | 1247 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", x1))) |
1248 | { | 1248 | { |
1249 | foreach (bool l3 in YP.unify(arg2, 1)) | 1249 | foreach (bool l3 in YP.unify(arg2, 1)) |
1250 | { | 1250 | { |
1251 | yield return false; | 1251 | yield return false; |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | { | 1255 | { |
1256 | object x2 = arg3; | 1256 | object x2 = arg3; |
1257 | Variable x1 = new Variable(); | 1257 | Variable x1 = new Variable(); |
1258 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", x1))) | 1258 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", x1))) |
1259 | { | 1259 | { |
1260 | foreach (bool l3 in YP.unify(arg2, 1)) | 1260 | foreach (bool l3 in YP.unify(arg2, 1)) |
1261 | { | 1261 | { |
1262 | yield return false; | 1262 | yield return false; |
1263 | } | 1263 | } |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | { | 1266 | { |
1267 | object x1 = arg3; | 1267 | object x1 = arg3; |
1268 | foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) | 1268 | foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) |
1269 | { | 1269 | { |
1270 | foreach (bool l3 in YP.unify(arg2, 1)) | 1270 | foreach (bool l3 in YP.unify(arg2, 1)) |
1271 | { | 1271 | { |
1272 | yield return false; | 1272 | yield return false; |
1273 | } | 1273 | } |
1274 | } | 1274 | } |
1275 | } | 1275 | } |
1276 | { | 1276 | { |
1277 | object x1 = arg3; | 1277 | object x1 = arg3; |
1278 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) | 1278 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) |
1279 | { | 1279 | { |
1280 | foreach (bool l3 in YP.unify(arg2, 0)) | 1280 | foreach (bool l3 in YP.unify(arg2, 0)) |
1281 | { | 1281 | { |
1282 | yield return false; | 1282 | yield return false; |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | } | 1285 | } |
1286 | { | 1286 | { |
1287 | object x1 = arg3; | 1287 | object x1 = arg3; |
1288 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) | 1288 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) |
1289 | { | 1289 | { |
1290 | foreach (bool l3 in YP.unify(arg2, -1)) | 1290 | foreach (bool l3 in YP.unify(arg2, -1)) |
1291 | { | 1291 | { |
1292 | yield return false; | 1292 | yield return false; |
1293 | } | 1293 | } |
1294 | } | 1294 | } |
1295 | } | 1295 | } |
1296 | { | 1296 | { |
1297 | Variable x1 = new Variable(); | 1297 | Variable x1 = new Variable(); |
1298 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) | 1298 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) |
1299 | { | 1299 | { |
1300 | foreach (bool l3 in YP.unify(arg2, 0)) | 1300 | foreach (bool l3 in YP.unify(arg2, 0)) |
1301 | { | 1301 | { |
1302 | foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"]"), x1))) | 1302 | foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"]"), x1))) |
1303 | { | 1303 | { |
1304 | yield return true; | 1304 | yield return true; |
1305 | yield break; | 1305 | yield break; |
1306 | } | 1306 | } |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | } | 1309 | } |
1310 | { | 1310 | { |
1311 | object x1 = arg3; | 1311 | object x1 = arg3; |
1312 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) | 1312 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) |
1313 | { | 1313 | { |
1314 | foreach (bool l3 in YP.unify(arg2, 1)) | 1314 | foreach (bool l3 in YP.unify(arg2, 1)) |
1315 | { | 1315 | { |
1316 | yield return false; | 1316 | yield return false; |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | } | 1319 | } |
1320 | { | 1320 | { |
1321 | object x1 = arg3; | 1321 | object x1 = arg3; |
1322 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) | 1322 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) |
1323 | { | 1323 | { |
1324 | foreach (bool l3 in YP.unify(arg2, -1)) | 1324 | foreach (bool l3 in YP.unify(arg2, -1)) |
1325 | { | 1325 | { |
1326 | yield return false; | 1326 | yield return false; |
1327 | } | 1327 | } |
1328 | } | 1328 | } |
1329 | } | 1329 | } |
1330 | { | 1330 | { |
1331 | Variable x1 = new Variable(); | 1331 | Variable x1 = new Variable(); |
1332 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) | 1332 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) |
1333 | { | 1333 | { |
1334 | foreach (bool l3 in YP.unify(arg2, 0)) | 1334 | foreach (bool l3 in YP.unify(arg2, 0)) |
1335 | { | 1335 | { |
1336 | foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"}"), x1))) | 1336 | foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"}"), x1))) |
1337 | { | 1337 | { |
1338 | yield return true; | 1338 | yield return true; |
1339 | yield break; | 1339 | yield break; |
1340 | } | 1340 | } |
1341 | } | 1341 | } |
1342 | } | 1342 | } |
1343 | } | 1343 | } |
1344 | { | 1344 | { |
1345 | object x1 = arg3; | 1345 | object x1 = arg3; |
1346 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) | 1346 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) |
1347 | { | 1347 | { |
1348 | foreach (bool l3 in YP.unify(arg2, 1)) | 1348 | foreach (bool l3 in YP.unify(arg2, 1)) |
1349 | { | 1349 | { |
1350 | yield return false; | 1350 | yield return false; |
1351 | } | 1351 | } |
1352 | } | 1352 | } |
1353 | } | 1353 | } |
1354 | { | 1354 | { |
1355 | object x1 = arg3; | 1355 | object x1 = arg3; |
1356 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) | 1356 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) |
1357 | { | 1357 | { |
1358 | foreach (bool l3 in YP.unify(arg2, -1)) | 1358 | foreach (bool l3 in YP.unify(arg2, -1)) |
1359 | { | 1359 | { |
1360 | yield return false; | 1360 | yield return false; |
1361 | } | 1361 | } |
1362 | } | 1362 | } |
1363 | } | 1363 | } |
1364 | { | 1364 | { |
1365 | object x1 = arg3; | 1365 | object x1 = arg3; |
1366 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) | 1366 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) |
1367 | { | 1367 | { |
1368 | foreach (bool l3 in YP.unify(arg2, -1)) | 1368 | foreach (bool l3 in YP.unify(arg2, -1)) |
1369 | { | 1369 | { |
1370 | yield return false; | 1370 | yield return false; |
1371 | } | 1371 | } |
1372 | } | 1372 | } |
1373 | } | 1373 | } |
1374 | { | 1374 | { |
1375 | object x1 = arg3; | 1375 | object x1 = arg3; |
1376 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) | 1376 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) |
1377 | { | 1377 | { |
1378 | foreach (bool l3 in YP.unify(arg2, -1)) | 1378 | foreach (bool l3 in YP.unify(arg2, -1)) |
1379 | { | 1379 | { |
1380 | yield return false; | 1380 | yield return false; |
1381 | } | 1381 | } |
1382 | } | 1382 | } |
1383 | } | 1383 | } |
1384 | { | 1384 | { |
1385 | object x3 = arg3; | 1385 | object x3 = arg3; |
1386 | Variable x1 = new Variable(); | 1386 | Variable x1 = new Variable(); |
1387 | Variable x2 = new Variable(); | 1387 | Variable x2 = new Variable(); |
1388 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", x1, x2))) | 1388 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", x1, x2))) |
1389 | { | 1389 | { |
1390 | foreach (bool l3 in YP.unify(arg2, 0)) | 1390 | foreach (bool l3 in YP.unify(arg2, 0)) |
1391 | { | 1391 | { |
1392 | yield return false; | 1392 | yield return false; |
1393 | } | 1393 | } |
1394 | } | 1394 | } |
1395 | } | 1395 | } |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | public static IEnumerable<bool> peepop(object arg1, object arg2) | 1398 | public static IEnumerable<bool> peepop(object arg1, object arg2) |
1399 | { | 1399 | { |
1400 | { | 1400 | { |
1401 | Variable F = new Variable(); | 1401 | Variable F = new Variable(); |
1402 | Variable Pos = new Variable(); | 1402 | Variable Pos = new Variable(); |
1403 | Variable S1 = new Variable(); | 1403 | Variable S1 = new Variable(); |
1404 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) | 1404 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) |
1405 | { | 1405 | { |
1406 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) | 1406 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) |
1407 | { | 1407 | { |
1408 | yield return true; | 1408 | yield return true; |
1409 | yield break; | 1409 | yield break; |
1410 | } | 1410 | } |
1411 | } | 1411 | } |
1412 | } | 1412 | } |
1413 | { | 1413 | { |
1414 | Variable F = new Variable(); | 1414 | Variable F = new Variable(); |
1415 | Variable Pos = new Variable(); | 1415 | Variable Pos = new Variable(); |
1416 | Variable S1 = new Variable(); | 1416 | Variable S1 = new Variable(); |
1417 | Variable L = new Variable(); | 1417 | Variable L = new Variable(); |
1418 | Variable P = new Variable(); | 1418 | Variable P = new Variable(); |
1419 | Variable R = new Variable(); | 1419 | Variable R = new Variable(); |
1420 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) | 1420 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) |
1421 | { | 1421 | { |
1422 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, P, R }), S1))) | 1422 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, P, R }), S1))) |
1423 | { | 1423 | { |
1424 | foreach (bool l4 in infixop(F, L, P, R)) | 1424 | foreach (bool l4 in infixop(F, L, P, R)) |
1425 | { | 1425 | { |
1426 | yield return false; | 1426 | yield return false; |
1427 | } | 1427 | } |
1428 | } | 1428 | } |
1429 | } | 1429 | } |
1430 | } | 1430 | } |
1431 | { | 1431 | { |
1432 | Variable F = new Variable(); | 1432 | Variable F = new Variable(); |
1433 | Variable Pos = new Variable(); | 1433 | Variable Pos = new Variable(); |
1434 | Variable S1 = new Variable(); | 1434 | Variable S1 = new Variable(); |
1435 | Variable L = new Variable(); | 1435 | Variable L = new Variable(); |
1436 | Variable P = new Variable(); | 1436 | Variable P = new Variable(); |
1437 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) | 1437 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) |
1438 | { | 1438 | { |
1439 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, P), S1))) | 1439 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, P), S1))) |
1440 | { | 1440 | { |
1441 | foreach (bool l4 in postfixop(F, L, P)) | 1441 | foreach (bool l4 in postfixop(F, L, P)) |
1442 | { | 1442 | { |
1443 | yield return false; | 1443 | yield return false; |
1444 | } | 1444 | } |
1445 | } | 1445 | } |
1446 | } | 1446 | } |
1447 | } | 1447 | } |
1448 | { | 1448 | { |
1449 | Variable S0 = new Variable(); | 1449 | Variable S0 = new Variable(); |
1450 | foreach (bool l2 in YP.unify(arg1, S0)) | 1450 | foreach (bool l2 in YP.unify(arg1, S0)) |
1451 | { | 1451 | { |
1452 | foreach (bool l3 in YP.unify(arg2, S0)) | 1452 | foreach (bool l3 in YP.unify(arg2, S0)) |
1453 | { | 1453 | { |
1454 | yield return false; | 1454 | yield return false; |
1455 | } | 1455 | } |
1456 | } | 1456 | } |
1457 | } | 1457 | } |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | public static IEnumerable<bool> prefix_is_atom(object arg1, object arg2) | 1460 | public static IEnumerable<bool> prefix_is_atom(object arg1, object arg2) |
1461 | { | 1461 | { |
1462 | { | 1462 | { |
1463 | object Precedence = arg2; | 1463 | object Precedence = arg2; |
1464 | Variable Token = new Variable(); | 1464 | Variable Token = new Variable(); |
1465 | Variable x2 = new Variable(); | 1465 | Variable x2 = new Variable(); |
1466 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, x2))) | 1466 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, x2))) |
1467 | { | 1467 | { |
1468 | foreach (bool l3 in prefix_is_atom(Token, Precedence)) | 1468 | foreach (bool l3 in prefix_is_atom(Token, Precedence)) |
1469 | { | 1469 | { |
1470 | yield return false; | 1470 | yield return false; |
1471 | } | 1471 | } |
1472 | } | 1472 | } |
1473 | } | 1473 | } |
1474 | { | 1474 | { |
1475 | object P = arg2; | 1475 | object P = arg2; |
1476 | Variable x1 = new Variable(); | 1476 | Variable x1 = new Variable(); |
1477 | Variable L = new Variable(); | 1477 | Variable L = new Variable(); |
1478 | Variable x3 = new Variable(); | 1478 | Variable x3 = new Variable(); |
1479 | Variable x4 = new Variable(); | 1479 | Variable x4 = new Variable(); |
1480 | foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { x1, L, x3, x4 }))) | 1480 | foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { x1, L, x3, x4 }))) |
1481 | { | 1481 | { |
1482 | if (YP.greaterThanOrEqual(L, P)) | 1482 | if (YP.greaterThanOrEqual(L, P)) |
1483 | { | 1483 | { |
1484 | yield return false; | 1484 | yield return false; |
1485 | } | 1485 | } |
1486 | } | 1486 | } |
1487 | } | 1487 | } |
1488 | { | 1488 | { |
1489 | object P = arg2; | 1489 | object P = arg2; |
1490 | Variable x1 = new Variable(); | 1490 | Variable x1 = new Variable(); |
1491 | Variable L = new Variable(); | 1491 | Variable L = new Variable(); |
1492 | Variable x3 = new Variable(); | 1492 | Variable x3 = new Variable(); |
1493 | foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), x1, L, x3))) | 1493 | foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), x1, L, x3))) |
1494 | { | 1494 | { |
1495 | if (YP.greaterThanOrEqual(L, P)) | 1495 | if (YP.greaterThanOrEqual(L, P)) |
1496 | { | 1496 | { |
1497 | yield return false; | 1497 | yield return false; |
1498 | } | 1498 | } |
1499 | } | 1499 | } |
1500 | } | 1500 | } |
1501 | { | 1501 | { |
1502 | object x1 = arg2; | 1502 | object x1 = arg2; |
1503 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) | 1503 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) |
1504 | { | 1504 | { |
1505 | yield return false; | 1505 | yield return false; |
1506 | } | 1506 | } |
1507 | } | 1507 | } |
1508 | { | 1508 | { |
1509 | object x1 = arg2; | 1509 | object x1 = arg2; |
1510 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) | 1510 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) |
1511 | { | 1511 | { |
1512 | yield return false; | 1512 | yield return false; |
1513 | } | 1513 | } |
1514 | } | 1514 | } |
1515 | { | 1515 | { |
1516 | object x1 = arg2; | 1516 | object x1 = arg2; |
1517 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) | 1517 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) |
1518 | { | 1518 | { |
1519 | yield return false; | 1519 | yield return false; |
1520 | } | 1520 | } |
1521 | } | 1521 | } |
1522 | { | 1522 | { |
1523 | object P = arg2; | 1523 | object P = arg2; |
1524 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) | 1524 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) |
1525 | { | 1525 | { |
1526 | if (YP.greaterThanOrEqual(1100, P)) | 1526 | if (YP.greaterThanOrEqual(1100, P)) |
1527 | { | 1527 | { |
1528 | yield return false; | 1528 | yield return false; |
1529 | } | 1529 | } |
1530 | } | 1530 | } |
1531 | } | 1531 | } |
1532 | { | 1532 | { |
1533 | object P = arg2; | 1533 | object P = arg2; |
1534 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) | 1534 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) |
1535 | { | 1535 | { |
1536 | if (YP.greaterThanOrEqual(1000, P)) | 1536 | if (YP.greaterThanOrEqual(1000, P)) |
1537 | { | 1537 | { |
1538 | yield return false; | 1538 | yield return false; |
1539 | } | 1539 | } |
1540 | } | 1540 | } |
1541 | } | 1541 | } |
1542 | { | 1542 | { |
1543 | object x1 = arg2; | 1543 | object x1 = arg2; |
1544 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1544 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1545 | { | 1545 | { |
1546 | yield return false; | 1546 | yield return false; |
1547 | } | 1547 | } |
1548 | } | 1548 | } |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | public static IEnumerable<bool> exprtl0(object arg1, object arg2, object arg3, object arg4, object arg5) | 1551 | public static IEnumerable<bool> exprtl0(object arg1, object arg2, object arg3, object arg4, object arg5) |
1552 | { | 1552 | { |
1553 | { | 1553 | { |
1554 | object x2 = arg3; | 1554 | object x2 = arg3; |
1555 | Variable Term = new Variable(); | 1555 | Variable Term = new Variable(); |
1556 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1556 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1557 | { | 1557 | { |
1558 | foreach (bool l3 in YP.unify(arg2, Term)) | 1558 | foreach (bool l3 in YP.unify(arg2, Term)) |
1559 | { | 1559 | { |
1560 | foreach (bool l4 in YP.unify(arg4, Term)) | 1560 | foreach (bool l4 in YP.unify(arg4, Term)) |
1561 | { | 1561 | { |
1562 | foreach (bool l5 in YP.unify(arg5, Atom.NIL)) | 1562 | foreach (bool l5 in YP.unify(arg5, Atom.NIL)) |
1563 | { | 1563 | { |
1564 | yield return false; | 1564 | yield return false; |
1565 | } | 1565 | } |
1566 | } | 1566 | } |
1567 | } | 1567 | } |
1568 | } | 1568 | } |
1569 | } | 1569 | } |
1570 | { | 1570 | { |
1571 | object Term = arg2; | 1571 | object Term = arg2; |
1572 | object Precedence = arg3; | 1572 | object Precedence = arg3; |
1573 | object Answer = arg4; | 1573 | object Answer = arg4; |
1574 | object S = arg5; | 1574 | object S = arg5; |
1575 | Variable Token = new Variable(); | 1575 | Variable Token = new Variable(); |
1576 | Variable S1 = new Variable(); | 1576 | Variable S1 = new Variable(); |
1577 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1))) | 1577 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S1))) |
1578 | { | 1578 | { |
1579 | foreach (bool l3 in exprtl0_6(Token, Term, Precedence, Answer, S, S1)) | 1579 | foreach (bool l3 in exprtl0_6(Token, Term, Precedence, Answer, S, S1)) |
1580 | { | 1580 | { |
1581 | yield return false; | 1581 | yield return false; |
1582 | } | 1582 | } |
1583 | } | 1583 | } |
1584 | } | 1584 | } |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | public static IEnumerable<bool> exprtl0_6(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) | 1587 | public static IEnumerable<bool> exprtl0_6(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) |
1588 | { | 1588 | { |
1589 | { | 1589 | { |
1590 | object x2 = arg3; | 1590 | object x2 = arg3; |
1591 | object S1 = arg6; | 1591 | object S1 = arg6; |
1592 | Variable Term = new Variable(); | 1592 | Variable Term = new Variable(); |
1593 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) | 1593 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) |
1594 | { | 1594 | { |
1595 | foreach (bool l3 in YP.unify(arg2, Term)) | 1595 | foreach (bool l3 in YP.unify(arg2, Term)) |
1596 | { | 1596 | { |
1597 | foreach (bool l4 in YP.unify(arg4, Term)) | 1597 | foreach (bool l4 in YP.unify(arg4, Term)) |
1598 | { | 1598 | { |
1599 | foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"}"), S1))) | 1599 | foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"}"), S1))) |
1600 | { | 1600 | { |
1601 | yield return false; | 1601 | yield return false; |
1602 | } | 1602 | } |
1603 | } | 1603 | } |
1604 | } | 1604 | } |
1605 | } | 1605 | } |
1606 | } | 1606 | } |
1607 | { | 1607 | { |
1608 | object x2 = arg3; | 1608 | object x2 = arg3; |
1609 | object S1 = arg6; | 1609 | object S1 = arg6; |
1610 | Variable Term = new Variable(); | 1610 | Variable Term = new Variable(); |
1611 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) | 1611 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) |
1612 | { | 1612 | { |
1613 | foreach (bool l3 in YP.unify(arg2, Term)) | 1613 | foreach (bool l3 in YP.unify(arg2, Term)) |
1614 | { | 1614 | { |
1615 | foreach (bool l4 in YP.unify(arg4, Term)) | 1615 | foreach (bool l4 in YP.unify(arg4, Term)) |
1616 | { | 1616 | { |
1617 | foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"]"), S1))) | 1617 | foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"]"), S1))) |
1618 | { | 1618 | { |
1619 | yield return false; | 1619 | yield return false; |
1620 | } | 1620 | } |
1621 | } | 1621 | } |
1622 | } | 1622 | } |
1623 | } | 1623 | } |
1624 | } | 1624 | } |
1625 | { | 1625 | { |
1626 | object x2 = arg3; | 1626 | object x2 = arg3; |
1627 | object S1 = arg6; | 1627 | object S1 = arg6; |
1628 | Variable Term = new Variable(); | 1628 | Variable Term = new Variable(); |
1629 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) | 1629 | foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) |
1630 | { | 1630 | { |
1631 | foreach (bool l3 in YP.unify(arg2, Term)) | 1631 | foreach (bool l3 in YP.unify(arg2, Term)) |
1632 | { | 1632 | { |
1633 | foreach (bool l4 in YP.unify(arg4, Term)) | 1633 | foreach (bool l4 in YP.unify(arg4, Term)) |
1634 | { | 1634 | { |
1635 | foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@")"), S1))) | 1635 | foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@")"), S1))) |
1636 | { | 1636 | { |
1637 | yield return false; | 1637 | yield return false; |
1638 | } | 1638 | } |
1639 | } | 1639 | } |
1640 | } | 1640 | } |
1641 | } | 1641 | } |
1642 | } | 1642 | } |
1643 | { | 1643 | { |
1644 | object Term = arg2; | 1644 | object Term = arg2; |
1645 | object Precedence = arg3; | 1645 | object Precedence = arg3; |
1646 | object Answer = arg4; | 1646 | object Answer = arg4; |
1647 | object S = arg5; | 1647 | object S = arg5; |
1648 | object S1 = arg6; | 1648 | object S1 = arg6; |
1649 | Variable Next = new Variable(); | 1649 | Variable Next = new Variable(); |
1650 | Variable S2 = new Variable(); | 1650 | Variable S2 = new Variable(); |
1651 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) | 1651 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) |
1652 | { | 1652 | { |
1653 | if (YP.greaterThanOrEqual(Precedence, 1000)) | 1653 | if (YP.greaterThanOrEqual(Precedence, 1000)) |
1654 | { | 1654 | { |
1655 | foreach (bool l4 in parse(S1, 1000, Next, S2)) | 1655 | foreach (bool l4 in parse(S1, 1000, Next, S2)) |
1656 | { | 1656 | { |
1657 | foreach (bool l5 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) | 1657 | foreach (bool l5 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) |
1658 | { | 1658 | { |
1659 | yield return false; | 1659 | yield return false; |
1660 | } | 1660 | } |
1661 | yield break; | 1661 | yield break; |
1662 | } | 1662 | } |
1663 | goto cutIf1; | 1663 | goto cutIf1; |
1664 | } | 1664 | } |
1665 | foreach (bool l3 in YP.unify(Answer, Term)) | 1665 | foreach (bool l3 in YP.unify(Answer, Term)) |
1666 | { | 1666 | { |
1667 | foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@","), S1))) | 1667 | foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@","), S1))) |
1668 | { | 1668 | { |
1669 | yield return false; | 1669 | yield return false; |
1670 | } | 1670 | } |
1671 | } | 1671 | } |
1672 | cutIf1: | 1672 | cutIf1: |
1673 | { } | 1673 | { } |
1674 | } | 1674 | } |
1675 | } | 1675 | } |
1676 | { | 1676 | { |
1677 | object Term = arg2; | 1677 | object Term = arg2; |
1678 | object Precedence = arg3; | 1678 | object Precedence = arg3; |
1679 | object Answer = arg4; | 1679 | object Answer = arg4; |
1680 | object S = arg5; | 1680 | object S = arg5; |
1681 | object S1 = arg6; | 1681 | object S1 = arg6; |
1682 | Variable Next = new Variable(); | 1682 | Variable Next = new Variable(); |
1683 | Variable S2 = new Variable(); | 1683 | Variable S2 = new Variable(); |
1684 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) | 1684 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) |
1685 | { | 1685 | { |
1686 | if (YP.greaterThanOrEqual(Precedence, 1100)) | 1686 | if (YP.greaterThanOrEqual(Precedence, 1100)) |
1687 | { | 1687 | { |
1688 | foreach (bool l4 in parse(S1, 1100, Next, S2)) | 1688 | foreach (bool l4 in parse(S1, 1100, Next, S2)) |
1689 | { | 1689 | { |
1690 | foreach (bool l5 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) | 1690 | foreach (bool l5 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) |
1691 | { | 1691 | { |
1692 | yield return false; | 1692 | yield return false; |
1693 | } | 1693 | } |
1694 | yield break; | 1694 | yield break; |
1695 | } | 1695 | } |
1696 | goto cutIf2; | 1696 | goto cutIf2; |
1697 | } | 1697 | } |
1698 | foreach (bool l3 in YP.unify(Answer, Term)) | 1698 | foreach (bool l3 in YP.unify(Answer, Term)) |
1699 | { | 1699 | { |
1700 | foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@"|"), S1))) | 1700 | foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@"|"), S1))) |
1701 | { | 1701 | { |
1702 | yield return false; | 1702 | yield return false; |
1703 | } | 1703 | } |
1704 | } | 1704 | } |
1705 | cutIf2: | 1705 | cutIf2: |
1706 | { } | 1706 | { } |
1707 | } | 1707 | } |
1708 | } | 1708 | } |
1709 | { | 1709 | { |
1710 | object x2 = arg2; | 1710 | object x2 = arg2; |
1711 | object x3 = arg3; | 1711 | object x3 = arg3; |
1712 | object x4 = arg4; | 1712 | object x4 = arg4; |
1713 | object x5 = arg5; | 1713 | object x5 = arg5; |
1714 | object S1 = arg6; | 1714 | object S1 = arg6; |
1715 | Variable S = new Variable(); | 1715 | Variable S = new Variable(); |
1716 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", S))) | 1716 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", S))) |
1717 | { | 1717 | { |
1718 | foreach (bool l3 in cannot_follow(Atom.a(@"chars"), new Functor1(@"string", S), S1)) | 1718 | foreach (bool l3 in cannot_follow(Atom.a(@"chars"), new Functor1(@"string", S), S1)) |
1719 | { | 1719 | { |
1720 | yield return false; | 1720 | yield return false; |
1721 | } | 1721 | } |
1722 | } | 1722 | } |
1723 | } | 1723 | } |
1724 | { | 1724 | { |
1725 | object x2 = arg2; | 1725 | object x2 = arg2; |
1726 | object x3 = arg3; | 1726 | object x3 = arg3; |
1727 | object x4 = arg4; | 1727 | object x4 = arg4; |
1728 | object x5 = arg5; | 1728 | object x5 = arg5; |
1729 | object S1 = arg6; | 1729 | object S1 = arg6; |
1730 | Variable N = new Variable(); | 1730 | Variable N = new Variable(); |
1731 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", N))) | 1731 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", N))) |
1732 | { | 1732 | { |
1733 | foreach (bool l3 in cannot_follow(Atom.a(@"number"), new Functor1(@"number", N), S1)) | 1733 | foreach (bool l3 in cannot_follow(Atom.a(@"number"), new Functor1(@"number", N), S1)) |
1734 | { | 1734 | { |
1735 | yield return false; | 1735 | yield return false; |
1736 | } | 1736 | } |
1737 | } | 1737 | } |
1738 | } | 1738 | } |
1739 | { | 1739 | { |
1740 | object Term = arg2; | 1740 | object Term = arg2; |
1741 | object Precedence = arg3; | 1741 | object Precedence = arg3; |
1742 | object Answer = arg4; | 1742 | object Answer = arg4; |
1743 | object S = arg5; | 1743 | object S = arg5; |
1744 | Variable S1 = new Variable(); | 1744 | Variable S1 = new Variable(); |
1745 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) | 1745 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) |
1746 | { | 1746 | { |
1747 | foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"}"), S1))) | 1747 | foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"}"), S1))) |
1748 | { | 1748 | { |
1749 | foreach (bool l4 in exprtl0_atom(Atom.a(@"{}"), Term, Precedence, Answer, S, S1)) | 1749 | foreach (bool l4 in exprtl0_atom(Atom.a(@"{}"), Term, Precedence, Answer, S, S1)) |
1750 | { | 1750 | { |
1751 | yield return false; | 1751 | yield return false; |
1752 | } | 1752 | } |
1753 | yield break; | 1753 | yield break; |
1754 | } | 1754 | } |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | { | 1757 | { |
1758 | object x1 = arg2; | 1758 | object x1 = arg2; |
1759 | object x2 = arg3; | 1759 | object x2 = arg3; |
1760 | object x3 = arg4; | 1760 | object x3 = arg4; |
1761 | object x4 = arg5; | 1761 | object x4 = arg5; |
1762 | object S1 = arg6; | 1762 | object S1 = arg6; |
1763 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) | 1763 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) |
1764 | { | 1764 | { |
1765 | foreach (bool l3 in cannot_follow(Atom.a(@"brace"), Atom.a(@"{"), S1)) | 1765 | foreach (bool l3 in cannot_follow(Atom.a(@"brace"), Atom.a(@"{"), S1)) |
1766 | { | 1766 | { |
1767 | yield return false; | 1767 | yield return false; |
1768 | } | 1768 | } |
1769 | } | 1769 | } |
1770 | } | 1770 | } |
1771 | { | 1771 | { |
1772 | object Term = arg2; | 1772 | object Term = arg2; |
1773 | object Precedence = arg3; | 1773 | object Precedence = arg3; |
1774 | object Answer = arg4; | 1774 | object Answer = arg4; |
1775 | object S = arg5; | 1775 | object S = arg5; |
1776 | Variable S1 = new Variable(); | 1776 | Variable S1 = new Variable(); |
1777 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) | 1777 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) |
1778 | { | 1778 | { |
1779 | foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"]"), S1))) | 1779 | foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"]"), S1))) |
1780 | { | 1780 | { |
1781 | foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1)) | 1781 | foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1)) |
1782 | { | 1782 | { |
1783 | yield return false; | 1783 | yield return false; |
1784 | } | 1784 | } |
1785 | yield break; | 1785 | yield break; |
1786 | } | 1786 | } |
1787 | } | 1787 | } |
1788 | } | 1788 | } |
1789 | { | 1789 | { |
1790 | object x1 = arg2; | 1790 | object x1 = arg2; |
1791 | object x2 = arg3; | 1791 | object x2 = arg3; |
1792 | object x3 = arg4; | 1792 | object x3 = arg4; |
1793 | object x4 = arg5; | 1793 | object x4 = arg5; |
1794 | object S1 = arg6; | 1794 | object S1 = arg6; |
1795 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) | 1795 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) |
1796 | { | 1796 | { |
1797 | foreach (bool l3 in cannot_follow(Atom.a(@"bracket"), Atom.a(@"["), S1)) | 1797 | foreach (bool l3 in cannot_follow(Atom.a(@"bracket"), Atom.a(@"["), S1)) |
1798 | { | 1798 | { |
1799 | yield return false; | 1799 | yield return false; |
1800 | } | 1800 | } |
1801 | } | 1801 | } |
1802 | } | 1802 | } |
1803 | { | 1803 | { |
1804 | object x1 = arg2; | 1804 | object x1 = arg2; |
1805 | object x2 = arg3; | 1805 | object x2 = arg3; |
1806 | object x3 = arg4; | 1806 | object x3 = arg4; |
1807 | object x4 = arg5; | 1807 | object x4 = arg5; |
1808 | object S1 = arg6; | 1808 | object S1 = arg6; |
1809 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) | 1809 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) |
1810 | { | 1810 | { |
1811 | foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) | 1811 | foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) |
1812 | { | 1812 | { |
1813 | yield return false; | 1813 | yield return false; |
1814 | } | 1814 | } |
1815 | } | 1815 | } |
1816 | } | 1816 | } |
1817 | { | 1817 | { |
1818 | object x1 = arg2; | 1818 | object x1 = arg2; |
1819 | object x2 = arg3; | 1819 | object x2 = arg3; |
1820 | object x3 = arg4; | 1820 | object x3 = arg4; |
1821 | object x4 = arg5; | 1821 | object x4 = arg5; |
1822 | object S1 = arg6; | 1822 | object S1 = arg6; |
1823 | foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) | 1823 | foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) |
1824 | { | 1824 | { |
1825 | foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) | 1825 | foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) |
1826 | { | 1826 | { |
1827 | yield return false; | 1827 | yield return false; |
1828 | } | 1828 | } |
1829 | } | 1829 | } |
1830 | } | 1830 | } |
1831 | { | 1831 | { |
1832 | object x4 = arg2; | 1832 | object x4 = arg2; |
1833 | object x5 = arg3; | 1833 | object x5 = arg3; |
1834 | object x6 = arg4; | 1834 | object x6 = arg4; |
1835 | object x7 = arg5; | 1835 | object x7 = arg5; |
1836 | object S1 = arg6; | 1836 | object S1 = arg6; |
1837 | Variable A = new Variable(); | 1837 | Variable A = new Variable(); |
1838 | Variable B = new Variable(); | 1838 | Variable B = new Variable(); |
1839 | Variable P = new Variable(); | 1839 | Variable P = new Variable(); |
1840 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", A, B, P))) | 1840 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", A, B, P))) |
1841 | { | 1841 | { |
1842 | foreach (bool l3 in cannot_follow(Atom.a(@"variable"), new Functor3(@"var", A, B, P), S1)) | 1842 | foreach (bool l3 in cannot_follow(Atom.a(@"variable"), new Functor3(@"var", A, B, P), S1)) |
1843 | { | 1843 | { |
1844 | yield return false; | 1844 | yield return false; |
1845 | } | 1845 | } |
1846 | } | 1846 | } |
1847 | } | 1847 | } |
1848 | { | 1848 | { |
1849 | object Term = arg2; | 1849 | object Term = arg2; |
1850 | object Precedence = arg3; | 1850 | object Precedence = arg3; |
1851 | object Answer = arg4; | 1851 | object Answer = arg4; |
1852 | object S = arg5; | 1852 | object S = arg5; |
1853 | object S1 = arg6; | 1853 | object S1 = arg6; |
1854 | Variable F = new Variable(); | 1854 | Variable F = new Variable(); |
1855 | Variable P = new Variable(); | 1855 | Variable P = new Variable(); |
1856 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", F, P))) | 1856 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", F, P))) |
1857 | { | 1857 | { |
1858 | foreach (bool l3 in exprtl0_atom(new Functor2(@"/", F, P), Term, Precedence, Answer, S, S1)) | 1858 | foreach (bool l3 in exprtl0_atom(new Functor2(@"/", F, P), Term, Precedence, Answer, S, S1)) |
1859 | { | 1859 | { |
1860 | yield return false; | 1860 | yield return false; |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | public static IEnumerable<bool> exprtl0_atom(object arg1, object arg2, object arg3, object arg4, object arg5, object S1) | 1866 | public static IEnumerable<bool> exprtl0_atom(object arg1, object arg2, object arg3, object arg4, object arg5, object S1) |
1867 | { | 1867 | { |
1868 | { | 1868 | { |
1869 | object Term = arg2; | 1869 | object Term = arg2; |
1870 | object Precedence = arg3; | 1870 | object Precedence = arg3; |
1871 | object Answer = arg4; | 1871 | object Answer = arg4; |
1872 | object S = arg5; | 1872 | object S = arg5; |
1873 | Variable F = new Variable(); | 1873 | Variable F = new Variable(); |
1874 | Variable Pos = new Variable(); | 1874 | Variable Pos = new Variable(); |
1875 | Variable L1 = new Variable(); | 1875 | Variable L1 = new Variable(); |
1876 | Variable O1 = new Variable(); | 1876 | Variable O1 = new Variable(); |
1877 | Variable R1 = new Variable(); | 1877 | Variable R1 = new Variable(); |
1878 | Variable L2 = new Variable(); | 1878 | Variable L2 = new Variable(); |
1879 | Variable O2 = new Variable(); | 1879 | Variable O2 = new Variable(); |
1880 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) | 1880 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) |
1881 | { | 1881 | { |
1882 | foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2)) | 1882 | foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2)) |
1883 | { | 1883 | { |
1884 | foreach (bool l4 in prefix_is_atom(S1, Precedence)) | 1884 | foreach (bool l4 in prefix_is_atom(S1, Precedence)) |
1885 | { | 1885 | { |
1886 | foreach (bool l5 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S)) | 1886 | foreach (bool l5 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S)) |
1887 | { | 1887 | { |
1888 | yield return false; | 1888 | yield return false; |
1889 | } | 1889 | } |
1890 | yield break; | 1890 | yield break; |
1891 | } | 1891 | } |
1892 | foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S)) | 1892 | foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S)) |
1893 | { | 1893 | { |
1894 | yield return false; | 1894 | yield return false; |
1895 | } | 1895 | } |
1896 | foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S)) | 1896 | foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S)) |
1897 | { | 1897 | { |
1898 | yield return false; | 1898 | yield return false; |
1899 | } | 1899 | } |
1900 | yield break; | 1900 | yield break; |
1901 | } | 1901 | } |
1902 | } | 1902 | } |
1903 | } | 1903 | } |
1904 | { | 1904 | { |
1905 | object Term = arg2; | 1905 | object Term = arg2; |
1906 | object Precedence = arg3; | 1906 | object Precedence = arg3; |
1907 | object Answer = arg4; | 1907 | object Answer = arg4; |
1908 | object S = arg5; | 1908 | object S = arg5; |
1909 | Variable F = new Variable(); | 1909 | Variable F = new Variable(); |
1910 | Variable Pos = new Variable(); | 1910 | Variable Pos = new Variable(); |
1911 | Variable L1 = new Variable(); | 1911 | Variable L1 = new Variable(); |
1912 | Variable O1 = new Variable(); | 1912 | Variable O1 = new Variable(); |
1913 | Variable R1 = new Variable(); | 1913 | Variable R1 = new Variable(); |
1914 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) | 1914 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) |
1915 | { | 1915 | { |
1916 | foreach (bool l3 in infixop(F, L1, O1, R1)) | 1916 | foreach (bool l3 in infixop(F, L1, O1, R1)) |
1917 | { | 1917 | { |
1918 | foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S)) | 1918 | foreach (bool l4 in exprtl(new ListPair(new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L1, O1, R1 }), S1), 0, Term, Precedence, Answer, S)) |
1919 | { | 1919 | { |
1920 | yield return false; | 1920 | yield return false; |
1921 | } | 1921 | } |
1922 | yield break; | 1922 | yield break; |
1923 | } | 1923 | } |
1924 | } | 1924 | } |
1925 | } | 1925 | } |
1926 | { | 1926 | { |
1927 | object Term = arg2; | 1927 | object Term = arg2; |
1928 | object Precedence = arg3; | 1928 | object Precedence = arg3; |
1929 | object Answer = arg4; | 1929 | object Answer = arg4; |
1930 | object S = arg5; | 1930 | object S = arg5; |
1931 | Variable F = new Variable(); | 1931 | Variable F = new Variable(); |
1932 | Variable Pos = new Variable(); | 1932 | Variable Pos = new Variable(); |
1933 | Variable L2 = new Variable(); | 1933 | Variable L2 = new Variable(); |
1934 | Variable O2 = new Variable(); | 1934 | Variable O2 = new Variable(); |
1935 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) | 1935 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) |
1936 | { | 1936 | { |
1937 | foreach (bool l3 in postfixop(F, L2, O2)) | 1937 | foreach (bool l3 in postfixop(F, L2, O2)) |
1938 | { | 1938 | { |
1939 | foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S)) | 1939 | foreach (bool l4 in exprtl(new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L2, O2), S1), 0, Term, Precedence, Answer, S)) |
1940 | { | 1940 | { |
1941 | yield return false; | 1941 | yield return false; |
1942 | } | 1942 | } |
1943 | yield break; | 1943 | yield break; |
1944 | } | 1944 | } |
1945 | } | 1945 | } |
1946 | } | 1946 | } |
1947 | { | 1947 | { |
1948 | object X = arg1; | 1948 | object X = arg1; |
1949 | object x2 = arg2; | 1949 | object x2 = arg2; |
1950 | object x3 = arg3; | 1950 | object x3 = arg3; |
1951 | object x4 = arg4; | 1951 | object x4 = arg4; |
1952 | object x5 = arg5; | 1952 | object x5 = arg5; |
1953 | Variable x7 = new Variable(); | 1953 | Variable x7 = new Variable(); |
1954 | foreach (bool l2 in syntax_error(new ListPair(new Functor2(@"-", Atom.a(@"non"), Atom.a(@"operator")), new ListPair(X, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(new Functor2(@"atom", X, x7), S1))) | 1954 | foreach (bool l2 in syntax_error(new ListPair(new Functor2(@"-", Atom.a(@"non"), Atom.a(@"operator")), new ListPair(X, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL)))), new ListPair(new Functor2(@"atom", X, x7), S1))) |
1955 | { | 1955 | { |
1956 | yield return false; | 1956 | yield return false; |
1957 | } | 1957 | } |
1958 | yield break; | 1958 | yield break; |
1959 | } | 1959 | } |
1960 | } | 1960 | } |
1961 | 1961 | ||
1962 | public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens) | 1962 | public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens) |
1963 | { | 1963 | { |
1964 | { | 1964 | { |
1965 | foreach (bool l2 in syntax_error(new ListPair(Type, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL))), new ListPair(Token, Tokens))) | 1965 | foreach (bool l2 in syntax_error(new ListPair(Type, new ListPair(Atom.a(@"follows"), new ListPair(Atom.a(@"expression"), Atom.NIL))), new ListPair(Token, Tokens))) |
1966 | { | 1966 | { |
1967 | yield return false; | 1967 | yield return false; |
1968 | } | 1968 | } |
1969 | } | 1969 | } |
1970 | } | 1970 | } |
1971 | 1971 | ||
1972 | public static IEnumerable<bool> exprtl(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) | 1972 | public static IEnumerable<bool> exprtl(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) |
1973 | { | 1973 | { |
1974 | { | 1974 | { |
1975 | object x1 = arg2; | 1975 | object x1 = arg2; |
1976 | object x3 = arg4; | 1976 | object x3 = arg4; |
1977 | Variable Term = new Variable(); | 1977 | Variable Term = new Variable(); |
1978 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1978 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1979 | { | 1979 | { |
1980 | foreach (bool l3 in YP.unify(arg3, Term)) | 1980 | foreach (bool l3 in YP.unify(arg3, Term)) |
1981 | { | 1981 | { |
1982 | foreach (bool l4 in YP.unify(arg5, Term)) | 1982 | foreach (bool l4 in YP.unify(arg5, Term)) |
1983 | { | 1983 | { |
1984 | foreach (bool l5 in YP.unify(arg6, Atom.NIL)) | 1984 | foreach (bool l5 in YP.unify(arg6, Atom.NIL)) |
1985 | { | 1985 | { |
1986 | yield return false; | 1986 | yield return false; |
1987 | } | 1987 | } |
1988 | } | 1988 | } |
1989 | } | 1989 | } |
1990 | } | 1990 | } |
1991 | } | 1991 | } |
1992 | { | 1992 | { |
1993 | object C = arg2; | 1993 | object C = arg2; |
1994 | object Term = arg3; | 1994 | object Term = arg3; |
1995 | object Precedence = arg4; | 1995 | object Precedence = arg4; |
1996 | object Answer = arg5; | 1996 | object Answer = arg5; |
1997 | object S = arg6; | 1997 | object S = arg6; |
1998 | Variable Token = new Variable(); | 1998 | Variable Token = new Variable(); |
1999 | Variable Tokens = new Variable(); | 1999 | Variable Tokens = new Variable(); |
2000 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Tokens))) | 2000 | foreach (bool l2 in YP.unify(arg1, new ListPair(Token, Tokens))) |
2001 | { | 2001 | { |
2002 | foreach (bool l3 in exprtl_7(Token, C, Term, Precedence, Answer, S, Tokens)) | 2002 | foreach (bool l3 in exprtl_7(Token, C, Term, Precedence, Answer, S, Tokens)) |
2003 | { | 2003 | { |
2004 | yield return false; | 2004 | yield return false; |
2005 | } | 2005 | } |
2006 | } | 2006 | } |
2007 | } | 2007 | } |
2008 | } | 2008 | } |
2009 | 2009 | ||
2010 | public static IEnumerable<bool> exprtl_7(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) | 2010 | public static IEnumerable<bool> exprtl_7(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) |
2011 | { | 2011 | { |
2012 | { | 2012 | { |
2013 | object C = arg2; | 2013 | object C = arg2; |
2014 | object Term = arg3; | 2014 | object Term = arg3; |
2015 | object Precedence = arg4; | 2015 | object Precedence = arg4; |
2016 | object Answer = arg5; | 2016 | object Answer = arg5; |
2017 | object S = arg6; | 2017 | object S = arg6; |
2018 | object S1 = arg7; | 2018 | object S1 = arg7; |
2019 | Variable F = new Variable(); | 2019 | Variable F = new Variable(); |
2020 | Variable Pos = new Variable(); | 2020 | Variable Pos = new Variable(); |
2021 | Variable L = new Variable(); | 2021 | Variable L = new Variable(); |
2022 | Variable O = new Variable(); | 2022 | Variable O = new Variable(); |
2023 | Variable R = new Variable(); | 2023 | Variable R = new Variable(); |
2024 | Variable Other = new Variable(); | 2024 | Variable Other = new Variable(); |
2025 | Variable S2 = new Variable(); | 2025 | Variable S2 = new Variable(); |
2026 | Variable Expr = new Variable(); | 2026 | Variable Expr = new Variable(); |
2027 | foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, O, R }))) | 2027 | foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, O, R }))) |
2028 | { | 2028 | { |
2029 | if (YP.greaterThanOrEqual(Precedence, O)) | 2029 | if (YP.greaterThanOrEqual(Precedence, O)) |
2030 | { | 2030 | { |
2031 | if (YP.lessThanOrEqual(C, L)) | 2031 | if (YP.lessThanOrEqual(C, L)) |
2032 | { | 2032 | { |
2033 | foreach (bool l5 in parse(S1, R, Other, S2)) | 2033 | foreach (bool l5 in parse(S1, R, Other, S2)) |
2034 | { | 2034 | { |
2035 | foreach (bool l6 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, new ListPair(Other, Atom.NIL)))))) | 2035 | foreach (bool l6 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, new ListPair(Other, Atom.NIL)))))) |
2036 | { | 2036 | { |
2037 | foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S)) | 2037 | foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S)) |
2038 | { | 2038 | { |
2039 | yield return false; | 2039 | yield return false; |
2040 | } | 2040 | } |
2041 | } | 2041 | } |
2042 | } | 2042 | } |
2043 | yield break; | 2043 | yield break; |
2044 | } | 2044 | } |
2045 | } | 2045 | } |
2046 | } | 2046 | } |
2047 | } | 2047 | } |
2048 | { | 2048 | { |
2049 | object C = arg2; | 2049 | object C = arg2; |
2050 | object Term = arg3; | 2050 | object Term = arg3; |
2051 | object Precedence = arg4; | 2051 | object Precedence = arg4; |
2052 | object Answer = arg5; | 2052 | object Answer = arg5; |
2053 | object S = arg6; | 2053 | object S = arg6; |
2054 | object S1 = arg7; | 2054 | object S1 = arg7; |
2055 | Variable F = new Variable(); | 2055 | Variable F = new Variable(); |
2056 | Variable Pos = new Variable(); | 2056 | Variable Pos = new Variable(); |
2057 | Variable L = new Variable(); | 2057 | Variable L = new Variable(); |
2058 | Variable O = new Variable(); | 2058 | Variable O = new Variable(); |
2059 | Variable Expr = new Variable(); | 2059 | Variable Expr = new Variable(); |
2060 | Variable S2 = new Variable(); | 2060 | Variable S2 = new Variable(); |
2061 | foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, O))) | 2061 | foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, O))) |
2062 | { | 2062 | { |
2063 | if (YP.greaterThanOrEqual(Precedence, O)) | 2063 | if (YP.greaterThanOrEqual(Precedence, O)) |
2064 | { | 2064 | { |
2065 | if (YP.lessThanOrEqual(C, L)) | 2065 | if (YP.lessThanOrEqual(C, L)) |
2066 | { | 2066 | { |
2067 | foreach (bool l5 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, Atom.NIL))))) | 2067 | foreach (bool l5 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, Atom.NIL))))) |
2068 | { | 2068 | { |
2069 | foreach (bool l6 in peepop(S1, S2)) | 2069 | foreach (bool l6 in peepop(S1, S2)) |
2070 | { | 2070 | { |
2071 | foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S)) | 2071 | foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S)) |
2072 | { | 2072 | { |
2073 | yield return false; | 2073 | yield return false; |
2074 | } | 2074 | } |
2075 | } | 2075 | } |
2076 | } | 2076 | } |
2077 | yield break; | 2077 | yield break; |
2078 | } | 2078 | } |
2079 | } | 2079 | } |
2080 | } | 2080 | } |
2081 | } | 2081 | } |
2082 | { | 2082 | { |
2083 | object C = arg2; | 2083 | object C = arg2; |
2084 | object Term = arg3; | 2084 | object Term = arg3; |
2085 | object Precedence = arg4; | 2085 | object Precedence = arg4; |
2086 | object Answer = arg5; | 2086 | object Answer = arg5; |
2087 | object S = arg6; | 2087 | object S = arg6; |
2088 | object S1 = arg7; | 2088 | object S1 = arg7; |
2089 | Variable Next = new Variable(); | 2089 | Variable Next = new Variable(); |
2090 | Variable S2 = new Variable(); | 2090 | Variable S2 = new Variable(); |
2091 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) | 2091 | foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) |
2092 | { | 2092 | { |
2093 | if (YP.greaterThanOrEqual(Precedence, 1000)) | 2093 | if (YP.greaterThanOrEqual(Precedence, 1000)) |
2094 | { | 2094 | { |
2095 | if (YP.lessThan(C, 1000)) | 2095 | if (YP.lessThan(C, 1000)) |
2096 | { | 2096 | { |
2097 | foreach (bool l5 in parse(S1, 1000, Next, S2)) | 2097 | foreach (bool l5 in parse(S1, 1000, Next, S2)) |
2098 | { | 2098 | { |
2099 | foreach (bool l6 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) | 2099 | foreach (bool l6 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) |
2100 | { | 2100 | { |
2101 | yield return false; | 2101 | yield return false; |
2102 | } | 2102 | } |
2103 | } | 2103 | } |
2104 | yield break; | 2104 | yield break; |
2105 | } | 2105 | } |
2106 | } | 2106 | } |
2107 | } | 2107 | } |
2108 | } | 2108 | } |
2109 | { | 2109 | { |
2110 | object C = arg2; | 2110 | object C = arg2; |
2111 | object Term = arg3; | 2111 | object Term = arg3; |
2112 | object Precedence = arg4; | 2112 | object Precedence = arg4; |
2113 | object Answer = arg5; | 2113 | object Answer = arg5; |
2114 | object S = arg6; | 2114 | object S = arg6; |
2115 | object S1 = arg7; | 2115 | object S1 = arg7; |
2116 | Variable Next = new Variable(); | 2116 | Variable Next = new Variable(); |
2117 | Variable S2 = new Variable(); | 2117 | Variable S2 = new Variable(); |
2118 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) | 2118 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) |
2119 | { | 2119 | { |
2120 | if (YP.greaterThanOrEqual(Precedence, 1100)) | 2120 | if (YP.greaterThanOrEqual(Precedence, 1100)) |
2121 | { | 2121 | { |
2122 | if (YP.lessThan(C, 1100)) | 2122 | if (YP.lessThan(C, 1100)) |
2123 | { | 2123 | { |
2124 | foreach (bool l5 in parse(S1, 1100, Next, S2)) | 2124 | foreach (bool l5 in parse(S1, 1100, Next, S2)) |
2125 | { | 2125 | { |
2126 | foreach (bool l6 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) | 2126 | foreach (bool l6 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) |
2127 | { | 2127 | { |
2128 | yield return false; | 2128 | yield return false; |
2129 | } | 2129 | } |
2130 | } | 2130 | } |
2131 | yield break; | 2131 | yield break; |
2132 | } | 2132 | } |
2133 | } | 2133 | } |
2134 | } | 2134 | } |
2135 | } | 2135 | } |
2136 | { | 2136 | { |
2137 | object Token = arg1; | 2137 | object Token = arg1; |
2138 | object x2 = arg2; | 2138 | object x2 = arg2; |
2139 | object x4 = arg4; | 2139 | object x4 = arg4; |
2140 | object Tokens = arg7; | 2140 | object Tokens = arg7; |
2141 | Variable Term = new Variable(); | 2141 | Variable Term = new Variable(); |
2142 | foreach (bool l2 in YP.unify(arg3, Term)) | 2142 | foreach (bool l2 in YP.unify(arg3, Term)) |
2143 | { | 2143 | { |
2144 | foreach (bool l3 in YP.unify(arg5, Term)) | 2144 | foreach (bool l3 in YP.unify(arg5, Term)) |
2145 | { | 2145 | { |
2146 | foreach (bool l4 in YP.unify(arg6, new ListPair(Token, Tokens))) | 2146 | foreach (bool l4 in YP.unify(arg6, new ListPair(Token, Tokens))) |
2147 | { | 2147 | { |
2148 | yield return false; | 2148 | yield return false; |
2149 | } | 2149 | } |
2150 | } | 2150 | } |
2151 | } | 2151 | } |
2152 | } | 2152 | } |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | public static IEnumerable<bool> syntax_error(object _Message, object _List) | 2155 | public static IEnumerable<bool> syntax_error(object _Message, object _List) |
2156 | { | 2156 | { |
2157 | { | 2157 | { |
2158 | yield break; | 2158 | yield break; |
2159 | } | 2159 | } |
2160 | } | 2160 | } |
2161 | 2161 | ||
2162 | public static IEnumerable<bool> syntax_error(object _List) | 2162 | public static IEnumerable<bool> syntax_error(object _List) |
2163 | { | 2163 | { |
2164 | { | 2164 | { |
2165 | yield break; | 2165 | yield break; |
2166 | } | 2166 | } |
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | public static IEnumerable<bool> prefixop(object F, object O, object Q) | 2169 | public static IEnumerable<bool> prefixop(object F, object O, object Q) |
2170 | { | 2170 | { |
2171 | { | 2171 | { |
2172 | foreach (bool l2 in YP.current_op(O, Atom.a(@"fx"), F)) | 2172 | foreach (bool l2 in YP.current_op(O, Atom.a(@"fx"), F)) |
2173 | { | 2173 | { |
2174 | foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) | 2174 | foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) |
2175 | { | 2175 | { |
2176 | yield return false; | 2176 | yield return false; |
2177 | } | 2177 | } |
2178 | goto cutIf1; | 2178 | goto cutIf1; |
2179 | } | 2179 | } |
2180 | foreach (bool l2 in YP.current_op(O, Atom.a(@"fy"), F)) | 2180 | foreach (bool l2 in YP.current_op(O, Atom.a(@"fy"), F)) |
2181 | { | 2181 | { |
2182 | foreach (bool l3 in YP.unify(Q, O)) | 2182 | foreach (bool l3 in YP.unify(Q, O)) |
2183 | { | 2183 | { |
2184 | yield return false; | 2184 | yield return false; |
2185 | } | 2185 | } |
2186 | goto cutIf2; | 2186 | goto cutIf2; |
2187 | } | 2187 | } |
2188 | cutIf2: | 2188 | cutIf2: |
2189 | cutIf1: | 2189 | cutIf1: |
2190 | { } | 2190 | { } |
2191 | } | 2191 | } |
2192 | } | 2192 | } |
2193 | 2193 | ||
2194 | public static IEnumerable<bool> postfixop(object F, object P, object O) | 2194 | public static IEnumerable<bool> postfixop(object F, object P, object O) |
2195 | { | 2195 | { |
2196 | { | 2196 | { |
2197 | foreach (bool l2 in YP.current_op(O, Atom.a(@"xf"), F)) | 2197 | foreach (bool l2 in YP.current_op(O, Atom.a(@"xf"), F)) |
2198 | { | 2198 | { |
2199 | foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) | 2199 | foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) |
2200 | { | 2200 | { |
2201 | yield return false; | 2201 | yield return false; |
2202 | } | 2202 | } |
2203 | goto cutIf1; | 2203 | goto cutIf1; |
2204 | } | 2204 | } |
2205 | foreach (bool l2 in YP.current_op(O, Atom.a(@"yf"), F)) | 2205 | foreach (bool l2 in YP.current_op(O, Atom.a(@"yf"), F)) |
2206 | { | 2206 | { |
2207 | foreach (bool l3 in YP.unify(P, O)) | 2207 | foreach (bool l3 in YP.unify(P, O)) |
2208 | { | 2208 | { |
2209 | yield return false; | 2209 | yield return false; |
2210 | } | 2210 | } |
2211 | goto cutIf2; | 2211 | goto cutIf2; |
2212 | } | 2212 | } |
2213 | cutIf2: | 2213 | cutIf2: |
2214 | cutIf1: | 2214 | cutIf1: |
2215 | { } | 2215 | { } |
2216 | } | 2216 | } |
2217 | } | 2217 | } |
2218 | 2218 | ||
2219 | public static IEnumerable<bool> infixop(object F, object P, object O, object Q) | 2219 | public static IEnumerable<bool> infixop(object F, object P, object O, object Q) |
2220 | { | 2220 | { |
2221 | { | 2221 | { |
2222 | foreach (bool l2 in YP.current_op(O, Atom.a(@"xfy"), F)) | 2222 | foreach (bool l2 in YP.current_op(O, Atom.a(@"xfy"), F)) |
2223 | { | 2223 | { |
2224 | foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) | 2224 | foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) |
2225 | { | 2225 | { |
2226 | foreach (bool l4 in YP.unify(Q, O)) | 2226 | foreach (bool l4 in YP.unify(Q, O)) |
2227 | { | 2227 | { |
2228 | yield return false; | 2228 | yield return false; |
2229 | } | 2229 | } |
2230 | } | 2230 | } |
2231 | goto cutIf1; | 2231 | goto cutIf1; |
2232 | } | 2232 | } |
2233 | foreach (bool l2 in YP.current_op(O, Atom.a(@"xfx"), F)) | 2233 | foreach (bool l2 in YP.current_op(O, Atom.a(@"xfx"), F)) |
2234 | { | 2234 | { |
2235 | foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) | 2235 | foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) |
2236 | { | 2236 | { |
2237 | foreach (bool l4 in YP.unify(Q, P)) | 2237 | foreach (bool l4 in YP.unify(Q, P)) |
2238 | { | 2238 | { |
2239 | yield return false; | 2239 | yield return false; |
2240 | } | 2240 | } |
2241 | } | 2241 | } |
2242 | goto cutIf2; | 2242 | goto cutIf2; |
2243 | } | 2243 | } |
2244 | foreach (bool l2 in YP.current_op(O, Atom.a(@"yfx"), F)) | 2244 | foreach (bool l2 in YP.current_op(O, Atom.a(@"yfx"), F)) |
2245 | { | 2245 | { |
2246 | foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) | 2246 | foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) |
2247 | { | 2247 | { |
2248 | foreach (bool l4 in YP.unify(P, O)) | 2248 | foreach (bool l4 in YP.unify(P, O)) |
2249 | { | 2249 | { |
2250 | yield return false; | 2250 | yield return false; |
2251 | } | 2251 | } |
2252 | } | 2252 | } |
2253 | goto cutIf3; | 2253 | goto cutIf3; |
2254 | } | 2254 | } |
2255 | cutIf3: | 2255 | cutIf3: |
2256 | cutIf2: | 2256 | cutIf2: |
2257 | cutIf1: | 2257 | cutIf1: |
2258 | { } | 2258 | { } |
2259 | } | 2259 | } |
2260 | } | 2260 | } |
2261 | 2261 | ||
2262 | public static IEnumerable<bool> ambigop(object F, object Precedence, object L1, object O1, object R1, object L2, object O2) | 2262 | public static IEnumerable<bool> ambigop(object F, object Precedence, object L1, object O1, object R1, object L2, object O2) |
2263 | { | 2263 | { |
2264 | { | 2264 | { |
2265 | foreach (bool l2 in postfixop(F, L2, O2)) | 2265 | foreach (bool l2 in postfixop(F, L2, O2)) |
2266 | { | 2266 | { |
2267 | if (YP.lessThanOrEqual(O2, Precedence)) | 2267 | if (YP.lessThanOrEqual(O2, Precedence)) |
2268 | { | 2268 | { |
2269 | foreach (bool l4 in infixop(F, L1, O1, R1)) | 2269 | foreach (bool l4 in infixop(F, L1, O1, R1)) |
2270 | { | 2270 | { |
2271 | if (YP.lessThanOrEqual(O1, Precedence)) | 2271 | if (YP.lessThanOrEqual(O1, Precedence)) |
2272 | { | 2272 | { |
2273 | yield return false; | 2273 | yield return false; |
2274 | } | 2274 | } |
2275 | } | 2275 | } |
2276 | } | 2276 | } |
2277 | } | 2277 | } |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | 2280 | ||
2281 | public static IEnumerable<bool> read_tokens1(object arg1) | 2281 | public static IEnumerable<bool> read_tokens1(object arg1) |
2282 | { | 2282 | { |
2283 | { | 2283 | { |
2284 | object TokenList = arg1; | 2284 | object TokenList = arg1; |
2285 | Variable C1 = new Variable(); | 2285 | Variable C1 = new Variable(); |
2286 | Variable _X = new Variable(); | 2286 | Variable _X = new Variable(); |
2287 | Variable ListOfTokens = new Variable(); | 2287 | Variable ListOfTokens = new Variable(); |
2288 | foreach (bool l2 in YP.get_code(C1)) | 2288 | foreach (bool l2 in YP.get_code(C1)) |
2289 | { | 2289 | { |
2290 | foreach (bool l3 in read_tokens(C1, _X, ListOfTokens)) | 2290 | foreach (bool l3 in read_tokens(C1, _X, ListOfTokens)) |
2291 | { | 2291 | { |
2292 | foreach (bool l4 in YP.unify(TokenList, ListOfTokens)) | 2292 | foreach (bool l4 in YP.unify(TokenList, ListOfTokens)) |
2293 | { | 2293 | { |
2294 | yield return false; | 2294 | yield return false; |
2295 | } | 2295 | } |
2296 | yield break; | 2296 | yield break; |
2297 | } | 2297 | } |
2298 | } | 2298 | } |
2299 | } | 2299 | } |
2300 | { | 2300 | { |
2301 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) | 2301 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) |
2302 | { | 2302 | { |
2303 | yield return false; | 2303 | yield return false; |
2304 | } | 2304 | } |
2305 | } | 2305 | } |
2306 | } | 2306 | } |
2307 | 2307 | ||
2308 | public static IEnumerable<bool> read_tokens2(object arg1, object arg2) | 2308 | public static IEnumerable<bool> read_tokens2(object arg1, object arg2) |
2309 | { | 2309 | { |
2310 | { | 2310 | { |
2311 | object TokenList = arg1; | 2311 | object TokenList = arg1; |
2312 | object Dictionary = arg2; | 2312 | object Dictionary = arg2; |
2313 | Variable C1 = new Variable(); | 2313 | Variable C1 = new Variable(); |
2314 | Variable Dict = new Variable(); | 2314 | Variable Dict = new Variable(); |
2315 | Variable ListOfTokens = new Variable(); | 2315 | Variable ListOfTokens = new Variable(); |
2316 | foreach (bool l2 in YP.get_code(C1)) | 2316 | foreach (bool l2 in YP.get_code(C1)) |
2317 | { | 2317 | { |
2318 | foreach (bool l3 in read_tokens(C1, Dict, ListOfTokens)) | 2318 | foreach (bool l3 in read_tokens(C1, Dict, ListOfTokens)) |
2319 | { | 2319 | { |
2320 | foreach (bool l4 in terminate_list(Dict)) | 2320 | foreach (bool l4 in terminate_list(Dict)) |
2321 | { | 2321 | { |
2322 | foreach (bool l5 in YP.unify(Dictionary, Dict)) | 2322 | foreach (bool l5 in YP.unify(Dictionary, Dict)) |
2323 | { | 2323 | { |
2324 | foreach (bool l6 in YP.unify(TokenList, ListOfTokens)) | 2324 | foreach (bool l6 in YP.unify(TokenList, ListOfTokens)) |
2325 | { | 2325 | { |
2326 | yield return false; | 2326 | yield return false; |
2327 | } | 2327 | } |
2328 | } | 2328 | } |
2329 | yield break; | 2329 | yield break; |
2330 | } | 2330 | } |
2331 | } | 2331 | } |
2332 | } | 2332 | } |
2333 | } | 2333 | } |
2334 | { | 2334 | { |
2335 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) | 2335 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) |
2336 | { | 2336 | { |
2337 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) | 2337 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) |
2338 | { | 2338 | { |
2339 | yield return false; | 2339 | yield return false; |
2340 | } | 2340 | } |
2341 | } | 2341 | } |
2342 | } | 2342 | } |
2343 | } | 2343 | } |
2344 | 2344 | ||
2345 | public static IEnumerable<bool> terminate_list(object arg1) | 2345 | public static IEnumerable<bool> terminate_list(object arg1) |
2346 | { | 2346 | { |
2347 | { | 2347 | { |
2348 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 2348 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
2349 | { | 2349 | { |
2350 | yield return false; | 2350 | yield return false; |
2351 | } | 2351 | } |
2352 | } | 2352 | } |
2353 | { | 2353 | { |
2354 | Variable x1 = new Variable(); | 2354 | Variable x1 = new Variable(); |
2355 | Variable Tail = new Variable(); | 2355 | Variable Tail = new Variable(); |
2356 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Tail))) | 2356 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Tail))) |
2357 | { | 2357 | { |
2358 | foreach (bool l3 in terminate_list(Tail)) | 2358 | foreach (bool l3 in terminate_list(Tail)) |
2359 | { | 2359 | { |
2360 | yield return false; | 2360 | yield return false; |
2361 | } | 2361 | } |
2362 | } | 2362 | } |
2363 | } | 2363 | } |
2364 | } | 2364 | } |
2365 | 2365 | ||
2366 | public static IEnumerable<bool> read_special(object arg1, object Dict, object arg3) | 2366 | public static IEnumerable<bool> read_special(object arg1, object Dict, object arg3) |
2367 | { | 2367 | { |
2368 | { | 2368 | { |
2369 | object Tokens = arg3; | 2369 | object Tokens = arg3; |
2370 | foreach (bool l2 in YP.unify(arg1, 95)) | 2370 | foreach (bool l2 in YP.unify(arg1, 95)) |
2371 | { | 2371 | { |
2372 | foreach (bool l3 in read_variable(95, Dict, Tokens)) | 2372 | foreach (bool l3 in read_variable(95, Dict, Tokens)) |
2373 | { | 2373 | { |
2374 | yield return false; | 2374 | yield return false; |
2375 | } | 2375 | } |
2376 | } | 2376 | } |
2377 | } | 2377 | } |
2378 | { | 2378 | { |
2379 | object Tokens = arg3; | 2379 | object Tokens = arg3; |
2380 | foreach (bool l2 in YP.unify(arg1, 247)) | 2380 | foreach (bool l2 in YP.unify(arg1, 247)) |
2381 | { | 2381 | { |
2382 | foreach (bool l3 in read_symbol(247, Dict, Tokens)) | 2382 | foreach (bool l3 in read_symbol(247, Dict, Tokens)) |
2383 | { | 2383 | { |
2384 | yield return false; | 2384 | yield return false; |
2385 | } | 2385 | } |
2386 | } | 2386 | } |
2387 | } | 2387 | } |
2388 | { | 2388 | { |
2389 | object Tokens = arg3; | 2389 | object Tokens = arg3; |
2390 | foreach (bool l2 in YP.unify(arg1, 215)) | 2390 | foreach (bool l2 in YP.unify(arg1, 215)) |
2391 | { | 2391 | { |
2392 | foreach (bool l3 in read_symbol(215, Dict, Tokens)) | 2392 | foreach (bool l3 in read_symbol(215, Dict, Tokens)) |
2393 | { | 2393 | { |
2394 | yield return false; | 2394 | yield return false; |
2395 | } | 2395 | } |
2396 | } | 2396 | } |
2397 | } | 2397 | } |
2398 | { | 2398 | { |
2399 | Variable StartPos = new Variable(); | 2399 | Variable StartPos = new Variable(); |
2400 | Variable EndPos = new Variable(); | 2400 | Variable EndPos = new Variable(); |
2401 | Variable Tokens = new Variable(); | 2401 | Variable Tokens = new Variable(); |
2402 | Variable Ch = new Variable(); | 2402 | Variable Ch = new Variable(); |
2403 | Variable NextCh = new Variable(); | 2403 | Variable NextCh = new Variable(); |
2404 | foreach (bool l2 in YP.unify(arg1, 37)) | 2404 | foreach (bool l2 in YP.unify(arg1, 37)) |
2405 | { | 2405 | { |
2406 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) | 2406 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) |
2407 | { | 2407 | { |
2408 | foreach (bool l4 in get_current_position(StartPos)) | 2408 | foreach (bool l4 in get_current_position(StartPos)) |
2409 | { | 2409 | { |
2410 | foreach (bool l5 in YP.repeat()) | 2410 | foreach (bool l5 in YP.repeat()) |
2411 | { | 2411 | { |
2412 | foreach (bool l6 in YP.get_code(Ch)) | 2412 | foreach (bool l6 in YP.get_code(Ch)) |
2413 | { | 2413 | { |
2414 | if (YP.lessThan(Ch, new ListPair(32, Atom.NIL))) | 2414 | if (YP.lessThan(Ch, new ListPair(32, Atom.NIL))) |
2415 | { | 2415 | { |
2416 | if (YP.notEqual(Ch, 9)) | 2416 | if (YP.notEqual(Ch, 9)) |
2417 | { | 2417 | { |
2418 | if (YP.termNotEqual(Ch, -1)) | 2418 | if (YP.termNotEqual(Ch, -1)) |
2419 | { | 2419 | { |
2420 | foreach (bool l10 in get_current_position(EndPos)) | 2420 | foreach (bool l10 in get_current_position(EndPos)) |
2421 | { | 2421 | { |
2422 | foreach (bool l11 in YP.get_code(NextCh)) | 2422 | foreach (bool l11 in YP.get_code(NextCh)) |
2423 | { | 2423 | { |
2424 | foreach (bool l12 in read_tokens(NextCh, Dict, Tokens)) | 2424 | foreach (bool l12 in read_tokens(NextCh, Dict, Tokens)) |
2425 | { | 2425 | { |
2426 | yield return false; | 2426 | yield return false; |
2427 | } | 2427 | } |
2428 | } | 2428 | } |
2429 | } | 2429 | } |
2430 | } | 2430 | } |
2431 | yield break; | 2431 | yield break; |
2432 | } | 2432 | } |
2433 | } | 2433 | } |
2434 | } | 2434 | } |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | } | 2437 | } |
2438 | } | 2438 | } |
2439 | } | 2439 | } |
2440 | { | 2440 | { |
2441 | object T = arg3; | 2441 | object T = arg3; |
2442 | Variable C2 = new Variable(); | 2442 | Variable C2 = new Variable(); |
2443 | Variable StartPos = new Variable(); | 2443 | Variable StartPos = new Variable(); |
2444 | Variable EndPos = new Variable(); | 2444 | Variable EndPos = new Variable(); |
2445 | Variable Tokens = new Variable(); | 2445 | Variable Tokens = new Variable(); |
2446 | Variable StartPos1 = new Variable(); | 2446 | Variable StartPos1 = new Variable(); |
2447 | Variable NextCh = new Variable(); | 2447 | Variable NextCh = new Variable(); |
2448 | Variable Chars = new Variable(); | 2448 | Variable Chars = new Variable(); |
2449 | foreach (bool l2 in YP.unify(arg1, 47)) | 2449 | foreach (bool l2 in YP.unify(arg1, 47)) |
2450 | { | 2450 | { |
2451 | foreach (bool l3 in YP.get_code(C2)) | 2451 | foreach (bool l3 in YP.get_code(C2)) |
2452 | { | 2452 | { |
2453 | if (YP.equal(C2, new ListPair(42, Atom.NIL))) | 2453 | if (YP.equal(C2, new ListPair(42, Atom.NIL))) |
2454 | { | 2454 | { |
2455 | foreach (bool l5 in YP.unify(T, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) | 2455 | foreach (bool l5 in YP.unify(T, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) |
2456 | { | 2456 | { |
2457 | foreach (bool l6 in get_current_position(StartPos1)) | 2457 | foreach (bool l6 in get_current_position(StartPos1)) |
2458 | { | 2458 | { |
2459 | foreach (bool l7 in YP.unify(StartPos, YP.subtract(StartPos1, 1))) | 2459 | foreach (bool l7 in YP.unify(StartPos, YP.subtract(StartPos1, 1))) |
2460 | { | 2460 | { |
2461 | foreach (bool l8 in read_solidus(32, NextCh)) | 2461 | foreach (bool l8 in read_solidus(32, NextCh)) |
2462 | { | 2462 | { |
2463 | foreach (bool l9 in get_current_position(EndPos)) | 2463 | foreach (bool l9 in get_current_position(EndPos)) |
2464 | { | 2464 | { |
2465 | foreach (bool l10 in read_tokens(NextCh, Dict, Tokens)) | 2465 | foreach (bool l10 in read_tokens(NextCh, Dict, Tokens)) |
2466 | { | 2466 | { |
2467 | yield return false; | 2467 | yield return false; |
2468 | } | 2468 | } |
2469 | } | 2469 | } |
2470 | } | 2470 | } |
2471 | } | 2471 | } |
2472 | } | 2472 | } |
2473 | } | 2473 | } |
2474 | goto cutIf1; | 2474 | goto cutIf1; |
2475 | } | 2475 | } |
2476 | foreach (bool l4 in YP.unify(T, Tokens)) | 2476 | foreach (bool l4 in YP.unify(T, Tokens)) |
2477 | { | 2477 | { |
2478 | foreach (bool l5 in rest_symbol(C2, Chars, NextCh)) | 2478 | foreach (bool l5 in rest_symbol(C2, Chars, NextCh)) |
2479 | { | 2479 | { |
2480 | foreach (bool l6 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(47, Chars))) | 2480 | foreach (bool l6 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(47, Chars))) |
2481 | { | 2481 | { |
2482 | yield return false; | 2482 | yield return false; |
2483 | } | 2483 | } |
2484 | } | 2484 | } |
2485 | } | 2485 | } |
2486 | cutIf1: | 2486 | cutIf1: |
2487 | { } | 2487 | { } |
2488 | } | 2488 | } |
2489 | } | 2489 | } |
2490 | } | 2490 | } |
2491 | { | 2491 | { |
2492 | Variable Pos = new Variable(); | 2492 | Variable Pos = new Variable(); |
2493 | Variable Tokens = new Variable(); | 2493 | Variable Tokens = new Variable(); |
2494 | Variable NextCh = new Variable(); | 2494 | Variable NextCh = new Variable(); |
2495 | foreach (bool l2 in YP.unify(arg1, 33)) | 2495 | foreach (bool l2 in YP.unify(arg1, 33)) |
2496 | { | 2496 | { |
2497 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@"!"), Pos), Tokens))) | 2497 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@"!"), Pos), Tokens))) |
2498 | { | 2498 | { |
2499 | foreach (bool l4 in get_current_position(Pos)) | 2499 | foreach (bool l4 in get_current_position(Pos)) |
2500 | { | 2500 | { |
2501 | foreach (bool l5 in YP.get_code(NextCh)) | 2501 | foreach (bool l5 in YP.get_code(NextCh)) |
2502 | { | 2502 | { |
2503 | foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens)) | 2503 | foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens)) |
2504 | { | 2504 | { |
2505 | yield return false; | 2505 | yield return false; |
2506 | } | 2506 | } |
2507 | } | 2507 | } |
2508 | } | 2508 | } |
2509 | } | 2509 | } |
2510 | } | 2510 | } |
2511 | } | 2511 | } |
2512 | { | 2512 | { |
2513 | Variable Tokens = new Variable(); | 2513 | Variable Tokens = new Variable(); |
2514 | Variable NextCh = new Variable(); | 2514 | Variable NextCh = new Variable(); |
2515 | foreach (bool l2 in YP.unify(arg1, 40)) | 2515 | foreach (bool l2 in YP.unify(arg1, 40)) |
2516 | { | 2516 | { |
2517 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@" ("), Tokens))) | 2517 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@" ("), Tokens))) |
2518 | { | 2518 | { |
2519 | foreach (bool l4 in YP.get_code(NextCh)) | 2519 | foreach (bool l4 in YP.get_code(NextCh)) |
2520 | { | 2520 | { |
2521 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) | 2521 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) |
2522 | { | 2522 | { |
2523 | yield return false; | 2523 | yield return false; |
2524 | } | 2524 | } |
2525 | } | 2525 | } |
2526 | } | 2526 | } |
2527 | } | 2527 | } |
2528 | } | 2528 | } |
2529 | { | 2529 | { |
2530 | Variable Tokens = new Variable(); | 2530 | Variable Tokens = new Variable(); |
2531 | Variable NextCh = new Variable(); | 2531 | Variable NextCh = new Variable(); |
2532 | foreach (bool l2 in YP.unify(arg1, 41)) | 2532 | foreach (bool l2 in YP.unify(arg1, 41)) |
2533 | { | 2533 | { |
2534 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@")"), Tokens))) | 2534 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@")"), Tokens))) |
2535 | { | 2535 | { |
2536 | foreach (bool l4 in YP.get_code(NextCh)) | 2536 | foreach (bool l4 in YP.get_code(NextCh)) |
2537 | { | 2537 | { |
2538 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) | 2538 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) |
2539 | { | 2539 | { |
2540 | yield return false; | 2540 | yield return false; |
2541 | } | 2541 | } |
2542 | } | 2542 | } |
2543 | } | 2543 | } |
2544 | } | 2544 | } |
2545 | } | 2545 | } |
2546 | { | 2546 | { |
2547 | Variable Tokens = new Variable(); | 2547 | Variable Tokens = new Variable(); |
2548 | Variable NextCh = new Variable(); | 2548 | Variable NextCh = new Variable(); |
2549 | foreach (bool l2 in YP.unify(arg1, 44)) | 2549 | foreach (bool l2 in YP.unify(arg1, 44)) |
2550 | { | 2550 | { |
2551 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@","), Tokens))) | 2551 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@","), Tokens))) |
2552 | { | 2552 | { |
2553 | foreach (bool l4 in YP.get_code(NextCh)) | 2553 | foreach (bool l4 in YP.get_code(NextCh)) |
2554 | { | 2554 | { |
2555 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) | 2555 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) |
2556 | { | 2556 | { |
2557 | yield return false; | 2557 | yield return false; |
2558 | } | 2558 | } |
2559 | } | 2559 | } |
2560 | } | 2560 | } |
2561 | } | 2561 | } |
2562 | } | 2562 | } |
2563 | { | 2563 | { |
2564 | Variable Pos = new Variable(); | 2564 | Variable Pos = new Variable(); |
2565 | Variable Tokens = new Variable(); | 2565 | Variable Tokens = new Variable(); |
2566 | Variable NextCh = new Variable(); | 2566 | Variable NextCh = new Variable(); |
2567 | foreach (bool l2 in YP.unify(arg1, 59)) | 2567 | foreach (bool l2 in YP.unify(arg1, 59)) |
2568 | { | 2568 | { |
2569 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@";"), Pos), Tokens))) | 2569 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@";"), Pos), Tokens))) |
2570 | { | 2570 | { |
2571 | foreach (bool l4 in get_current_position(Pos)) | 2571 | foreach (bool l4 in get_current_position(Pos)) |
2572 | { | 2572 | { |
2573 | foreach (bool l5 in YP.get_code(NextCh)) | 2573 | foreach (bool l5 in YP.get_code(NextCh)) |
2574 | { | 2574 | { |
2575 | foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens)) | 2575 | foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens)) |
2576 | { | 2576 | { |
2577 | yield return false; | 2577 | yield return false; |
2578 | } | 2578 | } |
2579 | } | 2579 | } |
2580 | } | 2580 | } |
2581 | } | 2581 | } |
2582 | } | 2582 | } |
2583 | } | 2583 | } |
2584 | { | 2584 | { |
2585 | Variable Pos = new Variable(); | 2585 | Variable Pos = new Variable(); |
2586 | Variable Tokens = new Variable(); | 2586 | Variable Tokens = new Variable(); |
2587 | Variable NextCh = new Variable(); | 2587 | Variable NextCh = new Variable(); |
2588 | foreach (bool l2 in YP.unify(arg1, 91)) | 2588 | foreach (bool l2 in YP.unify(arg1, 91)) |
2589 | { | 2589 | { |
2590 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Tokens))) | 2590 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Tokens))) |
2591 | { | 2591 | { |
2592 | foreach (bool l4 in get_current_position(Pos)) | 2592 | foreach (bool l4 in get_current_position(Pos)) |
2593 | { | 2593 | { |
2594 | foreach (bool l5 in YP.get_code(NextCh)) | 2594 | foreach (bool l5 in YP.get_code(NextCh)) |
2595 | { | 2595 | { |
2596 | foreach (bool l6 in read_tokens(NextCh, Dict, Tokens)) | 2596 | foreach (bool l6 in read_tokens(NextCh, Dict, Tokens)) |
2597 | { | 2597 | { |
2598 | yield return false; | 2598 | yield return false; |
2599 | } | 2599 | } |
2600 | } | 2600 | } |
2601 | } | 2601 | } |
2602 | } | 2602 | } |
2603 | } | 2603 | } |
2604 | } | 2604 | } |
2605 | { | 2605 | { |
2606 | Variable Pos = new Variable(); | 2606 | Variable Pos = new Variable(); |
2607 | Variable Tokens = new Variable(); | 2607 | Variable Tokens = new Variable(); |
2608 | Variable NextCh = new Variable(); | 2608 | Variable NextCh = new Variable(); |
2609 | foreach (bool l2 in YP.unify(arg1, 93)) | 2609 | foreach (bool l2 in YP.unify(arg1, 93)) |
2610 | { | 2610 | { |
2611 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Tokens))) | 2611 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Tokens))) |
2612 | { | 2612 | { |
2613 | foreach (bool l4 in get_current_position(Pos)) | 2613 | foreach (bool l4 in get_current_position(Pos)) |
2614 | { | 2614 | { |
2615 | foreach (bool l5 in YP.get_code(NextCh)) | 2615 | foreach (bool l5 in YP.get_code(NextCh)) |
2616 | { | 2616 | { |
2617 | foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens)) | 2617 | foreach (bool l6 in read_after_atom(NextCh, Dict, Tokens)) |
2618 | { | 2618 | { |
2619 | yield return false; | 2619 | yield return false; |
2620 | } | 2620 | } |
2621 | } | 2621 | } |
2622 | } | 2622 | } |
2623 | } | 2623 | } |
2624 | } | 2624 | } |
2625 | } | 2625 | } |
2626 | { | 2626 | { |
2627 | Variable Pos = new Variable(); | 2627 | Variable Pos = new Variable(); |
2628 | Variable Tokens = new Variable(); | 2628 | Variable Tokens = new Variable(); |
2629 | Variable NextCh = new Variable(); | 2629 | Variable NextCh = new Variable(); |
2630 | foreach (bool l2 in YP.unify(arg1, 123)) | 2630 | foreach (bool l2 in YP.unify(arg1, 123)) |
2631 | { | 2631 | { |
2632 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"{"), Pos), Tokens))) | 2632 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"{"), Pos), Tokens))) |
2633 | { | 2633 | { |
2634 | foreach (bool l4 in get_current_position(Pos)) | 2634 | foreach (bool l4 in get_current_position(Pos)) |
2635 | { | 2635 | { |
2636 | foreach (bool l5 in YP.get_code(NextCh)) | 2636 | foreach (bool l5 in YP.get_code(NextCh)) |
2637 | { | 2637 | { |
2638 | foreach (bool l6 in read_tokens(NextCh, Dict, Tokens)) | 2638 | foreach (bool l6 in read_tokens(NextCh, Dict, Tokens)) |
2639 | { | 2639 | { |
2640 | yield return false; | 2640 | yield return false; |
2641 | } | 2641 | } |
2642 | } | 2642 | } |
2643 | } | 2643 | } |
2644 | } | 2644 | } |
2645 | } | 2645 | } |
2646 | } | 2646 | } |
2647 | { | 2647 | { |
2648 | Variable Tokens = new Variable(); | 2648 | Variable Tokens = new Variable(); |
2649 | Variable NextCh = new Variable(); | 2649 | Variable NextCh = new Variable(); |
2650 | foreach (bool l2 in YP.unify(arg1, 124)) | 2650 | foreach (bool l2 in YP.unify(arg1, 124)) |
2651 | { | 2651 | { |
2652 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"|"), Tokens))) | 2652 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"|"), Tokens))) |
2653 | { | 2653 | { |
2654 | foreach (bool l4 in YP.get_code(NextCh)) | 2654 | foreach (bool l4 in YP.get_code(NextCh)) |
2655 | { | 2655 | { |
2656 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) | 2656 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) |
2657 | { | 2657 | { |
2658 | yield return false; | 2658 | yield return false; |
2659 | } | 2659 | } |
2660 | } | 2660 | } |
2661 | } | 2661 | } |
2662 | } | 2662 | } |
2663 | } | 2663 | } |
2664 | { | 2664 | { |
2665 | Variable Tokens = new Variable(); | 2665 | Variable Tokens = new Variable(); |
2666 | Variable NextCh = new Variable(); | 2666 | Variable NextCh = new Variable(); |
2667 | foreach (bool l2 in YP.unify(arg1, 125)) | 2667 | foreach (bool l2 in YP.unify(arg1, 125)) |
2668 | { | 2668 | { |
2669 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"}"), Tokens))) | 2669 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"}"), Tokens))) |
2670 | { | 2670 | { |
2671 | foreach (bool l4 in YP.get_code(NextCh)) | 2671 | foreach (bool l4 in YP.get_code(NextCh)) |
2672 | { | 2672 | { |
2673 | foreach (bool l5 in read_after_atom(NextCh, Dict, Tokens)) | 2673 | foreach (bool l5 in read_after_atom(NextCh, Dict, Tokens)) |
2674 | { | 2674 | { |
2675 | yield return false; | 2675 | yield return false; |
2676 | } | 2676 | } |
2677 | } | 2677 | } |
2678 | } | 2678 | } |
2679 | } | 2679 | } |
2680 | } | 2680 | } |
2681 | { | 2681 | { |
2682 | object Tokens = arg3; | 2682 | object Tokens = arg3; |
2683 | Variable NextCh = new Variable(); | 2683 | Variable NextCh = new Variable(); |
2684 | foreach (bool l2 in YP.unify(arg1, 46)) | 2684 | foreach (bool l2 in YP.unify(arg1, 46)) |
2685 | { | 2685 | { |
2686 | foreach (bool l3 in YP.get_code(NextCh)) | 2686 | foreach (bool l3 in YP.get_code(NextCh)) |
2687 | { | 2687 | { |
2688 | foreach (bool l4 in read_fullstop(NextCh, Dict, Tokens)) | 2688 | foreach (bool l4 in read_fullstop(NextCh, Dict, Tokens)) |
2689 | { | 2689 | { |
2690 | yield return false; | 2690 | yield return false; |
2691 | } | 2691 | } |
2692 | } | 2692 | } |
2693 | } | 2693 | } |
2694 | } | 2694 | } |
2695 | { | 2695 | { |
2696 | Variable Chars = new Variable(); | 2696 | Variable Chars = new Variable(); |
2697 | Variable Tokens = new Variable(); | 2697 | Variable Tokens = new Variable(); |
2698 | Variable NextCh = new Variable(); | 2698 | Variable NextCh = new Variable(); |
2699 | foreach (bool l2 in YP.unify(arg1, 34)) | 2699 | foreach (bool l2 in YP.unify(arg1, 34)) |
2700 | { | 2700 | { |
2701 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"string", Chars), Tokens))) | 2701 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"string", Chars), Tokens))) |
2702 | { | 2702 | { |
2703 | foreach (bool l4 in read_string(Chars, 34, NextCh)) | 2703 | foreach (bool l4 in read_string(Chars, 34, NextCh)) |
2704 | { | 2704 | { |
2705 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) | 2705 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) |
2706 | { | 2706 | { |
2707 | yield return false; | 2707 | yield return false; |
2708 | } | 2708 | } |
2709 | } | 2709 | } |
2710 | } | 2710 | } |
2711 | } | 2711 | } |
2712 | } | 2712 | } |
2713 | { | 2713 | { |
2714 | object Tokens = arg3; | 2714 | object Tokens = arg3; |
2715 | Variable Chars = new Variable(); | 2715 | Variable Chars = new Variable(); |
2716 | Variable NextCh = new Variable(); | 2716 | Variable NextCh = new Variable(); |
2717 | foreach (bool l2 in YP.unify(arg1, 39)) | 2717 | foreach (bool l2 in YP.unify(arg1, 39)) |
2718 | { | 2718 | { |
2719 | foreach (bool l3 in read_string(Chars, 39, NextCh)) | 2719 | foreach (bool l3 in read_string(Chars, 39, NextCh)) |
2720 | { | 2720 | { |
2721 | foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, Chars)) | 2721 | foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, Chars)) |
2722 | { | 2722 | { |
2723 | yield return false; | 2723 | yield return false; |
2724 | } | 2724 | } |
2725 | } | 2725 | } |
2726 | } | 2726 | } |
2727 | } | 2727 | } |
2728 | { | 2728 | { |
2729 | object Tokens = arg3; | 2729 | object Tokens = arg3; |
2730 | foreach (bool l2 in YP.unify(arg1, 35)) | 2730 | foreach (bool l2 in YP.unify(arg1, 35)) |
2731 | { | 2731 | { |
2732 | foreach (bool l3 in read_symbol(35, Dict, Tokens)) | 2732 | foreach (bool l3 in read_symbol(35, Dict, Tokens)) |
2733 | { | 2733 | { |
2734 | yield return false; | 2734 | yield return false; |
2735 | } | 2735 | } |
2736 | } | 2736 | } |
2737 | } | 2737 | } |
2738 | { | 2738 | { |
2739 | object Tokens = arg3; | 2739 | object Tokens = arg3; |
2740 | foreach (bool l2 in YP.unify(arg1, 36)) | 2740 | foreach (bool l2 in YP.unify(arg1, 36)) |
2741 | { | 2741 | { |
2742 | foreach (bool l3 in read_symbol(36, Dict, Tokens)) | 2742 | foreach (bool l3 in read_symbol(36, Dict, Tokens)) |
2743 | { | 2743 | { |
2744 | yield return false; | 2744 | yield return false; |
2745 | } | 2745 | } |
2746 | } | 2746 | } |
2747 | } | 2747 | } |
2748 | { | 2748 | { |
2749 | object Tokens = arg3; | 2749 | object Tokens = arg3; |
2750 | foreach (bool l2 in YP.unify(arg1, 38)) | 2750 | foreach (bool l2 in YP.unify(arg1, 38)) |
2751 | { | 2751 | { |
2752 | foreach (bool l3 in read_symbol(38, Dict, Tokens)) | 2752 | foreach (bool l3 in read_symbol(38, Dict, Tokens)) |
2753 | { | 2753 | { |
2754 | yield return false; | 2754 | yield return false; |
2755 | } | 2755 | } |
2756 | } | 2756 | } |
2757 | } | 2757 | } |
2758 | { | 2758 | { |
2759 | object Tokens = arg3; | 2759 | object Tokens = arg3; |
2760 | foreach (bool l2 in YP.unify(arg1, 42)) | 2760 | foreach (bool l2 in YP.unify(arg1, 42)) |
2761 | { | 2761 | { |
2762 | foreach (bool l3 in read_symbol(42, Dict, Tokens)) | 2762 | foreach (bool l3 in read_symbol(42, Dict, Tokens)) |
2763 | { | 2763 | { |
2764 | yield return false; | 2764 | yield return false; |
2765 | } | 2765 | } |
2766 | } | 2766 | } |
2767 | } | 2767 | } |
2768 | { | 2768 | { |
2769 | object Tokens = arg3; | 2769 | object Tokens = arg3; |
2770 | foreach (bool l2 in YP.unify(arg1, 43)) | 2770 | foreach (bool l2 in YP.unify(arg1, 43)) |
2771 | { | 2771 | { |
2772 | foreach (bool l3 in read_symbol(43, Dict, Tokens)) | 2772 | foreach (bool l3 in read_symbol(43, Dict, Tokens)) |
2773 | { | 2773 | { |
2774 | yield return false; | 2774 | yield return false; |
2775 | } | 2775 | } |
2776 | } | 2776 | } |
2777 | } | 2777 | } |
2778 | { | 2778 | { |
2779 | object Tokens = arg3; | 2779 | object Tokens = arg3; |
2780 | foreach (bool l2 in YP.unify(arg1, 45)) | 2780 | foreach (bool l2 in YP.unify(arg1, 45)) |
2781 | { | 2781 | { |
2782 | foreach (bool l3 in read_symbol(45, Dict, Tokens)) | 2782 | foreach (bool l3 in read_symbol(45, Dict, Tokens)) |
2783 | { | 2783 | { |
2784 | yield return false; | 2784 | yield return false; |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | } | 2787 | } |
2788 | { | 2788 | { |
2789 | object Tokens = arg3; | 2789 | object Tokens = arg3; |
2790 | foreach (bool l2 in YP.unify(arg1, 58)) | 2790 | foreach (bool l2 in YP.unify(arg1, 58)) |
2791 | { | 2791 | { |
2792 | foreach (bool l3 in read_symbol(58, Dict, Tokens)) | 2792 | foreach (bool l3 in read_symbol(58, Dict, Tokens)) |
2793 | { | 2793 | { |
2794 | yield return false; | 2794 | yield return false; |
2795 | } | 2795 | } |
2796 | } | 2796 | } |
2797 | } | 2797 | } |
2798 | { | 2798 | { |
2799 | object Tokens = arg3; | 2799 | object Tokens = arg3; |
2800 | foreach (bool l2 in YP.unify(arg1, 60)) | 2800 | foreach (bool l2 in YP.unify(arg1, 60)) |
2801 | { | 2801 | { |
2802 | foreach (bool l3 in read_symbol(60, Dict, Tokens)) | 2802 | foreach (bool l3 in read_symbol(60, Dict, Tokens)) |
2803 | { | 2803 | { |
2804 | yield return false; | 2804 | yield return false; |
2805 | } | 2805 | } |
2806 | } | 2806 | } |
2807 | } | 2807 | } |
2808 | { | 2808 | { |
2809 | object Tokens = arg3; | 2809 | object Tokens = arg3; |
2810 | foreach (bool l2 in YP.unify(arg1, 61)) | 2810 | foreach (bool l2 in YP.unify(arg1, 61)) |
2811 | { | 2811 | { |
2812 | foreach (bool l3 in read_symbol(61, Dict, Tokens)) | 2812 | foreach (bool l3 in read_symbol(61, Dict, Tokens)) |
2813 | { | 2813 | { |
2814 | yield return false; | 2814 | yield return false; |
2815 | } | 2815 | } |
2816 | } | 2816 | } |
2817 | } | 2817 | } |
2818 | { | 2818 | { |
2819 | object Tokens = arg3; | 2819 | object Tokens = arg3; |
2820 | foreach (bool l2 in YP.unify(arg1, 62)) | 2820 | foreach (bool l2 in YP.unify(arg1, 62)) |
2821 | { | 2821 | { |
2822 | foreach (bool l3 in read_symbol(62, Dict, Tokens)) | 2822 | foreach (bool l3 in read_symbol(62, Dict, Tokens)) |
2823 | { | 2823 | { |
2824 | yield return false; | 2824 | yield return false; |
2825 | } | 2825 | } |
2826 | } | 2826 | } |
2827 | } | 2827 | } |
2828 | { | 2828 | { |
2829 | object Tokens = arg3; | 2829 | object Tokens = arg3; |
2830 | foreach (bool l2 in YP.unify(arg1, 63)) | 2830 | foreach (bool l2 in YP.unify(arg1, 63)) |
2831 | { | 2831 | { |
2832 | foreach (bool l3 in read_symbol(63, Dict, Tokens)) | 2832 | foreach (bool l3 in read_symbol(63, Dict, Tokens)) |
2833 | { | 2833 | { |
2834 | yield return false; | 2834 | yield return false; |
2835 | } | 2835 | } |
2836 | } | 2836 | } |
2837 | } | 2837 | } |
2838 | { | 2838 | { |
2839 | object Tokens = arg3; | 2839 | object Tokens = arg3; |
2840 | foreach (bool l2 in YP.unify(arg1, 64)) | 2840 | foreach (bool l2 in YP.unify(arg1, 64)) |
2841 | { | 2841 | { |
2842 | foreach (bool l3 in read_symbol(64, Dict, Tokens)) | 2842 | foreach (bool l3 in read_symbol(64, Dict, Tokens)) |
2843 | { | 2843 | { |
2844 | yield return false; | 2844 | yield return false; |
2845 | } | 2845 | } |
2846 | } | 2846 | } |
2847 | } | 2847 | } |
2848 | { | 2848 | { |
2849 | object Tokens = arg3; | 2849 | object Tokens = arg3; |
2850 | foreach (bool l2 in YP.unify(arg1, 92)) | 2850 | foreach (bool l2 in YP.unify(arg1, 92)) |
2851 | { | 2851 | { |
2852 | foreach (bool l3 in read_symbol(92, Dict, Tokens)) | 2852 | foreach (bool l3 in read_symbol(92, Dict, Tokens)) |
2853 | { | 2853 | { |
2854 | yield return false; | 2854 | yield return false; |
2855 | } | 2855 | } |
2856 | } | 2856 | } |
2857 | } | 2857 | } |
2858 | { | 2858 | { |
2859 | object Tokens = arg3; | 2859 | object Tokens = arg3; |
2860 | foreach (bool l2 in YP.unify(arg1, 94)) | 2860 | foreach (bool l2 in YP.unify(arg1, 94)) |
2861 | { | 2861 | { |
2862 | foreach (bool l3 in read_symbol(94, Dict, Tokens)) | 2862 | foreach (bool l3 in read_symbol(94, Dict, Tokens)) |
2863 | { | 2863 | { |
2864 | yield return false; | 2864 | yield return false; |
2865 | } | 2865 | } |
2866 | } | 2866 | } |
2867 | } | 2867 | } |
2868 | { | 2868 | { |
2869 | object Tokens = arg3; | 2869 | object Tokens = arg3; |
2870 | foreach (bool l2 in YP.unify(arg1, 96)) | 2870 | foreach (bool l2 in YP.unify(arg1, 96)) |
2871 | { | 2871 | { |
2872 | foreach (bool l3 in read_symbol(96, Dict, Tokens)) | 2872 | foreach (bool l3 in read_symbol(96, Dict, Tokens)) |
2873 | { | 2873 | { |
2874 | yield return false; | 2874 | yield return false; |
2875 | } | 2875 | } |
2876 | } | 2876 | } |
2877 | } | 2877 | } |
2878 | { | 2878 | { |
2879 | object Tokens = arg3; | 2879 | object Tokens = arg3; |
2880 | foreach (bool l2 in YP.unify(arg1, 126)) | 2880 | foreach (bool l2 in YP.unify(arg1, 126)) |
2881 | { | 2881 | { |
2882 | foreach (bool l3 in read_symbol(126, Dict, Tokens)) | 2882 | foreach (bool l3 in read_symbol(126, Dict, Tokens)) |
2883 | { | 2883 | { |
2884 | yield return false; | 2884 | yield return false; |
2885 | } | 2885 | } |
2886 | } | 2886 | } |
2887 | } | 2887 | } |
2888 | } | 2888 | } |
2889 | 2889 | ||
2890 | public static IEnumerable<bool> read_symbol(object C1, object Dict, object Tokens) | 2890 | public static IEnumerable<bool> read_symbol(object C1, object Dict, object Tokens) |
2891 | { | 2891 | { |
2892 | { | 2892 | { |
2893 | Variable C2 = new Variable(); | 2893 | Variable C2 = new Variable(); |
2894 | Variable Chars = new Variable(); | 2894 | Variable Chars = new Variable(); |
2895 | Variable NextCh = new Variable(); | 2895 | Variable NextCh = new Variable(); |
2896 | foreach (bool l2 in YP.get_code(C2)) | 2896 | foreach (bool l2 in YP.get_code(C2)) |
2897 | { | 2897 | { |
2898 | foreach (bool l3 in rest_symbol(C2, Chars, NextCh)) | 2898 | foreach (bool l3 in rest_symbol(C2, Chars, NextCh)) |
2899 | { | 2899 | { |
2900 | foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(C1, Chars))) | 2900 | foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(C1, Chars))) |
2901 | { | 2901 | { |
2902 | yield return false; | 2902 | yield return false; |
2903 | } | 2903 | } |
2904 | } | 2904 | } |
2905 | } | 2905 | } |
2906 | } | 2906 | } |
2907 | } | 2907 | } |
2908 | 2908 | ||
2909 | public static IEnumerable<bool> rest_symbol(object arg1, object arg2, object arg3) | 2909 | public static IEnumerable<bool> rest_symbol(object arg1, object arg2, object arg3) |
2910 | { | 2910 | { |
2911 | { | 2911 | { |
2912 | object C2 = arg1; | 2912 | object C2 = arg1; |
2913 | object LastCh = arg3; | 2913 | object LastCh = arg3; |
2914 | Variable Chars = new Variable(); | 2914 | Variable Chars = new Variable(); |
2915 | Variable NextCh = new Variable(); | 2915 | Variable NextCh = new Variable(); |
2916 | foreach (bool l2 in YP.unify(arg2, new ListPair(C2, Chars))) | 2916 | foreach (bool l2 in YP.unify(arg2, new ListPair(C2, Chars))) |
2917 | { | 2917 | { |
2918 | if (YP.greaterThan(C2, 160)) | 2918 | if (YP.greaterThan(C2, 160)) |
2919 | { | 2919 | { |
2920 | if (YP.lessThan(C2, 192)) | 2920 | if (YP.lessThan(C2, 192)) |
2921 | { | 2921 | { |
2922 | if (YP.notEqual(C2, 186)) | 2922 | if (YP.notEqual(C2, 186)) |
2923 | { | 2923 | { |
2924 | if (YP.notEqual(C2, 170)) | 2924 | if (YP.notEqual(C2, 170)) |
2925 | { | 2925 | { |
2926 | foreach (bool l7 in YP.get_code(NextCh)) | 2926 | foreach (bool l7 in YP.get_code(NextCh)) |
2927 | { | 2927 | { |
2928 | foreach (bool l8 in rest_symbol(NextCh, Chars, LastCh)) | 2928 | foreach (bool l8 in rest_symbol(NextCh, Chars, LastCh)) |
2929 | { | 2929 | { |
2930 | yield return false; | 2930 | yield return false; |
2931 | } | 2931 | } |
2932 | } | 2932 | } |
2933 | yield break; | 2933 | yield break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | } | 2936 | } |
2937 | goto cutIf1; | 2937 | goto cutIf1; |
2938 | } | 2938 | } |
2939 | foreach (bool l3 in symbol_char(C2)) | 2939 | foreach (bool l3 in symbol_char(C2)) |
2940 | { | 2940 | { |
2941 | foreach (bool l4 in YP.get_code(NextCh)) | 2941 | foreach (bool l4 in YP.get_code(NextCh)) |
2942 | { | 2942 | { |
2943 | foreach (bool l5 in rest_symbol(NextCh, Chars, LastCh)) | 2943 | foreach (bool l5 in rest_symbol(NextCh, Chars, LastCh)) |
2944 | { | 2944 | { |
2945 | yield return false; | 2945 | yield return false; |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | yield break; | 2948 | yield break; |
2949 | } | 2949 | } |
2950 | cutIf1: | 2950 | cutIf1: |
2951 | { } | 2951 | { } |
2952 | } | 2952 | } |
2953 | } | 2953 | } |
2954 | { | 2954 | { |
2955 | Variable C2 = new Variable(); | 2955 | Variable C2 = new Variable(); |
2956 | foreach (bool l2 in YP.unify(arg1, C2)) | 2956 | foreach (bool l2 in YP.unify(arg1, C2)) |
2957 | { | 2957 | { |
2958 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) | 2958 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) |
2959 | { | 2959 | { |
2960 | foreach (bool l4 in YP.unify(arg3, C2)) | 2960 | foreach (bool l4 in YP.unify(arg3, C2)) |
2961 | { | 2961 | { |
2962 | yield return false; | 2962 | yield return false; |
2963 | } | 2963 | } |
2964 | } | 2964 | } |
2965 | } | 2965 | } |
2966 | } | 2966 | } |
2967 | } | 2967 | } |
2968 | 2968 | ||
2969 | public static IEnumerable<bool> symbol_char(object arg1) | 2969 | public static IEnumerable<bool> symbol_char(object arg1) |
2970 | { | 2970 | { |
2971 | { | 2971 | { |
2972 | foreach (bool l2 in YP.unify(arg1, 35)) | 2972 | foreach (bool l2 in YP.unify(arg1, 35)) |
2973 | { | 2973 | { |
2974 | yield return false; | 2974 | yield return false; |
2975 | } | 2975 | } |
2976 | } | 2976 | } |
2977 | { | 2977 | { |
2978 | foreach (bool l2 in YP.unify(arg1, 36)) | 2978 | foreach (bool l2 in YP.unify(arg1, 36)) |
2979 | { | 2979 | { |
2980 | yield return false; | 2980 | yield return false; |
2981 | } | 2981 | } |
2982 | } | 2982 | } |
2983 | { | 2983 | { |
2984 | foreach (bool l2 in YP.unify(arg1, 38)) | 2984 | foreach (bool l2 in YP.unify(arg1, 38)) |
2985 | { | 2985 | { |
2986 | yield return false; | 2986 | yield return false; |
2987 | } | 2987 | } |
2988 | } | 2988 | } |
2989 | { | 2989 | { |
2990 | foreach (bool l2 in YP.unify(arg1, 42)) | 2990 | foreach (bool l2 in YP.unify(arg1, 42)) |
2991 | { | 2991 | { |
2992 | yield return false; | 2992 | yield return false; |
2993 | } | 2993 | } |
2994 | } | 2994 | } |
2995 | { | 2995 | { |
2996 | foreach (bool l2 in YP.unify(arg1, 43)) | 2996 | foreach (bool l2 in YP.unify(arg1, 43)) |
2997 | { | 2997 | { |
2998 | yield return false; | 2998 | yield return false; |
2999 | } | 2999 | } |
3000 | } | 3000 | } |
3001 | { | 3001 | { |
3002 | foreach (bool l2 in YP.unify(arg1, 45)) | 3002 | foreach (bool l2 in YP.unify(arg1, 45)) |
3003 | { | 3003 | { |
3004 | yield return false; | 3004 | yield return false; |
3005 | } | 3005 | } |
3006 | } | 3006 | } |
3007 | { | 3007 | { |
3008 | foreach (bool l2 in YP.unify(arg1, 46)) | 3008 | foreach (bool l2 in YP.unify(arg1, 46)) |
3009 | { | 3009 | { |
3010 | yield return false; | 3010 | yield return false; |
3011 | } | 3011 | } |
3012 | } | 3012 | } |
3013 | { | 3013 | { |
3014 | foreach (bool l2 in YP.unify(arg1, 47)) | 3014 | foreach (bool l2 in YP.unify(arg1, 47)) |
3015 | { | 3015 | { |
3016 | yield return false; | 3016 | yield return false; |
3017 | } | 3017 | } |
3018 | } | 3018 | } |
3019 | { | 3019 | { |
3020 | foreach (bool l2 in YP.unify(arg1, 58)) | 3020 | foreach (bool l2 in YP.unify(arg1, 58)) |
3021 | { | 3021 | { |
3022 | yield return false; | 3022 | yield return false; |
3023 | } | 3023 | } |
3024 | } | 3024 | } |
3025 | { | 3025 | { |
3026 | foreach (bool l2 in YP.unify(arg1, 60)) | 3026 | foreach (bool l2 in YP.unify(arg1, 60)) |
3027 | { | 3027 | { |
3028 | yield return false; | 3028 | yield return false; |
3029 | } | 3029 | } |
3030 | } | 3030 | } |
3031 | { | 3031 | { |
3032 | foreach (bool l2 in YP.unify(arg1, 61)) | 3032 | foreach (bool l2 in YP.unify(arg1, 61)) |
3033 | { | 3033 | { |
3034 | yield return false; | 3034 | yield return false; |
3035 | } | 3035 | } |
3036 | } | 3036 | } |
3037 | { | 3037 | { |
3038 | foreach (bool l2 in YP.unify(arg1, 62)) | 3038 | foreach (bool l2 in YP.unify(arg1, 62)) |
3039 | { | 3039 | { |
3040 | yield return false; | 3040 | yield return false; |
3041 | } | 3041 | } |
3042 | } | 3042 | } |
3043 | { | 3043 | { |
3044 | foreach (bool l2 in YP.unify(arg1, 63)) | 3044 | foreach (bool l2 in YP.unify(arg1, 63)) |
3045 | { | 3045 | { |
3046 | yield return false; | 3046 | yield return false; |
3047 | } | 3047 | } |
3048 | } | 3048 | } |
3049 | { | 3049 | { |
3050 | foreach (bool l2 in YP.unify(arg1, 64)) | 3050 | foreach (bool l2 in YP.unify(arg1, 64)) |
3051 | { | 3051 | { |
3052 | yield return false; | 3052 | yield return false; |
3053 | } | 3053 | } |
3054 | } | 3054 | } |
3055 | { | 3055 | { |
3056 | foreach (bool l2 in YP.unify(arg1, 92)) | 3056 | foreach (bool l2 in YP.unify(arg1, 92)) |
3057 | { | 3057 | { |
3058 | yield return false; | 3058 | yield return false; |
3059 | } | 3059 | } |
3060 | } | 3060 | } |
3061 | { | 3061 | { |
3062 | foreach (bool l2 in YP.unify(arg1, 94)) | 3062 | foreach (bool l2 in YP.unify(arg1, 94)) |
3063 | { | 3063 | { |
3064 | yield return false; | 3064 | yield return false; |
3065 | } | 3065 | } |
3066 | } | 3066 | } |
3067 | { | 3067 | { |
3068 | foreach (bool l2 in YP.unify(arg1, 96)) | 3068 | foreach (bool l2 in YP.unify(arg1, 96)) |
3069 | { | 3069 | { |
3070 | yield return false; | 3070 | yield return false; |
3071 | } | 3071 | } |
3072 | } | 3072 | } |
3073 | { | 3073 | { |
3074 | foreach (bool l2 in YP.unify(arg1, 126)) | 3074 | foreach (bool l2 in YP.unify(arg1, 126)) |
3075 | { | 3075 | { |
3076 | yield return false; | 3076 | yield return false; |
3077 | } | 3077 | } |
3078 | } | 3078 | } |
3079 | } | 3079 | } |
3080 | 3080 | ||
3081 | public static IEnumerable<bool> get_current_position(object Pos) | 3081 | public static IEnumerable<bool> get_current_position(object Pos) |
3082 | { | 3082 | { |
3083 | { | 3083 | { |
3084 | foreach (bool l2 in YP.unify(Pos, 0)) | 3084 | foreach (bool l2 in YP.unify(Pos, 0)) |
3085 | { | 3085 | { |
3086 | yield return false; | 3086 | yield return false; |
3087 | } | 3087 | } |
3088 | } | 3088 | } |
3089 | } | 3089 | } |
3090 | 3090 | ||
3091 | public static IEnumerable<bool> read_after_atom4(object Ch, object Dict, object arg3, object Chars) | 3091 | public static IEnumerable<bool> read_after_atom4(object Ch, object Dict, object arg3, object Chars) |
3092 | { | 3092 | { |
3093 | { | 3093 | { |
3094 | Variable Atom_1 = new Variable(); | 3094 | Variable Atom_1 = new Variable(); |
3095 | Variable Pos = new Variable(); | 3095 | Variable Pos = new Variable(); |
3096 | Variable Tokens = new Variable(); | 3096 | Variable Tokens = new Variable(); |
3097 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom_1, Pos), Tokens))) | 3097 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom_1, Pos), Tokens))) |
3098 | { | 3098 | { |
3099 | foreach (bool l3 in YP.unify(Pos, 0)) | 3099 | foreach (bool l3 in YP.unify(Pos, 0)) |
3100 | { | 3100 | { |
3101 | foreach (bool l4 in YP.atom_codes(Atom_1, Chars)) | 3101 | foreach (bool l4 in YP.atom_codes(Atom_1, Chars)) |
3102 | { | 3102 | { |
3103 | foreach (bool l5 in read_after_atom(Ch, Dict, Tokens)) | 3103 | foreach (bool l5 in read_after_atom(Ch, Dict, Tokens)) |
3104 | { | 3104 | { |
3105 | yield return false; | 3105 | yield return false; |
3106 | } | 3106 | } |
3107 | } | 3107 | } |
3108 | } | 3108 | } |
3109 | } | 3109 | } |
3110 | } | 3110 | } |
3111 | } | 3111 | } |
3112 | 3112 | ||
3113 | public static IEnumerable<bool> read_after_atom(object arg1, object Dict, object arg3) | 3113 | public static IEnumerable<bool> read_after_atom(object arg1, object Dict, object arg3) |
3114 | { | 3114 | { |
3115 | { | 3115 | { |
3116 | Variable Tokens = new Variable(); | 3116 | Variable Tokens = new Variable(); |
3117 | Variable NextCh = new Variable(); | 3117 | Variable NextCh = new Variable(); |
3118 | foreach (bool l2 in YP.unify(arg1, 40)) | 3118 | foreach (bool l2 in YP.unify(arg1, 40)) |
3119 | { | 3119 | { |
3120 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"("), Tokens))) | 3120 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"("), Tokens))) |
3121 | { | 3121 | { |
3122 | foreach (bool l4 in YP.get_code(NextCh)) | 3122 | foreach (bool l4 in YP.get_code(NextCh)) |
3123 | { | 3123 | { |
3124 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) | 3124 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) |
3125 | { | 3125 | { |
3126 | yield return false; | 3126 | yield return false; |
3127 | } | 3127 | } |
3128 | } | 3128 | } |
3129 | yield break; | 3129 | yield break; |
3130 | } | 3130 | } |
3131 | } | 3131 | } |
3132 | } | 3132 | } |
3133 | { | 3133 | { |
3134 | object Ch = arg1; | 3134 | object Ch = arg1; |
3135 | object Tokens = arg3; | 3135 | object Tokens = arg3; |
3136 | foreach (bool l2 in read_tokens(Ch, Dict, Tokens)) | 3136 | foreach (bool l2 in read_tokens(Ch, Dict, Tokens)) |
3137 | { | 3137 | { |
3138 | yield return false; | 3138 | yield return false; |
3139 | } | 3139 | } |
3140 | } | 3140 | } |
3141 | } | 3141 | } |
3142 | 3142 | ||
3143 | public static IEnumerable<bool> read_string(object Chars, object Quote, object NextCh) | 3143 | public static IEnumerable<bool> read_string(object Chars, object Quote, object NextCh) |
3144 | { | 3144 | { |
3145 | { | 3145 | { |
3146 | Variable Ch = new Variable(); | 3146 | Variable Ch = new Variable(); |
3147 | Variable Char = new Variable(); | 3147 | Variable Char = new Variable(); |
3148 | Variable Next = new Variable(); | 3148 | Variable Next = new Variable(); |
3149 | foreach (bool l2 in YP.get_code(Ch)) | 3149 | foreach (bool l2 in YP.get_code(Ch)) |
3150 | { | 3150 | { |
3151 | foreach (bool l3 in read_char(Ch, Quote, Char, Next)) | 3151 | foreach (bool l3 in read_char(Ch, Quote, Char, Next)) |
3152 | { | 3152 | { |
3153 | foreach (bool l4 in rest_string5(Char, Next, Chars, Quote, NextCh)) | 3153 | foreach (bool l4 in rest_string5(Char, Next, Chars, Quote, NextCh)) |
3154 | { | 3154 | { |
3155 | yield return false; | 3155 | yield return false; |
3156 | } | 3156 | } |
3157 | } | 3157 | } |
3158 | } | 3158 | } |
3159 | } | 3159 | } |
3160 | } | 3160 | } |
3161 | 3161 | ||
3162 | public static IEnumerable<bool> rest_string5(object arg1, object arg2, object arg3, object arg4, object arg5) | 3162 | public static IEnumerable<bool> rest_string5(object arg1, object arg2, object arg3, object arg4, object arg5) |
3163 | { | 3163 | { |
3164 | { | 3164 | { |
3165 | object _X = arg4; | 3165 | object _X = arg4; |
3166 | Variable NextCh = new Variable(); | 3166 | Variable NextCh = new Variable(); |
3167 | foreach (bool l2 in YP.unify(arg1, -1)) | 3167 | foreach (bool l2 in YP.unify(arg1, -1)) |
3168 | { | 3168 | { |
3169 | foreach (bool l3 in YP.unify(arg2, NextCh)) | 3169 | foreach (bool l3 in YP.unify(arg2, NextCh)) |
3170 | { | 3170 | { |
3171 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) | 3171 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) |
3172 | { | 3172 | { |
3173 | foreach (bool l5 in YP.unify(arg5, NextCh)) | 3173 | foreach (bool l5 in YP.unify(arg5, NextCh)) |
3174 | { | 3174 | { |
3175 | yield return true; | 3175 | yield return true; |
3176 | yield break; | 3176 | yield break; |
3177 | } | 3177 | } |
3178 | } | 3178 | } |
3179 | } | 3179 | } |
3180 | } | 3180 | } |
3181 | } | 3181 | } |
3182 | { | 3182 | { |
3183 | object Char = arg1; | 3183 | object Char = arg1; |
3184 | object Next = arg2; | 3184 | object Next = arg2; |
3185 | object Quote = arg4; | 3185 | object Quote = arg4; |
3186 | object NextCh = arg5; | 3186 | object NextCh = arg5; |
3187 | Variable Chars = new Variable(); | 3187 | Variable Chars = new Variable(); |
3188 | Variable Char2 = new Variable(); | 3188 | Variable Char2 = new Variable(); |
3189 | Variable Next2 = new Variable(); | 3189 | Variable Next2 = new Variable(); |
3190 | foreach (bool l2 in YP.unify(arg3, new ListPair(Char, Chars))) | 3190 | foreach (bool l2 in YP.unify(arg3, new ListPair(Char, Chars))) |
3191 | { | 3191 | { |
3192 | foreach (bool l3 in read_char(Next, Quote, Char2, Next2)) | 3192 | foreach (bool l3 in read_char(Next, Quote, Char2, Next2)) |
3193 | { | 3193 | { |
3194 | foreach (bool l4 in rest_string5(Char2, Next2, Chars, Quote, NextCh)) | 3194 | foreach (bool l4 in rest_string5(Char2, Next2, Chars, Quote, NextCh)) |
3195 | { | 3195 | { |
3196 | yield return false; | 3196 | yield return false; |
3197 | } | 3197 | } |
3198 | } | 3198 | } |
3199 | } | 3199 | } |
3200 | } | 3200 | } |
3201 | } | 3201 | } |
3202 | 3202 | ||
3203 | public static IEnumerable<bool> escape_char(object arg1, object arg2) | 3203 | public static IEnumerable<bool> escape_char(object arg1, object arg2) |
3204 | { | 3204 | { |
3205 | { | 3205 | { |
3206 | foreach (bool l2 in YP.unify(arg1, 110)) | 3206 | foreach (bool l2 in YP.unify(arg1, 110)) |
3207 | { | 3207 | { |
3208 | foreach (bool l3 in YP.unify(arg2, 10)) | 3208 | foreach (bool l3 in YP.unify(arg2, 10)) |
3209 | { | 3209 | { |
3210 | yield return false; | 3210 | yield return false; |
3211 | } | 3211 | } |
3212 | } | 3212 | } |
3213 | } | 3213 | } |
3214 | { | 3214 | { |
3215 | foreach (bool l2 in YP.unify(arg1, 78)) | 3215 | foreach (bool l2 in YP.unify(arg1, 78)) |
3216 | { | 3216 | { |
3217 | foreach (bool l3 in YP.unify(arg2, 10)) | 3217 | foreach (bool l3 in YP.unify(arg2, 10)) |
3218 | { | 3218 | { |
3219 | yield return false; | 3219 | yield return false; |
3220 | } | 3220 | } |
3221 | } | 3221 | } |
3222 | } | 3222 | } |
3223 | { | 3223 | { |
3224 | foreach (bool l2 in YP.unify(arg1, 116)) | 3224 | foreach (bool l2 in YP.unify(arg1, 116)) |
3225 | { | 3225 | { |
3226 | foreach (bool l3 in YP.unify(arg2, 9)) | 3226 | foreach (bool l3 in YP.unify(arg2, 9)) |
3227 | { | 3227 | { |
3228 | yield return false; | 3228 | yield return false; |
3229 | } | 3229 | } |
3230 | } | 3230 | } |
3231 | } | 3231 | } |
3232 | { | 3232 | { |
3233 | foreach (bool l2 in YP.unify(arg1, 84)) | 3233 | foreach (bool l2 in YP.unify(arg1, 84)) |
3234 | { | 3234 | { |
3235 | foreach (bool l3 in YP.unify(arg2, 9)) | 3235 | foreach (bool l3 in YP.unify(arg2, 9)) |
3236 | { | 3236 | { |
3237 | yield return false; | 3237 | yield return false; |
3238 | } | 3238 | } |
3239 | } | 3239 | } |
3240 | } | 3240 | } |
3241 | { | 3241 | { |
3242 | foreach (bool l2 in YP.unify(arg1, 114)) | 3242 | foreach (bool l2 in YP.unify(arg1, 114)) |
3243 | { | 3243 | { |
3244 | foreach (bool l3 in YP.unify(arg2, 13)) | 3244 | foreach (bool l3 in YP.unify(arg2, 13)) |
3245 | { | 3245 | { |
3246 | yield return false; | 3246 | yield return false; |
3247 | } | 3247 | } |
3248 | } | 3248 | } |
3249 | } | 3249 | } |
3250 | { | 3250 | { |
3251 | foreach (bool l2 in YP.unify(arg1, 82)) | 3251 | foreach (bool l2 in YP.unify(arg1, 82)) |
3252 | { | 3252 | { |
3253 | foreach (bool l3 in YP.unify(arg2, 13)) | 3253 | foreach (bool l3 in YP.unify(arg2, 13)) |
3254 | { | 3254 | { |
3255 | yield return false; | 3255 | yield return false; |
3256 | } | 3256 | } |
3257 | } | 3257 | } |
3258 | } | 3258 | } |
3259 | { | 3259 | { |
3260 | foreach (bool l2 in YP.unify(arg1, 118)) | 3260 | foreach (bool l2 in YP.unify(arg1, 118)) |
3261 | { | 3261 | { |
3262 | foreach (bool l3 in YP.unify(arg2, 11)) | 3262 | foreach (bool l3 in YP.unify(arg2, 11)) |
3263 | { | 3263 | { |
3264 | yield return false; | 3264 | yield return false; |
3265 | } | 3265 | } |
3266 | } | 3266 | } |
3267 | } | 3267 | } |
3268 | { | 3268 | { |
3269 | foreach (bool l2 in YP.unify(arg1, 86)) | 3269 | foreach (bool l2 in YP.unify(arg1, 86)) |
3270 | { | 3270 | { |
3271 | foreach (bool l3 in YP.unify(arg2, 11)) | 3271 | foreach (bool l3 in YP.unify(arg2, 11)) |
3272 | { | 3272 | { |
3273 | yield return false; | 3273 | yield return false; |
3274 | } | 3274 | } |
3275 | } | 3275 | } |
3276 | } | 3276 | } |
3277 | { | 3277 | { |
3278 | foreach (bool l2 in YP.unify(arg1, 98)) | 3278 | foreach (bool l2 in YP.unify(arg1, 98)) |
3279 | { | 3279 | { |
3280 | foreach (bool l3 in YP.unify(arg2, 8)) | 3280 | foreach (bool l3 in YP.unify(arg2, 8)) |
3281 | { | 3281 | { |
3282 | yield return false; | 3282 | yield return false; |
3283 | } | 3283 | } |
3284 | } | 3284 | } |
3285 | } | 3285 | } |
3286 | { | 3286 | { |
3287 | foreach (bool l2 in YP.unify(arg1, 66)) | 3287 | foreach (bool l2 in YP.unify(arg1, 66)) |
3288 | { | 3288 | { |
3289 | foreach (bool l3 in YP.unify(arg2, 8)) | 3289 | foreach (bool l3 in YP.unify(arg2, 8)) |
3290 | { | 3290 | { |
3291 | yield return false; | 3291 | yield return false; |
3292 | } | 3292 | } |
3293 | } | 3293 | } |
3294 | } | 3294 | } |
3295 | { | 3295 | { |
3296 | foreach (bool l2 in YP.unify(arg1, 102)) | 3296 | foreach (bool l2 in YP.unify(arg1, 102)) |
3297 | { | 3297 | { |
3298 | foreach (bool l3 in YP.unify(arg2, 12)) | 3298 | foreach (bool l3 in YP.unify(arg2, 12)) |
3299 | { | 3299 | { |
3300 | yield return false; | 3300 | yield return false; |
3301 | } | 3301 | } |
3302 | } | 3302 | } |
3303 | } | 3303 | } |
3304 | { | 3304 | { |
3305 | foreach (bool l2 in YP.unify(arg1, 70)) | 3305 | foreach (bool l2 in YP.unify(arg1, 70)) |
3306 | { | 3306 | { |
3307 | foreach (bool l3 in YP.unify(arg2, 12)) | 3307 | foreach (bool l3 in YP.unify(arg2, 12)) |
3308 | { | 3308 | { |
3309 | yield return false; | 3309 | yield return false; |
3310 | } | 3310 | } |
3311 | } | 3311 | } |
3312 | } | 3312 | } |
3313 | { | 3313 | { |
3314 | foreach (bool l2 in YP.unify(arg1, 101)) | 3314 | foreach (bool l2 in YP.unify(arg1, 101)) |
3315 | { | 3315 | { |
3316 | foreach (bool l3 in YP.unify(arg2, 27)) | 3316 | foreach (bool l3 in YP.unify(arg2, 27)) |
3317 | { | 3317 | { |
3318 | yield return false; | 3318 | yield return false; |
3319 | } | 3319 | } |
3320 | } | 3320 | } |
3321 | } | 3321 | } |
3322 | { | 3322 | { |
3323 | foreach (bool l2 in YP.unify(arg1, 69)) | 3323 | foreach (bool l2 in YP.unify(arg1, 69)) |
3324 | { | 3324 | { |
3325 | foreach (bool l3 in YP.unify(arg2, 27)) | 3325 | foreach (bool l3 in YP.unify(arg2, 27)) |
3326 | { | 3326 | { |
3327 | yield return false; | 3327 | yield return false; |
3328 | } | 3328 | } |
3329 | } | 3329 | } |
3330 | } | 3330 | } |
3331 | { | 3331 | { |
3332 | foreach (bool l2 in YP.unify(arg1, 100)) | 3332 | foreach (bool l2 in YP.unify(arg1, 100)) |
3333 | { | 3333 | { |
3334 | foreach (bool l3 in YP.unify(arg2, 127)) | 3334 | foreach (bool l3 in YP.unify(arg2, 127)) |
3335 | { | 3335 | { |
3336 | yield return false; | 3336 | yield return false; |
3337 | } | 3337 | } |
3338 | } | 3338 | } |
3339 | } | 3339 | } |
3340 | { | 3340 | { |
3341 | foreach (bool l2 in YP.unify(arg1, 68)) | 3341 | foreach (bool l2 in YP.unify(arg1, 68)) |
3342 | { | 3342 | { |
3343 | foreach (bool l3 in YP.unify(arg2, 127)) | 3343 | foreach (bool l3 in YP.unify(arg2, 127)) |
3344 | { | 3344 | { |
3345 | yield return false; | 3345 | yield return false; |
3346 | } | 3346 | } |
3347 | } | 3347 | } |
3348 | } | 3348 | } |
3349 | { | 3349 | { |
3350 | foreach (bool l2 in YP.unify(arg1, 115)) | 3350 | foreach (bool l2 in YP.unify(arg1, 115)) |
3351 | { | 3351 | { |
3352 | foreach (bool l3 in YP.unify(arg2, 32)) | 3352 | foreach (bool l3 in YP.unify(arg2, 32)) |
3353 | { | 3353 | { |
3354 | yield return false; | 3354 | yield return false; |
3355 | } | 3355 | } |
3356 | } | 3356 | } |
3357 | } | 3357 | } |
3358 | { | 3358 | { |
3359 | foreach (bool l2 in YP.unify(arg1, 83)) | 3359 | foreach (bool l2 in YP.unify(arg1, 83)) |
3360 | { | 3360 | { |
3361 | foreach (bool l3 in YP.unify(arg2, 32)) | 3361 | foreach (bool l3 in YP.unify(arg2, 32)) |
3362 | { | 3362 | { |
3363 | yield return false; | 3363 | yield return false; |
3364 | } | 3364 | } |
3365 | } | 3365 | } |
3366 | } | 3366 | } |
3367 | { | 3367 | { |
3368 | foreach (bool l2 in YP.unify(arg1, 122)) | 3368 | foreach (bool l2 in YP.unify(arg1, 122)) |
3369 | { | 3369 | { |
3370 | foreach (bool l3 in YP.unify(arg2, -1)) | 3370 | foreach (bool l3 in YP.unify(arg2, -1)) |
3371 | { | 3371 | { |
3372 | yield return false; | 3372 | yield return false; |
3373 | } | 3373 | } |
3374 | } | 3374 | } |
3375 | } | 3375 | } |
3376 | { | 3376 | { |
3377 | foreach (bool l2 in YP.unify(arg1, 90)) | 3377 | foreach (bool l2 in YP.unify(arg1, 90)) |
3378 | { | 3378 | { |
3379 | foreach (bool l3 in YP.unify(arg2, -1)) | 3379 | foreach (bool l3 in YP.unify(arg2, -1)) |
3380 | { | 3380 | { |
3381 | yield return false; | 3381 | yield return false; |
3382 | } | 3382 | } |
3383 | } | 3383 | } |
3384 | } | 3384 | } |
3385 | } | 3385 | } |
3386 | 3386 | ||
3387 | public static IEnumerable<bool> read_variable(object C1, object Dict, object arg3) | 3387 | public static IEnumerable<bool> read_variable(object C1, object Dict, object arg3) |
3388 | { | 3388 | { |
3389 | { | 3389 | { |
3390 | Variable Var = new Variable(); | 3390 | Variable Var = new Variable(); |
3391 | Variable Name = new Variable(); | 3391 | Variable Name = new Variable(); |
3392 | Variable StartPos = new Variable(); | 3392 | Variable StartPos = new Variable(); |
3393 | Variable Tokens = new Variable(); | 3393 | Variable Tokens = new Variable(); |
3394 | Variable Chars = new Variable(); | 3394 | Variable Chars = new Variable(); |
3395 | Variable NextCh = new Variable(); | 3395 | Variable NextCh = new Variable(); |
3396 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3(@"var", Var, Name, StartPos), Tokens))) | 3396 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3(@"var", Var, Name, StartPos), Tokens))) |
3397 | { | 3397 | { |
3398 | foreach (bool l3 in get_current_position(StartPos)) | 3398 | foreach (bool l3 in get_current_position(StartPos)) |
3399 | { | 3399 | { |
3400 | foreach (bool l4 in read_name(C1, Chars, NextCh)) | 3400 | foreach (bool l4 in read_name(C1, Chars, NextCh)) |
3401 | { | 3401 | { |
3402 | foreach (bool l5 in YP.atom_codes(Name, Chars)) | 3402 | foreach (bool l5 in YP.atom_codes(Name, Chars)) |
3403 | { | 3403 | { |
3404 | if (YP.termEqual(Name, Atom.a(@"_"))) | 3404 | if (YP.termEqual(Name, Atom.a(@"_"))) |
3405 | { | 3405 | { |
3406 | foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens)) | 3406 | foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens)) |
3407 | { | 3407 | { |
3408 | yield return false; | 3408 | yield return false; |
3409 | } | 3409 | } |
3410 | goto cutIf1; | 3410 | goto cutIf1; |
3411 | } | 3411 | } |
3412 | foreach (bool l6 in read_lookup(Dict, Name, Var)) | 3412 | foreach (bool l6 in read_lookup(Dict, Name, Var)) |
3413 | { | 3413 | { |
3414 | foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens)) | 3414 | foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens)) |
3415 | { | 3415 | { |
3416 | yield return false; | 3416 | yield return false; |
3417 | } | 3417 | } |
3418 | } | 3418 | } |
3419 | cutIf1: | 3419 | cutIf1: |
3420 | { } | 3420 | { } |
3421 | } | 3421 | } |
3422 | } | 3422 | } |
3423 | } | 3423 | } |
3424 | } | 3424 | } |
3425 | } | 3425 | } |
3426 | } | 3426 | } |
3427 | 3427 | ||
3428 | public static IEnumerable<bool> read_lookup(object arg1, object Name, object Var) | 3428 | public static IEnumerable<bool> read_lookup(object arg1, object Name, object Var) |
3429 | { | 3429 | { |
3430 | { | 3430 | { |
3431 | Variable N = new Variable(); | 3431 | Variable N = new Variable(); |
3432 | Variable V = new Variable(); | 3432 | Variable V = new Variable(); |
3433 | Variable L = new Variable(); | 3433 | Variable L = new Variable(); |
3434 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", N, V), L))) | 3434 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", N, V), L))) |
3435 | { | 3435 | { |
3436 | foreach (bool l3 in YP.unify(N, Name)) | 3436 | foreach (bool l3 in YP.unify(N, Name)) |
3437 | { | 3437 | { |
3438 | foreach (bool l4 in YP.unify(V, Var)) | 3438 | foreach (bool l4 in YP.unify(V, Var)) |
3439 | { | 3439 | { |
3440 | yield return false; | 3440 | yield return false; |
3441 | } | 3441 | } |
3442 | goto cutIf1; | 3442 | goto cutIf1; |
3443 | } | 3443 | } |
3444 | foreach (bool l3 in read_lookup(L, Name, Var)) | 3444 | foreach (bool l3 in read_lookup(L, Name, Var)) |
3445 | { | 3445 | { |
3446 | yield return false; | 3446 | yield return false; |
3447 | } | 3447 | } |
3448 | cutIf1: | 3448 | cutIf1: |
3449 | { } | 3449 | { } |
3450 | } | 3450 | } |
3451 | } | 3451 | } |
3452 | } | 3452 | } |
3453 | 3453 | ||
3454 | public static IEnumerable<bool> read_solidus(object Ch, object LastCh) | 3454 | public static IEnumerable<bool> read_solidus(object Ch, object LastCh) |
3455 | { | 3455 | { |
3456 | { | 3456 | { |
3457 | Variable NextCh = new Variable(); | 3457 | Variable NextCh = new Variable(); |
3458 | if (YP.equal(Ch, 42)) | 3458 | if (YP.equal(Ch, 42)) |
3459 | { | 3459 | { |
3460 | foreach (bool l3 in YP.get_code(NextCh)) | 3460 | foreach (bool l3 in YP.get_code(NextCh)) |
3461 | { | 3461 | { |
3462 | if (YP.equal(NextCh, 47)) | 3462 | if (YP.equal(NextCh, 47)) |
3463 | { | 3463 | { |
3464 | foreach (bool l5 in YP.get_code(LastCh)) | 3464 | foreach (bool l5 in YP.get_code(LastCh)) |
3465 | { | 3465 | { |
3466 | yield return false; | 3466 | yield return false; |
3467 | } | 3467 | } |
3468 | goto cutIf2; | 3468 | goto cutIf2; |
3469 | } | 3469 | } |
3470 | foreach (bool l4 in read_solidus(NextCh, LastCh)) | 3470 | foreach (bool l4 in read_solidus(NextCh, LastCh)) |
3471 | { | 3471 | { |
3472 | yield return false; | 3472 | yield return false; |
3473 | } | 3473 | } |
3474 | cutIf2: | 3474 | cutIf2: |
3475 | { } | 3475 | { } |
3476 | } | 3476 | } |
3477 | goto cutIf1; | 3477 | goto cutIf1; |
3478 | } | 3478 | } |
3479 | if (YP.notEqual(Ch, -1)) | 3479 | if (YP.notEqual(Ch, -1)) |
3480 | { | 3480 | { |
3481 | foreach (bool l3 in YP.get_code(NextCh)) | 3481 | foreach (bool l3 in YP.get_code(NextCh)) |
3482 | { | 3482 | { |
3483 | foreach (bool l4 in read_solidus(NextCh, LastCh)) | 3483 | foreach (bool l4 in read_solidus(NextCh, LastCh)) |
3484 | { | 3484 | { |
3485 | yield return false; | 3485 | yield return false; |
3486 | } | 3486 | } |
3487 | } | 3487 | } |
3488 | goto cutIf3; | 3488 | goto cutIf3; |
3489 | } | 3489 | } |
3490 | foreach (bool l2 in YP.unify(LastCh, Ch)) | 3490 | foreach (bool l2 in YP.unify(LastCh, Ch)) |
3491 | { | 3491 | { |
3492 | foreach (bool l3 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in /*comment~n"), Atom.NIL)) | 3492 | foreach (bool l3 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in /*comment~n"), Atom.NIL)) |
3493 | { | 3493 | { |
3494 | yield return false; | 3494 | yield return false; |
3495 | } | 3495 | } |
3496 | } | 3496 | } |
3497 | cutIf3: | 3497 | cutIf3: |
3498 | cutIf1: | 3498 | cutIf1: |
3499 | { } | 3499 | { } |
3500 | } | 3500 | } |
3501 | } | 3501 | } |
3502 | 3502 | ||
3503 | public static IEnumerable<bool> read_identifier(object C1, object Dict, object Tokens) | 3503 | public static IEnumerable<bool> read_identifier(object C1, object Dict, object Tokens) |
3504 | { | 3504 | { |
3505 | { | 3505 | { |
3506 | Variable Chars = new Variable(); | 3506 | Variable Chars = new Variable(); |
3507 | Variable NextCh = new Variable(); | 3507 | Variable NextCh = new Variable(); |
3508 | foreach (bool l2 in read_name(C1, Chars, NextCh)) | 3508 | foreach (bool l2 in read_name(C1, Chars, NextCh)) |
3509 | { | 3509 | { |
3510 | foreach (bool l3 in read_after_atom4(NextCh, Dict, Tokens, Chars)) | 3510 | foreach (bool l3 in read_after_atom4(NextCh, Dict, Tokens, Chars)) |
3511 | { | 3511 | { |
3512 | yield return false; | 3512 | yield return false; |
3513 | } | 3513 | } |
3514 | } | 3514 | } |
3515 | } | 3515 | } |
3516 | } | 3516 | } |
3517 | 3517 | ||
3518 | public static IEnumerable<bool> read_name(object C1, object arg2, object LastCh) | 3518 | public static IEnumerable<bool> read_name(object C1, object arg2, object LastCh) |
3519 | { | 3519 | { |
3520 | { | 3520 | { |
3521 | Variable Chars = new Variable(); | 3521 | Variable Chars = new Variable(); |
3522 | Variable C2 = new Variable(); | 3522 | Variable C2 = new Variable(); |
3523 | foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars))) | 3523 | foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars))) |
3524 | { | 3524 | { |
3525 | foreach (bool l3 in YP.get_code(C2)) | 3525 | foreach (bool l3 in YP.get_code(C2)) |
3526 | { | 3526 | { |
3527 | if (YP.greaterThanOrEqual(C2, new ListPair(97, Atom.NIL))) | 3527 | if (YP.greaterThanOrEqual(C2, new ListPair(97, Atom.NIL))) |
3528 | { | 3528 | { |
3529 | if (YP.lessThanOrEqual(C2, new ListPair(122, Atom.NIL))) | 3529 | if (YP.lessThanOrEqual(C2, new ListPair(122, Atom.NIL))) |
3530 | { | 3530 | { |
3531 | foreach (bool l6 in read_name(C2, Chars, LastCh)) | 3531 | foreach (bool l6 in read_name(C2, Chars, LastCh)) |
3532 | { | 3532 | { |
3533 | yield return false; | 3533 | yield return false; |
3534 | } | 3534 | } |
3535 | goto cutIf2; | 3535 | goto cutIf2; |
3536 | } | 3536 | } |
3537 | if (YP.lessThan(C2, 192)) | 3537 | if (YP.lessThan(C2, 192)) |
3538 | { | 3538 | { |
3539 | if (YP.notEqual(YP.bitwiseOr(C2, 16), 186)) | 3539 | if (YP.notEqual(YP.bitwiseOr(C2, 16), 186)) |
3540 | { | 3540 | { |
3541 | foreach (bool l7 in YP.unify(Chars, Atom.NIL)) | 3541 | foreach (bool l7 in YP.unify(Chars, Atom.NIL)) |
3542 | { | 3542 | { |
3543 | foreach (bool l8 in YP.unify(LastCh, C2)) | 3543 | foreach (bool l8 in YP.unify(LastCh, C2)) |
3544 | { | 3544 | { |
3545 | yield return false; | 3545 | yield return false; |
3546 | } | 3546 | } |
3547 | } | 3547 | } |
3548 | goto cutIf3; | 3548 | goto cutIf3; |
3549 | } | 3549 | } |
3550 | } | 3550 | } |
3551 | if (YP.equal(YP.bitwiseOr(C2, 32), 247)) | 3551 | if (YP.equal(YP.bitwiseOr(C2, 32), 247)) |
3552 | { | 3552 | { |
3553 | foreach (bool l6 in YP.unify(Chars, Atom.NIL)) | 3553 | foreach (bool l6 in YP.unify(Chars, Atom.NIL)) |
3554 | { | 3554 | { |
3555 | foreach (bool l7 in YP.unify(LastCh, C2)) | 3555 | foreach (bool l7 in YP.unify(LastCh, C2)) |
3556 | { | 3556 | { |
3557 | yield return false; | 3557 | yield return false; |
3558 | } | 3558 | } |
3559 | } | 3559 | } |
3560 | goto cutIf4; | 3560 | goto cutIf4; |
3561 | } | 3561 | } |
3562 | foreach (bool l5 in read_name(C2, Chars, LastCh)) | 3562 | foreach (bool l5 in read_name(C2, Chars, LastCh)) |
3563 | { | 3563 | { |
3564 | yield return false; | 3564 | yield return false; |
3565 | } | 3565 | } |
3566 | cutIf4: | 3566 | cutIf4: |
3567 | cutIf3: | 3567 | cutIf3: |
3568 | cutIf2: | 3568 | cutIf2: |
3569 | goto cutIf1; | 3569 | goto cutIf1; |
3570 | } | 3570 | } |
3571 | if (YP.greaterThanOrEqual(C2, new ListPair(65, Atom.NIL))) | 3571 | if (YP.greaterThanOrEqual(C2, new ListPair(65, Atom.NIL))) |
3572 | { | 3572 | { |
3573 | if (YP.greaterThan(C2, new ListPair(90, Atom.NIL))) | 3573 | if (YP.greaterThan(C2, new ListPair(90, Atom.NIL))) |
3574 | { | 3574 | { |
3575 | if (YP.notEqual(C2, new ListPair(95, Atom.NIL))) | 3575 | if (YP.notEqual(C2, new ListPair(95, Atom.NIL))) |
3576 | { | 3576 | { |
3577 | foreach (bool l7 in YP.unify(Chars, Atom.NIL)) | 3577 | foreach (bool l7 in YP.unify(Chars, Atom.NIL)) |
3578 | { | 3578 | { |
3579 | foreach (bool l8 in YP.unify(LastCh, C2)) | 3579 | foreach (bool l8 in YP.unify(LastCh, C2)) |
3580 | { | 3580 | { |
3581 | yield return false; | 3581 | yield return false; |
3582 | } | 3582 | } |
3583 | } | 3583 | } |
3584 | goto cutIf6; | 3584 | goto cutIf6; |
3585 | } | 3585 | } |
3586 | } | 3586 | } |
3587 | foreach (bool l5 in read_name(C2, Chars, LastCh)) | 3587 | foreach (bool l5 in read_name(C2, Chars, LastCh)) |
3588 | { | 3588 | { |
3589 | yield return false; | 3589 | yield return false; |
3590 | } | 3590 | } |
3591 | cutIf6: | 3591 | cutIf6: |
3592 | goto cutIf5; | 3592 | goto cutIf5; |
3593 | } | 3593 | } |
3594 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) | 3594 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) |
3595 | { | 3595 | { |
3596 | if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) | 3596 | if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) |
3597 | { | 3597 | { |
3598 | foreach (bool l6 in read_name(C2, Chars, LastCh)) | 3598 | foreach (bool l6 in read_name(C2, Chars, LastCh)) |
3599 | { | 3599 | { |
3600 | yield return false; | 3600 | yield return false; |
3601 | } | 3601 | } |
3602 | goto cutIf7; | 3602 | goto cutIf7; |
3603 | } | 3603 | } |
3604 | } | 3604 | } |
3605 | foreach (bool l4 in YP.unify(Chars, Atom.NIL)) | 3605 | foreach (bool l4 in YP.unify(Chars, Atom.NIL)) |
3606 | { | 3606 | { |
3607 | foreach (bool l5 in YP.unify(LastCh, C2)) | 3607 | foreach (bool l5 in YP.unify(LastCh, C2)) |
3608 | { | 3608 | { |
3609 | yield return false; | 3609 | yield return false; |
3610 | } | 3610 | } |
3611 | } | 3611 | } |
3612 | cutIf7: | 3612 | cutIf7: |
3613 | cutIf5: | 3613 | cutIf5: |
3614 | cutIf1: | 3614 | cutIf1: |
3615 | { } | 3615 | { } |
3616 | } | 3616 | } |
3617 | } | 3617 | } |
3618 | } | 3618 | } |
3619 | } | 3619 | } |
3620 | 3620 | ||
3621 | public static IEnumerable<bool> read_fullstop(object Ch, object Dict, object Tokens) | 3621 | public static IEnumerable<bool> read_fullstop(object Ch, object Dict, object Tokens) |
3622 | { | 3622 | { |
3623 | { | 3623 | { |
3624 | Variable Number = new Variable(); | 3624 | Variable Number = new Variable(); |
3625 | Variable Tokens1 = new Variable(); | 3625 | Variable Tokens1 = new Variable(); |
3626 | Variable Chars = new Variable(); | 3626 | Variable Chars = new Variable(); |
3627 | Variable NextCh = new Variable(); | 3627 | Variable NextCh = new Variable(); |
3628 | if (YP.lessThanOrEqual(Ch, new ListPair(57, Atom.NIL))) | 3628 | if (YP.lessThanOrEqual(Ch, new ListPair(57, Atom.NIL))) |
3629 | { | 3629 | { |
3630 | if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL))) | 3630 | if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL))) |
3631 | { | 3631 | { |
3632 | foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1(@"number", Number), Tokens1))) | 3632 | foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1(@"number", Number), Tokens1))) |
3633 | { | 3633 | { |
3634 | foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch)) | 3634 | foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch)) |
3635 | { | 3635 | { |
3636 | yield return false; | 3636 | yield return false; |
3637 | } | 3637 | } |
3638 | } | 3638 | } |
3639 | goto cutIf1; | 3639 | goto cutIf1; |
3640 | } | 3640 | } |
3641 | } | 3641 | } |
3642 | if (YP.greaterThan(Ch, new ListPair(32, Atom.NIL))) | 3642 | if (YP.greaterThan(Ch, new ListPair(32, Atom.NIL))) |
3643 | { | 3643 | { |
3644 | foreach (bool l3 in rest_symbol(Ch, Chars, NextCh)) | 3644 | foreach (bool l3 in rest_symbol(Ch, Chars, NextCh)) |
3645 | { | 3645 | { |
3646 | foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(46, Chars))) | 3646 | foreach (bool l4 in read_after_atom4(NextCh, Dict, Tokens, new ListPair(46, Chars))) |
3647 | { | 3647 | { |
3648 | yield return false; | 3648 | yield return false; |
3649 | } | 3649 | } |
3650 | } | 3650 | } |
3651 | goto cutIf2; | 3651 | goto cutIf2; |
3652 | } | 3652 | } |
3653 | if (YP.greaterThanOrEqual(Ch, 0)) | 3653 | if (YP.greaterThanOrEqual(Ch, 0)) |
3654 | { | 3654 | { |
3655 | foreach (bool l3 in YP.unify(Tokens, Atom.NIL)) | 3655 | foreach (bool l3 in YP.unify(Tokens, Atom.NIL)) |
3656 | { | 3656 | { |
3657 | yield return false; | 3657 | yield return false; |
3658 | } | 3658 | } |
3659 | goto cutIf3; | 3659 | goto cutIf3; |
3660 | } | 3660 | } |
3661 | foreach (bool l2 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file just after full stop~n"), Atom.NIL)) | 3661 | foreach (bool l2 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file just after full stop~n"), Atom.NIL)) |
3662 | { | 3662 | { |
3663 | } | 3663 | } |
3664 | cutIf3: | 3664 | cutIf3: |
3665 | cutIf2: | 3665 | cutIf2: |
3666 | cutIf1: | 3666 | cutIf1: |
3667 | { } | 3667 | { } |
3668 | } | 3668 | } |
3669 | } | 3669 | } |
3670 | 3670 | ||
3671 | public static IEnumerable<bool> read_float(object Number, object Dict, object Tokens, object Digits, object Digit) | 3671 | public static IEnumerable<bool> read_float(object Number, object Dict, object Tokens, object Digits, object Digit) |
3672 | { | 3672 | { |
3673 | { | 3673 | { |
3674 | Variable Chars = new Variable(); | 3674 | Variable Chars = new Variable(); |
3675 | Variable Rest = new Variable(); | 3675 | Variable Rest = new Variable(); |
3676 | Variable NextCh = new Variable(); | 3676 | Variable NextCh = new Variable(); |
3677 | foreach (bool l2 in prepend(Digits, Chars, Rest)) | 3677 | foreach (bool l2 in prepend(Digits, Chars, Rest)) |
3678 | { | 3678 | { |
3679 | foreach (bool l3 in read_float(Digit, Rest, NextCh, Chars)) | 3679 | foreach (bool l3 in read_float(Digit, Rest, NextCh, Chars)) |
3680 | { | 3680 | { |
3681 | foreach (bool l4 in YP.number_codes(Number, Chars)) | 3681 | foreach (bool l4 in YP.number_codes(Number, Chars)) |
3682 | { | 3682 | { |
3683 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) | 3683 | foreach (bool l5 in read_tokens(NextCh, Dict, Tokens)) |
3684 | { | 3684 | { |
3685 | yield return false; | 3685 | yield return false; |
3686 | } | 3686 | } |
3687 | } | 3687 | } |
3688 | } | 3688 | } |
3689 | } | 3689 | } |
3690 | } | 3690 | } |
3691 | } | 3691 | } |
3692 | 3692 | ||
3693 | public static IEnumerable<bool> prepend(object arg1, object arg2, object arg3) | 3693 | public static IEnumerable<bool> prepend(object arg1, object arg2, object arg3) |
3694 | { | 3694 | { |
3695 | { | 3695 | { |
3696 | object X = arg3; | 3696 | object X = arg3; |
3697 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 3697 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
3698 | { | 3698 | { |
3699 | foreach (bool l3 in YP.unify(arg2, new ListPair(46, X))) | 3699 | foreach (bool l3 in YP.unify(arg2, new ListPair(46, X))) |
3700 | { | 3700 | { |
3701 | yield return false; | 3701 | yield return false; |
3702 | } | 3702 | } |
3703 | } | 3703 | } |
3704 | } | 3704 | } |
3705 | { | 3705 | { |
3706 | object Y = arg3; | 3706 | object Y = arg3; |
3707 | Variable C = new Variable(); | 3707 | Variable C = new Variable(); |
3708 | Variable Cs = new Variable(); | 3708 | Variable Cs = new Variable(); |
3709 | Variable X = new Variable(); | 3709 | Variable X = new Variable(); |
3710 | foreach (bool l2 in YP.unify(arg1, new ListPair(C, Cs))) | 3710 | foreach (bool l2 in YP.unify(arg1, new ListPair(C, Cs))) |
3711 | { | 3711 | { |
3712 | foreach (bool l3 in YP.unify(arg2, new ListPair(C, X))) | 3712 | foreach (bool l3 in YP.unify(arg2, new ListPair(C, X))) |
3713 | { | 3713 | { |
3714 | foreach (bool l4 in prepend(Cs, X, Y)) | 3714 | foreach (bool l4 in prepend(Cs, X, Y)) |
3715 | { | 3715 | { |
3716 | yield return false; | 3716 | yield return false; |
3717 | } | 3717 | } |
3718 | } | 3718 | } |
3719 | } | 3719 | } |
3720 | } | 3720 | } |
3721 | } | 3721 | } |
3722 | 3722 | ||
3723 | public static IEnumerable<bool> read_float(object C1, object arg2, object NextCh, object Total) | 3723 | public static IEnumerable<bool> read_float(object C1, object arg2, object NextCh, object Total) |
3724 | { | 3724 | { |
3725 | { | 3725 | { |
3726 | Variable Chars = new Variable(); | 3726 | Variable Chars = new Variable(); |
3727 | Variable C2 = new Variable(); | 3727 | Variable C2 = new Variable(); |
3728 | Variable C3 = new Variable(); | 3728 | Variable C3 = new Variable(); |
3729 | Variable C4 = new Variable(); | 3729 | Variable C4 = new Variable(); |
3730 | Variable More = new Variable(); | 3730 | Variable More = new Variable(); |
3731 | foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars))) | 3731 | foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars))) |
3732 | { | 3732 | { |
3733 | foreach (bool l3 in YP.get_code(C2)) | 3733 | foreach (bool l3 in YP.get_code(C2)) |
3734 | { | 3734 | { |
3735 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) | 3735 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) |
3736 | { | 3736 | { |
3737 | if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) | 3737 | if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) |
3738 | { | 3738 | { |
3739 | foreach (bool l6 in read_float(C2, Chars, NextCh, Total)) | 3739 | foreach (bool l6 in read_float(C2, Chars, NextCh, Total)) |
3740 | { | 3740 | { |
3741 | yield return false; | 3741 | yield return false; |
3742 | } | 3742 | } |
3743 | goto cutIf1; | 3743 | goto cutIf1; |
3744 | } | 3744 | } |
3745 | } | 3745 | } |
3746 | if (YP.equal(YP.bitwiseOr(C2, 32), new ListPair(101, Atom.NIL))) | 3746 | if (YP.equal(YP.bitwiseOr(C2, 32), new ListPair(101, Atom.NIL))) |
3747 | { | 3747 | { |
3748 | foreach (bool l5 in YP.get_code(C3)) | 3748 | foreach (bool l5 in YP.get_code(C3)) |
3749 | { | 3749 | { |
3750 | if (YP.equal(C3, new ListPair(45, Atom.NIL))) | 3750 | if (YP.equal(C3, new ListPair(45, Atom.NIL))) |
3751 | { | 3751 | { |
3752 | foreach (bool l7 in YP.get_code(C4)) | 3752 | foreach (bool l7 in YP.get_code(C4)) |
3753 | { | 3753 | { |
3754 | foreach (bool l8 in YP.unify(Chars, new ListPair(C2, new ListPair(45, More)))) | 3754 | foreach (bool l8 in YP.unify(Chars, new ListPair(C2, new ListPair(45, More)))) |
3755 | { | 3755 | { |
3756 | if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL))) | 3756 | if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL))) |
3757 | { | 3757 | { |
3758 | if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL))) | 3758 | if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL))) |
3759 | { | 3759 | { |
3760 | foreach (bool l11 in read_exponent(C4, More, NextCh)) | 3760 | foreach (bool l11 in read_exponent(C4, More, NextCh)) |
3761 | { | 3761 | { |
3762 | yield return false; | 3762 | yield return false; |
3763 | } | 3763 | } |
3764 | goto cutIf4; | 3764 | goto cutIf4; |
3765 | } | 3765 | } |
3766 | } | 3766 | } |
3767 | foreach (bool l9 in YP.unify(More, Atom.NIL)) | 3767 | foreach (bool l9 in YP.unify(More, Atom.NIL)) |
3768 | { | 3768 | { |
3769 | foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) | 3769 | foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) |
3770 | { | 3770 | { |
3771 | } | 3771 | } |
3772 | } | 3772 | } |
3773 | foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL))) | 3773 | foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL))) |
3774 | { | 3774 | { |
3775 | foreach (bool l10 in YP.unify(NextCh, C4)) | 3775 | foreach (bool l10 in YP.unify(NextCh, C4)) |
3776 | { | 3776 | { |
3777 | yield return false; | 3777 | yield return false; |
3778 | } | 3778 | } |
3779 | } | 3779 | } |
3780 | cutIf4: | 3780 | cutIf4: |
3781 | { } | 3781 | { } |
3782 | } | 3782 | } |
3783 | } | 3783 | } |
3784 | goto cutIf3; | 3784 | goto cutIf3; |
3785 | } | 3785 | } |
3786 | if (YP.equal(C3, new ListPair(43, Atom.NIL))) | 3786 | if (YP.equal(C3, new ListPair(43, Atom.NIL))) |
3787 | { | 3787 | { |
3788 | foreach (bool l7 in YP.get_code(C4)) | 3788 | foreach (bool l7 in YP.get_code(C4)) |
3789 | { | 3789 | { |
3790 | foreach (bool l8 in YP.unify(Chars, new ListPair(C2, More))) | 3790 | foreach (bool l8 in YP.unify(Chars, new ListPair(C2, More))) |
3791 | { | 3791 | { |
3792 | if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL))) | 3792 | if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL))) |
3793 | { | 3793 | { |
3794 | if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL))) | 3794 | if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL))) |
3795 | { | 3795 | { |
3796 | foreach (bool l11 in read_exponent(C4, More, NextCh)) | 3796 | foreach (bool l11 in read_exponent(C4, More, NextCh)) |
3797 | { | 3797 | { |
3798 | yield return false; | 3798 | yield return false; |
3799 | } | 3799 | } |
3800 | goto cutIf6; | 3800 | goto cutIf6; |
3801 | } | 3801 | } |
3802 | } | 3802 | } |
3803 | foreach (bool l9 in YP.unify(More, Atom.NIL)) | 3803 | foreach (bool l9 in YP.unify(More, Atom.NIL)) |
3804 | { | 3804 | { |
3805 | foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) | 3805 | foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) |
3806 | { | 3806 | { |
3807 | } | 3807 | } |
3808 | } | 3808 | } |
3809 | foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL))) | 3809 | foreach (bool l9 in YP.unify(More, new ListPair(48, Atom.NIL))) |
3810 | { | 3810 | { |
3811 | foreach (bool l10 in YP.unify(NextCh, C4)) | 3811 | foreach (bool l10 in YP.unify(NextCh, C4)) |
3812 | { | 3812 | { |
3813 | yield return false; | 3813 | yield return false; |
3814 | } | 3814 | } |
3815 | } | 3815 | } |
3816 | cutIf6: | 3816 | cutIf6: |
3817 | { } | 3817 | { } |
3818 | } | 3818 | } |
3819 | } | 3819 | } |
3820 | goto cutIf5; | 3820 | goto cutIf5; |
3821 | } | 3821 | } |
3822 | foreach (bool l6 in YP.unify(C4, C3)) | 3822 | foreach (bool l6 in YP.unify(C4, C3)) |
3823 | { | 3823 | { |
3824 | foreach (bool l7 in YP.unify(Chars, new ListPair(C2, More))) | 3824 | foreach (bool l7 in YP.unify(Chars, new ListPair(C2, More))) |
3825 | { | 3825 | { |
3826 | if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL))) | 3826 | if (YP.greaterThanOrEqual(C4, new ListPair(48, Atom.NIL))) |
3827 | { | 3827 | { |
3828 | if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL))) | 3828 | if (YP.lessThanOrEqual(C4, new ListPair(57, Atom.NIL))) |
3829 | { | 3829 | { |
3830 | foreach (bool l10 in read_exponent(C4, More, NextCh)) | 3830 | foreach (bool l10 in read_exponent(C4, More, NextCh)) |
3831 | { | 3831 | { |
3832 | yield return false; | 3832 | yield return false; |
3833 | } | 3833 | } |
3834 | goto cutIf7; | 3834 | goto cutIf7; |
3835 | } | 3835 | } |
3836 | } | 3836 | } |
3837 | foreach (bool l8 in YP.unify(More, Atom.NIL)) | 3837 | foreach (bool l8 in YP.unify(More, Atom.NIL)) |
3838 | { | 3838 | { |
3839 | foreach (bool l9 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) | 3839 | foreach (bool l9 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) |
3840 | { | 3840 | { |
3841 | } | 3841 | } |
3842 | } | 3842 | } |
3843 | foreach (bool l8 in YP.unify(More, new ListPair(48, Atom.NIL))) | 3843 | foreach (bool l8 in YP.unify(More, new ListPair(48, Atom.NIL))) |
3844 | { | 3844 | { |
3845 | foreach (bool l9 in YP.unify(NextCh, C4)) | 3845 | foreach (bool l9 in YP.unify(NextCh, C4)) |
3846 | { | 3846 | { |
3847 | yield return false; | 3847 | yield return false; |
3848 | } | 3848 | } |
3849 | } | 3849 | } |
3850 | cutIf7: | 3850 | cutIf7: |
3851 | { } | 3851 | { } |
3852 | } | 3852 | } |
3853 | } | 3853 | } |
3854 | cutIf5: | 3854 | cutIf5: |
3855 | cutIf3: | 3855 | cutIf3: |
3856 | { } | 3856 | { } |
3857 | } | 3857 | } |
3858 | goto cutIf2; | 3858 | goto cutIf2; |
3859 | } | 3859 | } |
3860 | foreach (bool l4 in YP.unify(Chars, Atom.NIL)) | 3860 | foreach (bool l4 in YP.unify(Chars, Atom.NIL)) |
3861 | { | 3861 | { |
3862 | foreach (bool l5 in YP.unify(NextCh, C2)) | 3862 | foreach (bool l5 in YP.unify(NextCh, C2)) |
3863 | { | 3863 | { |
3864 | yield return false; | 3864 | yield return false; |
3865 | } | 3865 | } |
3866 | } | 3866 | } |
3867 | cutIf2: | 3867 | cutIf2: |
3868 | cutIf1: | 3868 | cutIf1: |
3869 | { } | 3869 | { } |
3870 | } | 3870 | } |
3871 | } | 3871 | } |
3872 | } | 3872 | } |
3873 | } | 3873 | } |
3874 | 3874 | ||
3875 | public static IEnumerable<bool> read_exponent(object C1, object arg2, object NextCh) | 3875 | public static IEnumerable<bool> read_exponent(object C1, object arg2, object NextCh) |
3876 | { | 3876 | { |
3877 | { | 3877 | { |
3878 | Variable Chars = new Variable(); | 3878 | Variable Chars = new Variable(); |
3879 | Variable C2 = new Variable(); | 3879 | Variable C2 = new Variable(); |
3880 | foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars))) | 3880 | foreach (bool l2 in YP.unify(arg2, new ListPair(C1, Chars))) |
3881 | { | 3881 | { |
3882 | foreach (bool l3 in YP.get_code(C2)) | 3882 | foreach (bool l3 in YP.get_code(C2)) |
3883 | { | 3883 | { |
3884 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) | 3884 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) |
3885 | { | 3885 | { |
3886 | if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) | 3886 | if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) |
3887 | { | 3887 | { |
3888 | foreach (bool l6 in read_exponent(C2, Chars, NextCh)) | 3888 | foreach (bool l6 in read_exponent(C2, Chars, NextCh)) |
3889 | { | 3889 | { |
3890 | yield return false; | 3890 | yield return false; |
3891 | } | 3891 | } |
3892 | goto cutIf1; | 3892 | goto cutIf1; |
3893 | } | 3893 | } |
3894 | } | 3894 | } |
3895 | foreach (bool l4 in YP.unify(Chars, Atom.NIL)) | 3895 | foreach (bool l4 in YP.unify(Chars, Atom.NIL)) |
3896 | { | 3896 | { |
3897 | foreach (bool l5 in YP.unify(NextCh, C2)) | 3897 | foreach (bool l5 in YP.unify(NextCh, C2)) |
3898 | { | 3898 | { |
3899 | yield return false; | 3899 | yield return false; |
3900 | } | 3900 | } |
3901 | } | 3901 | } |
3902 | cutIf1: | 3902 | cutIf1: |
3903 | { } | 3903 | { } |
3904 | } | 3904 | } |
3905 | } | 3905 | } |
3906 | } | 3906 | } |
3907 | } | 3907 | } |
3908 | 3908 | ||
3909 | public static IEnumerable<bool> read_number(object C1, object Dict, object arg3) | 3909 | public static IEnumerable<bool> read_number(object C1, object Dict, object arg3) |
3910 | { | 3910 | { |
3911 | { | 3911 | { |
3912 | Variable Number = new Variable(); | 3912 | Variable Number = new Variable(); |
3913 | Variable Tokens = new Variable(); | 3913 | Variable Tokens = new Variable(); |
3914 | Variable C2 = new Variable(); | 3914 | Variable C2 = new Variable(); |
3915 | Variable N = new Variable(); | 3915 | Variable N = new Variable(); |
3916 | Variable C = new Variable(); | 3916 | Variable C = new Variable(); |
3917 | Variable C3 = new Variable(); | 3917 | Variable C3 = new Variable(); |
3918 | Variable Digits = new Variable(); | 3918 | Variable Digits = new Variable(); |
3919 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1(@"number", Number), Tokens))) | 3919 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1(@"number", Number), Tokens))) |
3920 | { | 3920 | { |
3921 | foreach (bool l3 in read_number4(C1, C2, 0, N)) | 3921 | foreach (bool l3 in read_number4(C1, C2, 0, N)) |
3922 | { | 3922 | { |
3923 | if (YP.equal(C2, 39)) | 3923 | if (YP.equal(C2, 39)) |
3924 | { | 3924 | { |
3925 | if (YP.greaterThanOrEqual(N, 2)) | 3925 | if (YP.greaterThanOrEqual(N, 2)) |
3926 | { | 3926 | { |
3927 | if (YP.lessThanOrEqual(N, 36)) | 3927 | if (YP.lessThanOrEqual(N, 36)) |
3928 | { | 3928 | { |
3929 | foreach (bool l7 in read_based(N, 0, Number, C)) | 3929 | foreach (bool l7 in read_based(N, 0, Number, C)) |
3930 | { | 3930 | { |
3931 | foreach (bool l8 in read_tokens(C, Dict, Tokens)) | 3931 | foreach (bool l8 in read_tokens(C, Dict, Tokens)) |
3932 | { | 3932 | { |
3933 | yield return false; | 3933 | yield return false; |
3934 | } | 3934 | } |
3935 | } | 3935 | } |
3936 | goto cutIf2; | 3936 | goto cutIf2; |
3937 | } | 3937 | } |
3938 | } | 3938 | } |
3939 | if (YP.equal(N, 0)) | 3939 | if (YP.equal(N, 0)) |
3940 | { | 3940 | { |
3941 | foreach (bool l6 in YP.get_code(C3)) | 3941 | foreach (bool l6 in YP.get_code(C3)) |
3942 | { | 3942 | { |
3943 | foreach (bool l7 in read_char(C3, -1, Number, C)) | 3943 | foreach (bool l7 in read_char(C3, -1, Number, C)) |
3944 | { | 3944 | { |
3945 | foreach (bool l8 in read_tokens(C, Dict, Tokens)) | 3945 | foreach (bool l8 in read_tokens(C, Dict, Tokens)) |
3946 | { | 3946 | { |
3947 | yield return false; | 3947 | yield return false; |
3948 | } | 3948 | } |
3949 | } | 3949 | } |
3950 | } | 3950 | } |
3951 | goto cutIf3; | 3951 | goto cutIf3; |
3952 | } | 3952 | } |
3953 | foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** ~d' read as ~d '~n"), new ListPair(N, new ListPair(N, Atom.NIL)))) | 3953 | foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** ~d' read as ~d '~n"), new ListPair(N, new ListPair(N, Atom.NIL)))) |
3954 | { | 3954 | { |
3955 | foreach (bool l6 in YP.unify(Number, N)) | 3955 | foreach (bool l6 in YP.unify(Number, N)) |
3956 | { | 3956 | { |
3957 | foreach (bool l7 in YP.unify(C, C2)) | 3957 | foreach (bool l7 in YP.unify(C, C2)) |
3958 | { | 3958 | { |
3959 | foreach (bool l8 in read_tokens(C, Dict, Tokens)) | 3959 | foreach (bool l8 in read_tokens(C, Dict, Tokens)) |
3960 | { | 3960 | { |
3961 | yield return false; | 3961 | yield return false; |
3962 | } | 3962 | } |
3963 | } | 3963 | } |
3964 | } | 3964 | } |
3965 | } | 3965 | } |
3966 | cutIf3: | 3966 | cutIf3: |
3967 | cutIf2: | 3967 | cutIf2: |
3968 | goto cutIf1; | 3968 | goto cutIf1; |
3969 | } | 3969 | } |
3970 | if (YP.equal(C2, 46)) | 3970 | if (YP.equal(C2, 46)) |
3971 | { | 3971 | { |
3972 | foreach (bool l5 in YP.get_code(C3)) | 3972 | foreach (bool l5 in YP.get_code(C3)) |
3973 | { | 3973 | { |
3974 | if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL))) | 3974 | if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL))) |
3975 | { | 3975 | { |
3976 | if (YP.lessThanOrEqual(C3, new ListPair(57, Atom.NIL))) | 3976 | if (YP.lessThanOrEqual(C3, new ListPair(57, Atom.NIL))) |
3977 | { | 3977 | { |
3978 | foreach (bool l8 in YP.number_codes(N, Digits)) | 3978 | foreach (bool l8 in YP.number_codes(N, Digits)) |
3979 | { | 3979 | { |
3980 | foreach (bool l9 in read_float(Number, Dict, Tokens, Digits, C3)) | 3980 | foreach (bool l9 in read_float(Number, Dict, Tokens, Digits, C3)) |
3981 | { | 3981 | { |
3982 | yield return false; | 3982 | yield return false; |
3983 | } | 3983 | } |
3984 | } | 3984 | } |
3985 | goto cutIf5; | 3985 | goto cutIf5; |
3986 | } | 3986 | } |
3987 | } | 3987 | } |
3988 | foreach (bool l6 in YP.unify(Number, N)) | 3988 | foreach (bool l6 in YP.unify(Number, N)) |
3989 | { | 3989 | { |
3990 | foreach (bool l7 in read_fullstop(C3, Dict, Tokens)) | 3990 | foreach (bool l7 in read_fullstop(C3, Dict, Tokens)) |
3991 | { | 3991 | { |
3992 | yield return false; | 3992 | yield return false; |
3993 | } | 3993 | } |
3994 | } | 3994 | } |
3995 | cutIf5: | 3995 | cutIf5: |
3996 | { } | 3996 | { } |
3997 | } | 3997 | } |
3998 | goto cutIf4; | 3998 | goto cutIf4; |
3999 | } | 3999 | } |
4000 | foreach (bool l4 in YP.unify(Number, N)) | 4000 | foreach (bool l4 in YP.unify(Number, N)) |
4001 | { | 4001 | { |
4002 | foreach (bool l5 in read_tokens(C2, Dict, Tokens)) | 4002 | foreach (bool l5 in read_tokens(C2, Dict, Tokens)) |
4003 | { | 4003 | { |
4004 | yield return false; | 4004 | yield return false; |
4005 | } | 4005 | } |
4006 | } | 4006 | } |
4007 | cutIf4: | 4007 | cutIf4: |
4008 | cutIf1: | 4008 | cutIf1: |
4009 | { } | 4009 | { } |
4010 | } | 4010 | } |
4011 | } | 4011 | } |
4012 | } | 4012 | } |
4013 | } | 4013 | } |
4014 | 4014 | ||
4015 | public static IEnumerable<bool> read_number4(object C0, object C, object N0, object N) | 4015 | public static IEnumerable<bool> read_number4(object C0, object C, object N0, object N) |
4016 | { | 4016 | { |
4017 | { | 4017 | { |
4018 | Variable N1 = new Variable(); | 4018 | Variable N1 = new Variable(); |
4019 | Variable C1 = new Variable(); | 4019 | Variable C1 = new Variable(); |
4020 | if (YP.greaterThanOrEqual(C0, new ListPair(48, Atom.NIL))) | 4020 | if (YP.greaterThanOrEqual(C0, new ListPair(48, Atom.NIL))) |
4021 | { | 4021 | { |
4022 | if (YP.lessThanOrEqual(C0, new ListPair(57, Atom.NIL))) | 4022 | if (YP.lessThanOrEqual(C0, new ListPair(57, Atom.NIL))) |
4023 | { | 4023 | { |
4024 | foreach (bool l4 in YP.unify(N1, YP.add(YP.subtract(YP.multiply(N0, 10), new ListPair(48, Atom.NIL)), C0))) | 4024 | foreach (bool l4 in YP.unify(N1, YP.add(YP.subtract(YP.multiply(N0, 10), new ListPair(48, Atom.NIL)), C0))) |
4025 | { | 4025 | { |
4026 | foreach (bool l5 in YP.get_code(C1)) | 4026 | foreach (bool l5 in YP.get_code(C1)) |
4027 | { | 4027 | { |
4028 | foreach (bool l6 in read_number4(C1, C, N1, N)) | 4028 | foreach (bool l6 in read_number4(C1, C, N1, N)) |
4029 | { | 4029 | { |
4030 | yield return false; | 4030 | yield return false; |
4031 | } | 4031 | } |
4032 | } | 4032 | } |
4033 | } | 4033 | } |
4034 | goto cutIf1; | 4034 | goto cutIf1; |
4035 | } | 4035 | } |
4036 | } | 4036 | } |
4037 | if (YP.equal(C0, 95)) | 4037 | if (YP.equal(C0, 95)) |
4038 | { | 4038 | { |
4039 | foreach (bool l3 in YP.get_code(C1)) | 4039 | foreach (bool l3 in YP.get_code(C1)) |
4040 | { | 4040 | { |
4041 | foreach (bool l4 in read_number4(C1, C, N0, N)) | 4041 | foreach (bool l4 in read_number4(C1, C, N0, N)) |
4042 | { | 4042 | { |
4043 | yield return false; | 4043 | yield return false; |
4044 | } | 4044 | } |
4045 | } | 4045 | } |
4046 | goto cutIf2; | 4046 | goto cutIf2; |
4047 | } | 4047 | } |
4048 | foreach (bool l2 in YP.unify(C, C0)) | 4048 | foreach (bool l2 in YP.unify(C, C0)) |
4049 | { | 4049 | { |
4050 | foreach (bool l3 in YP.unify(N, N0)) | 4050 | foreach (bool l3 in YP.unify(N, N0)) |
4051 | { | 4051 | { |
4052 | yield return false; | 4052 | yield return false; |
4053 | } | 4053 | } |
4054 | } | 4054 | } |
4055 | cutIf2: | 4055 | cutIf2: |
4056 | cutIf1: | 4056 | cutIf1: |
4057 | { } | 4057 | { } |
4058 | } | 4058 | } |
4059 | } | 4059 | } |
4060 | 4060 | ||
4061 | public static IEnumerable<bool> read_based(object Base, object N0, object N, object C) | 4061 | public static IEnumerable<bool> read_based(object Base, object N0, object N, object C) |
4062 | { | 4062 | { |
4063 | { | 4063 | { |
4064 | Variable C1 = new Variable(); | 4064 | Variable C1 = new Variable(); |
4065 | Variable Digit = new Variable(); | 4065 | Variable Digit = new Variable(); |
4066 | Variable N1 = new Variable(); | 4066 | Variable N1 = new Variable(); |
4067 | foreach (bool l2 in YP.get_code(C1)) | 4067 | foreach (bool l2 in YP.get_code(C1)) |
4068 | { | 4068 | { |
4069 | if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL))) | 4069 | if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL))) |
4070 | { | 4070 | { |
4071 | if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL))) | 4071 | if (YP.lessThanOrEqual(C1, new ListPair(57, Atom.NIL))) |
4072 | { | 4072 | { |
4073 | foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, new ListPair(48, Atom.NIL)))) | 4073 | foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, new ListPair(48, Atom.NIL)))) |
4074 | { | 4074 | { |
4075 | if (YP.lessThan(Digit, Base)) | 4075 | if (YP.lessThan(Digit, Base)) |
4076 | { | 4076 | { |
4077 | foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) | 4077 | foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) |
4078 | { | 4078 | { |
4079 | foreach (bool l8 in read_based(Base, N1, N, C)) | 4079 | foreach (bool l8 in read_based(Base, N1, N, C)) |
4080 | { | 4080 | { |
4081 | yield return false; | 4081 | yield return false; |
4082 | } | 4082 | } |
4083 | } | 4083 | } |
4084 | goto cutIf2; | 4084 | goto cutIf2; |
4085 | } | 4085 | } |
4086 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) | 4086 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) |
4087 | { | 4087 | { |
4088 | foreach (bool l7 in read_based(Base, N0, N, C)) | 4088 | foreach (bool l7 in read_based(Base, N0, N, C)) |
4089 | { | 4089 | { |
4090 | yield return false; | 4090 | yield return false; |
4091 | } | 4091 | } |
4092 | goto cutIf3; | 4092 | goto cutIf3; |
4093 | } | 4093 | } |
4094 | foreach (bool l6 in YP.unify(N, N0)) | 4094 | foreach (bool l6 in YP.unify(N, N0)) |
4095 | { | 4095 | { |
4096 | foreach (bool l7 in YP.unify(C, C1)) | 4096 | foreach (bool l7 in YP.unify(C, C1)) |
4097 | { | 4097 | { |
4098 | yield return false; | 4098 | yield return false; |
4099 | } | 4099 | } |
4100 | } | 4100 | } |
4101 | cutIf3: | 4101 | cutIf3: |
4102 | cutIf2: | 4102 | cutIf2: |
4103 | { } | 4103 | { } |
4104 | } | 4104 | } |
4105 | goto cutIf1; | 4105 | goto cutIf1; |
4106 | } | 4106 | } |
4107 | } | 4107 | } |
4108 | if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL))) | 4108 | if (YP.greaterThanOrEqual(C1, new ListPair(65, Atom.NIL))) |
4109 | { | 4109 | { |
4110 | if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL))) | 4110 | if (YP.lessThanOrEqual(C1, new ListPair(90, Atom.NIL))) |
4111 | { | 4111 | { |
4112 | foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(65, Atom.NIL), 10)))) | 4112 | foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(65, Atom.NIL), 10)))) |
4113 | { | 4113 | { |
4114 | if (YP.lessThan(Digit, Base)) | 4114 | if (YP.lessThan(Digit, Base)) |
4115 | { | 4115 | { |
4116 | foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) | 4116 | foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) |
4117 | { | 4117 | { |
4118 | foreach (bool l8 in read_based(Base, N1, N, C)) | 4118 | foreach (bool l8 in read_based(Base, N1, N, C)) |
4119 | { | 4119 | { |
4120 | yield return false; | 4120 | yield return false; |
4121 | } | 4121 | } |
4122 | } | 4122 | } |
4123 | goto cutIf5; | 4123 | goto cutIf5; |
4124 | } | 4124 | } |
4125 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) | 4125 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) |
4126 | { | 4126 | { |
4127 | foreach (bool l7 in read_based(Base, N0, N, C)) | 4127 | foreach (bool l7 in read_based(Base, N0, N, C)) |
4128 | { | 4128 | { |
4129 | yield return false; | 4129 | yield return false; |
4130 | } | 4130 | } |
4131 | goto cutIf6; | 4131 | goto cutIf6; |
4132 | } | 4132 | } |
4133 | foreach (bool l6 in YP.unify(N, N0)) | 4133 | foreach (bool l6 in YP.unify(N, N0)) |
4134 | { | 4134 | { |
4135 | foreach (bool l7 in YP.unify(C, C1)) | 4135 | foreach (bool l7 in YP.unify(C, C1)) |
4136 | { | 4136 | { |
4137 | yield return false; | 4137 | yield return false; |
4138 | } | 4138 | } |
4139 | } | 4139 | } |
4140 | cutIf6: | 4140 | cutIf6: |
4141 | cutIf5: | 4141 | cutIf5: |
4142 | { } | 4142 | { } |
4143 | } | 4143 | } |
4144 | goto cutIf4; | 4144 | goto cutIf4; |
4145 | } | 4145 | } |
4146 | } | 4146 | } |
4147 | if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL))) | 4147 | if (YP.greaterThanOrEqual(C1, new ListPair(97, Atom.NIL))) |
4148 | { | 4148 | { |
4149 | if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL))) | 4149 | if (YP.lessThanOrEqual(C1, new ListPair(122, Atom.NIL))) |
4150 | { | 4150 | { |
4151 | foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(97, Atom.NIL), 10)))) | 4151 | foreach (bool l5 in YP.unify(Digit, YP.subtract(C1, YP.subtract(new ListPair(97, Atom.NIL), 10)))) |
4152 | { | 4152 | { |
4153 | if (YP.lessThan(Digit, Base)) | 4153 | if (YP.lessThan(Digit, Base)) |
4154 | { | 4154 | { |
4155 | foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) | 4155 | foreach (bool l7 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) |
4156 | { | 4156 | { |
4157 | foreach (bool l8 in read_based(Base, N1, N, C)) | 4157 | foreach (bool l8 in read_based(Base, N1, N, C)) |
4158 | { | 4158 | { |
4159 | yield return false; | 4159 | yield return false; |
4160 | } | 4160 | } |
4161 | } | 4161 | } |
4162 | goto cutIf8; | 4162 | goto cutIf8; |
4163 | } | 4163 | } |
4164 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) | 4164 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) |
4165 | { | 4165 | { |
4166 | foreach (bool l7 in read_based(Base, N0, N, C)) | 4166 | foreach (bool l7 in read_based(Base, N0, N, C)) |
4167 | { | 4167 | { |
4168 | yield return false; | 4168 | yield return false; |
4169 | } | 4169 | } |
4170 | goto cutIf9; | 4170 | goto cutIf9; |
4171 | } | 4171 | } |
4172 | foreach (bool l6 in YP.unify(N, N0)) | 4172 | foreach (bool l6 in YP.unify(N, N0)) |
4173 | { | 4173 | { |
4174 | foreach (bool l7 in YP.unify(C, C1)) | 4174 | foreach (bool l7 in YP.unify(C, C1)) |
4175 | { | 4175 | { |
4176 | yield return false; | 4176 | yield return false; |
4177 | } | 4177 | } |
4178 | } | 4178 | } |
4179 | cutIf9: | 4179 | cutIf9: |
4180 | cutIf8: | 4180 | cutIf8: |
4181 | { } | 4181 | { } |
4182 | } | 4182 | } |
4183 | goto cutIf7; | 4183 | goto cutIf7; |
4184 | } | 4184 | } |
4185 | } | 4185 | } |
4186 | foreach (bool l3 in YP.unify(Digit, 99)) | 4186 | foreach (bool l3 in YP.unify(Digit, 99)) |
4187 | { | 4187 | { |
4188 | if (YP.lessThan(Digit, Base)) | 4188 | if (YP.lessThan(Digit, Base)) |
4189 | { | 4189 | { |
4190 | foreach (bool l5 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) | 4190 | foreach (bool l5 in YP.unify(N1, YP.add(YP.multiply(N0, Base), Digit))) |
4191 | { | 4191 | { |
4192 | foreach (bool l6 in read_based(Base, N1, N, C)) | 4192 | foreach (bool l6 in read_based(Base, N1, N, C)) |
4193 | { | 4193 | { |
4194 | yield return false; | 4194 | yield return false; |
4195 | } | 4195 | } |
4196 | } | 4196 | } |
4197 | goto cutIf10; | 4197 | goto cutIf10; |
4198 | } | 4198 | } |
4199 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) | 4199 | if (YP.equal(C1, new ListPair(95, Atom.NIL))) |
4200 | { | 4200 | { |
4201 | foreach (bool l5 in read_based(Base, N0, N, C)) | 4201 | foreach (bool l5 in read_based(Base, N0, N, C)) |
4202 | { | 4202 | { |
4203 | yield return false; | 4203 | yield return false; |
4204 | } | 4204 | } |
4205 | goto cutIf11; | 4205 | goto cutIf11; |
4206 | } | 4206 | } |
4207 | foreach (bool l4 in YP.unify(N, N0)) | 4207 | foreach (bool l4 in YP.unify(N, N0)) |
4208 | { | 4208 | { |
4209 | foreach (bool l5 in YP.unify(C, C1)) | 4209 | foreach (bool l5 in YP.unify(C, C1)) |
4210 | { | 4210 | { |
4211 | yield return false; | 4211 | yield return false; |
4212 | } | 4212 | } |
4213 | } | 4213 | } |
4214 | cutIf11: | 4214 | cutIf11: |
4215 | cutIf10: | 4215 | cutIf10: |
4216 | { } | 4216 | { } |
4217 | } | 4217 | } |
4218 | cutIf7: | 4218 | cutIf7: |
4219 | cutIf4: | 4219 | cutIf4: |
4220 | cutIf1: | 4220 | cutIf1: |
4221 | { } | 4221 | { } |
4222 | } | 4222 | } |
4223 | } | 4223 | } |
4224 | } | 4224 | } |
4225 | 4225 | ||
4226 | public static IEnumerable<bool> read_char(object Char, object Quote, object Result, object Next) | 4226 | public static IEnumerable<bool> read_char(object Char, object Quote, object Result, object Next) |
4227 | { | 4227 | { |
4228 | { | 4228 | { |
4229 | Variable C1 = new Variable(); | 4229 | Variable C1 = new Variable(); |
4230 | Variable C2 = new Variable(); | 4230 | Variable C2 = new Variable(); |
4231 | Variable C3 = new Variable(); | 4231 | Variable C3 = new Variable(); |
4232 | Variable Ch = new Variable(); | 4232 | Variable Ch = new Variable(); |
4233 | if (YP.equal(Char, 92)) | 4233 | if (YP.equal(Char, 92)) |
4234 | { | 4234 | { |
4235 | foreach (bool l3 in YP.get_code(C1)) | 4235 | foreach (bool l3 in YP.get_code(C1)) |
4236 | { | 4236 | { |
4237 | if (YP.lessThan(C1, 0)) | 4237 | if (YP.lessThan(C1, 0)) |
4238 | { | 4238 | { |
4239 | foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~cquoted~c~n"), new ListPair(Quote, new ListPair(Quote, Atom.NIL)))) | 4239 | foreach (bool l5 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~cquoted~c~n"), new ListPair(Quote, new ListPair(Quote, Atom.NIL)))) |
4240 | { | 4240 | { |
4241 | foreach (bool l6 in YP.unify(Result, -1)) | 4241 | foreach (bool l6 in YP.unify(Result, -1)) |
4242 | { | 4242 | { |
4243 | foreach (bool l7 in YP.unify(Next, C1)) | 4243 | foreach (bool l7 in YP.unify(Next, C1)) |
4244 | { | 4244 | { |
4245 | yield return false; | 4245 | yield return false; |
4246 | } | 4246 | } |
4247 | } | 4247 | } |
4248 | } | 4248 | } |
4249 | goto cutIf2; | 4249 | goto cutIf2; |
4250 | } | 4250 | } |
4251 | if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL))) | 4251 | if (YP.lessThanOrEqual(C1, new ListPair(32, Atom.NIL))) |
4252 | { | 4252 | { |
4253 | foreach (bool l5 in YP.get_code(C2)) | 4253 | foreach (bool l5 in YP.get_code(C2)) |
4254 | { | 4254 | { |
4255 | foreach (bool l6 in read_char(C2, Quote, Result, Next)) | 4255 | foreach (bool l6 in read_char(C2, Quote, Result, Next)) |
4256 | { | 4256 | { |
4257 | yield return false; | 4257 | yield return false; |
4258 | } | 4258 | } |
4259 | } | 4259 | } |
4260 | goto cutIf3; | 4260 | goto cutIf3; |
4261 | } | 4261 | } |
4262 | if (YP.equal(YP.bitwiseOr(C1, 32), new ListPair(99, Atom.NIL))) | 4262 | if (YP.equal(YP.bitwiseOr(C1, 32), new ListPair(99, Atom.NIL))) |
4263 | { | 4263 | { |
4264 | foreach (bool l5 in YP.get_code(C2)) | 4264 | foreach (bool l5 in YP.get_code(C2)) |
4265 | { | 4265 | { |
4266 | foreach (bool l6 in read_char(C2, Quote, Result, Next)) | 4266 | foreach (bool l6 in read_char(C2, Quote, Result, Next)) |
4267 | { | 4267 | { |
4268 | yield return false; | 4268 | yield return false; |
4269 | } | 4269 | } |
4270 | } | 4270 | } |
4271 | goto cutIf4; | 4271 | goto cutIf4; |
4272 | } | 4272 | } |
4273 | if (YP.lessThanOrEqual(C1, new ListPair(55, Atom.NIL))) | 4273 | if (YP.lessThanOrEqual(C1, new ListPair(55, Atom.NIL))) |
4274 | { | 4274 | { |
4275 | if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL))) | 4275 | if (YP.greaterThanOrEqual(C1, new ListPair(48, Atom.NIL))) |
4276 | { | 4276 | { |
4277 | foreach (bool l6 in YP.get_code(C2)) | 4277 | foreach (bool l6 in YP.get_code(C2)) |
4278 | { | 4278 | { |
4279 | if (YP.lessThanOrEqual(C2, new ListPair(55, Atom.NIL))) | 4279 | if (YP.lessThanOrEqual(C2, new ListPair(55, Atom.NIL))) |
4280 | { | 4280 | { |
4281 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) | 4281 | if (YP.greaterThanOrEqual(C2, new ListPair(48, Atom.NIL))) |
4282 | { | 4282 | { |
4283 | foreach (bool l9 in YP.get_code(C3)) | 4283 | foreach (bool l9 in YP.get_code(C3)) |
4284 | { | 4284 | { |
4285 | if (YP.lessThanOrEqual(C3, new ListPair(55, Atom.NIL))) | 4285 | if (YP.lessThanOrEqual(C3, new ListPair(55, Atom.NIL))) |
4286 | { | 4286 | { |
4287 | if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL))) | 4287 | if (YP.greaterThanOrEqual(C3, new ListPair(48, Atom.NIL))) |
4288 | { | 4288 | { |
4289 | foreach (bool l12 in YP.get_code(Next)) | 4289 | foreach (bool l12 in YP.get_code(Next)) |
4290 | { | 4290 | { |
4291 | foreach (bool l13 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(YP.add(YP.multiply(C1, 8), C2), 8), C3), YP.multiply(73, new ListPair(48, Atom.NIL))))) | 4291 | foreach (bool l13 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(YP.add(YP.multiply(C1, 8), C2), 8), C3), YP.multiply(73, new ListPair(48, Atom.NIL))))) |
4292 | { | 4292 | { |
4293 | yield return false; | 4293 | yield return false; |
4294 | } | 4294 | } |
4295 | } | 4295 | } |
4296 | goto cutIf7; | 4296 | goto cutIf7; |
4297 | } | 4297 | } |
4298 | } | 4298 | } |
4299 | foreach (bool l10 in YP.unify(Next, C3)) | 4299 | foreach (bool l10 in YP.unify(Next, C3)) |
4300 | { | 4300 | { |
4301 | foreach (bool l11 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(C1, 8), C2), YP.multiply(9, new ListPair(48, Atom.NIL))))) | 4301 | foreach (bool l11 in YP.unify(Result, YP.subtract(YP.add(YP.multiply(C1, 8), C2), YP.multiply(9, new ListPair(48, Atom.NIL))))) |
4302 | { | 4302 | { |
4303 | yield return false; | 4303 | yield return false; |
4304 | } | 4304 | } |
4305 | } | 4305 | } |
4306 | cutIf7: | 4306 | cutIf7: |
4307 | { } | 4307 | { } |
4308 | } | 4308 | } |
4309 | goto cutIf6; | 4309 | goto cutIf6; |
4310 | } | 4310 | } |
4311 | } | 4311 | } |
4312 | foreach (bool l7 in YP.unify(Next, C2)) | 4312 | foreach (bool l7 in YP.unify(Next, C2)) |
4313 | { | 4313 | { |
4314 | foreach (bool l8 in YP.unify(Result, YP.subtract(C1, new ListPair(48, Atom.NIL)))) | 4314 | foreach (bool l8 in YP.unify(Result, YP.subtract(C1, new ListPair(48, Atom.NIL)))) |
4315 | { | 4315 | { |
4316 | yield return false; | 4316 | yield return false; |
4317 | } | 4317 | } |
4318 | } | 4318 | } |
4319 | cutIf6: | 4319 | cutIf6: |
4320 | { } | 4320 | { } |
4321 | } | 4321 | } |
4322 | goto cutIf5; | 4322 | goto cutIf5; |
4323 | } | 4323 | } |
4324 | } | 4324 | } |
4325 | if (YP.equal(C1, new ListPair(94, Atom.NIL))) | 4325 | if (YP.equal(C1, new ListPair(94, Atom.NIL))) |
4326 | { | 4326 | { |
4327 | foreach (bool l5 in YP.get_code(C2)) | 4327 | foreach (bool l5 in YP.get_code(C2)) |
4328 | { | 4328 | { |
4329 | if (YP.lessThan(C2, 0)) | 4329 | if (YP.lessThan(C2, 0)) |
4330 | { | 4330 | { |
4331 | foreach (bool l7 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~c..~c^..~c~n"), new ListPair(Quote, new ListPair(92, new ListPair(Quote, Atom.NIL))))) | 4331 | foreach (bool l7 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in ~c..~c^..~c~n"), new ListPair(Quote, new ListPair(92, new ListPair(Quote, Atom.NIL))))) |
4332 | { | 4332 | { |
4333 | foreach (bool l8 in YP.unify(Result, -1)) | 4333 | foreach (bool l8 in YP.unify(Result, -1)) |
4334 | { | 4334 | { |
4335 | foreach (bool l9 in YP.unify(Next, C2)) | 4335 | foreach (bool l9 in YP.unify(Next, C2)) |
4336 | { | 4336 | { |
4337 | yield return false; | 4337 | yield return false; |
4338 | } | 4338 | } |
4339 | } | 4339 | } |
4340 | } | 4340 | } |
4341 | goto cutIf9; | 4341 | goto cutIf9; |
4342 | } | 4342 | } |
4343 | if (YP.equal(C2, new ListPair(63, Atom.NIL))) | 4343 | if (YP.equal(C2, new ListPair(63, Atom.NIL))) |
4344 | { | 4344 | { |
4345 | foreach (bool l7 in YP.unify(Result, 127)) | 4345 | foreach (bool l7 in YP.unify(Result, 127)) |
4346 | { | 4346 | { |
4347 | foreach (bool l8 in YP.get_code(Next)) | 4347 | foreach (bool l8 in YP.get_code(Next)) |
4348 | { | 4348 | { |
4349 | yield return false; | 4349 | yield return false; |
4350 | } | 4350 | } |
4351 | } | 4351 | } |
4352 | goto cutIf10; | 4352 | goto cutIf10; |
4353 | } | 4353 | } |
4354 | foreach (bool l6 in YP.unify(Result, YP.bitwiseAnd(C2, 31))) | 4354 | foreach (bool l6 in YP.unify(Result, YP.bitwiseAnd(C2, 31))) |
4355 | { | 4355 | { |
4356 | foreach (bool l7 in YP.get_code(Next)) | 4356 | foreach (bool l7 in YP.get_code(Next)) |
4357 | { | 4357 | { |
4358 | yield return false; | 4358 | yield return false; |
4359 | } | 4359 | } |
4360 | } | 4360 | } |
4361 | cutIf10: | 4361 | cutIf10: |
4362 | cutIf9: | 4362 | cutIf9: |
4363 | { } | 4363 | { } |
4364 | } | 4364 | } |
4365 | goto cutIf8; | 4365 | goto cutIf8; |
4366 | } | 4366 | } |
4367 | foreach (bool l4 in escape_char(C1, Result)) | 4367 | foreach (bool l4 in escape_char(C1, Result)) |
4368 | { | 4368 | { |
4369 | foreach (bool l5 in YP.get_code(Next)) | 4369 | foreach (bool l5 in YP.get_code(Next)) |
4370 | { | 4370 | { |
4371 | yield return false; | 4371 | yield return false; |
4372 | } | 4372 | } |
4373 | goto cutIf11; | 4373 | goto cutIf11; |
4374 | } | 4374 | } |
4375 | foreach (bool l4 in YP.unify(Result, C1)) | 4375 | foreach (bool l4 in YP.unify(Result, C1)) |
4376 | { | 4376 | { |
4377 | foreach (bool l5 in YP.get_code(Next)) | 4377 | foreach (bool l5 in YP.get_code(Next)) |
4378 | { | 4378 | { |
4379 | yield return false; | 4379 | yield return false; |
4380 | } | 4380 | } |
4381 | } | 4381 | } |
4382 | cutIf11: | 4382 | cutIf11: |
4383 | cutIf8: | 4383 | cutIf8: |
4384 | cutIf5: | 4384 | cutIf5: |
4385 | cutIf4: | 4385 | cutIf4: |
4386 | cutIf3: | 4386 | cutIf3: |
4387 | cutIf2: | 4387 | cutIf2: |
4388 | { } | 4388 | { } |
4389 | } | 4389 | } |
4390 | goto cutIf1; | 4390 | goto cutIf1; |
4391 | } | 4391 | } |
4392 | if (YP.equal(Char, Quote)) | 4392 | if (YP.equal(Char, Quote)) |
4393 | { | 4393 | { |
4394 | foreach (bool l3 in YP.get_code(Ch)) | 4394 | foreach (bool l3 in YP.get_code(Ch)) |
4395 | { | 4395 | { |
4396 | if (YP.equal(Ch, Quote)) | 4396 | if (YP.equal(Ch, Quote)) |
4397 | { | 4397 | { |
4398 | foreach (bool l5 in YP.unify(Result, Quote)) | 4398 | foreach (bool l5 in YP.unify(Result, Quote)) |
4399 | { | 4399 | { |
4400 | foreach (bool l6 in YP.get_code(Next)) | 4400 | foreach (bool l6 in YP.get_code(Next)) |
4401 | { | 4401 | { |
4402 | yield return false; | 4402 | yield return false; |
4403 | } | 4403 | } |
4404 | } | 4404 | } |
4405 | goto cutIf13; | 4405 | goto cutIf13; |
4406 | } | 4406 | } |
4407 | foreach (bool l4 in YP.unify(Result, -1)) | 4407 | foreach (bool l4 in YP.unify(Result, -1)) |
4408 | { | 4408 | { |
4409 | foreach (bool l5 in YP.unify(Next, Ch)) | 4409 | foreach (bool l5 in YP.unify(Next, Ch)) |
4410 | { | 4410 | { |
4411 | yield return false; | 4411 | yield return false; |
4412 | } | 4412 | } |
4413 | } | 4413 | } |
4414 | cutIf13: | 4414 | cutIf13: |
4415 | { } | 4415 | { } |
4416 | } | 4416 | } |
4417 | goto cutIf12; | 4417 | goto cutIf12; |
4418 | } | 4418 | } |
4419 | if (YP.lessThan(Char, new ListPair(32, Atom.NIL))) | 4419 | if (YP.lessThan(Char, new ListPair(32, Atom.NIL))) |
4420 | { | 4420 | { |
4421 | if (YP.notEqual(Char, 9)) | 4421 | if (YP.notEqual(Char, 9)) |
4422 | { | 4422 | { |
4423 | if (YP.notEqual(Char, 10)) | 4423 | if (YP.notEqual(Char, 10)) |
4424 | { | 4424 | { |
4425 | if (YP.notEqual(Char, 13)) | 4425 | if (YP.notEqual(Char, 13)) |
4426 | { | 4426 | { |
4427 | foreach (bool l6 in YP.unify(Result, -1)) | 4427 | foreach (bool l6 in YP.unify(Result, -1)) |
4428 | { | 4428 | { |
4429 | foreach (bool l7 in YP.unify(Next, Char)) | 4429 | foreach (bool l7 in YP.unify(Next, Char)) |
4430 | { | 4430 | { |
4431 | foreach (bool l8 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Strange character ~d ends ~ctoken~c~n"), new ListPair(Char, new ListPair(Quote, new ListPair(Quote, Atom.NIL))))) | 4431 | foreach (bool l8 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Strange character ~d ends ~ctoken~c~n"), new ListPair(Char, new ListPair(Quote, new ListPair(Quote, Atom.NIL))))) |
4432 | { | 4432 | { |
4433 | yield return false; | 4433 | yield return false; |
4434 | } | 4434 | } |
4435 | } | 4435 | } |
4436 | } | 4436 | } |
4437 | goto cutIf14; | 4437 | goto cutIf14; |
4438 | } | 4438 | } |
4439 | } | 4439 | } |
4440 | } | 4440 | } |
4441 | } | 4441 | } |
4442 | foreach (bool l2 in YP.unify(Result, Char)) | 4442 | foreach (bool l2 in YP.unify(Result, Char)) |
4443 | { | 4443 | { |
4444 | foreach (bool l3 in YP.get_code(Next)) | 4444 | foreach (bool l3 in YP.get_code(Next)) |
4445 | { | 4445 | { |
4446 | yield return false; | 4446 | yield return false; |
4447 | } | 4447 | } |
4448 | } | 4448 | } |
4449 | cutIf14: | 4449 | cutIf14: |
4450 | cutIf12: | 4450 | cutIf12: |
4451 | cutIf1: | 4451 | cutIf1: |
4452 | { } | 4452 | { } |
4453 | } | 4453 | } |
4454 | } | 4454 | } |
4455 | 4455 | ||
4456 | } | 4456 | } |
4457 | } | 4457 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs index ffb8ddc..63b304a 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/PrologException.cs | |||
@@ -1,71 +1,71 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 33 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A PrologException is used as the exception thrown by YP.throw(Term). | 36 | /// A PrologException is used as the exception thrown by YP.throw(Term). |
37 | /// </summary> | 37 | /// </summary> |
38 | public class PrologException : Exception | 38 | public class PrologException : Exception |
39 | { | 39 | { |
40 | public readonly object _term; | 40 | public readonly object _term; |
41 | 41 | ||
42 | /// <summary> | 42 | /// <summary> |
43 | /// Create a PrologException with the given Term. The printable exception message is the full Term. | 43 | /// Create a PrologException with the given Term. The printable exception message is the full Term. |
44 | /// </summary> | 44 | /// </summary> |
45 | /// <param name="Term">the term of the exception</param> | 45 | /// <param name="Term">the term of the exception</param> |
46 | /// </param> | 46 | /// </param> |
47 | public PrologException(object Term) | 47 | public PrologException(object Term) |
48 | : base(YP.getValue(Term).ToString()) | 48 | : base(YP.getValue(Term).ToString()) |
49 | { | 49 | { |
50 | _term = YP.makeCopy(Term, new Variable.CopyStore()); | 50 | _term = YP.makeCopy(Term, new Variable.CopyStore()); |
51 | } | 51 | } |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// Create a PrologException where the Term is error(ErrorTerm, Message). | 54 | /// Create a PrologException where the Term is error(ErrorTerm, Message). |
55 | /// This uses YP.makeCopy to copy the ErrorTerm and Message so that they are valid after unbinding. | 55 | /// This uses YP.makeCopy to copy the ErrorTerm and Message so that they are valid after unbinding. |
56 | /// </summary> | 56 | /// </summary> |
57 | /// <param name="ErrorTerm">the term of the exception</param> | 57 | /// <param name="ErrorTerm">the term of the exception</param> |
58 | /// <param name="Messsage">the message, converted to a string, to use as the printable exception message | 58 | /// <param name="Messsage">the message, converted to a string, to use as the printable exception message |
59 | /// </param> | 59 | /// </param> |
60 | public PrologException(object ErrorTerm, object Message) | 60 | public PrologException(object ErrorTerm, object Message) |
61 | : base(YP.getValue(Message).ToString()) | 61 | : base(YP.getValue(Message).ToString()) |
62 | { | 62 | { |
63 | _term = YP.makeCopy(new Functor2(Atom.a("error"), ErrorTerm, Message), new Variable.CopyStore()); | 63 | _term = YP.makeCopy(new Functor2(Atom.a("error"), ErrorTerm, Message), new Variable.CopyStore()); |
64 | } | 64 | } |
65 | 65 | ||
66 | public object Term | 66 | public object Term |
67 | { | 67 | { |
68 | get { return _term; } | 68 | get { return _term; } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | } | 71 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT index 05186f1..a1beeb6 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT | |||
@@ -1,405 +1,405 @@ | |||
1 | YPOS: YieldProlog for OpenSim | 1 | YPOS: YieldProlog for OpenSim |
2 | 2 | ||
3 | a compiler from Prolog to OpenSim compatible C# scripts | 3 | a compiler from Prolog to OpenSim compatible C# scripts |
4 | 4 | ||
5 | Ported by Kino Coursey and Douglas Miles at Daxtron Labs. | 5 | Ported by Kino Coursey and Douglas Miles at Daxtron Labs. |
6 | Based on Jeff Thompson Yield Prolog, http://yieldprolog.sourceforge.net/ | 6 | Based on Jeff Thompson Yield Prolog, http://yieldprolog.sourceforge.net/ |
7 | For Prolog see http://en.wikipedia.org/wiki/Prolog | 7 | For Prolog see http://en.wikipedia.org/wiki/Prolog |
8 | 8 | ||
9 | 9 | ||
10 | INTRODUCTION | 10 | INTRODUCTION |
11 | 11 | ||
12 | This folder contains code to implement a Prolog compiler using the "Yield Statement" found in C#, Javascript, and Python. | 12 | This folder contains code to implement a Prolog compiler using the "Yield Statement" found in C#, Javascript, and Python. |
13 | The original Yield Prolog system can transform Prolog programs into C# code. | 13 | The original Yield Prolog system can transform Prolog programs into C# code. |
14 | In this system we detect and extract YieldProlog code (with "//YP" as the first four characters in the script) and seperate it from any c# code ("marked by "//CS"). | 14 | In this system we detect and extract YieldProlog code (with "//YP" as the first four characters in the script) and seperate it from any c# code ("marked by "//CS"). |
15 | The YP code is transformed to C# and prepended to the "//CS" section, and passed as a bundel to the existing C# compiler. | 15 | The YP code is transformed to C# and prepended to the "//CS" section, and passed as a bundel to the existing C# compiler. |
16 | The end result is Prolog can interface to OpenSim using the existing "//CS" functionality, and C# can call the compiled Prolog. | 16 | The end result is Prolog can interface to OpenSim using the existing "//CS" functionality, and C# can call the compiled Prolog. |
17 | As such YP allows both declaritive and procedural programming in a 3D script enabled environment. | 17 | As such YP allows both declaritive and procedural programming in a 3D script enabled environment. |
18 | 18 | ||
19 | FEATURES | 19 | FEATURES |
20 | * Allows implementation of logic programming for objects and agents. | 20 | * Allows implementation of logic programming for objects and agents. |
21 | * C#/Javascript/Python as intermediate language | 21 | * C#/Javascript/Python as intermediate language |
22 | * Yield Prolog has relatively high speed of execution which is important in OpenSim. http://yieldprolog.sourceforge.net/benchmarks.html | 22 | * Yield Prolog has relatively high speed of execution which is important in OpenSim. http://yieldprolog.sourceforge.net/benchmarks.html |
23 | * It is compatable with the existing C#/Mono based system. | 23 | * It is compatable with the existing C#/Mono based system. |
24 | * Yield Prolog is BSD license | 24 | * Yield Prolog is BSD license |
25 | * Calling Prolog from C# scripts | 25 | * Calling Prolog from C# scripts |
26 | * Calling C# functions (with LSL and OS functions) from Prolog | 26 | * Calling C# functions (with LSL and OS functions) from Prolog |
27 | * Prolog dynamic database | 27 | * Prolog dynamic database |
28 | * Edinburgh, Cocksin & Mellish style syntax. | 28 | * Edinburgh, Cocksin & Mellish style syntax. |
29 | * Compiler is generated by compiling the Prolog descrition of itself into C# | 29 | * Compiler is generated by compiling the Prolog descrition of itself into C# |
30 | * Same script entry interface as LSL | 30 | * Same script entry interface as LSL |
31 | 31 | ||
32 | 32 | ||
33 | TODO | 33 | TODO |
34 | * Utilize ability to generate Javascript and Python code | 34 | * Utilize ability to generate Javascript and Python code |
35 | * Integrate Prolog database with Sim | 35 | * Integrate Prolog database with Sim |
36 | * Translation error reporting back to the editor | 36 | * Translation error reporting back to the editor |
37 | * Communications via message passing | 37 | * Communications via message passing |
38 | * Interface to external inference engines | 38 | * Interface to external inference engines |
39 | 39 | ||
40 | POSSIBILITIES | 40 | POSSIBILITIES |
41 | * Inworld expert systems | 41 | * Inworld expert systems |
42 | * Parallel logic programming and expert systems | 42 | * Parallel logic programming and expert systems |
43 | * Ontology based processing | 43 | * Ontology based processing |
44 | * Knowledge based alerting, accessing and business rules | 44 | * Knowledge based alerting, accessing and business rules |
45 | For instance, listen on channel x, filter the events and broadcast alerts on channel y | 45 | For instance, listen on channel x, filter the events and broadcast alerts on channel y |
46 | or send IM, emails etc. | 46 | or send IM, emails etc. |
47 | 47 | ||
48 | 48 | ||
49 | USAGE: | 49 | USAGE: |
50 | 50 | ||
51 | Add "yp" as an allowed compiler | 51 | Add "yp" as an allowed compiler |
52 | 52 | ||
53 | OpenSim.ini | 53 | OpenSim.ini |
54 | [ScriptEngine.DotNetEngine] | 54 | [ScriptEngine.DotNetEngine] |
55 | AllowedCompilers=lsl,cs,js,vb,yp | 55 | AllowedCompilers=lsl,cs,js,vb,yp |
56 | 56 | ||
57 | Enter scripts using the inworld editing process. Scripts have the following format. | 57 | Enter scripts using the inworld editing process. Scripts have the following format. |
58 | The first line of a file must have "//yp". | 58 | The first line of a file must have "//yp". |
59 | 59 | ||
60 | //yp | 60 | //yp |
61 | <PROLOG CODE> | 61 | <PROLOG CODE> |
62 | //CS | 62 | //CS |
63 | <CS CODE> | 63 | <CS CODE> |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | C# code calling a Prolog Predicate: | 70 | C# code calling a Prolog Predicate: |
71 | ----------------------------------- | 71 | ----------------------------------- |
72 | The Prolog predicate is transformed into a C# boolean function. So the general calling format is: | 72 | The Prolog predicate is transformed into a C# boolean function. So the general calling format is: |
73 | foreach( bool var in prolog_predicate(ARGS)) {}; | 73 | foreach( bool var in prolog_predicate(ARGS)) {}; |
74 | 74 | ||
75 | I/O is via using a string reader and writer in conjunction with YP.See() and YP.Tell() | 75 | I/O is via using a string reader and writer in conjunction with YP.See() and YP.Tell() |
76 | 76 | ||
77 | StringWriter PrologOutuput= new StringWriter(); | 77 | StringWriter PrologOutuput= new StringWriter(); |
78 | StringReader PrologInput= new StringReader(myInputString); | 78 | StringReader PrologInput= new StringReader(myInputString); |
79 | YP.see(PrologInput); | 79 | YP.see(PrologInput); |
80 | YP.tell(PrologOutuput); | 80 | YP.tell(PrologOutuput); |
81 | <CALL PROLOG CODE HERE> | 81 | <CALL PROLOG CODE HERE> |
82 | YP.seen(); | 82 | YP.seen(); |
83 | YP.told(); | 83 | YP.told(); |
84 | StringBuilder builder = PrologOutput.GetStringBuilder(); | 84 | StringBuilder builder = PrologOutput.GetStringBuilder(); |
85 | string finaloutput = builder.ToString(); | 85 | string finaloutput = builder.ToString(); |
86 | 86 | ||
87 | Any prolog reads and writes will be to the passed StringReader and StringWriter. In fact any TextReader/TextWriter class can be used. | 87 | Any prolog reads and writes will be to the passed StringReader and StringWriter. In fact any TextReader/TextWriter class can be used. |
88 | 88 | ||
89 | Strings in Prolog are stored as Atom's and you need to use an Atom object to match. | 89 | Strings in Prolog are stored as Atom's and you need to use an Atom object to match. |
90 | 90 | ||
91 | \\yp | 91 | \\yp |
92 | wanted('bob'). | 92 | wanted('bob'). |
93 | \\cs | 93 | \\cs |
94 | string Who="bob"; | 94 | string Who="bob"; |
95 | foreach( bool ans in wanted(Atom.a(Who) )){}; | 95 | foreach( bool ans in wanted(Atom.a(Who) )){}; |
96 | 96 | ||
97 | 97 | ||
98 | Prolog code calling a C# function: | 98 | Prolog code calling a C# function: |
99 | ----------------------------------- | 99 | ----------------------------------- |
100 | The prolog code uses the script_event('name_of_function',ARGS) builtin, which is transformed into the function call. | 100 | The prolog code uses the script_event('name_of_function',ARGS) builtin, which is transformed into the function call. |
101 | The C# function called uses "PrologCallback" and returns a boolean. | 101 | The C# function called uses "PrologCallback" and returns a boolean. |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | Dynamic database assertions: | 105 | Dynamic database assertions: |
106 | ----------------------------------- | 106 | ----------------------------------- |
107 | 107 | ||
108 | void assertdb2(string predicate, string arg1, string arg2) | 108 | void assertdb2(string predicate, string arg1, string arg2) |
109 | { | 109 | { |
110 | name = Atom.a(predicate); | 110 | name = Atom.a(predicate); |
111 | YP.assertFact(name, new object[] { arg1, arg2 }); | 111 | YP.assertFact(name, new object[] { arg1, arg2 }); |
112 | } | 112 | } |
113 | 113 | ||
114 | void retractdb2(string predicate, string arg1, string arg2) | 114 | void retractdb2(string predicate, string arg1, string arg2) |
115 | { | 115 | { |
116 | name = Atom.a(predicate); | 116 | name = Atom.a(predicate); |
117 | YP.retractFact(name, new object[] { arg1, arg2 }); | 117 | YP.retractFact(name, new object[] { arg1, arg2 }); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | ========================= APPENDIX A: touch test ================================ | 121 | ========================= APPENDIX A: touch test ================================ |
122 | 122 | ||
123 | 123 | ||
124 | =================================== | 124 | =================================== |
125 | Input YP Code | 125 | Input YP Code |
126 | =================================== | 126 | =================================== |
127 | //yp | 127 | //yp |
128 | mydb('field2','field1'). | 128 | mydb('field2','field1'). |
129 | mydb('andy','jane'). | 129 | mydb('andy','jane'). |
130 | mydb('carl','dan'). | 130 | mydb('carl','dan'). |
131 | mydb('andy','bill'). | 131 | mydb('andy','bill'). |
132 | mydb('andy','betty'). | 132 | mydb('andy','betty'). |
133 | 133 | ||
134 | call_me(X):-mydb(X,Y) , respond(Y). | 134 | call_me(X):-mydb(X,Y) , respond(Y). |
135 | respond(X):- script_event('sayit',X). | 135 | respond(X):- script_event('sayit',X). |
136 | 136 | ||
137 | //cs | 137 | //cs |
138 | public void default_event_touch_start(int N ) | 138 | public void default_event_touch_start(int N ) |
139 | { | 139 | { |
140 | llSay(0,"pstart1"); | 140 | llSay(0,"pstart1"); |
141 | foreach( bool ans in call_me(Atom.a(@"andy") )){}; | 141 | foreach( bool ans in call_me(Atom.a(@"andy") )){}; |
142 | llSay(0,"pstop2"); | 142 | llSay(0,"pstop2"); |
143 | } | 143 | } |
144 | 144 | ||
145 | public void default_event_state_entry() | 145 | public void default_event_state_entry() |
146 | { | 146 | { |
147 | llSay(0,"prolog tester active."); | 147 | llSay(0,"prolog tester active."); |
148 | } | 148 | } |
149 | 149 | ||
150 | PrologCallback sayit(object ans) | 150 | PrologCallback sayit(object ans) |
151 | { | 151 | { |
152 | llSay(0,"sayit1"); | 152 | llSay(0,"sayit1"); |
153 | string msg = "one answer is :"+((Variable)ans).getValue(); | 153 | string msg = "one answer is :"+((Variable)ans).getValue(); |
154 | llSay(0,msg); | 154 | llSay(0,msg); |
155 | yield return false; | 155 | yield return false; |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | =================================== | 159 | =================================== |
160 | Generated CS Code | 160 | Generated CS Code |
161 | =================================== | 161 | =================================== |
162 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog;using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic; | 162 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog;using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic; |
163 | namespace SecondLife { public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { | 163 | namespace SecondLife { public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { |
164 | static OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP YP=null;public Script() { YP= new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP(); } | 164 | static OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP YP=null;public Script() { YP= new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP(); } |
165 | //cs | 165 | //cs |
166 | public void default_event_touch_start(int N ) | 166 | public void default_event_touch_start(int N ) |
167 | { | 167 | { |
168 | llSay(0,"pstart1"); | 168 | llSay(0,"pstart1"); |
169 | foreach( bool ans in call_me(Atom.a(@"carl") )){}; | 169 | foreach( bool ans in call_me(Atom.a(@"carl") )){}; |
170 | llSay(0,"pstop2"); | 170 | llSay(0,"pstop2"); |
171 | } | 171 | } |
172 | 172 | ||
173 | public void default_event_state_entry() | 173 | public void default_event_state_entry() |
174 | { | 174 | { |
175 | llSay(0,"prolog tester active."); | 175 | llSay(0,"prolog tester active."); |
176 | } | 176 | } |
177 | 177 | ||
178 | public IEnumerable<bool> sayit(object ans) | 178 | public IEnumerable<bool> sayit(object ans) |
179 | { | 179 | { |
180 | llSay(0,"sayit1"); | 180 | llSay(0,"sayit1"); |
181 | string msg = "one answer is :"+((Variable)ans).getValue(); | 181 | string msg = "one answer is :"+((Variable)ans).getValue(); |
182 | llSay(0,msg); | 182 | llSay(0,msg); |
183 | yield return false; | 183 | yield return false; |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | //YPEncoded | 187 | //YPEncoded |
188 | public IEnumerable<bool> mydb(object arg1, object arg2) { | 188 | public IEnumerable<bool> mydb(object arg1, object arg2) { |
189 | { | 189 | { |
190 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"carl"))) { | 190 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"carl"))) { |
191 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"dan"))) { | 191 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"dan"))) { |
192 | yield return false; | 192 | yield return false; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | { | 196 | { |
197 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"andy"))) { | 197 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"andy"))) { |
198 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"bill"))) { | 198 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"bill"))) { |
199 | yield return false; | 199 | yield return false; |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | { | 203 | { |
204 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"andy"))) { | 204 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"andy"))) { |
205 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"betty"))) { | 205 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"betty"))) { |
206 | yield return false; | 206 | yield return false; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | public IEnumerable<bool> call_me(object X) { | 212 | public IEnumerable<bool> call_me(object X) { |
213 | { | 213 | { |
214 | Variable Y = new Variable(); | 214 | Variable Y = new Variable(); |
215 | foreach (bool l2 in mydb(X, Y)) { | 215 | foreach (bool l2 in mydb(X, Y)) { |
216 | foreach (bool l3 in respond(Y)) { | 216 | foreach (bool l3 in respond(Y)) { |
217 | yield return false; | 217 | yield return false; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | public IEnumerable<bool> respond(object X) { | 223 | public IEnumerable<bool> respond(object X) { |
224 | { | 224 | { |
225 | foreach (bool l2 in this.sayit( X)) { | 225 | foreach (bool l2 in this.sayit( X)) { |
226 | yield return false; | 226 | yield return false; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | } } | 231 | } } |
232 | 232 | ||
233 | 233 | ||
234 | 234 | ||
235 | ========================= APPENDIX B:SENSOR INFORMED SCRIPT ===================== | 235 | ========================= APPENDIX B:SENSOR INFORMED SCRIPT ===================== |
236 | 236 | ||
237 | 237 | ||
238 | =================================== | 238 | =================================== |
239 | Input YP Code | 239 | Input YP Code |
240 | =================================== | 240 | =================================== |
241 | //yp | 241 | //yp |
242 | 242 | ||
243 | nop. | 243 | nop. |
244 | 244 | ||
245 | good('Daxxon Kinoc'). | 245 | good('Daxxon Kinoc'). |
246 | good('Fluffy Kitty'). | 246 | good('Fluffy Kitty'). |
247 | 247 | ||
248 | bad('Eric Evil'). | 248 | bad('Eric Evil'). |
249 | bad('Spikey Plant'). | 249 | bad('Spikey Plant'). |
250 | 250 | ||
251 | prolog_notify(X) :- good(X) , script_event('accept',X). | 251 | prolog_notify(X) :- good(X) , script_event('accept',X). |
252 | prolog_notify(X) :- bad(X) , script_event('reject',X). | 252 | prolog_notify(X) :- bad(X) , script_event('reject',X). |
253 | 253 | ||
254 | 254 | ||
255 | //cs | 255 | //cs |
256 | 256 | ||
257 | public void default_event_state_entry() | 257 | public void default_event_state_entry() |
258 | { | 258 | { |
259 | llSay(0,"prolog sensor tester active."); | 259 | llSay(0,"prolog sensor tester active."); |
260 | 260 | ||
261 | // Start a sensor looking for Agents | 261 | // Start a sensor looking for Agents |
262 | llSensorRepeat("","",AGENT, 10, PI,20); | 262 | llSensorRepeat("","",AGENT, 10, PI,20); |
263 | 263 | ||
264 | } | 264 | } |
265 | 265 | ||
266 | public void default_event_sensor(int number_detected ) | 266 | public void default_event_sensor(int number_detected ) |
267 | { | 267 | { |
268 | int i; | 268 | int i; |
269 | for(i=0;i< number_detected ;i++) | 269 | for(i=0;i< number_detected ;i++) |
270 | { | 270 | { |
271 | string dName = llDetectedName(i); | 271 | string dName = llDetectedName(i); |
272 | string dOwner = llDetectedName(i); | 272 | string dOwner = llDetectedName(i); |
273 | foreach(bool response in prolog_notify(Atom.a(dName)) ){}; | 273 | foreach(bool response in prolog_notify(Atom.a(dName)) ){}; |
274 | foreach(bool response in prolog_notify(dOwner) ){}; | 274 | foreach(bool response in prolog_notify(dOwner) ){}; |
275 | llSay(0,"Saw "+dName); | 275 | llSay(0,"Saw "+dName); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | string decodeToString(object obj) | 279 | string decodeToString(object obj) |
280 | { | 280 | { |
281 | if (obj is Variable) { return (string) ((Variable)obj).getValue();} | 281 | if (obj is Variable) { return (string) ((Variable)obj).getValue();} |
282 | if (obj is Atom) { return (string) ((Atom)obj)._name;} | 282 | if (obj is Atom) { return (string) ((Atom)obj)._name;} |
283 | return "unknown type"; | 283 | return "unknown type"; |
284 | } | 284 | } |
285 | 285 | ||
286 | PrologCallback accept(object ans) | 286 | PrologCallback accept(object ans) |
287 | { | 287 | { |
288 | string msg = "Welcoming :"+decodeToString(ans); | 288 | string msg = "Welcoming :"+decodeToString(ans); |
289 | llSay(0,msg); | 289 | llSay(0,msg); |
290 | yield return false; | 290 | yield return false; |
291 | } | 291 | } |
292 | 292 | ||
293 | PrologCallback reject(object ans) | 293 | PrologCallback reject(object ans) |
294 | { | 294 | { |
295 | string msg = "Watching :"+decodeToString(ans); | 295 | string msg = "Watching :"+decodeToString(ans); |
296 | llSay(0,msg); | 296 | llSay(0,msg); |
297 | yield return false; | 297 | yield return false; |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | =================================== | 301 | =================================== |
302 | Generated CS Code | 302 | Generated CS Code |
303 | =================================== | 303 | =================================== |
304 | 304 | ||
305 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic; | 305 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic; |
306 | namespace SecondLife { public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { | 306 | namespace SecondLife { public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { |
307 | static OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP YP=null; public Script() { YP= new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP(); } | 307 | static OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP YP=null; public Script() { YP= new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP(); } |
308 | //cs | 308 | //cs |
309 | 309 | ||
310 | public void default_event_state_entry() | 310 | public void default_event_state_entry() |
311 | { | 311 | { |
312 | llSay(0,"prolog sensor tester active."); | 312 | llSay(0,"prolog sensor tester active."); |
313 | 313 | ||
314 | // Start a sensor looking for Agents | 314 | // Start a sensor looking for Agents |
315 | llSensorRepeat("","",AGENT, 10, PI,20); | 315 | llSensorRepeat("","",AGENT, 10, PI,20); |
316 | 316 | ||
317 | } | 317 | } |
318 | 318 | ||
319 | public void default_event_sensor(int number_detected ) | 319 | public void default_event_sensor(int number_detected ) |
320 | { | 320 | { |
321 | int i; | 321 | int i; |
322 | for(i=0;i< number_detected ;i++) | 322 | for(i=0;i< number_detected ;i++) |
323 | { | 323 | { |
324 | string dName = llDetectedName(i); | 324 | string dName = llDetectedName(i); |
325 | string dOwner = llDetectedName(i); | 325 | string dOwner = llDetectedName(i); |
326 | foreach(bool response in prolog_notify(Atom.a(dName)) ){}; | 326 | foreach(bool response in prolog_notify(Atom.a(dName)) ){}; |
327 | foreach(bool response in prolog_notify(dOwner) ){}; | 327 | foreach(bool response in prolog_notify(dOwner) ){}; |
328 | llSay(0,"Saw "+dName); | 328 | llSay(0,"Saw "+dName); |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | string decodeToString(object obj) | 332 | string decodeToString(object obj) |
333 | { | 333 | { |
334 | if (obj is Variable) { return (string) ((Variable)obj).getValue();} | 334 | if (obj is Variable) { return (string) ((Variable)obj).getValue();} |
335 | if (obj is Atom) { return (string) ((Atom)obj)._name;} | 335 | if (obj is Atom) { return (string) ((Atom)obj)._name;} |
336 | return "unknown type"; | 336 | return "unknown type"; |
337 | } | 337 | } |
338 | 338 | ||
339 | public IEnumerable<bool> accept(object ans) | 339 | public IEnumerable<bool> accept(object ans) |
340 | { | 340 | { |
341 | string msg = "Welcoming :"+decodeToString(ans); | 341 | string msg = "Welcoming :"+decodeToString(ans); |
342 | llSay(0,msg); | 342 | llSay(0,msg); |
343 | yield return false; | 343 | yield return false; |
344 | } | 344 | } |
345 | 345 | ||
346 | public IEnumerable<bool> reject(object ans) | 346 | public IEnumerable<bool> reject(object ans) |
347 | { | 347 | { |
348 | string msg = "Watching :"+decodeToString(ans); | 348 | string msg = "Watching :"+decodeToString(ans); |
349 | llSay(0,msg); | 349 | llSay(0,msg); |
350 | yield return false; | 350 | yield return false; |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | //YPEncoded | 354 | //YPEncoded |
355 | public IEnumerable<bool> yp_nop_header_nop() { | 355 | public IEnumerable<bool> yp_nop_header_nop() { |
356 | { | 356 | { |
357 | yield return false; | 357 | yield return false; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | public IEnumerable<bool> good(object arg1) { | 361 | public IEnumerable<bool> good(object arg1) { |
362 | { | 362 | { |
363 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Daxxon Kinoc"))) { | 363 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Daxxon Kinoc"))) { |
364 | yield return false; | 364 | yield return false; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | { | 367 | { |
368 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Fluffy Kitty"))) { | 368 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Fluffy Kitty"))) { |
369 | yield return false; | 369 | yield return false; |
370 | } | 370 | } |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | public IEnumerable<bool> bad(object arg1) { | 374 | public IEnumerable<bool> bad(object arg1) { |
375 | { | 375 | { |
376 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Eric Evil"))) { | 376 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Eric Evil"))) { |
377 | yield return false; | 377 | yield return false; |
378 | } | 378 | } |
379 | } | 379 | } |
380 | { | 380 | { |
381 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Spikey Plant"))) { | 381 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"Spikey Plant"))) { |
382 | yield return false; | 382 | yield return false; |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | public IEnumerable<bool> prolog_notify(object X) { | 387 | public IEnumerable<bool> prolog_notify(object X) { |
388 | { | 388 | { |
389 | foreach (bool l2 in good(X)) { | 389 | foreach (bool l2 in good(X)) { |
390 | foreach (bool l3 in this.accept( X)) { | 390 | foreach (bool l3 in this.accept( X)) { |
391 | yield return false; | 391 | yield return false; |
392 | } | 392 | } |
393 | } | 393 | } |
394 | } | 394 | } |
395 | { | 395 | { |
396 | foreach (bool l2 in bad(X)) { | 396 | foreach (bool l2 in bad(X)) { |
397 | foreach (bool l3 in this.reject( X)) { | 397 | foreach (bool l3 in this.reject( X)) { |
398 | yield return false; | 398 | yield return false; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | } } | 404 | } } |
405 | 405 | ||
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/UndefinedPredicateException.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/UndefinedPredicateException.cs index 035b79c..f746a07 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/UndefinedPredicateException.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/UndefinedPredicateException.cs | |||
@@ -1,62 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 33 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// An UndefinedPredicateException extends PrologException to create an existence_error exception. | 36 | /// An UndefinedPredicateException extends PrologException to create an existence_error exception. |
37 | /// </summary> | 37 | /// </summary> |
38 | public class UndefinedPredicateException : PrologException | 38 | public class UndefinedPredicateException : PrologException |
39 | { | 39 | { |
40 | private Atom _predicateName; | 40 | private Atom _predicateName; |
41 | private int _arity; | 41 | private int _arity; |
42 | 42 | ||
43 | public UndefinedPredicateException(object message, Atom predicateName, int arity) | 43 | public UndefinedPredicateException(object message, Atom predicateName, int arity) |
44 | : base(new Functor2 | 44 | : base(new Functor2 |
45 | (Atom.a("existence_error"), Atom.a("procedure"), new Functor2(Atom.a("/"), predicateName, arity)), | 45 | (Atom.a("existence_error"), Atom.a("procedure"), new Functor2(Atom.a("/"), predicateName, arity)), |
46 | message) | 46 | message) |
47 | { | 47 | { |
48 | _predicateName = predicateName; | 48 | _predicateName = predicateName; |
49 | _arity = arity; | 49 | _arity = arity; |
50 | } | 50 | } |
51 | 51 | ||
52 | public Atom PredicateName | 52 | public Atom PredicateName |
53 | { | 53 | { |
54 | get { return _predicateName; } | 54 | get { return _predicateName; } |
55 | } | 55 | } |
56 | 56 | ||
57 | public int Arity | 57 | public int Arity |
58 | { | 58 | { |
59 | get { return _arity; } | 59 | get { return _arity; } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } | 62 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs index d5ee21c..47b5278 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs | |||
@@ -1,196 +1,196 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections; | 32 | using System.Collections; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | 34 | ||
35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 35 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
36 | { | 36 | { |
37 | public interface IUnifiable | 37 | public interface IUnifiable |
38 | { | 38 | { |
39 | IEnumerable<bool> unify(object arg); | 39 | IEnumerable<bool> unify(object arg); |
40 | void addUniqueVariables(List<Variable> variableSet); | 40 | void addUniqueVariables(List<Variable> variableSet); |
41 | object makeCopy(Variable.CopyStore copyStore); | 41 | object makeCopy(Variable.CopyStore copyStore); |
42 | bool termEqual(object term); | 42 | bool termEqual(object term); |
43 | bool ground(); | 43 | bool ground(); |
44 | } | 44 | } |
45 | 45 | ||
46 | public class Variable : IUnifiable | 46 | public class Variable : IUnifiable |
47 | { | 47 | { |
48 | // Use _isBound separate from _value so that it can be bound to any value, | 48 | // Use _isBound separate from _value so that it can be bound to any value, |
49 | // including null. | 49 | // including null. |
50 | private bool _isBound = false; | 50 | private bool _isBound = false; |
51 | private object _value; | 51 | private object _value; |
52 | 52 | ||
53 | public object getValue() | 53 | public object getValue() |
54 | { | 54 | { |
55 | if (!_isBound) | 55 | if (!_isBound) |
56 | return this; | 56 | return this; |
57 | 57 | ||
58 | object result = _value; | 58 | object result = _value; |
59 | while (result is Variable) | 59 | while (result is Variable) |
60 | { | 60 | { |
61 | if (!((Variable)result)._isBound) | 61 | if (!((Variable)result)._isBound) |
62 | return result; | 62 | return result; |
63 | 63 | ||
64 | // Keep following the Variable chain. | 64 | // Keep following the Variable chain. |
65 | result = ((Variable)result)._value; | 65 | result = ((Variable)result)._value; |
66 | } | 66 | } |
67 | 67 | ||
68 | return result; | 68 | return result; |
69 | } | 69 | } |
70 | 70 | ||
71 | public IEnumerable<bool> unify(object arg) | 71 | public IEnumerable<bool> unify(object arg) |
72 | { | 72 | { |
73 | if (!_isBound) | 73 | if (!_isBound) |
74 | { | 74 | { |
75 | _value = YP.getValue(arg); | 75 | _value = YP.getValue(arg); |
76 | if (_value == this) | 76 | if (_value == this) |
77 | // We are unifying this unbound variable with itself, so leave it unbound. | 77 | // We are unifying this unbound variable with itself, so leave it unbound. |
78 | yield return false; | 78 | yield return false; |
79 | else | 79 | else |
80 | { | 80 | { |
81 | _isBound = true; | 81 | _isBound = true; |
82 | try | 82 | try |
83 | { | 83 | { |
84 | yield return false; | 84 | yield return false; |
85 | } | 85 | } |
86 | finally | 86 | finally |
87 | { | 87 | { |
88 | // Remove the binding. | 88 | // Remove the binding. |
89 | _isBound = false; | 89 | _isBound = false; |
90 | } | 90 | } |
91 | } | 91 | } |
92 | } | 92 | } |
93 | else | 93 | else |
94 | { | 94 | { |
95 | foreach (bool l1 in YP.unify(this, arg)) | 95 | foreach (bool l1 in YP.unify(this, arg)) |
96 | yield return false; | 96 | yield return false; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | public override string ToString() | 100 | public override string ToString() |
101 | { | 101 | { |
102 | object value = getValue(); | 102 | object value = getValue(); |
103 | if (value == this) | 103 | if (value == this) |
104 | return "Variable"; | 104 | return "Variable"; |
105 | else | 105 | else |
106 | return getValue().ToString(); | 106 | return getValue().ToString(); |
107 | } | 107 | } |
108 | 108 | ||
109 | /// <summary> | 109 | /// <summary> |
110 | /// If bound, call YP.addUniqueVariables on the value. Otherwise, if this unbound | 110 | /// If bound, call YP.addUniqueVariables on the value. Otherwise, if this unbound |
111 | /// variable is not already in variableSet, add it. | 111 | /// variable is not already in variableSet, add it. |
112 | /// </summary> | 112 | /// </summary> |
113 | /// <param name="variableSet"></param> | 113 | /// <param name="variableSet"></param> |
114 | public void addUniqueVariables(List<Variable> variableSet) | 114 | public void addUniqueVariables(List<Variable> variableSet) |
115 | { | 115 | { |
116 | if (_isBound) | 116 | if (_isBound) |
117 | YP.addUniqueVariables(getValue(), variableSet); | 117 | YP.addUniqueVariables(getValue(), variableSet); |
118 | else | 118 | else |
119 | { | 119 | { |
120 | if (variableSet.IndexOf(this) < 0) | 120 | if (variableSet.IndexOf(this) < 0) |
121 | variableSet.Add(this); | 121 | variableSet.Add(this); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | /// <summary> | 125 | /// <summary> |
126 | /// If bound, return YP.makeCopy for the value, else return copyStore.getCopy(this). | 126 | /// If bound, return YP.makeCopy for the value, else return copyStore.getCopy(this). |
127 | /// However, if copyStore is null, just return this. | 127 | /// However, if copyStore is null, just return this. |
128 | /// </summary> | 128 | /// </summary> |
129 | /// <param name="copyStore"></param> | 129 | /// <param name="copyStore"></param> |
130 | /// <returns></returns> | 130 | /// <returns></returns> |
131 | public object makeCopy(Variable.CopyStore copyStore) | 131 | public object makeCopy(Variable.CopyStore copyStore) |
132 | { | 132 | { |
133 | if (_isBound) | 133 | if (_isBound) |
134 | return YP.makeCopy(getValue(), copyStore); | 134 | return YP.makeCopy(getValue(), copyStore); |
135 | else | 135 | else |
136 | return copyStore == null ? this : copyStore.getCopy(this); | 136 | return copyStore == null ? this : copyStore.getCopy(this); |
137 | } | 137 | } |
138 | 138 | ||
139 | public bool termEqual(object term) | 139 | public bool termEqual(object term) |
140 | { | 140 | { |
141 | if (_isBound) | 141 | if (_isBound) |
142 | return YP.termEqual(getValue(), term); | 142 | return YP.termEqual(getValue(), term); |
143 | else | 143 | else |
144 | return this == YP.getValue(term); | 144 | return this == YP.getValue(term); |
145 | } | 145 | } |
146 | 146 | ||
147 | public bool ground() | 147 | public bool ground() |
148 | { | 148 | { |
149 | if (_isBound) | 149 | if (_isBound) |
150 | // This is usually called by YP.ground which already did getValue, so this | 150 | // This is usually called by YP.ground which already did getValue, so this |
151 | // should never be reached, but check anyway. | 151 | // should never be reached, but check anyway. |
152 | return YP.ground(getValue()); | 152 | return YP.ground(getValue()); |
153 | else | 153 | else |
154 | return false; | 154 | return false; |
155 | } | 155 | } |
156 | 156 | ||
157 | /// <summary> | 157 | /// <summary> |
158 | /// A CopyStore is used by makeCopy to track which Variable objects have | 158 | /// A CopyStore is used by makeCopy to track which Variable objects have |
159 | /// been copied. | 159 | /// been copied. |
160 | /// </summary> | 160 | /// </summary> |
161 | public class CopyStore | 161 | public class CopyStore |
162 | { | 162 | { |
163 | private List<Variable> _inVariableSet = new List<Variable>(); | 163 | private List<Variable> _inVariableSet = new List<Variable>(); |
164 | private List<Variable> _outVariableSet = new List<Variable>(); | 164 | private List<Variable> _outVariableSet = new List<Variable>(); |
165 | 165 | ||
166 | /// <summary> | 166 | /// <summary> |
167 | /// If inVariable has already been copied, return its copy. Otherwise, | 167 | /// If inVariable has already been copied, return its copy. Otherwise, |
168 | /// return a fresh Variable associated with inVariable. | 168 | /// return a fresh Variable associated with inVariable. |
169 | /// </summary> | 169 | /// </summary> |
170 | /// <param name="inVariable"></param> | 170 | /// <param name="inVariable"></param> |
171 | /// <returns></returns> | 171 | /// <returns></returns> |
172 | public Variable getCopy(Variable inVariable) | 172 | public Variable getCopy(Variable inVariable) |
173 | { | 173 | { |
174 | int index = _inVariableSet.IndexOf(inVariable); | 174 | int index = _inVariableSet.IndexOf(inVariable); |
175 | if (index >= 0) | 175 | if (index >= 0) |
176 | return _outVariableSet[index]; | 176 | return _outVariableSet[index]; |
177 | else | 177 | else |
178 | { | 178 | { |
179 | Variable outVariable = new Variable(); | 179 | Variable outVariable = new Variable(); |
180 | _inVariableSet.Add(inVariable); | 180 | _inVariableSet.Add(inVariable); |
181 | _outVariableSet.Add(outVariable); | 181 | _outVariableSet.Add(outVariable); |
182 | return outVariable; | 182 | return outVariable; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | /// <summary> | 186 | /// <summary> |
187 | /// Return the number of unique variables that have been copied. | 187 | /// Return the number of unique variables that have been copied. |
188 | /// </summary> | 188 | /// </summary> |
189 | /// <returns></returns> | 189 | /// <returns></returns> |
190 | public int getNUniqueVariables() | 190 | public int getNUniqueVariables() |
191 | { | 191 | { |
192 | return _inVariableSet.Count; | 192 | return _inVariableSet.Count; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs index 3c0e4e0..2912ab9 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs | |||
@@ -1,1440 +1,1440 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections; | 32 | using System.Collections; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | using System.IO; | 34 | using System.IO; |
35 | using System.Reflection; | 35 | using System.Reflection; |
36 | 36 | ||
37 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 37 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// YP has static methods for general functions in Yield Prolog such as <see cref="getValue"/> | 40 | /// YP has static methods for general functions in Yield Prolog such as <see cref="getValue"/> |
41 | /// and <see cref="unify"/>. | 41 | /// and <see cref="unify"/>. |
42 | /// </summary> | 42 | /// </summary> |
43 | public class YP | 43 | public class YP |
44 | { | 44 | { |
45 | private static Fail _fail = new Fail(); | 45 | private static Fail _fail = new Fail(); |
46 | private static Repeat _repeat = new Repeat(); | 46 | private static Repeat _repeat = new Repeat(); |
47 | private static Dictionary<NameArity, List<IClause>> _predicatesStore = | 47 | private static Dictionary<NameArity, List<IClause>> _predicatesStore = |
48 | new Dictionary<NameArity, List<IClause>>(); | 48 | new Dictionary<NameArity, List<IClause>>(); |
49 | private static TextWriter _outputStream = System.Console.Out; | 49 | private static TextWriter _outputStream = System.Console.Out; |
50 | private static TextReader _inputStream = System.Console.In; | 50 | private static TextReader _inputStream = System.Console.In; |
51 | private static List<object[]> _operatorTable = null; | 51 | private static List<object[]> _operatorTable = null; |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// An IClause is used so that dynamic predicates can call match. | 54 | /// An IClause is used so that dynamic predicates can call match. |
55 | /// </summary> | 55 | /// </summary> |
56 | public interface IClause | 56 | public interface IClause |
57 | { | 57 | { |
58 | IEnumerable<bool> match(object[] args); | 58 | IEnumerable<bool> match(object[] args); |
59 | } | 59 | } |
60 | 60 | ||
61 | public static object getValue(object value) | 61 | public static object getValue(object value) |
62 | { | 62 | { |
63 | if (value is Variable) | 63 | if (value is Variable) |
64 | return ((Variable)value).getValue(); | 64 | return ((Variable)value).getValue(); |
65 | else | 65 | else |
66 | return value; | 66 | return value; |
67 | } | 67 | } |
68 | 68 | ||
69 | public static IEnumerable<bool> unify(object arg1, object arg2) | 69 | public static IEnumerable<bool> unify(object arg1, object arg2) |
70 | { | 70 | { |
71 | arg1 = getValue(arg1); | 71 | arg1 = getValue(arg1); |
72 | arg2 = getValue(arg2); | 72 | arg2 = getValue(arg2); |
73 | if (arg1 is IUnifiable) | 73 | if (arg1 is IUnifiable) |
74 | return ((IUnifiable)arg1).unify(arg2); | 74 | return ((IUnifiable)arg1).unify(arg2); |
75 | else if (arg2 is IUnifiable) | 75 | else if (arg2 is IUnifiable) |
76 | return ((IUnifiable)arg2).unify(arg1); | 76 | return ((IUnifiable)arg2).unify(arg1); |
77 | else | 77 | else |
78 | { | 78 | { |
79 | // Arguments are "normal" types. | 79 | // Arguments are "normal" types. |
80 | if (arg1.Equals(arg2)) | 80 | if (arg1.Equals(arg2)) |
81 | return new Succeed(); | 81 | return new Succeed(); |
82 | else | 82 | else |
83 | return _fail; | 83 | return _fail; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | /// <summary> | 87 | /// <summary> |
88 | /// This is used for the lookup key in _factStore. | 88 | /// This is used for the lookup key in _factStore. |
89 | /// </summary> | 89 | /// </summary> |
90 | public struct NameArity | 90 | public struct NameArity |
91 | { | 91 | { |
92 | public readonly Atom _name; | 92 | public readonly Atom _name; |
93 | public readonly int _arity; | 93 | public readonly int _arity; |
94 | 94 | ||
95 | public NameArity(Atom name, int arity) | 95 | public NameArity(Atom name, int arity) |
96 | { | 96 | { |
97 | _name = name; | 97 | _name = name; |
98 | _arity = arity; | 98 | _arity = arity; |
99 | } | 99 | } |
100 | 100 | ||
101 | public override bool Equals(object obj) | 101 | public override bool Equals(object obj) |
102 | { | 102 | { |
103 | if (obj is NameArity) | 103 | if (obj is NameArity) |
104 | { | 104 | { |
105 | NameArity nameArity = (NameArity)obj; | 105 | NameArity nameArity = (NameArity)obj; |
106 | return nameArity._name.Equals(_name) && nameArity._arity.Equals(_arity); | 106 | return nameArity._name.Equals(_name) && nameArity._arity.Equals(_arity); |
107 | } | 107 | } |
108 | else | 108 | else |
109 | { | 109 | { |
110 | return false; | 110 | return false; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | public override int GetHashCode() | 114 | public override int GetHashCode() |
115 | { | 115 | { |
116 | return _name.GetHashCode() ^ _arity.GetHashCode(); | 116 | return _name.GetHashCode() ^ _arity.GetHashCode(); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | /// <summary> | 120 | /// <summary> |
121 | /// Convert term to an int. | 121 | /// Convert term to an int. |
122 | /// If term is a single-element List, use its first element | 122 | /// If term is a single-element List, use its first element |
123 | /// (to handle the char types like "a"). If can't convert, throw an exception. | 123 | /// (to handle the char types like "a"). If can't convert, throw an exception. |
124 | /// </summary> | 124 | /// </summary> |
125 | /// <param name="term"></param> | 125 | /// <param name="term"></param> |
126 | /// <returns></returns> | 126 | /// <returns></returns> |
127 | public static int convertInt(object term) | 127 | public static int convertInt(object term) |
128 | { | 128 | { |
129 | term = YP.getValue(term); | 129 | term = YP.getValue(term); |
130 | if (term is Functor2 && ((Functor2)term)._name == Atom.DOT && | 130 | if (term is Functor2 && ((Functor2)term)._name == Atom.DOT && |
131 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) | 131 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) |
132 | // Assume it is a char type like "a". | 132 | // Assume it is a char type like "a". |
133 | term = YP.getValue(((Functor2)term)._arg1); | 133 | term = YP.getValue(((Functor2)term)._arg1); |
134 | 134 | ||
135 | return (int)term; | 135 | return (int)term; |
136 | } | 136 | } |
137 | 137 | ||
138 | /// <summary> | 138 | /// <summary> |
139 | /// Convert term to a double. This may convert an int to a double, etc. | 139 | /// Convert term to a double. This may convert an int to a double, etc. |
140 | /// If term is a single-element List, use its first element | 140 | /// If term is a single-element List, use its first element |
141 | /// (to handle the char types like "a"). If can't convert, throw an exception. | 141 | /// (to handle the char types like "a"). If can't convert, throw an exception. |
142 | /// </summary> | 142 | /// </summary> |
143 | /// <param name="term"></param> | 143 | /// <param name="term"></param> |
144 | /// <returns></returns> | 144 | /// <returns></returns> |
145 | public static double convertDouble(object term) | 145 | public static double convertDouble(object term) |
146 | { | 146 | { |
147 | term = YP.getValue(term); | 147 | term = YP.getValue(term); |
148 | if (term is Functor2 && ((Functor2)term)._name == Atom.DOT && | 148 | if (term is Functor2 && ((Functor2)term)._name == Atom.DOT && |
149 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) | 149 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) |
150 | // Assume it is a char type like "a". | 150 | // Assume it is a char type like "a". |
151 | term = YP.getValue(((Functor2)term)._arg1); | 151 | term = YP.getValue(((Functor2)term)._arg1); |
152 | 152 | ||
153 | return Convert.ToDouble(term); | 153 | return Convert.ToDouble(term); |
154 | } | 154 | } |
155 | 155 | ||
156 | /// <summary> | 156 | /// <summary> |
157 | /// If term is an integer, set intTerm. | 157 | /// If term is an integer, set intTerm. |
158 | /// If term is a single-element List, use its first element | 158 | /// If term is a single-element List, use its first element |
159 | /// (to handle the char types like "a"). Return true for success, false if can't convert. | 159 | /// (to handle the char types like "a"). Return true for success, false if can't convert. |
160 | /// We use a success return value because throwing an exception is inefficient. | 160 | /// We use a success return value because throwing an exception is inefficient. |
161 | /// </summary> | 161 | /// </summary> |
162 | /// <param name="term"></param> | 162 | /// <param name="term"></param> |
163 | /// <returns></returns> | 163 | /// <returns></returns> |
164 | public static bool getInt(object term, out int intTerm) | 164 | public static bool getInt(object term, out int intTerm) |
165 | { | 165 | { |
166 | term = YP.getValue(term); | 166 | term = YP.getValue(term); |
167 | if (term is Functor2 && ((Functor2)term)._name == Atom.DOT && | 167 | if (term is Functor2 && ((Functor2)term)._name == Atom.DOT && |
168 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) | 168 | YP.getValue(((Functor2)term)._arg2) == Atom.NIL) |
169 | // Assume it is a char type like "a". | 169 | // Assume it is a char type like "a". |
170 | term = YP.getValue(((Functor2)term)._arg1); | 170 | term = YP.getValue(((Functor2)term)._arg1); |
171 | 171 | ||
172 | if (term is int) | 172 | if (term is int) |
173 | { | 173 | { |
174 | intTerm = (int)term; | 174 | intTerm = (int)term; |
175 | return true; | 175 | return true; |
176 | } | 176 | } |
177 | 177 | ||
178 | intTerm = 0; | 178 | intTerm = 0; |
179 | return false; | 179 | return false; |
180 | } | 180 | } |
181 | 181 | ||
182 | public static bool equal(object x, object y) | 182 | public static bool equal(object x, object y) |
183 | { | 183 | { |
184 | x = YP.getValue(x); | 184 | x = YP.getValue(x); |
185 | if (x is DateTime) | 185 | if (x is DateTime) |
186 | return (DateTime)x == (DateTime)YP.getValue(y); | 186 | return (DateTime)x == (DateTime)YP.getValue(y); |
187 | // Assume convertDouble converts an int to a double perfectly. | 187 | // Assume convertDouble converts an int to a double perfectly. |
188 | return YP.convertDouble(x) == YP.convertDouble(y); | 188 | return YP.convertDouble(x) == YP.convertDouble(y); |
189 | } | 189 | } |
190 | 190 | ||
191 | public static bool notEqual(object x, object y) | 191 | public static bool notEqual(object x, object y) |
192 | { | 192 | { |
193 | x = YP.getValue(x); | 193 | x = YP.getValue(x); |
194 | if (x is DateTime) | 194 | if (x is DateTime) |
195 | return (DateTime)x != (DateTime)YP.getValue(y); | 195 | return (DateTime)x != (DateTime)YP.getValue(y); |
196 | // Assume convertDouble converts an int to a double perfectly. | 196 | // Assume convertDouble converts an int to a double perfectly. |
197 | return YP.convertDouble(x) != YP.convertDouble(y); | 197 | return YP.convertDouble(x) != YP.convertDouble(y); |
198 | } | 198 | } |
199 | 199 | ||
200 | public static bool greaterThan(object x, object y) | 200 | public static bool greaterThan(object x, object y) |
201 | { | 201 | { |
202 | x = YP.getValue(x); | 202 | x = YP.getValue(x); |
203 | if (x is DateTime) | 203 | if (x is DateTime) |
204 | return (DateTime)x > (DateTime)YP.getValue(y); | 204 | return (DateTime)x > (DateTime)YP.getValue(y); |
205 | // Assume convertDouble converts an int to a double perfectly. | 205 | // Assume convertDouble converts an int to a double perfectly. |
206 | return YP.convertDouble(x) > YP.convertDouble(y); | 206 | return YP.convertDouble(x) > YP.convertDouble(y); |
207 | } | 207 | } |
208 | 208 | ||
209 | public static bool lessThan(object x, object y) | 209 | public static bool lessThan(object x, object y) |
210 | { | 210 | { |
211 | x = YP.getValue(x); | 211 | x = YP.getValue(x); |
212 | if (x is DateTime) | 212 | if (x is DateTime) |
213 | return (DateTime)x < (DateTime)YP.getValue(y); | 213 | return (DateTime)x < (DateTime)YP.getValue(y); |
214 | // Assume convertDouble converts an int to a double perfectly. | 214 | // Assume convertDouble converts an int to a double perfectly. |
215 | return YP.convertDouble(x) < YP.convertDouble(y); | 215 | return YP.convertDouble(x) < YP.convertDouble(y); |
216 | } | 216 | } |
217 | 217 | ||
218 | public static bool greaterThanOrEqual(object x, object y) | 218 | public static bool greaterThanOrEqual(object x, object y) |
219 | { | 219 | { |
220 | x = YP.getValue(x); | 220 | x = YP.getValue(x); |
221 | if (x is DateTime) | 221 | if (x is DateTime) |
222 | return (DateTime)x >= (DateTime)YP.getValue(y); | 222 | return (DateTime)x >= (DateTime)YP.getValue(y); |
223 | // Assume convertDouble converts an int to a double perfectly. | 223 | // Assume convertDouble converts an int to a double perfectly. |
224 | return YP.convertDouble(x) >= YP.convertDouble(y); | 224 | return YP.convertDouble(x) >= YP.convertDouble(y); |
225 | } | 225 | } |
226 | 226 | ||
227 | public static bool lessThanOrEqual(object x, object y) | 227 | public static bool lessThanOrEqual(object x, object y) |
228 | { | 228 | { |
229 | x = YP.getValue(x); | 229 | x = YP.getValue(x); |
230 | if (x is DateTime) | 230 | if (x is DateTime) |
231 | return (DateTime)x <= (DateTime)YP.getValue(y); | 231 | return (DateTime)x <= (DateTime)YP.getValue(y); |
232 | // Assume convertDouble converts an int to a double perfectly. | 232 | // Assume convertDouble converts an int to a double perfectly. |
233 | return YP.convertDouble(x) <= YP.convertDouble(y); | 233 | return YP.convertDouble(x) <= YP.convertDouble(y); |
234 | } | 234 | } |
235 | 235 | ||
236 | public static object negate(object x) | 236 | public static object negate(object x) |
237 | { | 237 | { |
238 | int intX; | 238 | int intX; |
239 | if (getInt(x, out intX)) | 239 | if (getInt(x, out intX)) |
240 | return -intX; | 240 | return -intX; |
241 | return -convertDouble(x); | 241 | return -convertDouble(x); |
242 | } | 242 | } |
243 | 243 | ||
244 | public static object abs(object x) | 244 | public static object abs(object x) |
245 | { | 245 | { |
246 | int intX; | 246 | int intX; |
247 | if (getInt(x, out intX)) | 247 | if (getInt(x, out intX)) |
248 | return Math.Abs(intX); | 248 | return Math.Abs(intX); |
249 | return Math.Abs(convertDouble(x)); | 249 | return Math.Abs(convertDouble(x)); |
250 | } | 250 | } |
251 | 251 | ||
252 | public static object sign(object x) | 252 | public static object sign(object x) |
253 | { | 253 | { |
254 | int intX; | 254 | int intX; |
255 | if (getInt(x, out intX)) | 255 | if (getInt(x, out intX)) |
256 | return Math.Sign(intX); | 256 | return Math.Sign(intX); |
257 | return Math.Sign(convertDouble(x)); | 257 | return Math.Sign(convertDouble(x)); |
258 | } | 258 | } |
259 | 259 | ||
260 | /// <summary> | 260 | /// <summary> |
261 | /// The ISO standard returns an int. | 261 | /// The ISO standard returns an int. |
262 | /// </summary> | 262 | /// </summary> |
263 | /// <param name="x"></param> | 263 | /// <param name="x"></param> |
264 | /// <returns></returns> | 264 | /// <returns></returns> |
265 | public static object floor(object x) | 265 | public static object floor(object x) |
266 | { | 266 | { |
267 | return (int)Math.Floor(convertDouble(x)); | 267 | return (int)Math.Floor(convertDouble(x)); |
268 | } | 268 | } |
269 | 269 | ||
270 | /// <summary> | 270 | /// <summary> |
271 | /// The ISO standard returns an int. | 271 | /// The ISO standard returns an int. |
272 | /// </summary> | 272 | /// </summary> |
273 | /// <param name="x"></param> | 273 | /// <param name="x"></param> |
274 | /// <returns></returns> | 274 | /// <returns></returns> |
275 | public static object truncate(object x) | 275 | public static object truncate(object x) |
276 | { | 276 | { |
277 | return (int)Math.Truncate(convertDouble(x)); | 277 | return (int)Math.Truncate(convertDouble(x)); |
278 | } | 278 | } |
279 | 279 | ||
280 | /// <summary> | 280 | /// <summary> |
281 | /// The ISO standard returns an int. | 281 | /// The ISO standard returns an int. |
282 | /// </summary> | 282 | /// </summary> |
283 | /// <param name="x"></param> | 283 | /// <param name="x"></param> |
284 | /// <returns></returns> | 284 | /// <returns></returns> |
285 | public static object round(object x) | 285 | public static object round(object x) |
286 | { | 286 | { |
287 | return (int)Math.Round(convertDouble(x)); | 287 | return (int)Math.Round(convertDouble(x)); |
288 | } | 288 | } |
289 | 289 | ||
290 | /// <summary> | 290 | /// <summary> |
291 | /// The ISO standard returns an int. | 291 | /// The ISO standard returns an int. |
292 | /// </summary> | 292 | /// </summary> |
293 | /// <param name="x"></param> | 293 | /// <param name="x"></param> |
294 | /// <returns></returns> | 294 | /// <returns></returns> |
295 | public static object ceiling(object x) | 295 | public static object ceiling(object x) |
296 | { | 296 | { |
297 | return (int)Math.Ceiling(convertDouble(x)); | 297 | return (int)Math.Ceiling(convertDouble(x)); |
298 | } | 298 | } |
299 | 299 | ||
300 | public static object sin(object x) | 300 | public static object sin(object x) |
301 | { | 301 | { |
302 | return Math.Sin(YP.convertDouble(x)); | 302 | return Math.Sin(YP.convertDouble(x)); |
303 | } | 303 | } |
304 | 304 | ||
305 | public static object cos(object x) | 305 | public static object cos(object x) |
306 | { | 306 | { |
307 | return Math.Cos(YP.convertDouble(x)); | 307 | return Math.Cos(YP.convertDouble(x)); |
308 | } | 308 | } |
309 | 309 | ||
310 | public static object atan(object x) | 310 | public static object atan(object x) |
311 | { | 311 | { |
312 | return Math.Atan(YP.convertDouble(x)); | 312 | return Math.Atan(YP.convertDouble(x)); |
313 | } | 313 | } |
314 | 314 | ||
315 | public static object exp(object x) | 315 | public static object exp(object x) |
316 | { | 316 | { |
317 | return Math.Exp(YP.convertDouble(x)); | 317 | return Math.Exp(YP.convertDouble(x)); |
318 | } | 318 | } |
319 | 319 | ||
320 | public static object log(object x) | 320 | public static object log(object x) |
321 | { | 321 | { |
322 | return Math.Log(YP.convertDouble(x)); | 322 | return Math.Log(YP.convertDouble(x)); |
323 | } | 323 | } |
324 | 324 | ||
325 | public static object sqrt(object x) | 325 | public static object sqrt(object x) |
326 | { | 326 | { |
327 | return Math.Sqrt(convertDouble(x)); | 327 | return Math.Sqrt(convertDouble(x)); |
328 | } | 328 | } |
329 | 329 | ||
330 | public static object bitwiseComplement(object x) | 330 | public static object bitwiseComplement(object x) |
331 | { | 331 | { |
332 | return ~YP.convertInt(x); | 332 | return ~YP.convertInt(x); |
333 | } | 333 | } |
334 | 334 | ||
335 | public static object add(object x, object y) | 335 | public static object add(object x, object y) |
336 | { | 336 | { |
337 | int intX, intY; | 337 | int intX, intY; |
338 | if (getInt(x, out intX) && getInt(y, out intY)) | 338 | if (getInt(x, out intX) && getInt(y, out intY)) |
339 | return intX + intY; | 339 | return intX + intY; |
340 | return convertDouble(x) + convertDouble(y); | 340 | return convertDouble(x) + convertDouble(y); |
341 | } | 341 | } |
342 | 342 | ||
343 | public static object subtract(object x, object y) | 343 | public static object subtract(object x, object y) |
344 | { | 344 | { |
345 | int intX, intY; | 345 | int intX, intY; |
346 | if (getInt(x, out intX) && getInt(y, out intY)) | 346 | if (getInt(x, out intX) && getInt(y, out intY)) |
347 | return intX - intY; | 347 | return intX - intY; |
348 | return convertDouble(x) - convertDouble(y); | 348 | return convertDouble(x) - convertDouble(y); |
349 | } | 349 | } |
350 | 350 | ||
351 | public static object multiply(object x, object y) | 351 | public static object multiply(object x, object y) |
352 | { | 352 | { |
353 | int intX, intY; | 353 | int intX, intY; |
354 | if (getInt(x, out intX) && getInt(y, out intY)) | 354 | if (getInt(x, out intX) && getInt(y, out intY)) |
355 | return intX * intY; | 355 | return intX * intY; |
356 | return convertDouble(x) * convertDouble(y); | 356 | return convertDouble(x) * convertDouble(y); |
357 | } | 357 | } |
358 | 358 | ||
359 | /// <summary> | 359 | /// <summary> |
360 | /// Return floating point, even if both arguments are integer. | 360 | /// Return floating point, even if both arguments are integer. |
361 | /// </summary> | 361 | /// </summary> |
362 | /// <param name="x"></param> | 362 | /// <param name="x"></param> |
363 | /// <param name="y"></param> | 363 | /// <param name="y"></param> |
364 | /// <returns></returns> | 364 | /// <returns></returns> |
365 | public static object divide(object x, object y) | 365 | public static object divide(object x, object y) |
366 | { | 366 | { |
367 | return convertDouble(x) / convertDouble(y); | 367 | return convertDouble(x) / convertDouble(y); |
368 | } | 368 | } |
369 | 369 | ||
370 | public static object intDivide(object x, object y) | 370 | public static object intDivide(object x, object y) |
371 | { | 371 | { |
372 | int intX, intY; | 372 | int intX, intY; |
373 | if (getInt(x, out intX) && getInt(y, out intY)) | 373 | if (getInt(x, out intX) && getInt(y, out intY)) |
374 | return intX / intY; | 374 | return intX / intY; |
375 | // Still allow passing a double, but treat as an int. | 375 | // Still allow passing a double, but treat as an int. |
376 | return (int)convertDouble(x) / (int)convertDouble(y); | 376 | return (int)convertDouble(x) / (int)convertDouble(y); |
377 | } | 377 | } |
378 | 378 | ||
379 | public static object mod(object x, object y) | 379 | public static object mod(object x, object y) |
380 | { | 380 | { |
381 | int intX, intY; | 381 | int intX, intY; |
382 | if (getInt(x, out intX) && getInt(y, out intY)) | 382 | if (getInt(x, out intX) && getInt(y, out intY)) |
383 | return intX % intY; | 383 | return intX % intY; |
384 | // Still allow passing a double, but treat as an int. | 384 | // Still allow passing a double, but treat as an int. |
385 | return (int)convertDouble(x) % (int)convertDouble(y); | 385 | return (int)convertDouble(x) % (int)convertDouble(y); |
386 | } | 386 | } |
387 | 387 | ||
388 | public static object pow(object x, object y) | 388 | public static object pow(object x, object y) |
389 | { | 389 | { |
390 | return Math.Pow(YP.convertDouble(x), YP.convertDouble(y)); | 390 | return Math.Pow(YP.convertDouble(x), YP.convertDouble(y)); |
391 | } | 391 | } |
392 | 392 | ||
393 | public static object bitwiseShiftRight(object x, object y) | 393 | public static object bitwiseShiftRight(object x, object y) |
394 | { | 394 | { |
395 | return YP.convertInt(x) >> YP.convertInt(y); | 395 | return YP.convertInt(x) >> YP.convertInt(y); |
396 | } | 396 | } |
397 | 397 | ||
398 | public static object bitwiseShiftLeft(object x, object y) | 398 | public static object bitwiseShiftLeft(object x, object y) |
399 | { | 399 | { |
400 | return YP.convertInt(x) << YP.convertInt(y); | 400 | return YP.convertInt(x) << YP.convertInt(y); |
401 | } | 401 | } |
402 | 402 | ||
403 | public static object bitwiseAnd(object x, object y) | 403 | public static object bitwiseAnd(object x, object y) |
404 | { | 404 | { |
405 | return YP.convertInt(x) & YP.convertInt(y); | 405 | return YP.convertInt(x) & YP.convertInt(y); |
406 | } | 406 | } |
407 | 407 | ||
408 | public static object bitwiseOr(object x, object y) | 408 | public static object bitwiseOr(object x, object y) |
409 | { | 409 | { |
410 | return YP.convertInt(x) | YP.convertInt(y); | 410 | return YP.convertInt(x) | YP.convertInt(y); |
411 | } | 411 | } |
412 | 412 | ||
413 | public static object min(object x, object y) | 413 | public static object min(object x, object y) |
414 | { | 414 | { |
415 | int intX, intY; | 415 | int intX, intY; |
416 | if (getInt(x, out intX) && getInt(y, out intY)) | 416 | if (getInt(x, out intX) && getInt(y, out intY)) |
417 | return Math.Min(intX, intY); | 417 | return Math.Min(intX, intY); |
418 | return Math.Min(convertDouble(x), convertDouble(y)); | 418 | return Math.Min(convertDouble(x), convertDouble(y)); |
419 | } | 419 | } |
420 | 420 | ||
421 | public static object max(object x, object y) | 421 | public static object max(object x, object y) |
422 | { | 422 | { |
423 | int intX, intY; | 423 | int intX, intY; |
424 | if (getInt(x, out intX) && getInt(y, out intY)) | 424 | if (getInt(x, out intX) && getInt(y, out intY)) |
425 | return Math.Max(intX, intY); | 425 | return Math.Max(intX, intY); |
426 | return Math.Max(convertDouble(x), convertDouble(y)); | 426 | return Math.Max(convertDouble(x), convertDouble(y)); |
427 | } | 427 | } |
428 | 428 | ||
429 | public static IEnumerable<bool> copy_term(object inTerm, object outTerm) | 429 | public static IEnumerable<bool> copy_term(object inTerm, object outTerm) |
430 | { | 430 | { |
431 | return YP.unify(outTerm, YP.makeCopy(inTerm, new Variable.CopyStore())); | 431 | return YP.unify(outTerm, YP.makeCopy(inTerm, new Variable.CopyStore())); |
432 | } | 432 | } |
433 | 433 | ||
434 | public static void addUniqueVariables(object term, List<Variable> variableSet) | 434 | public static void addUniqueVariables(object term, List<Variable> variableSet) |
435 | { | 435 | { |
436 | term = YP.getValue(term); | 436 | term = YP.getValue(term); |
437 | if (term is IUnifiable) | 437 | if (term is IUnifiable) |
438 | ((IUnifiable)term).addUniqueVariables(variableSet); | 438 | ((IUnifiable)term).addUniqueVariables(variableSet); |
439 | } | 439 | } |
440 | 440 | ||
441 | public static object makeCopy(object term, Variable.CopyStore copyStore) | 441 | public static object makeCopy(object term, Variable.CopyStore copyStore) |
442 | { | 442 | { |
443 | term = YP.getValue(term); | 443 | term = YP.getValue(term); |
444 | if (term is IUnifiable) | 444 | if (term is IUnifiable) |
445 | return ((IUnifiable)term).makeCopy(copyStore); | 445 | return ((IUnifiable)term).makeCopy(copyStore); |
446 | else | 446 | else |
447 | // term is a "normal" type. Assume it is ground. | 447 | // term is a "normal" type. Assume it is ground. |
448 | return term; | 448 | return term; |
449 | } | 449 | } |
450 | 450 | ||
451 | /// <summary> | 451 | /// <summary> |
452 | /// Sort the array in place according to termLessThan. This does not remove duplicates | 452 | /// Sort the array in place according to termLessThan. This does not remove duplicates |
453 | /// </summary> | 453 | /// </summary> |
454 | /// <param name="array"></param> | 454 | /// <param name="array"></param> |
455 | public static void sortArray(object[] array) | 455 | public static void sortArray(object[] array) |
456 | { | 456 | { |
457 | Array.Sort(array, YP.compareTerms); | 457 | Array.Sort(array, YP.compareTerms); |
458 | } | 458 | } |
459 | 459 | ||
460 | /// <summary> | 460 | /// <summary> |
461 | /// Sort the array in place according to termLessThan. This does not remove duplicates | 461 | /// Sort the array in place according to termLessThan. This does not remove duplicates |
462 | /// </summary> | 462 | /// </summary> |
463 | /// <param name="array"></param> | 463 | /// <param name="array"></param> |
464 | public static void sortArray(List<object> array) | 464 | public static void sortArray(List<object> array) |
465 | { | 465 | { |
466 | array.Sort(YP.compareTerms); | 466 | array.Sort(YP.compareTerms); |
467 | } | 467 | } |
468 | 468 | ||
469 | /// <summary> | 469 | /// <summary> |
470 | /// Sort List according to termLessThan, remove duplicates and unify with Sorted. | 470 | /// Sort List according to termLessThan, remove duplicates and unify with Sorted. |
471 | /// </summary> | 471 | /// </summary> |
472 | /// <param name="List"></param> | 472 | /// <param name="List"></param> |
473 | /// <param name="Sorted"></param> | 473 | /// <param name="Sorted"></param> |
474 | /// <returns></returns> | 474 | /// <returns></returns> |
475 | public static IEnumerable<bool> sort(object List, object Sorted) | 475 | public static IEnumerable<bool> sort(object List, object Sorted) |
476 | { | 476 | { |
477 | object[] array = ListPair.toArray(List); | 477 | object[] array = ListPair.toArray(List); |
478 | if (array == null) | 478 | if (array == null) |
479 | return YP.fail(); | 479 | return YP.fail(); |
480 | if (array.Length > 1) | 480 | if (array.Length > 1) |
481 | sortArray(array); | 481 | sortArray(array); |
482 | return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array)); | 482 | return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array)); |
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | 486 | ||
487 | /// <summary> | 487 | /// <summary> |
488 | /// Use YP.unify to unify each of the elements of the two arrays, and yield | 488 | /// Use YP.unify to unify each of the elements of the two arrays, and yield |
489 | /// once if they all unify. | 489 | /// once if they all unify. |
490 | /// </summary> | 490 | /// </summary> |
491 | /// <param name="array1"></param> | 491 | /// <param name="array1"></param> |
492 | /// <param name="array2"></param> | 492 | /// <param name="array2"></param> |
493 | /// <returns></returns> | 493 | /// <returns></returns> |
494 | public static IEnumerable<bool> unifyArrays(object[] array1, object[] array2) | 494 | public static IEnumerable<bool> unifyArrays(object[] array1, object[] array2) |
495 | { | 495 | { |
496 | if (array1.Length != array2.Length) | 496 | if (array1.Length != array2.Length) |
497 | yield break; | 497 | yield break; |
498 | 498 | ||
499 | IEnumerator<bool>[] iterators = new IEnumerator<bool>[array1.Length]; | 499 | IEnumerator<bool>[] iterators = new IEnumerator<bool>[array1.Length]; |
500 | bool gotMatch = true; | 500 | bool gotMatch = true; |
501 | int nIterators = 0; | 501 | int nIterators = 0; |
502 | // Try to bind all the arguments. | 502 | // Try to bind all the arguments. |
503 | for (int i = 0; i < array1.Length; ++i) | 503 | for (int i = 0; i < array1.Length; ++i) |
504 | { | 504 | { |
505 | IEnumerator<bool> iterator = YP.unify(array1[i], array2[i]).GetEnumerator(); | 505 | IEnumerator<bool> iterator = YP.unify(array1[i], array2[i]).GetEnumerator(); |
506 | iterators[nIterators++] = iterator; | 506 | iterators[nIterators++] = iterator; |
507 | // MoveNext() is true if YP.unify succeeds. | 507 | // MoveNext() is true if YP.unify succeeds. |
508 | if (!iterator.MoveNext()) | 508 | if (!iterator.MoveNext()) |
509 | { | 509 | { |
510 | gotMatch = false; | 510 | gotMatch = false; |
511 | break; | 511 | break; |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | try | 515 | try |
516 | { | 516 | { |
517 | if (gotMatch) | 517 | if (gotMatch) |
518 | yield return false; | 518 | yield return false; |
519 | } | 519 | } |
520 | finally | 520 | finally |
521 | { | 521 | { |
522 | // Manually finalize all the iterators. | 522 | // Manually finalize all the iterators. |
523 | for (int i = 0; i < nIterators; ++i) | 523 | for (int i = 0; i < nIterators; ++i) |
524 | iterators[i].Dispose(); | 524 | iterators[i].Dispose(); |
525 | } | 525 | } |
526 | } | 526 | } |
527 | 527 | ||
528 | /// <summary> | 528 | /// <summary> |
529 | /// Return an iterator (which you can use in a for-in loop) which does | 529 | /// Return an iterator (which you can use in a for-in loop) which does |
530 | /// zero iterations. This returns a pre-existing iterator which is | 530 | /// zero iterations. This returns a pre-existing iterator which is |
531 | /// more efficient than letting the compiler generate a new one. | 531 | /// more efficient than letting the compiler generate a new one. |
532 | /// </summary> | 532 | /// </summary> |
533 | /// <returns></returns> | 533 | /// <returns></returns> |
534 | public static IEnumerable<bool> fail() | 534 | public static IEnumerable<bool> fail() |
535 | { | 535 | { |
536 | return _fail; | 536 | return _fail; |
537 | } | 537 | } |
538 | 538 | ||
539 | /// <summary> | 539 | /// <summary> |
540 | /// Return an iterator (which you can use in a for-in loop) which does | 540 | /// Return an iterator (which you can use in a for-in loop) which does |
541 | /// one iteration. This returns a pre-existing iterator which is | 541 | /// one iteration. This returns a pre-existing iterator which is |
542 | /// more efficient than letting the compiler generate a new one. | 542 | /// more efficient than letting the compiler generate a new one. |
543 | /// </summary> | 543 | /// </summary> |
544 | /// <returns></returns> | 544 | /// <returns></returns> |
545 | public static IEnumerable<bool> succeed() | 545 | public static IEnumerable<bool> succeed() |
546 | { | 546 | { |
547 | return new Succeed(); | 547 | return new Succeed(); |
548 | } | 548 | } |
549 | 549 | ||
550 | /// <summary> | 550 | /// <summary> |
551 | /// Return an iterator (which you can use in a for-in loop) which repeats | 551 | /// Return an iterator (which you can use in a for-in loop) which repeats |
552 | /// indefinitely. This returns a pre-existing iterator which is | 552 | /// indefinitely. This returns a pre-existing iterator which is |
553 | /// more efficient than letting the compiler generate a new one. | 553 | /// more efficient than letting the compiler generate a new one. |
554 | /// </summary> | 554 | /// </summary> |
555 | /// <returns></returns> | 555 | /// <returns></returns> |
556 | public static IEnumerable<bool> repeat() | 556 | public static IEnumerable<bool> repeat() |
557 | { | 557 | { |
558 | return _repeat; | 558 | return _repeat; |
559 | } | 559 | } |
560 | 560 | ||
561 | public static IEnumerable<bool> univ(object Term, object List) | 561 | public static IEnumerable<bool> univ(object Term, object List) |
562 | { | 562 | { |
563 | Term = YP.getValue(Term); | 563 | Term = YP.getValue(Term); |
564 | List = YP.getValue(List); | 564 | List = YP.getValue(List); |
565 | 565 | ||
566 | if (nonvar(Term)) | 566 | if (nonvar(Term)) |
567 | return YP.unify(new ListPair | 567 | return YP.unify(new ListPair |
568 | (getFunctorName(Term), ListPair.make(getFunctorArgs(Term))), List); | 568 | (getFunctorName(Term), ListPair.make(getFunctorArgs(Term))), List); |
569 | 569 | ||
570 | Variable Name = new Variable(); | 570 | Variable Name = new Variable(); |
571 | Variable ArgList = new Variable(); | 571 | Variable ArgList = new Variable(); |
572 | foreach (bool l1 in new ListPair(Name, ArgList).unify(List)) | 572 | foreach (bool l1 in new ListPair(Name, ArgList).unify(List)) |
573 | { | 573 | { |
574 | object[] args = ListPair.toArray(ArgList); | 574 | object[] args = ListPair.toArray(ArgList); |
575 | if (args == null) | 575 | if (args == null) |
576 | throw new Exception("Expected a list. Got: " + ArgList.getValue()); | 576 | throw new Exception("Expected a list. Got: " + ArgList.getValue()); |
577 | if (args.Length == 0) | 577 | if (args.Length == 0) |
578 | // Return the Name, even if it is not an Atom. | 578 | // Return the Name, even if it is not an Atom. |
579 | return YP.unify(Term, Name); | 579 | return YP.unify(Term, Name); |
580 | if (!atom(Name)) | 580 | if (!atom(Name)) |
581 | throw new Exception("Expected an atom. Got: " + Name.getValue()); | 581 | throw new Exception("Expected an atom. Got: " + Name.getValue()); |
582 | 582 | ||
583 | return YP.unify(Term, Functor.make((Atom)YP.getValue(Name), args)); | 583 | return YP.unify(Term, Functor.make((Atom)YP.getValue(Name), args)); |
584 | } | 584 | } |
585 | 585 | ||
586 | return YP.fail(); | 586 | return YP.fail(); |
587 | } | 587 | } |
588 | 588 | ||
589 | public static IEnumerable<bool> functor(object Term, object FunctorName, object Arity) | 589 | public static IEnumerable<bool> functor(object Term, object FunctorName, object Arity) |
590 | { | 590 | { |
591 | Term = YP.getValue(Term); | 591 | Term = YP.getValue(Term); |
592 | FunctorName = YP.getValue(FunctorName); | 592 | FunctorName = YP.getValue(FunctorName); |
593 | Arity = YP.getValue(Arity); | 593 | Arity = YP.getValue(Arity); |
594 | 594 | ||
595 | if (!(Term is Variable)) | 595 | if (!(Term is Variable)) |
596 | { | 596 | { |
597 | foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term))) | 597 | foreach (bool l1 in YP.unify(FunctorName, getFunctorName(Term))) |
598 | { | 598 | { |
599 | foreach (bool l2 in YP.unify(Arity, getFunctorArgs(Term).Length)) | 599 | foreach (bool l2 in YP.unify(Arity, getFunctorArgs(Term).Length)) |
600 | yield return false; | 600 | yield return false; |
601 | } | 601 | } |
602 | } | 602 | } |
603 | else | 603 | else |
604 | throw new NotImplementedException("Debug: must finish functor/3"); | 604 | throw new NotImplementedException("Debug: must finish functor/3"); |
605 | } | 605 | } |
606 | 606 | ||
607 | public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value) | 607 | public static IEnumerable<bool> arg(object ArgNumber, object Term, object Value) |
608 | { | 608 | { |
609 | if (YP.var(ArgNumber)) | 609 | if (YP.var(ArgNumber)) |
610 | throw new NotImplementedException("Debug: must finish arg/3"); | 610 | throw new NotImplementedException("Debug: must finish arg/3"); |
611 | else | 611 | else |
612 | { | 612 | { |
613 | int argNumberInt = convertInt(ArgNumber); | 613 | int argNumberInt = convertInt(ArgNumber); |
614 | if (argNumberInt < 0) | 614 | if (argNumberInt < 0) |
615 | throw new Exception("ArgNumber must be non-negative"); | 615 | throw new Exception("ArgNumber must be non-negative"); |
616 | object[] termArgs = YP.getFunctorArgs(Term); | 616 | object[] termArgs = YP.getFunctorArgs(Term); |
617 | // Silently fail if argNumberInt is out of range. | 617 | // Silently fail if argNumberInt is out of range. |
618 | if (argNumberInt >= 1 && argNumberInt <= termArgs.Length) | 618 | if (argNumberInt >= 1 && argNumberInt <= termArgs.Length) |
619 | { | 619 | { |
620 | // The first ArgNumber is at 1, not 0. | 620 | // The first ArgNumber is at 1, not 0. |
621 | foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1])) | 621 | foreach (bool l1 in YP.unify(Value, termArgs[argNumberInt - 1])) |
622 | yield return false; | 622 | yield return false; |
623 | } | 623 | } |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | public static bool termEqual(object Term1, object Term2) | 627 | public static bool termEqual(object Term1, object Term2) |
628 | { | 628 | { |
629 | Term1 = YP.getValue(Term1); | 629 | Term1 = YP.getValue(Term1); |
630 | if (Term1 is IUnifiable) | 630 | if (Term1 is IUnifiable) |
631 | return ((IUnifiable)Term1).termEqual(Term2); | 631 | return ((IUnifiable)Term1).termEqual(Term2); |
632 | return Term1.Equals(YP.getValue(Term2)); | 632 | return Term1.Equals(YP.getValue(Term2)); |
633 | } | 633 | } |
634 | 634 | ||
635 | public static bool termNotEqual(object Term1, object Term2) | 635 | public static bool termNotEqual(object Term1, object Term2) |
636 | { | 636 | { |
637 | return !termEqual(Term1, Term2); | 637 | return !termEqual(Term1, Term2); |
638 | } | 638 | } |
639 | 639 | ||
640 | public static bool termLessThan(object Term1, object Term2) | 640 | public static bool termLessThan(object Term1, object Term2) |
641 | { | 641 | { |
642 | Term1 = YP.getValue(Term1); | 642 | Term1 = YP.getValue(Term1); |
643 | Term2 = YP.getValue(Term2); | 643 | Term2 = YP.getValue(Term2); |
644 | int term1TypeCode = getTypeCode(Term1); | 644 | int term1TypeCode = getTypeCode(Term1); |
645 | int term2TypeCode = getTypeCode(Term2); | 645 | int term2TypeCode = getTypeCode(Term2); |
646 | if (term1TypeCode != term2TypeCode) | 646 | if (term1TypeCode != term2TypeCode) |
647 | return term1TypeCode < term2TypeCode; | 647 | return term1TypeCode < term2TypeCode; |
648 | 648 | ||
649 | // The terms are the same type code. | 649 | // The terms are the same type code. |
650 | if (term1TypeCode == -2) | 650 | if (term1TypeCode == -2) |
651 | { | 651 | { |
652 | // Variable. | 652 | // Variable. |
653 | // We always check for equality first because we want to be sure | 653 | // We always check for equality first because we want to be sure |
654 | // that less than returns false if the terms are equal, in | 654 | // that less than returns false if the terms are equal, in |
655 | // case that the less than check really behaves like less than or equal. | 655 | // case that the less than check really behaves like less than or equal. |
656 | if ((Variable)Term1 != (Variable)Term2) | 656 | if ((Variable)Term1 != (Variable)Term2) |
657 | // The hash code should be unique to a Variable object. | 657 | // The hash code should be unique to a Variable object. |
658 | return Term1.GetHashCode() < Term2.GetHashCode(); | 658 | return Term1.GetHashCode() < Term2.GetHashCode(); |
659 | return false; | 659 | return false; |
660 | } | 660 | } |
661 | if (term1TypeCode == 0) | 661 | if (term1TypeCode == 0) |
662 | return ((Atom)Term1)._name.CompareTo(((Atom)Term2)._name) < 0; | 662 | return ((Atom)Term1)._name.CompareTo(((Atom)Term2)._name) < 0; |
663 | if (term1TypeCode == 1) | 663 | if (term1TypeCode == 1) |
664 | return ((Functor1)Term1).lessThan((Functor1)Term2); | 664 | return ((Functor1)Term1).lessThan((Functor1)Term2); |
665 | if (term1TypeCode == 2) | 665 | if (term1TypeCode == 2) |
666 | return ((Functor2)Term1).lessThan((Functor2)Term2); | 666 | return ((Functor2)Term1).lessThan((Functor2)Term2); |
667 | if (term1TypeCode == 3) | 667 | if (term1TypeCode == 3) |
668 | return ((Functor3)Term1).lessThan((Functor3)Term2); | 668 | return ((Functor3)Term1).lessThan((Functor3)Term2); |
669 | if (term1TypeCode == 4) | 669 | if (term1TypeCode == 4) |
670 | return ((Functor)Term1).lessThan((Functor)Term2); | 670 | return ((Functor)Term1).lessThan((Functor)Term2); |
671 | 671 | ||
672 | // Type code is -1 for general objects. First compare their type names. | 672 | // Type code is -1 for general objects. First compare their type names. |
673 | // Note that this puts Double before Int32 as required by ISO Prolog. | 673 | // Note that this puts Double before Int32 as required by ISO Prolog. |
674 | string term1TypeName = Term1.GetType().ToString(); | 674 | string term1TypeName = Term1.GetType().ToString(); |
675 | string term2TypeName = Term2.GetType().ToString(); | 675 | string term2TypeName = Term2.GetType().ToString(); |
676 | if (term1TypeName != term2TypeName) | 676 | if (term1TypeName != term2TypeName) |
677 | return term1TypeName.CompareTo(term2TypeName) < 0; | 677 | return term1TypeName.CompareTo(term2TypeName) < 0; |
678 | 678 | ||
679 | // The terms are the same type name. | 679 | // The terms are the same type name. |
680 | if (Term1 is int) | 680 | if (Term1 is int) |
681 | return (int)Term1 < (int)Term2; | 681 | return (int)Term1 < (int)Term2; |
682 | else if (Term1 is double) | 682 | else if (Term1 is double) |
683 | return (double)Term1 < (double)Term2; | 683 | return (double)Term1 < (double)Term2; |
684 | else if (Term1 is DateTime) | 684 | else if (Term1 is DateTime) |
685 | return (DateTime)Term1 < (DateTime)Term2; | 685 | return (DateTime)Term1 < (DateTime)Term2; |
686 | else if (Term1 is String) | 686 | else if (Term1 is String) |
687 | return ((String)Term1).CompareTo((String)Term2) < 0; | 687 | return ((String)Term1).CompareTo((String)Term2) < 0; |
688 | // Debug: Should we try arrays, etc.? | 688 | // Debug: Should we try arrays, etc.? |
689 | 689 | ||
690 | if (!Term1.Equals(Term2)) | 690 | if (!Term1.Equals(Term2)) |
691 | // Could be equal or greater than. | 691 | // Could be equal or greater than. |
692 | return Term1.GetHashCode() < Term2.GetHashCode(); | 692 | return Term1.GetHashCode() < Term2.GetHashCode(); |
693 | return false; | 693 | return false; |
694 | } | 694 | } |
695 | 695 | ||
696 | /// <summary> | 696 | /// <summary> |
697 | /// Type code is -2 if term is a Variable, 0 if it is an Atom, | 697 | /// Type code is -2 if term is a Variable, 0 if it is an Atom, |
698 | /// 1 if it is a Functor1, 2 if it is a Functor2, 3 if it is a Functor3, | 698 | /// 1 if it is a Functor1, 2 if it is a Functor2, 3 if it is a Functor3, |
699 | /// 4 if it is Functor. | 699 | /// 4 if it is Functor. |
700 | /// Otherwise, type code is -1. | 700 | /// Otherwise, type code is -1. |
701 | /// This does not call YP.getValue(term). | 701 | /// This does not call YP.getValue(term). |
702 | /// </summary> | 702 | /// </summary> |
703 | /// <param name="term"></param> | 703 | /// <param name="term"></param> |
704 | /// <returns></returns> | 704 | /// <returns></returns> |
705 | private static int getTypeCode(object term) | 705 | private static int getTypeCode(object term) |
706 | { | 706 | { |
707 | if (term is Variable) | 707 | if (term is Variable) |
708 | return -2; | 708 | return -2; |
709 | else if (term is Atom) | 709 | else if (term is Atom) |
710 | return 0; | 710 | return 0; |
711 | else if (term is Functor1) | 711 | else if (term is Functor1) |
712 | return 1; | 712 | return 1; |
713 | else if (term is Functor2) | 713 | else if (term is Functor2) |
714 | return 2; | 714 | return 2; |
715 | else if (term is Functor3) | 715 | else if (term is Functor3) |
716 | return 3; | 716 | return 3; |
717 | else if (term is Functor) | 717 | else if (term is Functor) |
718 | return 4; | 718 | return 4; |
719 | else | 719 | else |
720 | return -1; | 720 | return -1; |
721 | } | 721 | } |
722 | 722 | ||
723 | public static bool termLessThanOrEqual(object Term1, object Term2) | 723 | public static bool termLessThanOrEqual(object Term1, object Term2) |
724 | { | 724 | { |
725 | if (YP.termEqual(Term1, Term2)) | 725 | if (YP.termEqual(Term1, Term2)) |
726 | return true; | 726 | return true; |
727 | return YP.termLessThan(Term1, Term2); | 727 | return YP.termLessThan(Term1, Term2); |
728 | } | 728 | } |
729 | 729 | ||
730 | public static bool termGreaterThan(object Term1, object Term2) | 730 | public static bool termGreaterThan(object Term1, object Term2) |
731 | { | 731 | { |
732 | return !YP.termLessThanOrEqual(Term1, Term2); | 732 | return !YP.termLessThanOrEqual(Term1, Term2); |
733 | } | 733 | } |
734 | 734 | ||
735 | public static bool termGreaterThanOrEqual(object Term1, object Term2) | 735 | public static bool termGreaterThanOrEqual(object Term1, object Term2) |
736 | { | 736 | { |
737 | // termLessThan should ensure that it returns false if terms are equal, | 737 | // termLessThan should ensure that it returns false if terms are equal, |
738 | // so that this would return true. | 738 | // so that this would return true. |
739 | return !YP.termLessThan(Term1, Term2); | 739 | return !YP.termLessThan(Term1, Term2); |
740 | } | 740 | } |
741 | 741 | ||
742 | public static int compareTerms(object Term1, object Term2) | 742 | public static int compareTerms(object Term1, object Term2) |
743 | { | 743 | { |
744 | if (YP.termEqual(Term1, Term2)) | 744 | if (YP.termEqual(Term1, Term2)) |
745 | return 0; | 745 | return 0; |
746 | else if (YP.termLessThan(Term1, Term2)) | 746 | else if (YP.termLessThan(Term1, Term2)) |
747 | return -1; | 747 | return -1; |
748 | else | 748 | else |
749 | return 1; | 749 | return 1; |
750 | } | 750 | } |
751 | 751 | ||
752 | public static bool ground(object Term) | 752 | public static bool ground(object Term) |
753 | { | 753 | { |
754 | Term = YP.getValue(Term); | 754 | Term = YP.getValue(Term); |
755 | if (Term is IUnifiable) | 755 | if (Term is IUnifiable) |
756 | return ((IUnifiable)Term).ground(); | 756 | return ((IUnifiable)Term).ground(); |
757 | return true; | 757 | return true; |
758 | } | 758 | } |
759 | 759 | ||
760 | public static IEnumerable<bool> current_op | 760 | public static IEnumerable<bool> current_op |
761 | (object Priority, object Specifier, object Operator) | 761 | (object Priority, object Specifier, object Operator) |
762 | { | 762 | { |
763 | if (_operatorTable == null) | 763 | if (_operatorTable == null) |
764 | { | 764 | { |
765 | // Initialize. | 765 | // Initialize. |
766 | _operatorTable = new List<object[]>(); | 766 | _operatorTable = new List<object[]>(); |
767 | _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") }); | 767 | _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a(":-") }); |
768 | _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") }); | 768 | _operatorTable.Add(new object[] { 1200, Atom.a("xfx"), Atom.a("-->") }); |
769 | _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a(":-") }); | 769 | _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a(":-") }); |
770 | _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a("?-") }); | 770 | _operatorTable.Add(new object[] { 1200, Atom.a("fx"), Atom.a("?-") }); |
771 | _operatorTable.Add(new object[] { 1100, Atom.a("xfy"), Atom.a(";") }); | 771 | _operatorTable.Add(new object[] { 1100, Atom.a("xfy"), Atom.a(";") }); |
772 | _operatorTable.Add(new object[] { 1050, Atom.a("xfy"), Atom.a("->") }); | 772 | _operatorTable.Add(new object[] { 1050, Atom.a("xfy"), Atom.a("->") }); |
773 | _operatorTable.Add(new object[] { 1000, Atom.a("xfy"), Atom.a(",") }); | 773 | _operatorTable.Add(new object[] { 1000, Atom.a("xfy"), Atom.a(",") }); |
774 | _operatorTable.Add(new object[] { 900, Atom.a("fy"), Atom.a("\\+") }); | 774 | _operatorTable.Add(new object[] { 900, Atom.a("fy"), Atom.a("\\+") }); |
775 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=") }); | 775 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=") }); |
776 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") }); | 776 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\=") }); |
777 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("==") }); | 777 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("==") }); |
778 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") }); | 778 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("\\==") }); |
779 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@<") }); | 779 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@<") }); |
780 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") }); | 780 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@=<") }); |
781 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>") }); | 781 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>") }); |
782 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") }); | 782 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("@>=") }); |
783 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=..") }); | 783 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=..") }); |
784 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("is") }); | 784 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("is") }); |
785 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") }); | 785 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=:=") }); |
786 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") }); | 786 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=\\=") }); |
787 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("<") }); | 787 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("<") }); |
788 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=<") }); | 788 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a("=<") }); |
789 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">") }); | 789 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">") }); |
790 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">=") }); | 790 | _operatorTable.Add(new object[] { 700, Atom.a("xfx"), Atom.a(">=") }); |
791 | _operatorTable.Add(new object[] { 600, Atom.a("xfy"), Atom.a(":") }); | 791 | _operatorTable.Add(new object[] { 600, Atom.a("xfy"), Atom.a(":") }); |
792 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("+") }); | 792 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("+") }); |
793 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("-") }); | 793 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("-") }); |
794 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") }); | 794 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("/\\") }); |
795 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") }); | 795 | _operatorTable.Add(new object[] { 500, Atom.a("yfx"), Atom.a("\\/") }); |
796 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("*") }); | 796 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("*") }); |
797 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("/") }); | 797 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("/") }); |
798 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("//") }); | 798 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("//") }); |
799 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("rem") }); | 799 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("rem") }); |
800 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("mod") }); | 800 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("mod") }); |
801 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("<<") }); | 801 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a("<<") }); |
802 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a(">>") }); | 802 | _operatorTable.Add(new object[] { 400, Atom.a("yfx"), Atom.a(">>") }); |
803 | _operatorTable.Add(new object[] { 200, Atom.a("xfx"), Atom.a("**") }); | 803 | _operatorTable.Add(new object[] { 200, Atom.a("xfx"), Atom.a("**") }); |
804 | _operatorTable.Add(new object[] { 200, Atom.a("xfy"), Atom.a("^") }); | 804 | _operatorTable.Add(new object[] { 200, Atom.a("xfy"), Atom.a("^") }); |
805 | _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("-") }); | 805 | _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("-") }); |
806 | _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("\\") }); | 806 | _operatorTable.Add(new object[] { 200, Atom.a("fy"), Atom.a("\\") }); |
807 | // Debug: This is hacked in to run the Prolog test suite until we implement op/3. | 807 | // Debug: This is hacked in to run the Prolog test suite until we implement op/3. |
808 | _operatorTable.Add(new object[] { 20, Atom.a("xfx"), Atom.a("<--") }); | 808 | _operatorTable.Add(new object[] { 20, Atom.a("xfx"), Atom.a("<--") }); |
809 | } | 809 | } |
810 | 810 | ||
811 | object[] args = new object[] { Priority, Specifier, Operator }; | 811 | object[] args = new object[] { Priority, Specifier, Operator }; |
812 | foreach (object[] answer in _operatorTable) | 812 | foreach (object[] answer in _operatorTable) |
813 | { | 813 | { |
814 | foreach (bool l1 in YP.unifyArrays(args, answer)) | 814 | foreach (bool l1 in YP.unifyArrays(args, answer)) |
815 | yield return false; | 815 | yield return false; |
816 | } | 816 | } |
817 | } | 817 | } |
818 | 818 | ||
819 | public static IEnumerable<bool> atom_length(object atom, object Length) | 819 | public static IEnumerable<bool> atom_length(object atom, object Length) |
820 | { | 820 | { |
821 | return YP.unify(Length, ((Atom)YP.getValue(atom))._name.Length); | 821 | return YP.unify(Length, ((Atom)YP.getValue(atom))._name.Length); |
822 | } | 822 | } |
823 | 823 | ||
824 | public static IEnumerable<bool> atom_concat(object Start, object End, object Whole) | 824 | public static IEnumerable<bool> atom_concat(object Start, object End, object Whole) |
825 | { | 825 | { |
826 | // Debug: Should implement for var(Start) which is a kind of search. | 826 | // Debug: Should implement for var(Start) which is a kind of search. |
827 | // Debug: Should we try to preserve the _declaringClass? | 827 | // Debug: Should we try to preserve the _declaringClass? |
828 | return YP.unify(Whole, Atom.a(((Atom)YP.getValue(Start))._name + | 828 | return YP.unify(Whole, Atom.a(((Atom)YP.getValue(Start))._name + |
829 | ((Atom)YP.getValue(End))._name)); | 829 | ((Atom)YP.getValue(End))._name)); |
830 | } | 830 | } |
831 | 831 | ||
832 | public static IEnumerable<bool> sub_atom | 832 | public static IEnumerable<bool> sub_atom |
833 | (object atom, object Before, object Length, object After, object Sub_atom) | 833 | (object atom, object Before, object Length, object After, object Sub_atom) |
834 | { | 834 | { |
835 | // Debug: Should implement for var(atom) which is a kind of search. | 835 | // Debug: Should implement for var(atom) which is a kind of search. |
836 | // Debug: Should we try to preserve the _declaringClass? | 836 | // Debug: Should we try to preserve the _declaringClass? |
837 | Atom atomAtom = (Atom)YP.getValue(atom); | 837 | Atom atomAtom = (Atom)YP.getValue(atom); |
838 | int beforeInt = YP.convertInt(Before); | 838 | int beforeInt = YP.convertInt(Before); |
839 | int lengthInt = YP.convertInt(Length); | 839 | int lengthInt = YP.convertInt(Length); |
840 | if (beforeInt < 0) | 840 | if (beforeInt < 0) |
841 | throw new Exception("Before must be non-negative"); | 841 | throw new Exception("Before must be non-negative"); |
842 | if (lengthInt < 0) | 842 | if (lengthInt < 0) |
843 | throw new Exception("Length must be non-negative"); | 843 | throw new Exception("Length must be non-negative"); |
844 | int afterInt = atomAtom._name.Length - (beforeInt + lengthInt); | 844 | int afterInt = atomAtom._name.Length - (beforeInt + lengthInt); |
845 | if (afterInt >= 0) | 845 | if (afterInt >= 0) |
846 | { | 846 | { |
847 | foreach (bool l1 in YP.unify(After, afterInt)) | 847 | foreach (bool l1 in YP.unify(After, afterInt)) |
848 | { | 848 | { |
849 | foreach (bool l2 in YP.unify | 849 | foreach (bool l2 in YP.unify |
850 | (Sub_atom, Atom.a(atomAtom._name.Substring(beforeInt, lengthInt)))) | 850 | (Sub_atom, Atom.a(atomAtom._name.Substring(beforeInt, lengthInt)))) |
851 | yield return false; | 851 | yield return false; |
852 | } | 852 | } |
853 | } | 853 | } |
854 | } | 854 | } |
855 | 855 | ||
856 | public static IEnumerable<bool> atom_codes(object atom, object List) | 856 | public static IEnumerable<bool> atom_codes(object atom, object List) |
857 | { | 857 | { |
858 | atom = YP.getValue(atom); | 858 | atom = YP.getValue(atom); |
859 | List = YP.getValue(List); | 859 | List = YP.getValue(List); |
860 | 860 | ||
861 | if (nonvar(atom)) | 861 | if (nonvar(atom)) |
862 | { | 862 | { |
863 | string name = ((Atom)atom)._name; | 863 | string name = ((Atom)atom)._name; |
864 | object codeList = Atom.NIL; | 864 | object codeList = Atom.NIL; |
865 | // Start from the back to make the list. | 865 | // Start from the back to make the list. |
866 | for (int i = name.Length - 1; i >= 0; --i) | 866 | for (int i = name.Length - 1; i >= 0; --i) |
867 | codeList = new ListPair((int)name[i], codeList); | 867 | codeList = new ListPair((int)name[i], codeList); |
868 | return YP.unify(List, codeList); | 868 | return YP.unify(List, codeList); |
869 | } | 869 | } |
870 | { | 870 | { |
871 | object[] codeArray = ListPair.toArray(List); | 871 | object[] codeArray = ListPair.toArray(List); |
872 | char[] charArray = new char[codeArray.Length]; | 872 | char[] charArray = new char[codeArray.Length]; |
873 | for (int i = 0; i < codeArray.Length; ++i) | 873 | for (int i = 0; i < codeArray.Length; ++i) |
874 | charArray[i] = (char)YP.convertInt(codeArray[i]); | 874 | charArray[i] = (char)YP.convertInt(codeArray[i]); |
875 | return YP.unify(atom, Atom.a(new String(charArray))); | 875 | return YP.unify(atom, Atom.a(new String(charArray))); |
876 | } | 876 | } |
877 | } | 877 | } |
878 | 878 | ||
879 | public static IEnumerable<bool> number_codes(object number, object List) | 879 | public static IEnumerable<bool> number_codes(object number, object List) |
880 | { | 880 | { |
881 | number = YP.getValue(number); | 881 | number = YP.getValue(number); |
882 | List = YP.getValue(List); | 882 | List = YP.getValue(List); |
883 | 883 | ||
884 | if (nonvar(number)) | 884 | if (nonvar(number)) |
885 | { | 885 | { |
886 | string numberString = null; | 886 | string numberString = null; |
887 | // Try converting to an int first. | 887 | // Try converting to an int first. |
888 | int intNumber; | 888 | int intNumber; |
889 | if (YP.getInt(number, out intNumber)) | 889 | if (YP.getInt(number, out intNumber)) |
890 | numberString = intNumber.ToString(); | 890 | numberString = intNumber.ToString(); |
891 | else | 891 | else |
892 | numberString = YP.doubleToString(YP.convertDouble(number)); | 892 | numberString = YP.doubleToString(YP.convertDouble(number)); |
893 | 893 | ||
894 | object codeList = Atom.NIL; | 894 | object codeList = Atom.NIL; |
895 | // Start from the back to make the list. | 895 | // Start from the back to make the list. |
896 | for (int i = numberString.Length - 1; i >= 0; --i) | 896 | for (int i = numberString.Length - 1; i >= 0; --i) |
897 | codeList = new ListPair((int)numberString[i], codeList); | 897 | codeList = new ListPair((int)numberString[i], codeList); |
898 | return YP.unify(List, codeList); | 898 | return YP.unify(List, codeList); |
899 | } | 899 | } |
900 | { | 900 | { |
901 | object[] codeArray = ListPair.toArray(List); | 901 | object[] codeArray = ListPair.toArray(List); |
902 | char[] charArray = new char[codeArray.Length]; | 902 | char[] charArray = new char[codeArray.Length]; |
903 | for (int i = 0; i < codeArray.Length; ++i) | 903 | for (int i = 0; i < codeArray.Length; ++i) |
904 | charArray[i] = (char)YP.convertInt(codeArray[i]); | 904 | charArray[i] = (char)YP.convertInt(codeArray[i]); |
905 | String numberString = new String(charArray); | 905 | String numberString = new String(charArray); |
906 | // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception? | 906 | // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception? |
907 | try | 907 | try |
908 | { | 908 | { |
909 | // Try an int first. | 909 | // Try an int first. |
910 | return YP.unify(number, Convert.ToInt32(numberString)); | 910 | return YP.unify(number, Convert.ToInt32(numberString)); |
911 | } | 911 | } |
912 | catch (FormatException) { } | 912 | catch (FormatException) { } |
913 | return YP.unify(number, Convert.ToDouble(numberString)); | 913 | return YP.unify(number, Convert.ToDouble(numberString)); |
914 | } | 914 | } |
915 | } | 915 | } |
916 | 916 | ||
917 | /// <summary> | 917 | /// <summary> |
918 | /// If term is an Atom or functor type, return its name. | 918 | /// If term is an Atom or functor type, return its name. |
919 | /// Otherwise, return term. | 919 | /// Otherwise, return term. |
920 | /// </summary> | 920 | /// </summary> |
921 | /// <param name="term"></param> | 921 | /// <param name="term"></param> |
922 | /// <returns></returns> | 922 | /// <returns></returns> |
923 | public static object getFunctorName(object term) | 923 | public static object getFunctorName(object term) |
924 | { | 924 | { |
925 | term = YP.getValue(term); | 925 | term = YP.getValue(term); |
926 | if (term is Functor1) | 926 | if (term is Functor1) |
927 | return ((Functor1)term)._name; | 927 | return ((Functor1)term)._name; |
928 | else if (term is Functor2) | 928 | else if (term is Functor2) |
929 | return ((Functor2)term)._name; | 929 | return ((Functor2)term)._name; |
930 | else if (term is Functor3) | 930 | else if (term is Functor3) |
931 | return ((Functor3)term)._name; | 931 | return ((Functor3)term)._name; |
932 | else if (term is Functor) | 932 | else if (term is Functor) |
933 | return ((Functor)term)._name; | 933 | return ((Functor)term)._name; |
934 | else | 934 | else |
935 | return term; | 935 | return term; |
936 | } | 936 | } |
937 | 937 | ||
938 | /// <summary> | 938 | /// <summary> |
939 | /// If term is an Atom or functor type, return an array of its args. | 939 | /// If term is an Atom or functor type, return an array of its args. |
940 | /// Otherwise, return an empty array. | 940 | /// Otherwise, return an empty array. |
941 | /// </summary> | 941 | /// </summary> |
942 | /// <param name="term"></param> | 942 | /// <param name="term"></param> |
943 | /// <returns></returns> | 943 | /// <returns></returns> |
944 | public static object[] getFunctorArgs(object term) | 944 | public static object[] getFunctorArgs(object term) |
945 | { | 945 | { |
946 | term = YP.getValue(term); | 946 | term = YP.getValue(term); |
947 | if (term is Functor1) | 947 | if (term is Functor1) |
948 | { | 948 | { |
949 | Functor1 functor = (Functor1)term; | 949 | Functor1 functor = (Functor1)term; |
950 | return new object[] { functor._arg1 }; | 950 | return new object[] { functor._arg1 }; |
951 | } | 951 | } |
952 | else if (term is Functor2) | 952 | else if (term is Functor2) |
953 | { | 953 | { |
954 | Functor2 functor = (Functor2)term; | 954 | Functor2 functor = (Functor2)term; |
955 | return new object[] { functor._arg1, functor._arg2 }; | 955 | return new object[] { functor._arg1, functor._arg2 }; |
956 | } | 956 | } |
957 | else if (term is Functor3) | 957 | else if (term is Functor3) |
958 | { | 958 | { |
959 | Functor3 functor = (Functor3)term; | 959 | Functor3 functor = (Functor3)term; |
960 | return new object[] { functor._arg1, functor._arg2, functor._arg3 }; | 960 | return new object[] { functor._arg1, functor._arg2, functor._arg3 }; |
961 | } | 961 | } |
962 | else if (term is Functor) { | 962 | else if (term is Functor) { |
963 | Functor functor = (Functor)term; | 963 | Functor functor = (Functor)term; |
964 | return functor._args; | 964 | return functor._args; |
965 | } | 965 | } |
966 | else | 966 | else |
967 | return new object[0]; | 967 | return new object[0]; |
968 | } | 968 | } |
969 | 969 | ||
970 | public static bool var(object Term) | 970 | public static bool var(object Term) |
971 | { | 971 | { |
972 | return YP.getValue(Term) is Variable; | 972 | return YP.getValue(Term) is Variable; |
973 | } | 973 | } |
974 | 974 | ||
975 | public static bool nonvar(object Term) | 975 | public static bool nonvar(object Term) |
976 | { | 976 | { |
977 | return !YP.var(Term); | 977 | return !YP.var(Term); |
978 | } | 978 | } |
979 | 979 | ||
980 | public static bool atom(object Term) | 980 | public static bool atom(object Term) |
981 | { | 981 | { |
982 | return YP.getValue(Term) is Atom; | 982 | return YP.getValue(Term) is Atom; |
983 | } | 983 | } |
984 | 984 | ||
985 | public static bool number(object Term) | 985 | public static bool number(object Term) |
986 | { | 986 | { |
987 | Term = getValue(Term); | 987 | Term = getValue(Term); |
988 | // Debug: Should exhaustively check for all number types. | 988 | // Debug: Should exhaustively check for all number types. |
989 | return Term is int || Term is double; | 989 | return Term is int || Term is double; |
990 | } | 990 | } |
991 | 991 | ||
992 | public static bool atomic(object Term) | 992 | public static bool atomic(object Term) |
993 | { | 993 | { |
994 | return YP.atom(Term) || YP.number(Term); | 994 | return YP.atom(Term) || YP.number(Term); |
995 | } | 995 | } |
996 | 996 | ||
997 | public static bool compound(object Term) | 997 | public static bool compound(object Term) |
998 | { | 998 | { |
999 | Term = getValue(Term); | 999 | Term = getValue(Term); |
1000 | return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor; | 1000 | return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | public static void see(object input) | 1003 | public static void see(object input) |
1004 | { | 1004 | { |
1005 | input = YP.getValue(input); | 1005 | input = YP.getValue(input); |
1006 | if (input is TextReader) | 1006 | if (input is TextReader) |
1007 | { | 1007 | { |
1008 | _inputStream = (TextReader)input; | 1008 | _inputStream = (TextReader)input; |
1009 | return; | 1009 | return; |
1010 | } | 1010 | } |
1011 | else if (input is Atom) | 1011 | else if (input is Atom) |
1012 | { | 1012 | { |
1013 | _inputStream = new StreamReader(((Atom)input)._name); | 1013 | _inputStream = new StreamReader(((Atom)input)._name); |
1014 | return; | 1014 | return; |
1015 | } | 1015 | } |
1016 | else if (input is String) | 1016 | else if (input is String) |
1017 | { | 1017 | { |
1018 | _inputStream = new StreamReader((String)input); | 1018 | _inputStream = new StreamReader((String)input); |
1019 | return; | 1019 | return; |
1020 | } | 1020 | } |
1021 | else | 1021 | else |
1022 | throw new InvalidOperationException("Can't open stream for " + input); | 1022 | throw new InvalidOperationException("Can't open stream for " + input); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | public static void seen() | 1025 | public static void seen() |
1026 | { | 1026 | { |
1027 | if (_inputStream == Console.In) | 1027 | if (_inputStream == Console.In) |
1028 | return; | 1028 | return; |
1029 | _inputStream.Close(); | 1029 | _inputStream.Close(); |
1030 | _inputStream = Console.In; | 1030 | _inputStream = Console.In; |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | public static void tell(object output) | 1033 | public static void tell(object output) |
1034 | { | 1034 | { |
1035 | output = YP.getValue(output); | 1035 | output = YP.getValue(output); |
1036 | if (output is TextWriter) | 1036 | if (output is TextWriter) |
1037 | { | 1037 | { |
1038 | _outputStream = (TextWriter)output; | 1038 | _outputStream = (TextWriter)output; |
1039 | return; | 1039 | return; |
1040 | } | 1040 | } |
1041 | else if (output is Atom) | 1041 | else if (output is Atom) |
1042 | { | 1042 | { |
1043 | _outputStream = new StreamWriter(((Atom)output)._name); | 1043 | _outputStream = new StreamWriter(((Atom)output)._name); |
1044 | return; | 1044 | return; |
1045 | } | 1045 | } |
1046 | else if (output is String) | 1046 | else if (output is String) |
1047 | { | 1047 | { |
1048 | _outputStream = new StreamWriter((String)output); | 1048 | _outputStream = new StreamWriter((String)output); |
1049 | return; | 1049 | return; |
1050 | } | 1050 | } |
1051 | else | 1051 | else |
1052 | throw new InvalidOperationException("Can't open stream for " + output); | 1052 | throw new InvalidOperationException("Can't open stream for " + output); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | public static void told() | 1055 | public static void told() |
1056 | { | 1056 | { |
1057 | if (_outputStream == Console.Out) | 1057 | if (_outputStream == Console.Out) |
1058 | return; | 1058 | return; |
1059 | _outputStream.Close(); | 1059 | _outputStream.Close(); |
1060 | _outputStream = Console.Out; | 1060 | _outputStream = Console.Out; |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | public static void write(object x) | 1063 | public static void write(object x) |
1064 | { | 1064 | { |
1065 | x = YP.getValue(x); | 1065 | x = YP.getValue(x); |
1066 | if (x is double) | 1066 | if (x is double) |
1067 | _outputStream.Write(doubleToString((double)x)); | 1067 | _outputStream.Write(doubleToString((double)x)); |
1068 | else | 1068 | else |
1069 | _outputStream.Write(x.ToString()); | 1069 | _outputStream.Write(x.ToString()); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | /// <summary> | 1072 | /// <summary> |
1073 | /// Format x as a string, making sure that it will parse as an int later. I.e., for 1.0, don't just | 1073 | /// Format x as a string, making sure that it will parse as an int later. I.e., for 1.0, don't just |
1074 | /// use "1" which will parse as an int. | 1074 | /// use "1" which will parse as an int. |
1075 | /// </summary> | 1075 | /// </summary> |
1076 | /// <param name="x"></param> | 1076 | /// <param name="x"></param> |
1077 | /// <returns></returns> | 1077 | /// <returns></returns> |
1078 | private static string doubleToString(double x) | 1078 | private static string doubleToString(double x) |
1079 | { | 1079 | { |
1080 | string xString = x.ToString(); | 1080 | string xString = x.ToString(); |
1081 | // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception? | 1081 | // Debug: Is there a way in C# to ask if a string parses as int without throwing an exception? |
1082 | try | 1082 | try |
1083 | { | 1083 | { |
1084 | Convert.ToInt32(xString); | 1084 | Convert.ToInt32(xString); |
1085 | // The string will parse as an int, not a double, so re-format so that it does. | 1085 | // The string will parse as an int, not a double, so re-format so that it does. |
1086 | // Use float if possible, else exponential if it would be too big. | 1086 | // Use float if possible, else exponential if it would be too big. |
1087 | return x.ToString(x >= 100000.0 ? "E1" : "f1"); | 1087 | return x.ToString(x >= 100000.0 ? "E1" : "f1"); |
1088 | } | 1088 | } |
1089 | catch (FormatException) | 1089 | catch (FormatException) |
1090 | { | 1090 | { |
1091 | // Assume it will parse as a double. | 1091 | // Assume it will parse as a double. |
1092 | } | 1092 | } |
1093 | return xString; | 1093 | return xString; |
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | public static void put_code(object x) | 1096 | public static void put_code(object x) |
1097 | { | 1097 | { |
1098 | _outputStream.Write((char)YP.convertInt(x)); | 1098 | _outputStream.Write((char)YP.convertInt(x)); |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | public static void nl() | 1101 | public static void nl() |
1102 | { | 1102 | { |
1103 | _outputStream.WriteLine(); | 1103 | _outputStream.WriteLine(); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | public static IEnumerable<bool> get_code(object code) | 1106 | public static IEnumerable<bool> get_code(object code) |
1107 | { | 1107 | { |
1108 | return YP.unify(code, _inputStream.Read()); | 1108 | return YP.unify(code, _inputStream.Read()); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | public static void assertFact(Atom name, object[] values) | 1111 | public static void assertFact(Atom name, object[] values) |
1112 | { | 1112 | { |
1113 | NameArity nameArity = new NameArity(name, values.Length); | 1113 | NameArity nameArity = new NameArity(name, values.Length); |
1114 | List<IClause> clauses; | 1114 | List<IClause> clauses; |
1115 | IndexedAnswers indexedAnswers; | 1115 | IndexedAnswers indexedAnswers; |
1116 | if (!_predicatesStore.TryGetValue(nameArity, out clauses)) | 1116 | if (!_predicatesStore.TryGetValue(nameArity, out clauses)) |
1117 | { | 1117 | { |
1118 | // Create an IndexedAnswers as the first clause of the predicate. | 1118 | // Create an IndexedAnswers as the first clause of the predicate. |
1119 | _predicatesStore[nameArity] = (clauses = new List<IClause>()); | 1119 | _predicatesStore[nameArity] = (clauses = new List<IClause>()); |
1120 | clauses.Add(indexedAnswers = new IndexedAnswers()); | 1120 | clauses.Add(indexedAnswers = new IndexedAnswers()); |
1121 | } | 1121 | } |
1122 | else | 1122 | else |
1123 | { | 1123 | { |
1124 | indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers; | 1124 | indexedAnswers = clauses[clauses.Count - 1] as IndexedAnswers; |
1125 | if (indexedAnswers == null) | 1125 | if (indexedAnswers == null) |
1126 | // The latest clause is not an IndexedAnswers, so add one. | 1126 | // The latest clause is not an IndexedAnswers, so add one. |
1127 | clauses.Add(indexedAnswers = new IndexedAnswers()); | 1127 | clauses.Add(indexedAnswers = new IndexedAnswers()); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | indexedAnswers.addAnswer(values); | 1130 | indexedAnswers.addAnswer(values); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | public static IEnumerable<bool> matchFact(Atom name, object[] arguments) | 1133 | public static IEnumerable<bool> matchFact(Atom name, object[] arguments) |
1134 | { | 1134 | { |
1135 | List<IClause> clauses; | 1135 | List<IClause> clauses; |
1136 | if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) | 1136 | if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) |
1137 | throw new UndefinedPredicateException | 1137 | throw new UndefinedPredicateException |
1138 | ("Undefined fact: " + name + "/" + arguments.Length, name, | 1138 | ("Undefined fact: " + name + "/" + arguments.Length, name, |
1139 | arguments.Length); | 1139 | arguments.Length); |
1140 | 1140 | ||
1141 | if (clauses.Count == 1) | 1141 | if (clauses.Count == 1) |
1142 | // Usually there is only one clause, so return it without needing to wrap it in an iterator. | 1142 | // Usually there is only one clause, so return it without needing to wrap it in an iterator. |
1143 | return clauses[0].match(arguments); | 1143 | return clauses[0].match(arguments); |
1144 | else | 1144 | else |
1145 | return matchAllClauses(clauses, arguments); | 1145 | return matchAllClauses(clauses, arguments); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | /// <summary> | 1148 | /// <summary> |
1149 | /// Call match(arguments) for each IClause in clauses. We make this a separate | 1149 | /// Call match(arguments) for each IClause in clauses. We make this a separate |
1150 | /// function so that matchFact itself does not need to be an iterator object. | 1150 | /// function so that matchFact itself does not need to be an iterator object. |
1151 | /// </summary> | 1151 | /// </summary> |
1152 | /// <param name="clauses"></param> | 1152 | /// <param name="clauses"></param> |
1153 | /// <param name="arguments"></param> | 1153 | /// <param name="arguments"></param> |
1154 | /// <returns></returns> | 1154 | /// <returns></returns> |
1155 | private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments) | 1155 | private static IEnumerable<bool> matchAllClauses(List<IClause> clauses, object[] arguments) |
1156 | { | 1156 | { |
1157 | foreach (IClause clause in clauses) | 1157 | foreach (IClause clause in clauses) |
1158 | { | 1158 | { |
1159 | foreach (bool lastCall in clause.match(arguments)) | 1159 | foreach (bool lastCall in clause.match(arguments)) |
1160 | yield return false; | 1160 | yield return false; |
1161 | } | 1161 | } |
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | public static void retractFact(Atom name, object[] arguments) | 1164 | public static void retractFact(Atom name, object[] arguments) |
1165 | { | 1165 | { |
1166 | NameArity nameArity = new NameArity(name, arguments.Length); | 1166 | NameArity nameArity = new NameArity(name, arguments.Length); |
1167 | List<IClause> clauses; | 1167 | List<IClause> clauses; |
1168 | if (!_predicatesStore.TryGetValue(nameArity, out clauses)) | 1168 | if (!_predicatesStore.TryGetValue(nameArity, out clauses)) |
1169 | // Can't find, so ignore. | 1169 | // Can't find, so ignore. |
1170 | return; | 1170 | return; |
1171 | 1171 | ||
1172 | foreach (object arg in arguments) | 1172 | foreach (object arg in arguments) |
1173 | { | 1173 | { |
1174 | if (!YP.var(arg)) | 1174 | if (!YP.var(arg)) |
1175 | throw new InvalidOperationException("All arguments must be unbound"); | 1175 | throw new InvalidOperationException("All arguments must be unbound"); |
1176 | } | 1176 | } |
1177 | // Set to a fresh empty IndexedAnswers. | 1177 | // Set to a fresh empty IndexedAnswers. |
1178 | _predicatesStore[nameArity] = (clauses = new List<IClause>()); | 1178 | _predicatesStore[nameArity] = (clauses = new List<IClause>()); |
1179 | clauses.Add(new IndexedAnswers()); | 1179 | clauses.Add(new IndexedAnswers()); |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | public static IEnumerable<bool> current_predicate(object NameSlashArity) | 1182 | public static IEnumerable<bool> current_predicate(object NameSlashArity) |
1183 | { | 1183 | { |
1184 | NameSlashArity = YP.getValue(NameSlashArity); | 1184 | NameSlashArity = YP.getValue(NameSlashArity); |
1185 | // First check if Name and Arity are nonvar so we can do a direct lookup. | 1185 | // First check if Name and Arity are nonvar so we can do a direct lookup. |
1186 | if (YP.ground(NameSlashArity)) | 1186 | if (YP.ground(NameSlashArity)) |
1187 | { | 1187 | { |
1188 | if (NameSlashArity is Functor2) | 1188 | if (NameSlashArity is Functor2) |
1189 | { | 1189 | { |
1190 | Functor2 NameArityFunctor = (Functor2)NameSlashArity; | 1190 | Functor2 NameArityFunctor = (Functor2)NameSlashArity; |
1191 | if (NameArityFunctor._name == Atom.SLASH) | 1191 | if (NameArityFunctor._name == Atom.SLASH) |
1192 | { | 1192 | { |
1193 | if (_predicatesStore.ContainsKey(new NameArity | 1193 | if (_predicatesStore.ContainsKey(new NameArity |
1194 | ((Atom)YP.getValue(NameArityFunctor._arg1), | 1194 | ((Atom)YP.getValue(NameArityFunctor._arg1), |
1195 | (int)YP.getValue(NameArityFunctor._arg2)))) | 1195 | (int)YP.getValue(NameArityFunctor._arg2)))) |
1196 | // The predicate is defined. | 1196 | // The predicate is defined. |
1197 | yield return false; | 1197 | yield return false; |
1198 | } | 1198 | } |
1199 | } | 1199 | } |
1200 | yield break; | 1200 | yield break; |
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | foreach (NameArity key in _predicatesStore.Keys) | 1203 | foreach (NameArity key in _predicatesStore.Keys) |
1204 | { | 1204 | { |
1205 | foreach (bool l1 in YP.unify | 1205 | foreach (bool l1 in YP.unify |
1206 | (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity)) | 1206 | (new Functor2(Atom.SLASH, key._name, key._arity), NameSlashArity)) |
1207 | yield return false; | 1207 | yield return false; |
1208 | } | 1208 | } |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | /// <summary> | 1211 | /// <summary> |
1212 | /// Use YP.getFunctorName(Goal) and invoke the static method of this name in the | 1212 | /// Use YP.getFunctorName(Goal) and invoke the static method of this name in the |
1213 | /// declaringClass, using arguments from YP.getFunctorArgs(Goal). | 1213 | /// declaringClass, using arguments from YP.getFunctorArgs(Goal). |
1214 | /// Note that Goal must be a simple functor, not a complex expression. | 1214 | /// Note that Goal must be a simple functor, not a complex expression. |
1215 | /// If not found, this throws UndefinedPredicateException. | 1215 | /// If not found, this throws UndefinedPredicateException. |
1216 | /// </summary> | 1216 | /// </summary> |
1217 | /// <param name="Goal"></param> | 1217 | /// <param name="Goal"></param> |
1218 | /// <param name="contextClass">the class for looking up default function references</param> | 1218 | /// <param name="contextClass">the class for looking up default function references</param> |
1219 | /// <returns></returns> | 1219 | /// <returns></returns> |
1220 | public static IEnumerable<bool> getIterator(object Goal, Type declaringClass) | 1220 | public static IEnumerable<bool> getIterator(object Goal, Type declaringClass) |
1221 | { | 1221 | { |
1222 | #if true | 1222 | #if true |
1223 | List<Variable> variableSetList = new List<Variable>(); | 1223 | List<Variable> variableSetList = new List<Variable>(); |
1224 | addUniqueVariables(Goal, variableSetList); | 1224 | addUniqueVariables(Goal, variableSetList); |
1225 | Variable[] variableSet = variableSetList.ToArray(); | 1225 | Variable[] variableSet = variableSetList.ToArray(); |
1226 | object Head = Functor.make("function", variableSet); | 1226 | object Head = Functor.make("function", variableSet); |
1227 | 1227 | ||
1228 | object Rule = new Functor2(Atom.RULE, Head, Goal); | 1228 | object Rule = new Functor2(Atom.RULE, Head, Goal); |
1229 | object RuleList = ListPair.make(new Functor2(Atom.F, Rule, Atom.NIL)); | 1229 | object RuleList = ListPair.make(new Functor2(Atom.F, Rule, Atom.NIL)); |
1230 | StringWriter functionCode = new StringWriter(); | 1230 | StringWriter functionCode = new StringWriter(); |
1231 | TextWriter saveOutputStream = _outputStream; | 1231 | TextWriter saveOutputStream = _outputStream; |
1232 | try | 1232 | try |
1233 | { | 1233 | { |
1234 | tell(functionCode); | 1234 | tell(functionCode); |
1235 | Variable FunctionCode = new Variable(); | 1235 | Variable FunctionCode = new Variable(); |
1236 | foreach (bool l1 in YPCompiler.makeFunctionPseudoCode(RuleList, FunctionCode)) | 1236 | foreach (bool l1 in YPCompiler.makeFunctionPseudoCode(RuleList, FunctionCode)) |
1237 | { | 1237 | { |
1238 | if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass"))) | 1238 | if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass"))) |
1239 | // Ignore getDeclaringClass since we have access to the one passed in. | 1239 | // Ignore getDeclaringClass since we have access to the one passed in. |
1240 | continue; | 1240 | continue; |
1241 | 1241 | ||
1242 | // Debug: should check if FunctionCode is a single call. | 1242 | // Debug: should check if FunctionCode is a single call. |
1243 | YPCompiler.convertFunctionCSharp(FunctionCode); | 1243 | YPCompiler.convertFunctionCSharp(FunctionCode); |
1244 | } | 1244 | } |
1245 | told(); | 1245 | told(); |
1246 | } | 1246 | } |
1247 | finally | 1247 | finally |
1248 | { | 1248 | { |
1249 | // Restore after calling tell. | 1249 | // Restore after calling tell. |
1250 | _outputStream = saveOutputStream; | 1250 | _outputStream = saveOutputStream; |
1251 | } | 1251 | } |
1252 | return YPCompiler.compileAnonymousFunction | 1252 | return YPCompiler.compileAnonymousFunction |
1253 | (functionCode.ToString(), variableSet.Length, declaringClass).match(variableSet); | 1253 | (functionCode.ToString(), variableSet.Length, declaringClass).match(variableSet); |
1254 | #else | 1254 | #else |
1255 | Goal = YP.getValue(Goal); | 1255 | Goal = YP.getValue(Goal); |
1256 | Atom name; | 1256 | Atom name; |
1257 | object[] args; | 1257 | object[] args; |
1258 | while (true) | 1258 | while (true) |
1259 | { | 1259 | { |
1260 | name = (Atom)YP.getFunctorName(Goal); | 1260 | name = (Atom)YP.getFunctorName(Goal); |
1261 | args = YP.getFunctorArgs(Goal); | 1261 | args = YP.getFunctorArgs(Goal); |
1262 | if (name == Atom.HAT && args.Length == 2) | 1262 | if (name == Atom.HAT && args.Length == 2) |
1263 | // Assume this is called from a bagof operation. Skip the leading qualifiers. | 1263 | // Assume this is called from a bagof operation. Skip the leading qualifiers. |
1264 | Goal = YP.getValue(((Functor2)Goal)._arg2); | 1264 | Goal = YP.getValue(((Functor2)Goal)._arg2); |
1265 | else | 1265 | else |
1266 | break; | 1266 | break; |
1267 | } | 1267 | } |
1268 | try | 1268 | try |
1269 | { | 1269 | { |
1270 | return (IEnumerable<bool>)declaringClass.InvokeMember | 1270 | return (IEnumerable<bool>)declaringClass.InvokeMember |
1271 | (name._name, BindingFlags.InvokeMethod, null, null, args); | 1271 | (name._name, BindingFlags.InvokeMethod, null, null, args); |
1272 | } | 1272 | } |
1273 | catch (TargetInvocationException exception) | 1273 | catch (TargetInvocationException exception) |
1274 | { | 1274 | { |
1275 | throw exception.InnerException; | 1275 | throw exception.InnerException; |
1276 | } | 1276 | } |
1277 | catch (MissingMethodException) | 1277 | catch (MissingMethodException) |
1278 | { | 1278 | { |
1279 | throw new UndefinedPredicateException | 1279 | throw new UndefinedPredicateException |
1280 | ("Cannot find predicate function: " + name + "/" + args.Length + " in " + | 1280 | ("Cannot find predicate function: " + name + "/" + args.Length + " in " + |
1281 | declaringClass.FullName, name, args.Length); | 1281 | declaringClass.FullName, name, args.Length); |
1282 | } | 1282 | } |
1283 | #endif | 1283 | #endif |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | public static void throwException(object Term) | 1286 | public static void throwException(object Term) |
1287 | { | 1287 | { |
1288 | throw new PrologException(Term); | 1288 | throw new PrologException(Term); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | /// <summary> | 1291 | /// <summary> |
1292 | /// script_event calls hosting script with events as a callback method. | 1292 | /// script_event calls hosting script with events as a callback method. |
1293 | /// </summary> | 1293 | /// </summary> |
1294 | /// <param name="script_event"></param> | 1294 | /// <param name="script_event"></param> |
1295 | /// <param name="script_params"></param> | 1295 | /// <param name="script_params"></param> |
1296 | /// <returns></returns> | 1296 | /// <returns></returns> |
1297 | public static void script_event(object script_event, object script_params) | 1297 | public static void script_event(object script_event, object script_params) |
1298 | { | 1298 | { |
1299 | string function = ((Atom)YP.getValue(script_event))._name; | 1299 | string function = ((Atom)YP.getValue(script_event))._name; |
1300 | object[] array = ListPair.toArray(script_params); | 1300 | object[] array = ListPair.toArray(script_params); |
1301 | if (array == null) | 1301 | if (array == null) |
1302 | return; // YP.fail(); | 1302 | return; // YP.fail(); |
1303 | if (array.Length > 1) | 1303 | if (array.Length > 1) |
1304 | { | 1304 | { |
1305 | //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue | 1305 | //m_CmdManager.m_ScriptEngine.m_EventQueManager.AddToScriptQueue |
1306 | //(localID, itemID, function, array); | 1306 | //(localID, itemID, function, array); |
1307 | // sortArray(array); | 1307 | // sortArray(array); |
1308 | } | 1308 | } |
1309 | //return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array)); | 1309 | //return YP.unify(Sorted, ListPair.makeWithoutRepeatedTerms(array)); |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | /// <summary> | 1312 | /// <summary> |
1313 | /// An enumerator that does zero loops. | 1313 | /// An enumerator that does zero loops. |
1314 | /// </summary> | 1314 | /// </summary> |
1315 | private class Fail : IEnumerator<bool>, IEnumerable<bool> | 1315 | private class Fail : IEnumerator<bool>, IEnumerable<bool> |
1316 | { | 1316 | { |
1317 | public bool MoveNext() | 1317 | public bool MoveNext() |
1318 | { | 1318 | { |
1319 | return false; | 1319 | return false; |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | public IEnumerator<bool> GetEnumerator() | 1322 | public IEnumerator<bool> GetEnumerator() |
1323 | { | 1323 | { |
1324 | return (IEnumerator<bool>)this; | 1324 | return (IEnumerator<bool>)this; |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | IEnumerator IEnumerable.GetEnumerator() | 1327 | IEnumerator IEnumerable.GetEnumerator() |
1328 | { | 1328 | { |
1329 | return GetEnumerator(); | 1329 | return GetEnumerator(); |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | public bool Current | 1332 | public bool Current |
1333 | { | 1333 | { |
1334 | get { return true; } | 1334 | get { return true; } |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | object IEnumerator.Current | 1337 | object IEnumerator.Current |
1338 | { | 1338 | { |
1339 | get { return true; } | 1339 | get { return true; } |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | public void Dispose() | 1342 | public void Dispose() |
1343 | { | 1343 | { |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | public void Reset() | 1346 | public void Reset() |
1347 | { | 1347 | { |
1348 | throw new NotImplementedException(); | 1348 | throw new NotImplementedException(); |
1349 | } | 1349 | } |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | /// <summary> | 1352 | /// <summary> |
1353 | /// An enumerator that does one iteration. | 1353 | /// An enumerator that does one iteration. |
1354 | /// </summary> | 1354 | /// </summary> |
1355 | private class Succeed : IEnumerator<bool>, IEnumerable<bool> | 1355 | private class Succeed : IEnumerator<bool>, IEnumerable<bool> |
1356 | { | 1356 | { |
1357 | private bool _didIteration = false; | 1357 | private bool _didIteration = false; |
1358 | 1358 | ||
1359 | public bool MoveNext() | 1359 | public bool MoveNext() |
1360 | { | 1360 | { |
1361 | if (!_didIteration) | 1361 | if (!_didIteration) |
1362 | { | 1362 | { |
1363 | _didIteration = true; | 1363 | _didIteration = true; |
1364 | return true; | 1364 | return true; |
1365 | } | 1365 | } |
1366 | else | 1366 | else |
1367 | return false; | 1367 | return false; |
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | public IEnumerator<bool> GetEnumerator() | 1370 | public IEnumerator<bool> GetEnumerator() |
1371 | { | 1371 | { |
1372 | return (IEnumerator<bool>)this; | 1372 | return (IEnumerator<bool>)this; |
1373 | } | 1373 | } |
1374 | 1374 | ||
1375 | IEnumerator IEnumerable.GetEnumerator() | 1375 | IEnumerator IEnumerable.GetEnumerator() |
1376 | { | 1376 | { |
1377 | return GetEnumerator(); | 1377 | return GetEnumerator(); |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | public bool Current | 1380 | public bool Current |
1381 | { | 1381 | { |
1382 | get { return false; } | 1382 | get { return false; } |
1383 | } | 1383 | } |
1384 | 1384 | ||
1385 | object IEnumerator.Current | 1385 | object IEnumerator.Current |
1386 | { | 1386 | { |
1387 | get { return false; } | 1387 | get { return false; } |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | public void Dispose() | 1390 | public void Dispose() |
1391 | { | 1391 | { |
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | public void Reset() | 1394 | public void Reset() |
1395 | { | 1395 | { |
1396 | throw new NotImplementedException(); | 1396 | throw new NotImplementedException(); |
1397 | } | 1397 | } |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | /// <summary> | 1400 | /// <summary> |
1401 | /// An enumerator that repeats forever. | 1401 | /// An enumerator that repeats forever. |
1402 | /// </summary> | 1402 | /// </summary> |
1403 | private class Repeat : IEnumerator<bool>, IEnumerable<bool> | 1403 | private class Repeat : IEnumerator<bool>, IEnumerable<bool> |
1404 | { | 1404 | { |
1405 | public bool MoveNext() | 1405 | public bool MoveNext() |
1406 | { | 1406 | { |
1407 | return true; | 1407 | return true; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | public IEnumerator<bool> GetEnumerator() | 1410 | public IEnumerator<bool> GetEnumerator() |
1411 | { | 1411 | { |
1412 | return (IEnumerator<bool>)this; | 1412 | return (IEnumerator<bool>)this; |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | IEnumerator IEnumerable.GetEnumerator() | 1415 | IEnumerator IEnumerable.GetEnumerator() |
1416 | { | 1416 | { |
1417 | return GetEnumerator(); | 1417 | return GetEnumerator(); |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | public bool Current | 1420 | public bool Current |
1421 | { | 1421 | { |
1422 | get { return false; } | 1422 | get { return false; } |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | object IEnumerator.Current | 1425 | object IEnumerator.Current |
1426 | { | 1426 | { |
1427 | get { return false; } | 1427 | get { return false; } |
1428 | } | 1428 | } |
1429 | 1429 | ||
1430 | public void Dispose() | 1430 | public void Dispose() |
1431 | { | 1431 | { |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | public void Reset() | 1434 | public void Reset() |
1435 | { | 1435 | { |
1436 | throw new NotImplementedException(); | 1436 | throw new NotImplementedException(); |
1437 | } | 1437 | } |
1438 | } | 1438 | } |
1439 | } | 1439 | } |
1440 | } | 1440 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs index 923906b..a0a92b6 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs | |||
@@ -1,5247 +1,5247 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Collections; | 33 | using System.Collections; |
34 | using System.Collections.Generic; | 34 | using System.Collections.Generic; |
35 | using System.Text; | 35 | using System.Text; |
36 | using System.CodeDom.Compiler; | 36 | using System.CodeDom.Compiler; |
37 | 37 | ||
38 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 38 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
39 | { | 39 | { |
40 | public class YPCompiler | 40 | public class YPCompiler |
41 | { | 41 | { |
42 | private class CompilerState | 42 | private class CompilerState |
43 | { | 43 | { |
44 | public IndexedAnswers _pred = new IndexedAnswers(); | 44 | public IndexedAnswers _pred = new IndexedAnswers(); |
45 | public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>(); | 45 | public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>(); |
46 | public int _gensymCounter; | 46 | public int _gensymCounter; |
47 | public bool _useFinalCutCode; | 47 | public bool _useFinalCutCode; |
48 | public Variable _finalCutCode; | 48 | public Variable _finalCutCode; |
49 | public bool _codeUsesYield; | 49 | public bool _codeUsesYield; |
50 | public Atom _determinism; | 50 | public Atom _determinism; |
51 | // a list of '='(Name, Variable) | 51 | // a list of '='(Name, Variable) |
52 | public List<object> _variableNames; | 52 | public List<object> _variableNames; |
53 | 53 | ||
54 | // Make these static functions that explicitly take the State so Prolog can call it. | 54 | // Make these static functions that explicitly take the State so Prolog can call it. |
55 | 55 | ||
56 | /// <summary> | 56 | /// <summary> |
57 | /// Make a new CompilerState and bind it to State. | 57 | /// Make a new CompilerState and bind it to State. |
58 | /// </summary> | 58 | /// </summary> |
59 | /// <param name="State"></param> | 59 | /// <param name="State"></param> |
60 | /// <returns></returns> | 60 | /// <returns></returns> |
61 | public static IEnumerable<bool> make(object State) | 61 | public static IEnumerable<bool> make(object State) |
62 | { | 62 | { |
63 | return YP.unify(State, new CompilerState()); | 63 | return YP.unify(State, new CompilerState()); |
64 | } | 64 | } |
65 | 65 | ||
66 | public static void assertPred(object State, object Pred, object Determinism) | 66 | public static void assertPred(object State, object Pred, object Determinism) |
67 | { | 67 | { |
68 | State = YP.getValue(State); | 68 | State = YP.getValue(State); |
69 | object functorName = YP.getFunctorName(Pred); | 69 | object functorName = YP.getFunctorName(Pred); |
70 | object[] functorArgs = YP.getFunctorArgs(Pred); | 70 | object[] functorArgs = YP.getFunctorArgs(Pred); |
71 | // Debug: Should check if it's already asserted and is the same. | 71 | // Debug: Should check if it's already asserted and is the same. |
72 | ((CompilerState)State)._pred.addAnswer | 72 | ((CompilerState)State)._pred.addAnswer |
73 | (new object[] { functorName, functorArgs.Length, Pred, YP.getValue(Determinism) }); | 73 | (new object[] { functorName, functorArgs.Length, Pred, YP.getValue(Determinism) }); |
74 | } | 74 | } |
75 | 75 | ||
76 | public static void assertModuleForNameArity(object State, object Name, object Arity, object Module) | 76 | public static void assertModuleForNameArity(object State, object Name, object Arity, object Module) |
77 | { | 77 | { |
78 | State = YP.getValue(State); | 78 | State = YP.getValue(State); |
79 | Name = YP.getValue(Name); | 79 | Name = YP.getValue(Name); |
80 | Arity = YP.getValue(Arity); | 80 | Arity = YP.getValue(Arity); |
81 | Module = YP.getValue(Module); | 81 | Module = YP.getValue(Module); |
82 | // If the Module Atom comes from the parser, it always has null _declaringClass. | 82 | // If the Module Atom comes from the parser, it always has null _declaringClass. |
83 | if (Module is Atom && ((Atom)Module)._module == null && Name is Atom && Arity is int) | 83 | if (Module is Atom && ((Atom)Module)._module == null && Name is Atom && Arity is int) |
84 | { | 84 | { |
85 | // Replace a previous entry if it exists. | 85 | // Replace a previous entry if it exists. |
86 | ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] = | 86 | ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] = |
87 | (Atom)Module; | 87 | (Atom)Module; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | public static void startFunction(object State, object Head) | 91 | public static void startFunction(object State, object Head) |
92 | { | 92 | { |
93 | State = YP.getValue(State); | 93 | State = YP.getValue(State); |
94 | ((CompilerState)State)._gensymCounter = 0; | 94 | ((CompilerState)State)._gensymCounter = 0; |
95 | ((CompilerState)State)._useFinalCutCode = false; | 95 | ((CompilerState)State)._useFinalCutCode = false; |
96 | ((CompilerState)State)._finalCutCode = new Variable(); | 96 | ((CompilerState)State)._finalCutCode = new Variable(); |
97 | ((CompilerState)State)._codeUsesYield = false; | 97 | ((CompilerState)State)._codeUsesYield = false; |
98 | if (CompilerState.isDetNoneOut(State, Head)) | 98 | if (CompilerState.isDetNoneOut(State, Head)) |
99 | ((CompilerState)State)._determinism = Atom.a("detNoneOut"); | 99 | ((CompilerState)State)._determinism = Atom.a("detNoneOut"); |
100 | else if (CompilerState.isSemidetNoneOut(State, Head)) | 100 | else if (CompilerState.isSemidetNoneOut(State, Head)) |
101 | ((CompilerState)State)._determinism = Atom.a("semidetNoneOut"); | 101 | ((CompilerState)State)._determinism = Atom.a("semidetNoneOut"); |
102 | else | 102 | else |
103 | ((CompilerState)State)._determinism = Atom.a("nondet"); | 103 | ((CompilerState)State)._determinism = Atom.a("nondet"); |
104 | } | 104 | } |
105 | 105 | ||
106 | public static void setCodeUsesYield(object State) | 106 | public static void setCodeUsesYield(object State) |
107 | { | 107 | { |
108 | State = YP.getValue(State); | 108 | State = YP.getValue(State); |
109 | ((CompilerState)State)._codeUsesYield = true; | 109 | ((CompilerState)State)._codeUsesYield = true; |
110 | } | 110 | } |
111 | 111 | ||
112 | public static bool codeUsesYield(object State) | 112 | public static bool codeUsesYield(object State) |
113 | { | 113 | { |
114 | State = YP.getValue(State); | 114 | State = YP.getValue(State); |
115 | return ((CompilerState)State)._codeUsesYield; | 115 | return ((CompilerState)State)._codeUsesYield; |
116 | } | 116 | } |
117 | 117 | ||
118 | public static bool determinismEquals(object State, object Term) | 118 | public static bool determinismEquals(object State, object Term) |
119 | { | 119 | { |
120 | State = YP.getValue(State); | 120 | State = YP.getValue(State); |
121 | return YP.termEqual(((CompilerState)State)._determinism, Term); | 121 | return YP.termEqual(((CompilerState)State)._determinism, Term); |
122 | } | 122 | } |
123 | 123 | ||
124 | /// <summary> | 124 | /// <summary> |
125 | /// Set _variableNames to a new list of (Name = Variable) for each unique variable in rule. | 125 | /// Set _variableNames to a new list of (Name = Variable) for each unique variable in rule. |
126 | /// If the variable is in variableNameSuggestions, use it, otherwise use x1, x2, etc. | 126 | /// If the variable is in variableNameSuggestions, use it, otherwise use x1, x2, etc. |
127 | /// </summary> | 127 | /// </summary> |
128 | /// <param name="State"></param> | 128 | /// <param name="State"></param> |
129 | /// <param name="rule"></param> | 129 | /// <param name="rule"></param> |
130 | /// <param name="variableNameSuggestions"></param> | 130 | /// <param name="variableNameSuggestions"></param> |
131 | public static void newVariableNames(object State, object Rule, object VariableNameSuggestions) | 131 | public static void newVariableNames(object State, object Rule, object VariableNameSuggestions) |
132 | { | 132 | { |
133 | State = YP.getValue(State); | 133 | State = YP.getValue(State); |
134 | List<Variable> variablesSet = new List<Variable>(); | 134 | List<Variable> variablesSet = new List<Variable>(); |
135 | YP.addUniqueVariables(Rule, variablesSet); | 135 | YP.addUniqueVariables(Rule, variablesSet); |
136 | 136 | ||
137 | ((CompilerState)State)._variableNames = new List<object>(); | 137 | ((CompilerState)State)._variableNames = new List<object>(); |
138 | int xCounter = 0; | 138 | int xCounter = 0; |
139 | foreach (Variable variable in variablesSet) | 139 | foreach (Variable variable in variablesSet) |
140 | ((CompilerState)State)._variableNames.Add | 140 | ((CompilerState)State)._variableNames.Add |
141 | (new Functor2(Atom.a("="), makeVariableName(variable, VariableNameSuggestions, ++xCounter), | 141 | (new Functor2(Atom.a("="), makeVariableName(variable, VariableNameSuggestions, ++xCounter), |
142 | variable)); | 142 | variable)); |
143 | } | 143 | } |
144 | 144 | ||
145 | private static object makeVariableName(object variable, object variableNameSuggestions, int xCounter) | 145 | private static object makeVariableName(object variable, object variableNameSuggestions, int xCounter) |
146 | { | 146 | { |
147 | // Debug: should require named variables to start with _ or capital. Should | 147 | // Debug: should require named variables to start with _ or capital. Should |
148 | // check for duplicates and clashes with keywords. | 148 | // check for duplicates and clashes with keywords. |
149 | for (object element = YP.getValue(variableNameSuggestions); | 149 | for (object element = YP.getValue(variableNameSuggestions); |
150 | element is Functor2 && ((Functor2)element)._name == Atom.DOT; | 150 | element is Functor2 && ((Functor2)element)._name == Atom.DOT; |
151 | element = YP.getValue(((Functor2)element)._arg2)) | 151 | element = YP.getValue(((Functor2)element)._arg2)) |
152 | { | 152 | { |
153 | object suggestionPair = YP.getValue(((Functor2)element)._arg1); | 153 | object suggestionPair = YP.getValue(((Functor2)element)._arg1); |
154 | if (sameVariable(variable, ((Functor2)suggestionPair)._arg2)) | 154 | if (sameVariable(variable, ((Functor2)suggestionPair)._arg2)) |
155 | { | 155 | { |
156 | Atom suggestion = (Atom)YP.getValue(((Functor2)suggestionPair)._arg1); | 156 | Atom suggestion = (Atom)YP.getValue(((Functor2)suggestionPair)._arg1); |
157 | if (suggestion.Equals(Atom.a("Atom"))) | 157 | if (suggestion.Equals(Atom.a("Atom"))) |
158 | suggestion = Atom.a("Atom_1"); | 158 | suggestion = Atom.a("Atom_1"); |
159 | if (suggestion.Equals(Atom.a("Variable"))) | 159 | if (suggestion.Equals(Atom.a("Variable"))) |
160 | suggestion = Atom.a("Variable_1"); | 160 | suggestion = Atom.a("Variable_1"); |
161 | if (suggestion.Equals(Atom.a("Functor"))) | 161 | if (suggestion.Equals(Atom.a("Functor"))) |
162 | suggestion = Atom.a("Functor_1"); | 162 | suggestion = Atom.a("Functor_1"); |
163 | return suggestion; | 163 | return suggestion; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | return Atom.a("x" + xCounter); | 167 | return Atom.a("x" + xCounter); |
168 | } | 168 | } |
169 | 169 | ||
170 | /// <summary> | 170 | /// <summary> |
171 | /// Unify Result with the name assigned by CompilerState.newVariableNames in State._variableNames | 171 | /// Unify Result with the name assigned by CompilerState.newVariableNames in State._variableNames |
172 | /// for variable. | 172 | /// for variable. |
173 | /// </summary> | 173 | /// </summary> |
174 | /// <param name="variable">a Variable</param> | 174 | /// <param name="variable">a Variable</param> |
175 | /// <param name="State"></param> | 175 | /// <param name="State"></param> |
176 | /// <param name="Result">the assigned Name</param> | 176 | /// <param name="Result">the assigned Name</param> |
177 | public static IEnumerable<bool> getVariableName(object State, object variable, object Result) | 177 | public static IEnumerable<bool> getVariableName(object State, object variable, object Result) |
178 | { | 178 | { |
179 | State = YP.getValue(State); | 179 | State = YP.getValue(State); |
180 | foreach (object variableInfo in ((CompilerState)State)._variableNames) | 180 | foreach (object variableInfo in ((CompilerState)State)._variableNames) |
181 | { | 181 | { |
182 | if (variableInfo is Functor2 && ((Functor2)variableInfo)._name.Equals(Atom.a("="))) | 182 | if (variableInfo is Functor2 && ((Functor2)variableInfo)._name.Equals(Atom.a("="))) |
183 | { | 183 | { |
184 | if (sameVariable(variable, ((Functor2)variableInfo)._arg2)) | 184 | if (sameVariable(variable, ((Functor2)variableInfo)._arg2)) |
185 | return YP.unify(Result, ((Functor2)variableInfo)._arg1); | 185 | return YP.unify(Result, ((Functor2)variableInfo)._arg1); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | // We set up names for all unique variables, so this should never happen. | 189 | // We set up names for all unique variables, so this should never happen. |
190 | throw new PrologException(Atom.a("Can't find entry in _variableNames")); | 190 | throw new PrologException(Atom.a("Can't find entry in _variableNames")); |
191 | } | 191 | } |
192 | 192 | ||
193 | public static IEnumerable<bool> variableNamesList(object State, object VariableNamesList) | 193 | public static IEnumerable<bool> variableNamesList(object State, object VariableNamesList) |
194 | { | 194 | { |
195 | State = YP.getValue(State); | 195 | State = YP.getValue(State); |
196 | return YP.unify(VariableNamesList, ListPair.make(((CompilerState)State)._variableNames)); | 196 | return YP.unify(VariableNamesList, ListPair.make(((CompilerState)State)._variableNames)); |
197 | } | 197 | } |
198 | 198 | ||
199 | public static IEnumerable<bool> gensym(object State, object Base, object Symbol) | 199 | public static IEnumerable<bool> gensym(object State, object Base, object Symbol) |
200 | { | 200 | { |
201 | State = YP.getValue(State); | 201 | State = YP.getValue(State); |
202 | return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter)); | 202 | return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter)); |
203 | } | 203 | } |
204 | 204 | ||
205 | public static bool isDetNoneOut(object State, object Term) | 205 | public static bool isDetNoneOut(object State, object Term) |
206 | { | 206 | { |
207 | State = YP.getValue(State); | 207 | State = YP.getValue(State); |
208 | object functorName = YP.getFunctorName(Term); | 208 | object functorName = YP.getFunctorName(Term); |
209 | object[] functorArgs = YP.getFunctorArgs(Term); | 209 | object[] functorArgs = YP.getFunctorArgs(Term); |
210 | 210 | ||
211 | Variable pred = new Variable(); | 211 | Variable pred = new Variable(); |
212 | foreach (bool l1 in ((CompilerState)State)._pred.match | 212 | foreach (bool l1 in ((CompilerState)State)._pred.match |
213 | (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") })) | 213 | (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") })) |
214 | { | 214 | { |
215 | if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue()))) | 215 | if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue()))) |
216 | { | 216 | { |
217 | return true; | 217 | return true; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | return false; | 221 | return false; |
222 | } | 222 | } |
223 | 223 | ||
224 | public static bool isSemidetNoneOut(object State, object Term) | 224 | public static bool isSemidetNoneOut(object State, object Term) |
225 | { | 225 | { |
226 | State = YP.getValue(State); | 226 | State = YP.getValue(State); |
227 | object functorName = YP.getFunctorName(Term); | 227 | object functorName = YP.getFunctorName(Term); |
228 | object[] functorArgs = YP.getFunctorArgs(Term); | 228 | object[] functorArgs = YP.getFunctorArgs(Term); |
229 | 229 | ||
230 | Variable pred = new Variable(); | 230 | Variable pred = new Variable(); |
231 | foreach (bool l1 in ((CompilerState)State)._pred.match | 231 | foreach (bool l1 in ((CompilerState)State)._pred.match |
232 | (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") })) | 232 | (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") })) |
233 | { | 233 | { |
234 | if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue()))) | 234 | if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue()))) |
235 | { | 235 | { |
236 | return true; | 236 | return true; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | return false; | 240 | return false; |
241 | } | 241 | } |
242 | 242 | ||
243 | /// <summary> | 243 | /// <summary> |
244 | /// Return false if any of args is out, otherwise true. | 244 | /// Return false if any of args is out, otherwise true. |
245 | /// args is an array of ::(Type,Mode) where Mode is in or out. | 245 | /// args is an array of ::(Type,Mode) where Mode is in or out. |
246 | /// </summary> | 246 | /// </summary> |
247 | /// <param name="args"></param> | 247 | /// <param name="args"></param> |
248 | /// <returns></returns> | 248 | /// <returns></returns> |
249 | private static bool isNoneOut(object[] args) | 249 | private static bool isNoneOut(object[] args) |
250 | { | 250 | { |
251 | foreach (object arg in args) | 251 | foreach (object arg in args) |
252 | { | 252 | { |
253 | if (arg is Functor2 && ((Functor2)arg)._name == Atom.a("::") && | 253 | if (arg is Functor2 && ((Functor2)arg)._name == Atom.a("::") && |
254 | ((Functor2)arg)._arg2 == Atom.a("out")) | 254 | ((Functor2)arg)._arg2 == Atom.a("out")) |
255 | return false; | 255 | return false; |
256 | } | 256 | } |
257 | return true; | 257 | return true; |
258 | } | 258 | } |
259 | 259 | ||
260 | public static bool nameArityHasModule(object State, object Name, object Arity, object Module) | 260 | public static bool nameArityHasModule(object State, object Name, object Arity, object Module) |
261 | { | 261 | { |
262 | State = YP.getValue(State); | 262 | State = YP.getValue(State); |
263 | Name = YP.getValue(Name); | 263 | Name = YP.getValue(Name); |
264 | Arity = YP.getValue(Arity); | 264 | Arity = YP.getValue(Arity); |
265 | Module = YP.getValue(Module); | 265 | Module = YP.getValue(Module); |
266 | if (Name is Atom && Arity is int) | 266 | if (Name is Atom && Arity is int) |
267 | { | 267 | { |
268 | Atom FoundModule; | 268 | Atom FoundModule; |
269 | if (!((CompilerState)State)._moduleForNameArity.TryGetValue | 269 | if (!((CompilerState)State)._moduleForNameArity.TryGetValue |
270 | (new YP.NameArity((Atom)Name, (int)Arity), out FoundModule)) | 270 | (new YP.NameArity((Atom)Name, (int)Arity), out FoundModule)) |
271 | return false; | 271 | return false; |
272 | return FoundModule == Module; | 272 | return FoundModule == Module; |
273 | } | 273 | } |
274 | return false; | 274 | return false; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | /// <summary> | 278 | /// <summary> |
279 | /// Use CodeDomProvider to compile the functionCode and return a YP.IClause. | 279 | /// Use CodeDomProvider to compile the functionCode and return a YP.IClause. |
280 | /// The function name must be "function" and have nArgs arguments. | 280 | /// The function name must be "function" and have nArgs arguments. |
281 | /// </summary> | 281 | /// </summary> |
282 | /// <param name="functionCode">the code for the iterator, such as | 282 | /// <param name="functionCode">the code for the iterator, such as |
283 | /// "public static IEnumerable<bool> function() { yield return false; }" | 283 | /// "public static IEnumerable<bool> function() { yield return false; }" |
284 | /// </param> | 284 | /// </param> |
285 | /// <param name="nArgs">the number of args in the function</param> | 285 | /// <param name="nArgs">the number of args in the function</param> |
286 | /// <param name="declaringClass">if not null, then use the functionCode inside a class which | 286 | /// <param name="declaringClass">if not null, then use the functionCode inside a class which |
287 | /// inherits from contextClass, so that references in functionCode to methods in declaringClass don't | 287 | /// inherits from contextClass, so that references in functionCode to methods in declaringClass don't |
288 | /// have to be qualified</param> | 288 | /// have to be qualified</param> |
289 | /// <returns>a new YP.IClause object on which you can call match(object[] args) where | 289 | /// <returns>a new YP.IClause object on which you can call match(object[] args) where |
290 | /// args length is nArgs</returns> | 290 | /// args length is nArgs</returns> |
291 | public static YP.IClause compileAnonymousFunction(string functionCode, int nArgs, Type declaringClass) | 291 | public static YP.IClause compileAnonymousFunction(string functionCode, int nArgs, Type declaringClass) |
292 | { | 292 | { |
293 | CompilerParameters parameters = new CompilerParameters(); | 293 | CompilerParameters parameters = new CompilerParameters(); |
294 | // This gets the location of the System assembly. | 294 | // This gets the location of the System assembly. |
295 | parameters.ReferencedAssemblies.Add(typeof(System.Int32).Assembly.Location); | 295 | parameters.ReferencedAssemblies.Add(typeof(System.Int32).Assembly.Location); |
296 | // This gets the location of this assembly which also has YieldProlog.YP, etc. | 296 | // This gets the location of this assembly which also has YieldProlog.YP, etc. |
297 | parameters.ReferencedAssemblies.Add(typeof(YPCompiler).Assembly.Location); | 297 | parameters.ReferencedAssemblies.Add(typeof(YPCompiler).Assembly.Location); |
298 | if (declaringClass != null) | 298 | if (declaringClass != null) |
299 | parameters.ReferencedAssemblies.Add(declaringClass.Assembly.Location); | 299 | parameters.ReferencedAssemblies.Add(declaringClass.Assembly.Location); |
300 | parameters.GenerateInMemory = true; | 300 | parameters.GenerateInMemory = true; |
301 | 301 | ||
302 | StringBuilder sourceCode = new StringBuilder(); | 302 | StringBuilder sourceCode = new StringBuilder(); |
303 | sourceCode.Append(@" | 303 | sourceCode.Append(@" |
304 | using System; | 304 | using System; |
305 | using System.Collections.Generic; | 305 | using System.Collections.Generic; |
306 | using YieldProlog; | 306 | using YieldProlog; |
307 | 307 | ||
308 | namespace Temporary { | 308 | namespace Temporary { |
309 | public class Temporary : YP.IClause { | 309 | public class Temporary : YP.IClause { |
310 | public class Inner" + (declaringClass == null ? "" : " : " + declaringClass.FullName) + @" { | 310 | public class Inner" + (declaringClass == null ? "" : " : " + declaringClass.FullName) + @" { |
311 | "); | 311 | "); |
312 | sourceCode.Append(functionCode); | 312 | sourceCode.Append(functionCode); |
313 | // Basically, match applies the args to function. | 313 | // Basically, match applies the args to function. |
314 | sourceCode.Append(@" | 314 | sourceCode.Append(@" |
315 | } | 315 | } |
316 | public IEnumerable<bool> match(object[] args) { | 316 | public IEnumerable<bool> match(object[] args) { |
317 | return Inner.function("); | 317 | return Inner.function("); |
318 | if (nArgs >= 1) | 318 | if (nArgs >= 1) |
319 | sourceCode.Append("args[0]"); | 319 | sourceCode.Append("args[0]"); |
320 | for (int i = 1; i < nArgs; ++i) | 320 | for (int i = 1; i < nArgs; ++i) |
321 | sourceCode.Append(", args[" + i + "]"); | 321 | sourceCode.Append(", args[" + i + "]"); |
322 | sourceCode.Append(@"); | 322 | sourceCode.Append(@"); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | } | 325 | } |
326 | "); | 326 | "); |
327 | 327 | ||
328 | CompilerResults results = CodeDomProvider.CreateProvider | 328 | CompilerResults results = CodeDomProvider.CreateProvider |
329 | ("CSharp").CompileAssemblyFromSource(parameters, sourceCode.ToString()); | 329 | ("CSharp").CompileAssemblyFromSource(parameters, sourceCode.ToString()); |
330 | if (results.Errors.Count > 0) | 330 | if (results.Errors.Count > 0) |
331 | throw new Exception("Error evaluating code: " + results.Errors[0]); | 331 | throw new Exception("Error evaluating code: " + results.Errors[0]); |
332 | 332 | ||
333 | // Return a new Temporary.Temporary object. | 333 | // Return a new Temporary.Temporary object. |
334 | return (YP.IClause)results.CompiledAssembly.GetType | 334 | return (YP.IClause)results.CompiledAssembly.GetType |
335 | ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null); | 335 | ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null); |
336 | } | 336 | } |
337 | 337 | ||
338 | // Compiler output follows. | 338 | // Compiler output follows. |
339 | 339 | ||
340 | class YPInnerClass { } | 340 | class YPInnerClass { } |
341 | static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; } | 341 | static Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; } |
342 | 342 | ||
343 | public static void repeatWrite(object arg1, object N) | 343 | public static void repeatWrite(object arg1, object N) |
344 | { | 344 | { |
345 | { | 345 | { |
346 | object _Value = arg1; | 346 | object _Value = arg1; |
347 | if (YP.termEqual(N, 0)) | 347 | if (YP.termEqual(N, 0)) |
348 | { | 348 | { |
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | { | 352 | { |
353 | object Value = arg1; | 353 | object Value = arg1; |
354 | Variable NextN = new Variable(); | 354 | Variable NextN = new Variable(); |
355 | YP.write(Value); | 355 | YP.write(Value); |
356 | foreach (bool l2 in YP.unify(NextN, YP.subtract(N, 1))) | 356 | foreach (bool l2 in YP.unify(NextN, YP.subtract(N, 1))) |
357 | { | 357 | { |
358 | repeatWrite(Value, NextN); | 358 | repeatWrite(Value, NextN); |
359 | return; | 359 | return; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | public static bool sameVariable(object Variable1, object Variable2) | 364 | public static bool sameVariable(object Variable1, object Variable2) |
365 | { | 365 | { |
366 | { | 366 | { |
367 | if (YP.var(Variable1)) | 367 | if (YP.var(Variable1)) |
368 | { | 368 | { |
369 | if (YP.var(Variable2)) | 369 | if (YP.var(Variable2)) |
370 | { | 370 | { |
371 | if (YP.termEqual(Variable1, Variable2)) | 371 | if (YP.termEqual(Variable1, Variable2)) |
372 | { | 372 | { |
373 | return true; | 373 | return true; |
374 | } | 374 | } |
375 | } | 375 | } |
376 | } | 376 | } |
377 | } | 377 | } |
378 | return false; | 378 | return false; |
379 | } | 379 | } |
380 | 380 | ||
381 | public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode) | 381 | public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode) |
382 | { | 382 | { |
383 | { | 383 | { |
384 | Variable State = new Variable(); | 384 | Variable State = new Variable(); |
385 | foreach (bool l2 in CompilerState.make(State)) | 385 | foreach (bool l2 in CompilerState.make(State)) |
386 | { | 386 | { |
387 | CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det")); | 387 | CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det")); |
388 | CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det")); | 388 | CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det")); |
389 | CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det")); | 389 | CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det")); |
390 | CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det")); | 390 | CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det")); |
391 | CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 391 | CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
392 | CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 392 | CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
393 | CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 393 | CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
394 | CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 394 | CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
395 | CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 395 | CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
396 | CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 396 | CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
397 | CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 397 | CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
398 | CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 398 | CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
399 | CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 399 | CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
400 | CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); | 400 | CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet")); |
401 | processCompilerDirectives(RuleList, State); | 401 | processCompilerDirectives(RuleList, State); |
402 | foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass"))) | 402 | foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass"))) |
403 | { | 403 | { |
404 | yield return false; | 404 | yield return false; |
405 | } | 405 | } |
406 | foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode)) | 406 | foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode)) |
407 | { | 407 | { |
408 | yield return false; | 408 | yield return false; |
409 | } | 409 | } |
410 | } | 410 | } |
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | public static void processCompilerDirectives(object arg1, object arg2) | 414 | public static void processCompilerDirectives(object arg1, object arg2) |
415 | { | 415 | { |
416 | { | 416 | { |
417 | object _State = arg2; | 417 | object _State = arg2; |
418 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 418 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
419 | { | 419 | { |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | } | 422 | } |
423 | { | 423 | { |
424 | object State = arg2; | 424 | object State = arg2; |
425 | Variable Pred = new Variable(); | 425 | Variable Pred = new Variable(); |
426 | Variable Determinism = new Variable(); | 426 | Variable Determinism = new Variable(); |
427 | Variable x3 = new Variable(); | 427 | Variable x3 = new Variable(); |
428 | Variable RestRules = new Variable(); | 428 | Variable RestRules = new Variable(); |
429 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor1(@"pred", new Functor2(@"is", Pred, Determinism))), x3), RestRules))) | 429 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor1(@"pred", new Functor2(@"is", Pred, Determinism))), x3), RestRules))) |
430 | { | 430 | { |
431 | CompilerState.assertPred(State, Pred, Determinism); | 431 | CompilerState.assertPred(State, Pred, Determinism); |
432 | processCompilerDirectives(RestRules, State); | 432 | processCompilerDirectives(RestRules, State); |
433 | return; | 433 | return; |
434 | } | 434 | } |
435 | } | 435 | } |
436 | { | 436 | { |
437 | object State = arg2; | 437 | object State = arg2; |
438 | Variable Module = new Variable(); | 438 | Variable Module = new Variable(); |
439 | Variable PredicateList = new Variable(); | 439 | Variable PredicateList = new Variable(); |
440 | Variable x3 = new Variable(); | 440 | Variable x3 = new Variable(); |
441 | Variable RestRules = new Variable(); | 441 | Variable RestRules = new Variable(); |
442 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor2(@"import", Module, PredicateList)), x3), RestRules))) | 442 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor2(@"import", Module, PredicateList)), x3), RestRules))) |
443 | { | 443 | { |
444 | foreach (bool l3 in importPredicateList(State, Module, PredicateList)) | 444 | foreach (bool l3 in importPredicateList(State, Module, PredicateList)) |
445 | { | 445 | { |
446 | processCompilerDirectives(RestRules, State); | 446 | processCompilerDirectives(RestRules, State); |
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | } | 450 | } |
451 | { | 451 | { |
452 | object State = arg2; | 452 | object State = arg2; |
453 | Variable x1 = new Variable(); | 453 | Variable x1 = new Variable(); |
454 | Variable x2 = new Variable(); | 454 | Variable x2 = new Variable(); |
455 | Variable RestRules = new Variable(); | 455 | Variable RestRules = new Variable(); |
456 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", x1), x2), RestRules))) | 456 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", x1), x2), RestRules))) |
457 | { | 457 | { |
458 | processCompilerDirectives(RestRules, State); | 458 | processCompilerDirectives(RestRules, State); |
459 | return; | 459 | return; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | { | 462 | { |
463 | object State = arg2; | 463 | object State = arg2; |
464 | Variable Head = new Variable(); | 464 | Variable Head = new Variable(); |
465 | Variable _Body = new Variable(); | 465 | Variable _Body = new Variable(); |
466 | Variable x3 = new Variable(); | 466 | Variable x3 = new Variable(); |
467 | Variable RestRules = new Variable(); | 467 | Variable RestRules = new Variable(); |
468 | Variable Name = new Variable(); | 468 | Variable Name = new Variable(); |
469 | Variable Arity = new Variable(); | 469 | Variable Arity = new Variable(); |
470 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor2(@":-", Head, _Body), x3), RestRules))) | 470 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor2(@":-", Head, _Body), x3), RestRules))) |
471 | { | 471 | { |
472 | foreach (bool l3 in YP.functor(Head, Name, Arity)) | 472 | foreach (bool l3 in YP.functor(Head, Name, Arity)) |
473 | { | 473 | { |
474 | CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); | 474 | CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); |
475 | processCompilerDirectives(RestRules, State); | 475 | processCompilerDirectives(RestRules, State); |
476 | return; | 476 | return; |
477 | } | 477 | } |
478 | } | 478 | } |
479 | } | 479 | } |
480 | { | 480 | { |
481 | object State = arg2; | 481 | object State = arg2; |
482 | Variable Fact = new Variable(); | 482 | Variable Fact = new Variable(); |
483 | Variable x2 = new Variable(); | 483 | Variable x2 = new Variable(); |
484 | Variable RestRules = new Variable(); | 484 | Variable RestRules = new Variable(); |
485 | Variable Name = new Variable(); | 485 | Variable Name = new Variable(); |
486 | Variable Arity = new Variable(); | 486 | Variable Arity = new Variable(); |
487 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", Fact, x2), RestRules))) | 487 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", Fact, x2), RestRules))) |
488 | { | 488 | { |
489 | foreach (bool l3 in YP.functor(Fact, Name, Arity)) | 489 | foreach (bool l3 in YP.functor(Fact, Name, Arity)) |
490 | { | 490 | { |
491 | CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); | 491 | CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@"")); |
492 | processCompilerDirectives(RestRules, State); | 492 | processCompilerDirectives(RestRules, State); |
493 | return; | 493 | return; |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } | 496 | } |
497 | { | 497 | { |
498 | object State = arg2; | 498 | object State = arg2; |
499 | Variable x1 = new Variable(); | 499 | Variable x1 = new Variable(); |
500 | Variable RestRules = new Variable(); | 500 | Variable RestRules = new Variable(); |
501 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestRules))) | 501 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestRules))) |
502 | { | 502 | { |
503 | processCompilerDirectives(RestRules, State); | 503 | processCompilerDirectives(RestRules, State); |
504 | return; | 504 | return; |
505 | } | 505 | } |
506 | } | 506 | } |
507 | } | 507 | } |
508 | 508 | ||
509 | public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3) | 509 | public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3) |
510 | { | 510 | { |
511 | { | 511 | { |
512 | object _State = arg1; | 512 | object _State = arg1; |
513 | object _Module = arg2; | 513 | object _Module = arg2; |
514 | foreach (bool l2 in YP.unify(arg3, Atom.NIL)) | 514 | foreach (bool l2 in YP.unify(arg3, Atom.NIL)) |
515 | { | 515 | { |
516 | yield return true; | 516 | yield return true; |
517 | yield break; | 517 | yield break; |
518 | } | 518 | } |
519 | } | 519 | } |
520 | { | 520 | { |
521 | object State = arg1; | 521 | object State = arg1; |
522 | object Module = arg2; | 522 | object Module = arg2; |
523 | Variable Name = new Variable(); | 523 | Variable Name = new Variable(); |
524 | Variable Arity = new Variable(); | 524 | Variable Arity = new Variable(); |
525 | Variable Rest = new Variable(); | 525 | Variable Rest = new Variable(); |
526 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"/", Name, Arity), Rest))) | 526 | foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"/", Name, Arity), Rest))) |
527 | { | 527 | { |
528 | CompilerState.assertModuleForNameArity(State, Name, Arity, Module); | 528 | CompilerState.assertModuleForNameArity(State, Name, Arity, Module); |
529 | foreach (bool l3 in importPredicateList(State, Module, Rest)) | 529 | foreach (bool l3 in importPredicateList(State, Module, Rest)) |
530 | { | 530 | { |
531 | yield return true; | 531 | yield return true; |
532 | yield break; | 532 | yield break; |
533 | } | 533 | } |
534 | } | 534 | } |
535 | } | 535 | } |
536 | { | 536 | { |
537 | object State = arg1; | 537 | object State = arg1; |
538 | object Module = arg2; | 538 | object Module = arg2; |
539 | Variable x3 = new Variable(); | 539 | Variable x3 = new Variable(); |
540 | Variable Rest = new Variable(); | 540 | Variable Rest = new Variable(); |
541 | foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest))) | 541 | foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest))) |
542 | { | 542 | { |
543 | foreach (bool l3 in importPredicateList(State, Module, Rest)) | 543 | foreach (bool l3 in importPredicateList(State, Module, Rest)) |
544 | { | 544 | { |
545 | yield return true; | 545 | yield return true; |
546 | yield break; | 546 | yield break; |
547 | } | 547 | } |
548 | } | 548 | } |
549 | } | 549 | } |
550 | } | 550 | } |
551 | 551 | ||
552 | public static IEnumerable<bool> makeFunctionPseudoCode3(object RuleList, object State, object FunctionCode) | 552 | public static IEnumerable<bool> makeFunctionPseudoCode3(object RuleList, object State, object FunctionCode) |
553 | { | 553 | { |
554 | { | 554 | { |
555 | Variable SamePredicateRuleList = new Variable(); | 555 | Variable SamePredicateRuleList = new Variable(); |
556 | Variable RestRules = new Variable(); | 556 | Variable RestRules = new Variable(); |
557 | foreach (bool l2 in samePredicateRuleList(RuleList, SamePredicateRuleList, RestRules)) | 557 | foreach (bool l2 in samePredicateRuleList(RuleList, SamePredicateRuleList, RestRules)) |
558 | { | 558 | { |
559 | if (YP.termNotEqual(SamePredicateRuleList, Atom.NIL)) | 559 | if (YP.termNotEqual(SamePredicateRuleList, Atom.NIL)) |
560 | { | 560 | { |
561 | foreach (bool l4 in compileSamePredicateFunction(SamePredicateRuleList, State, FunctionCode)) | 561 | foreach (bool l4 in compileSamePredicateFunction(SamePredicateRuleList, State, FunctionCode)) |
562 | { | 562 | { |
563 | yield return false; | 563 | yield return false; |
564 | } | 564 | } |
565 | foreach (bool l4 in makeFunctionPseudoCode3(RestRules, State, FunctionCode)) | 565 | foreach (bool l4 in makeFunctionPseudoCode3(RestRules, State, FunctionCode)) |
566 | { | 566 | { |
567 | yield return false; | 567 | yield return false; |
568 | } | 568 | } |
569 | } | 569 | } |
570 | } | 570 | } |
571 | } | 571 | } |
572 | } | 572 | } |
573 | 573 | ||
574 | public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode) | 574 | public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode) |
575 | { | 575 | { |
576 | { | 576 | { |
577 | Variable FirstRule = new Variable(); | 577 | Variable FirstRule = new Variable(); |
578 | Variable x5 = new Variable(); | 578 | Variable x5 = new Variable(); |
579 | Variable x6 = new Variable(); | 579 | Variable x6 = new Variable(); |
580 | Variable x7 = new Variable(); | 580 | Variable x7 = new Variable(); |
581 | Variable Head = new Variable(); | 581 | Variable Head = new Variable(); |
582 | Variable x9 = new Variable(); | 582 | Variable x9 = new Variable(); |
583 | Variable ArgAssignments = new Variable(); | 583 | Variable ArgAssignments = new Variable(); |
584 | Variable Calls = new Variable(); | 584 | Variable Calls = new Variable(); |
585 | Variable Rule = new Variable(); | 585 | Variable Rule = new Variable(); |
586 | Variable VariableNameSuggestions = new Variable(); | 586 | Variable VariableNameSuggestions = new Variable(); |
587 | Variable ClauseBag = new Variable(); | 587 | Variable ClauseBag = new Variable(); |
588 | Variable Name = new Variable(); | 588 | Variable Name = new Variable(); |
589 | Variable ArgsList = new Variable(); | 589 | Variable ArgsList = new Variable(); |
590 | Variable FunctionArgNames = new Variable(); | 590 | Variable FunctionArgNames = new Variable(); |
591 | Variable MergedArgName = new Variable(); | 591 | Variable MergedArgName = new Variable(); |
592 | Variable ArgName = new Variable(); | 592 | Variable ArgName = new Variable(); |
593 | Variable MergedArgNames = new Variable(); | 593 | Variable MergedArgNames = new Variable(); |
594 | Variable FunctionArgs = new Variable(); | 594 | Variable FunctionArgs = new Variable(); |
595 | Variable BodyCode = new Variable(); | 595 | Variable BodyCode = new Variable(); |
596 | Variable ReturnType = new Variable(); | 596 | Variable ReturnType = new Variable(); |
597 | Variable BodyWithReturn = new Variable(); | 597 | Variable BodyWithReturn = new Variable(); |
598 | foreach (bool l2 in YP.unify(new ListPair(new Functor2(@"f", FirstRule, x5), x6), SamePredicateRuleList)) | 598 | foreach (bool l2 in YP.unify(new ListPair(new Functor2(@"f", FirstRule, x5), x6), SamePredicateRuleList)) |
599 | { | 599 | { |
600 | foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7))) | 600 | foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7))) |
601 | { | 601 | { |
602 | goto cutIf1; | 602 | goto cutIf1; |
603 | } | 603 | } |
604 | foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule)) | 604 | foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule)) |
605 | { | 605 | { |
606 | CompilerState.startFunction(State, Head); | 606 | CompilerState.startFunction(State, Head); |
607 | FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); | 607 | FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); |
608 | foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) | 608 | foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) |
609 | { | 609 | { |
610 | foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) | 610 | foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) |
611 | { | 611 | { |
612 | findallAnswers3.add(); | 612 | findallAnswers3.add(); |
613 | } | 613 | } |
614 | } | 614 | } |
615 | foreach (bool l4 in findallAnswers3.result(ClauseBag)) | 615 | foreach (bool l4 in findallAnswers3.result(ClauseBag)) |
616 | { | 616 | { |
617 | foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList))) | 617 | foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList))) |
618 | { | 618 | { |
619 | foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames)) | 619 | foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames)) |
620 | { | 620 | { |
621 | FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName); | 621 | FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName); |
622 | foreach (bool l7 in member(ArgName, FunctionArgNames)) | 622 | foreach (bool l7 in member(ArgName, FunctionArgNames)) |
623 | { | 623 | { |
624 | foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName)) | 624 | foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName)) |
625 | { | 625 | { |
626 | findallAnswers4.add(); | 626 | findallAnswers4.add(); |
627 | goto cutIf5; | 627 | goto cutIf5; |
628 | } | 628 | } |
629 | foreach (bool l8 in YP.unify(MergedArgName, ArgName)) | 629 | foreach (bool l8 in YP.unify(MergedArgName, ArgName)) |
630 | { | 630 | { |
631 | findallAnswers4.add(); | 631 | findallAnswers4.add(); |
632 | } | 632 | } |
633 | cutIf5: | 633 | cutIf5: |
634 | { } | 634 | { } |
635 | } | 635 | } |
636 | foreach (bool l7 in findallAnswers4.result(MergedArgNames)) | 636 | foreach (bool l7 in findallAnswers4.result(MergedArgNames)) |
637 | { | 637 | { |
638 | foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs)) | 638 | foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs)) |
639 | { | 639 | { |
640 | foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) | 640 | foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) |
641 | { | 641 | { |
642 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) | 642 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
643 | { | 643 | { |
644 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) | 644 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) |
645 | { | 645 | { |
646 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 646 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
647 | { | 647 | { |
648 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) | 648 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) |
649 | { | 649 | { |
650 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 650 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
651 | { | 651 | { |
652 | yield return false; | 652 | yield return false; |
653 | } | 653 | } |
654 | } | 654 | } |
655 | goto cutIf7; | 655 | goto cutIf7; |
656 | } | 656 | } |
657 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 657 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) |
658 | { | 658 | { |
659 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 659 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
660 | { | 660 | { |
661 | yield return false; | 661 | yield return false; |
662 | } | 662 | } |
663 | } | 663 | } |
664 | cutIf7: | 664 | cutIf7: |
665 | { } | 665 | { } |
666 | } | 666 | } |
667 | goto cutIf6; | 667 | goto cutIf6; |
668 | } | 668 | } |
669 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 669 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
670 | { | 670 | { |
671 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) | 671 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) |
672 | { | 672 | { |
673 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 673 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
674 | { | 674 | { |
675 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) | 675 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) |
676 | { | 676 | { |
677 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 677 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
678 | { | 678 | { |
679 | yield return false; | 679 | yield return false; |
680 | } | 680 | } |
681 | } | 681 | } |
682 | goto cutIf9; | 682 | goto cutIf9; |
683 | } | 683 | } |
684 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 684 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) |
685 | { | 685 | { |
686 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 686 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
687 | { | 687 | { |
688 | yield return false; | 688 | yield return false; |
689 | } | 689 | } |
690 | } | 690 | } |
691 | cutIf9: | 691 | cutIf9: |
692 | { } | 692 | { } |
693 | } | 693 | } |
694 | goto cutIf8; | 694 | goto cutIf8; |
695 | } | 695 | } |
696 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) | 696 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) |
697 | { | 697 | { |
698 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 698 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
699 | { | 699 | { |
700 | foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) | 700 | foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) |
701 | { | 701 | { |
702 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 702 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
703 | { | 703 | { |
704 | yield return false; | 704 | yield return false; |
705 | } | 705 | } |
706 | } | 706 | } |
707 | goto cutIf10; | 707 | goto cutIf10; |
708 | } | 708 | } |
709 | foreach (bool l11 in YP.unify(BodyWithReturn, BodyCode)) | 709 | foreach (bool l11 in YP.unify(BodyWithReturn, BodyCode)) |
710 | { | 710 | { |
711 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 711 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
712 | { | 712 | { |
713 | yield return false; | 713 | yield return false; |
714 | } | 714 | } |
715 | } | 715 | } |
716 | cutIf10: | 716 | cutIf10: |
717 | { } | 717 | { } |
718 | } | 718 | } |
719 | cutIf8: | 719 | cutIf8: |
720 | cutIf6: | 720 | cutIf6: |
721 | { } | 721 | { } |
722 | } | 722 | } |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | } | 727 | } |
728 | goto cutIf2; | 728 | goto cutIf2; |
729 | } | 729 | } |
730 | foreach (bool l3 in YP.unify(Head, FirstRule)) | 730 | foreach (bool l3 in YP.unify(Head, FirstRule)) |
731 | { | 731 | { |
732 | CompilerState.startFunction(State, Head); | 732 | CompilerState.startFunction(State, Head); |
733 | FindallAnswers findallAnswers11 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); | 733 | FindallAnswers findallAnswers11 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls)); |
734 | foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) | 734 | foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList)) |
735 | { | 735 | { |
736 | foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) | 736 | foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls)) |
737 | { | 737 | { |
738 | findallAnswers11.add(); | 738 | findallAnswers11.add(); |
739 | } | 739 | } |
740 | } | 740 | } |
741 | foreach (bool l4 in findallAnswers11.result(ClauseBag)) | 741 | foreach (bool l4 in findallAnswers11.result(ClauseBag)) |
742 | { | 742 | { |
743 | foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList))) | 743 | foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList))) |
744 | { | 744 | { |
745 | foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames)) | 745 | foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames)) |
746 | { | 746 | { |
747 | FindallAnswers findallAnswers12 = new FindallAnswers(MergedArgName); | 747 | FindallAnswers findallAnswers12 = new FindallAnswers(MergedArgName); |
748 | foreach (bool l7 in member(ArgName, FunctionArgNames)) | 748 | foreach (bool l7 in member(ArgName, FunctionArgNames)) |
749 | { | 749 | { |
750 | foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName)) | 750 | foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName)) |
751 | { | 751 | { |
752 | findallAnswers12.add(); | 752 | findallAnswers12.add(); |
753 | goto cutIf13; | 753 | goto cutIf13; |
754 | } | 754 | } |
755 | foreach (bool l8 in YP.unify(MergedArgName, ArgName)) | 755 | foreach (bool l8 in YP.unify(MergedArgName, ArgName)) |
756 | { | 756 | { |
757 | findallAnswers12.add(); | 757 | findallAnswers12.add(); |
758 | } | 758 | } |
759 | cutIf13: | 759 | cutIf13: |
760 | { } | 760 | { } |
761 | } | 761 | } |
762 | foreach (bool l7 in findallAnswers12.result(MergedArgNames)) | 762 | foreach (bool l7 in findallAnswers12.result(MergedArgNames)) |
763 | { | 763 | { |
764 | foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs)) | 764 | foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs)) |
765 | { | 765 | { |
766 | foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) | 766 | foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode)) |
767 | { | 767 | { |
768 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) | 768 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
769 | { | 769 | { |
770 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) | 770 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void"))) |
771 | { | 771 | { |
772 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 772 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
773 | { | 773 | { |
774 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) | 774 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) |
775 | { | 775 | { |
776 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 776 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
777 | { | 777 | { |
778 | yield return false; | 778 | yield return false; |
779 | } | 779 | } |
780 | } | 780 | } |
781 | goto cutIf15; | 781 | goto cutIf15; |
782 | } | 782 | } |
783 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 783 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) |
784 | { | 784 | { |
785 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 785 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
786 | { | 786 | { |
787 | yield return false; | 787 | yield return false; |
788 | } | 788 | } |
789 | } | 789 | } |
790 | cutIf15: | 790 | cutIf15: |
791 | { } | 791 | { } |
792 | } | 792 | } |
793 | goto cutIf14; | 793 | goto cutIf14; |
794 | } | 794 | } |
795 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 795 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
796 | { | 796 | { |
797 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) | 797 | foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool"))) |
798 | { | 798 | { |
799 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 799 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
800 | { | 800 | { |
801 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) | 801 | foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) |
802 | { | 802 | { |
803 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 803 | foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
804 | { | 804 | { |
805 | yield return false; | 805 | yield return false; |
806 | } | 806 | } |
807 | } | 807 | } |
808 | goto cutIf17; | 808 | goto cutIf17; |
809 | } | 809 | } |
810 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) | 810 | foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode)) |
811 | { | 811 | { |
812 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 812 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
813 | { | 813 | { |
814 | yield return false; | 814 | yield return false; |
815 | } | 815 | } |
816 | } | 816 | } |
817 | cutIf17: | 817 | cutIf17: |
818 | { } | 818 | { } |
819 | } | 819 | } |
820 | goto cutIf16; | 820 | goto cutIf16; |
821 | } | 821 | } |
822 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) | 822 | foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>"))) |
823 | { | 823 | { |
824 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 824 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
825 | { | 825 | { |
826 | foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) | 826 | foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn)) |
827 | { | 827 | { |
828 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 828 | foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
829 | { | 829 | { |
830 | yield return false; | 830 | yield return false; |
831 | } | 831 | } |
832 | } | 832 | } |
833 | goto cutIf18; | 833 | goto cutIf18; |
834 | } | 834 | } |
835 | foreach (bool l11 in YP.unify(BodyWithReturn, BodyCode)) | 835 | foreach (bool l11 in YP.unify(BodyWithReturn, BodyCode)) |
836 | { | 836 | { |
837 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) | 837 | foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn }))) |
838 | { | 838 | { |
839 | yield return false; | 839 | yield return false; |
840 | } | 840 | } |
841 | } | 841 | } |
842 | cutIf18: | 842 | cutIf18: |
843 | { } | 843 | { } |
844 | } | 844 | } |
845 | cutIf16: | 845 | cutIf16: |
846 | cutIf14: | 846 | cutIf14: |
847 | { } | 847 | { } |
848 | } | 848 | } |
849 | } | 849 | } |
850 | } | 850 | } |
851 | } | 851 | } |
852 | } | 852 | } |
853 | } | 853 | } |
854 | } | 854 | } |
855 | cutIf2: | 855 | cutIf2: |
856 | cutIf1: | 856 | cutIf1: |
857 | { } | 857 | { } |
858 | } | 858 | } |
859 | } | 859 | } |
860 | } | 860 | } |
861 | 861 | ||
862 | public static IEnumerable<bool> samePredicateRuleList(object arg1, object arg2, object arg3) | 862 | public static IEnumerable<bool> samePredicateRuleList(object arg1, object arg2, object arg3) |
863 | { | 863 | { |
864 | { | 864 | { |
865 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 865 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
866 | { | 866 | { |
867 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) | 867 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) |
868 | { | 868 | { |
869 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) | 869 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) |
870 | { | 870 | { |
871 | yield return true; | 871 | yield return true; |
872 | yield break; | 872 | yield break; |
873 | } | 873 | } |
874 | } | 874 | } |
875 | } | 875 | } |
876 | } | 876 | } |
877 | { | 877 | { |
878 | Variable First = new Variable(); | 878 | Variable First = new Variable(); |
879 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Atom.NIL))) | 879 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Atom.NIL))) |
880 | { | 880 | { |
881 | foreach (bool l3 in YP.unify(arg2, new ListPair(First, Atom.NIL))) | 881 | foreach (bool l3 in YP.unify(arg2, new ListPair(First, Atom.NIL))) |
882 | { | 882 | { |
883 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) | 883 | foreach (bool l4 in YP.unify(arg3, Atom.NIL)) |
884 | { | 884 | { |
885 | yield return true; | 885 | yield return true; |
886 | yield break; | 886 | yield break; |
887 | } | 887 | } |
888 | } | 888 | } |
889 | } | 889 | } |
890 | } | 890 | } |
891 | { | 891 | { |
892 | object SamePredicateRuleList = arg2; | 892 | object SamePredicateRuleList = arg2; |
893 | object RestRules = arg3; | 893 | object RestRules = arg3; |
894 | Variable First = new Variable(); | 894 | Variable First = new Variable(); |
895 | Variable Rest = new Variable(); | 895 | Variable Rest = new Variable(); |
896 | Variable FirstRule = new Variable(); | 896 | Variable FirstRule = new Variable(); |
897 | Variable x6 = new Variable(); | 897 | Variable x6 = new Variable(); |
898 | Variable SecondRule = new Variable(); | 898 | Variable SecondRule = new Variable(); |
899 | Variable x8 = new Variable(); | 899 | Variable x8 = new Variable(); |
900 | Variable x9 = new Variable(); | 900 | Variable x9 = new Variable(); |
901 | Variable FirstHead = new Variable(); | 901 | Variable FirstHead = new Variable(); |
902 | Variable x11 = new Variable(); | 902 | Variable x11 = new Variable(); |
903 | Variable SecondHead = new Variable(); | 903 | Variable SecondHead = new Variable(); |
904 | Variable x13 = new Variable(); | 904 | Variable x13 = new Variable(); |
905 | Variable Name = new Variable(); | 905 | Variable Name = new Variable(); |
906 | Variable Arity = new Variable(); | 906 | Variable Arity = new Variable(); |
907 | Variable RestSamePredicates = new Variable(); | 907 | Variable RestSamePredicates = new Variable(); |
908 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) | 908 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) |
909 | { | 909 | { |
910 | foreach (bool l3 in YP.unify(new Functor2(@"f", FirstRule, x6), First)) | 910 | foreach (bool l3 in YP.unify(new Functor2(@"f", FirstRule, x6), First)) |
911 | { | 911 | { |
912 | foreach (bool l4 in YP.unify(new ListPair(new Functor2(@"f", SecondRule, x8), x9), Rest)) | 912 | foreach (bool l4 in YP.unify(new ListPair(new Functor2(@"f", SecondRule, x8), x9), Rest)) |
913 | { | 913 | { |
914 | foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule)) | 914 | foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule)) |
915 | { | 915 | { |
916 | foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) | 916 | foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) |
917 | { | 917 | { |
918 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) | 918 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) |
919 | { | 919 | { |
920 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) | 920 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) |
921 | { | 921 | { |
922 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) | 922 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) |
923 | { | 923 | { |
924 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) | 924 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) |
925 | { | 925 | { |
926 | yield return true; | 926 | yield return true; |
927 | yield break; | 927 | yield break; |
928 | } | 928 | } |
929 | } | 929 | } |
930 | goto cutIf3; | 930 | goto cutIf3; |
931 | } | 931 | } |
932 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) | 932 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) |
933 | { | 933 | { |
934 | foreach (bool l9 in YP.unify(RestRules, Rest)) | 934 | foreach (bool l9 in YP.unify(RestRules, Rest)) |
935 | { | 935 | { |
936 | yield return true; | 936 | yield return true; |
937 | yield break; | 937 | yield break; |
938 | } | 938 | } |
939 | } | 939 | } |
940 | cutIf3: | 940 | cutIf3: |
941 | { } | 941 | { } |
942 | } | 942 | } |
943 | goto cutIf2; | 943 | goto cutIf2; |
944 | } | 944 | } |
945 | foreach (bool l6 in YP.unify(SecondHead, SecondRule)) | 945 | foreach (bool l6 in YP.unify(SecondHead, SecondRule)) |
946 | { | 946 | { |
947 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) | 947 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) |
948 | { | 948 | { |
949 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) | 949 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) |
950 | { | 950 | { |
951 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) | 951 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) |
952 | { | 952 | { |
953 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) | 953 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) |
954 | { | 954 | { |
955 | yield return true; | 955 | yield return true; |
956 | yield break; | 956 | yield break; |
957 | } | 957 | } |
958 | } | 958 | } |
959 | goto cutIf4; | 959 | goto cutIf4; |
960 | } | 960 | } |
961 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) | 961 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) |
962 | { | 962 | { |
963 | foreach (bool l9 in YP.unify(RestRules, Rest)) | 963 | foreach (bool l9 in YP.unify(RestRules, Rest)) |
964 | { | 964 | { |
965 | yield return true; | 965 | yield return true; |
966 | yield break; | 966 | yield break; |
967 | } | 967 | } |
968 | } | 968 | } |
969 | cutIf4: | 969 | cutIf4: |
970 | { } | 970 | { } |
971 | } | 971 | } |
972 | } | 972 | } |
973 | cutIf2: | 973 | cutIf2: |
974 | goto cutIf1; | 974 | goto cutIf1; |
975 | } | 975 | } |
976 | foreach (bool l5 in YP.unify(FirstHead, FirstRule)) | 976 | foreach (bool l5 in YP.unify(FirstHead, FirstRule)) |
977 | { | 977 | { |
978 | foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) | 978 | foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule)) |
979 | { | 979 | { |
980 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) | 980 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) |
981 | { | 981 | { |
982 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) | 982 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) |
983 | { | 983 | { |
984 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) | 984 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) |
985 | { | 985 | { |
986 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) | 986 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) |
987 | { | 987 | { |
988 | yield return true; | 988 | yield return true; |
989 | yield break; | 989 | yield break; |
990 | } | 990 | } |
991 | } | 991 | } |
992 | goto cutIf6; | 992 | goto cutIf6; |
993 | } | 993 | } |
994 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) | 994 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) |
995 | { | 995 | { |
996 | foreach (bool l9 in YP.unify(RestRules, Rest)) | 996 | foreach (bool l9 in YP.unify(RestRules, Rest)) |
997 | { | 997 | { |
998 | yield return true; | 998 | yield return true; |
999 | yield break; | 999 | yield break; |
1000 | } | 1000 | } |
1001 | } | 1001 | } |
1002 | cutIf6: | 1002 | cutIf6: |
1003 | { } | 1003 | { } |
1004 | } | 1004 | } |
1005 | goto cutIf5; | 1005 | goto cutIf5; |
1006 | } | 1006 | } |
1007 | foreach (bool l6 in YP.unify(SecondHead, SecondRule)) | 1007 | foreach (bool l6 in YP.unify(SecondHead, SecondRule)) |
1008 | { | 1008 | { |
1009 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) | 1009 | foreach (bool l7 in YP.functor(FirstHead, Name, Arity)) |
1010 | { | 1010 | { |
1011 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) | 1011 | foreach (bool l8 in YP.functor(SecondHead, Name, Arity)) |
1012 | { | 1012 | { |
1013 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) | 1013 | foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules)) |
1014 | { | 1014 | { |
1015 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) | 1015 | foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates))) |
1016 | { | 1016 | { |
1017 | yield return true; | 1017 | yield return true; |
1018 | yield break; | 1018 | yield break; |
1019 | } | 1019 | } |
1020 | } | 1020 | } |
1021 | goto cutIf7; | 1021 | goto cutIf7; |
1022 | } | 1022 | } |
1023 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) | 1023 | foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL))) |
1024 | { | 1024 | { |
1025 | foreach (bool l9 in YP.unify(RestRules, Rest)) | 1025 | foreach (bool l9 in YP.unify(RestRules, Rest)) |
1026 | { | 1026 | { |
1027 | yield return true; | 1027 | yield return true; |
1028 | yield break; | 1028 | yield break; |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | cutIf7: | 1031 | cutIf7: |
1032 | { } | 1032 | { } |
1033 | } | 1033 | } |
1034 | } | 1034 | } |
1035 | cutIf5: | 1035 | cutIf5: |
1036 | { } | 1036 | { } |
1037 | } | 1037 | } |
1038 | cutIf1: | 1038 | cutIf1: |
1039 | { } | 1039 | { } |
1040 | } | 1040 | } |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | public static IEnumerable<bool> maplist_compileClause(object arg1, object arg2, object arg3) | 1046 | public static IEnumerable<bool> maplist_compileClause(object arg1, object arg2, object arg3) |
1047 | { | 1047 | { |
1048 | { | 1048 | { |
1049 | object _MergedArgNames = arg2; | 1049 | object _MergedArgNames = arg2; |
1050 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1050 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1051 | { | 1051 | { |
1052 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) | 1052 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) |
1053 | { | 1053 | { |
1054 | yield return true; | 1054 | yield return true; |
1055 | yield break; | 1055 | yield break; |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | { | 1059 | { |
1060 | object MergedArgNames = arg2; | 1060 | object MergedArgNames = arg2; |
1061 | Variable ArgAssignments = new Variable(); | 1061 | Variable ArgAssignments = new Variable(); |
1062 | Variable Calls = new Variable(); | 1062 | Variable Calls = new Variable(); |
1063 | Variable Rest = new Variable(); | 1063 | Variable Rest = new Variable(); |
1064 | Variable ClauseCode = new Variable(); | 1064 | Variable ClauseCode = new Variable(); |
1065 | Variable RestResults = new Variable(); | 1065 | Variable RestResults = new Variable(); |
1066 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", ArgAssignments, Calls), Rest))) | 1066 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", ArgAssignments, Calls), Rest))) |
1067 | { | 1067 | { |
1068 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"blockScope", ClauseCode), RestResults))) | 1068 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"blockScope", ClauseCode), RestResults))) |
1069 | { | 1069 | { |
1070 | foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode)) | 1070 | foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode)) |
1071 | { | 1071 | { |
1072 | foreach (bool l5 in maplist_compileClause(Rest, MergedArgNames, RestResults)) | 1072 | foreach (bool l5 in maplist_compileClause(Rest, MergedArgNames, RestResults)) |
1073 | { | 1073 | { |
1074 | yield return true; | 1074 | yield return true; |
1075 | yield break; | 1075 | yield break; |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | public static IEnumerable<bool> prependArgAssignments(object arg1, object arg2, object arg3, object arg4) | 1083 | public static IEnumerable<bool> prependArgAssignments(object arg1, object arg2, object arg3, object arg4) |
1084 | { | 1084 | { |
1085 | { | 1085 | { |
1086 | object _MergedArgNames = arg3; | 1086 | object _MergedArgNames = arg3; |
1087 | Variable In = new Variable(); | 1087 | Variable In = new Variable(); |
1088 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1088 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1089 | { | 1089 | { |
1090 | foreach (bool l3 in YP.unify(arg2, In)) | 1090 | foreach (bool l3 in YP.unify(arg2, In)) |
1091 | { | 1091 | { |
1092 | foreach (bool l4 in YP.unify(arg4, In)) | 1092 | foreach (bool l4 in YP.unify(arg4, In)) |
1093 | { | 1093 | { |
1094 | yield return true; | 1094 | yield return true; |
1095 | yield break; | 1095 | yield break; |
1096 | } | 1096 | } |
1097 | } | 1097 | } |
1098 | } | 1098 | } |
1099 | } | 1099 | } |
1100 | { | 1100 | { |
1101 | object In = arg2; | 1101 | object In = arg2; |
1102 | object MergedArgNames = arg3; | 1102 | object MergedArgNames = arg3; |
1103 | object ClauseCode = arg4; | 1103 | object ClauseCode = arg4; |
1104 | Variable VariableName = new Variable(); | 1104 | Variable VariableName = new Variable(); |
1105 | Variable ArgName = new Variable(); | 1105 | Variable ArgName = new Variable(); |
1106 | Variable RestArgAssignments = new Variable(); | 1106 | Variable RestArgAssignments = new Variable(); |
1107 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", VariableName, ArgName), RestArgAssignments))) | 1107 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", VariableName, ArgName), RestArgAssignments))) |
1108 | { | 1108 | { |
1109 | foreach (bool l3 in member(VariableName, MergedArgNames)) | 1109 | foreach (bool l3 in member(VariableName, MergedArgNames)) |
1110 | { | 1110 | { |
1111 | foreach (bool l4 in prependArgAssignments(RestArgAssignments, In, MergedArgNames, ClauseCode)) | 1111 | foreach (bool l4 in prependArgAssignments(RestArgAssignments, In, MergedArgNames, ClauseCode)) |
1112 | { | 1112 | { |
1113 | yield return true; | 1113 | yield return true; |
1114 | yield break; | 1114 | yield break; |
1115 | } | 1115 | } |
1116 | goto cutIf1; | 1116 | goto cutIf1; |
1117 | } | 1117 | } |
1118 | foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3(@"declare", Atom.a(@"object"), VariableName, new Functor1(@"var", ArgName)), In), MergedArgNames, ClauseCode)) | 1118 | foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3(@"declare", Atom.a(@"object"), VariableName, new Functor1(@"var", ArgName)), In), MergedArgNames, ClauseCode)) |
1119 | { | 1119 | { |
1120 | yield return true; | 1120 | yield return true; |
1121 | yield break; | 1121 | yield break; |
1122 | } | 1122 | } |
1123 | cutIf1: | 1123 | cutIf1: |
1124 | { } | 1124 | { } |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | public static IEnumerable<bool> argAssignedAll(object arg1, object arg2, object VariableName) | 1129 | public static IEnumerable<bool> argAssignedAll(object arg1, object arg2, object VariableName) |
1130 | { | 1130 | { |
1131 | { | 1131 | { |
1132 | object _ArgName = arg1; | 1132 | object _ArgName = arg1; |
1133 | foreach (bool l2 in YP.unify(arg2, Atom.NIL)) | 1133 | foreach (bool l2 in YP.unify(arg2, Atom.NIL)) |
1134 | { | 1134 | { |
1135 | if (YP.nonvar(VariableName)) | 1135 | if (YP.nonvar(VariableName)) |
1136 | { | 1136 | { |
1137 | yield return true; | 1137 | yield return true; |
1138 | yield break; | 1138 | yield break; |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | { | 1142 | { |
1143 | object ArgName = arg1; | 1143 | object ArgName = arg1; |
1144 | Variable ArgAssignments = new Variable(); | 1144 | Variable ArgAssignments = new Variable(); |
1145 | Variable _Calls = new Variable(); | 1145 | Variable _Calls = new Variable(); |
1146 | Variable RestClauseBag = new Variable(); | 1146 | Variable RestClauseBag = new Variable(); |
1147 | foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2(@"f", ArgAssignments, _Calls), RestClauseBag))) | 1147 | foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2(@"f", ArgAssignments, _Calls), RestClauseBag))) |
1148 | { | 1148 | { |
1149 | foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments)) | 1149 | foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments)) |
1150 | { | 1150 | { |
1151 | foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName)) | 1151 | foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName)) |
1152 | { | 1152 | { |
1153 | yield return false; | 1153 | yield return false; |
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | } | 1156 | } |
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | public static IEnumerable<bool> maplist_arg(object arg1, object arg2) | 1160 | public static IEnumerable<bool> maplist_arg(object arg1, object arg2) |
1161 | { | 1161 | { |
1162 | { | 1162 | { |
1163 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1163 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1164 | { | 1164 | { |
1165 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) | 1165 | foreach (bool l3 in YP.unify(arg2, Atom.NIL)) |
1166 | { | 1166 | { |
1167 | yield return true; | 1167 | yield return true; |
1168 | yield break; | 1168 | yield break; |
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | } | 1171 | } |
1172 | { | 1172 | { |
1173 | Variable First = new Variable(); | 1173 | Variable First = new Variable(); |
1174 | Variable Rest = new Variable(); | 1174 | Variable Rest = new Variable(); |
1175 | Variable RestResults = new Variable(); | 1175 | Variable RestResults = new Variable(); |
1176 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) | 1176 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) |
1177 | { | 1177 | { |
1178 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"arg", First), RestResults))) | 1178 | foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"arg", First), RestResults))) |
1179 | { | 1179 | { |
1180 | foreach (bool l4 in maplist_arg(Rest, RestResults)) | 1180 | foreach (bool l4 in maplist_arg(Rest, RestResults)) |
1181 | { | 1181 | { |
1182 | yield return true; | 1182 | yield return true; |
1183 | yield break; | 1183 | yield break; |
1184 | } | 1184 | } |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | public static IEnumerable<bool> getFunctionArgNames(object arg1, object arg2, object arg3) | 1190 | public static IEnumerable<bool> getFunctionArgNames(object arg1, object arg2, object arg3) |
1191 | { | 1191 | { |
1192 | { | 1192 | { |
1193 | object _StartArgNumber = arg2; | 1193 | object _StartArgNumber = arg2; |
1194 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1194 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1195 | { | 1195 | { |
1196 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) | 1196 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) |
1197 | { | 1197 | { |
1198 | yield return true; | 1198 | yield return true; |
1199 | yield break; | 1199 | yield break; |
1200 | } | 1200 | } |
1201 | } | 1201 | } |
1202 | } | 1202 | } |
1203 | { | 1203 | { |
1204 | object StartArgNumber = arg2; | 1204 | object StartArgNumber = arg2; |
1205 | Variable x1 = new Variable(); | 1205 | Variable x1 = new Variable(); |
1206 | Variable Rest = new Variable(); | 1206 | Variable Rest = new Variable(); |
1207 | Variable ArgName = new Variable(); | 1207 | Variable ArgName = new Variable(); |
1208 | Variable RestFunctionArgs = new Variable(); | 1208 | Variable RestFunctionArgs = new Variable(); |
1209 | Variable NumberCodes = new Variable(); | 1209 | Variable NumberCodes = new Variable(); |
1210 | Variable NumberAtom = new Variable(); | 1210 | Variable NumberAtom = new Variable(); |
1211 | Variable NextArgNumber = new Variable(); | 1211 | Variable NextArgNumber = new Variable(); |
1212 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Rest))) | 1212 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Rest))) |
1213 | { | 1213 | { |
1214 | foreach (bool l3 in YP.unify(arg3, new ListPair(ArgName, RestFunctionArgs))) | 1214 | foreach (bool l3 in YP.unify(arg3, new ListPair(ArgName, RestFunctionArgs))) |
1215 | { | 1215 | { |
1216 | foreach (bool l4 in YP.number_codes(StartArgNumber, NumberCodes)) | 1216 | foreach (bool l4 in YP.number_codes(StartArgNumber, NumberCodes)) |
1217 | { | 1217 | { |
1218 | foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) | 1218 | foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) |
1219 | { | 1219 | { |
1220 | foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) | 1220 | foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) |
1221 | { | 1221 | { |
1222 | foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1))) | 1222 | foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1))) |
1223 | { | 1223 | { |
1224 | foreach (bool l8 in getFunctionArgNames(Rest, NextArgNumber, RestFunctionArgs)) | 1224 | foreach (bool l8 in getFunctionArgNames(Rest, NextArgNumber, RestFunctionArgs)) |
1225 | { | 1225 | { |
1226 | yield return true; | 1226 | yield return true; |
1227 | yield break; | 1227 | yield break; |
1228 | } | 1228 | } |
1229 | } | 1229 | } |
1230 | } | 1230 | } |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | } | 1234 | } |
1235 | } | 1235 | } |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | public static IEnumerable<bool> compileBodyWithHeadBindings(object Rule, object VariableNameSuggestions, object State, object ArgAssignments, object Calls) | 1238 | public static IEnumerable<bool> compileBodyWithHeadBindings(object Rule, object VariableNameSuggestions, object State, object ArgAssignments, object Calls) |
1239 | { | 1239 | { |
1240 | { | 1240 | { |
1241 | Variable Head = new Variable(); | 1241 | Variable Head = new Variable(); |
1242 | Variable Body = new Variable(); | 1242 | Variable Body = new Variable(); |
1243 | Variable x8 = new Variable(); | 1243 | Variable x8 = new Variable(); |
1244 | Variable HeadArgs = new Variable(); | 1244 | Variable HeadArgs = new Variable(); |
1245 | Variable CompiledHeadArgs = new Variable(); | 1245 | Variable CompiledHeadArgs = new Variable(); |
1246 | Variable BodyCode = new Variable(); | 1246 | Variable BodyCode = new Variable(); |
1247 | Variable VariableNamesList = new Variable(); | 1247 | Variable VariableNamesList = new Variable(); |
1248 | Variable ArgUnifications = new Variable(); | 1248 | Variable ArgUnifications = new Variable(); |
1249 | foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule)) | 1249 | foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule)) |
1250 | { | 1250 | { |
1251 | CompilerState.newVariableNames(State, Rule, VariableNameSuggestions); | 1251 | CompilerState.newVariableNames(State, Rule, VariableNameSuggestions); |
1252 | foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs))) | 1252 | foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs))) |
1253 | { | 1253 | { |
1254 | foreach (bool l4 in maplist_compileTerm(HeadArgs, State, CompiledHeadArgs)) | 1254 | foreach (bool l4 in maplist_compileTerm(HeadArgs, State, CompiledHeadArgs)) |
1255 | { | 1255 | { |
1256 | foreach (bool l5 in compileRuleBody(Body, State, BodyCode)) | 1256 | foreach (bool l5 in compileRuleBody(Body, State, BodyCode)) |
1257 | { | 1257 | { |
1258 | foreach (bool l6 in CompilerState.variableNamesList(State, VariableNamesList)) | 1258 | foreach (bool l6 in CompilerState.variableNamesList(State, VariableNamesList)) |
1259 | { | 1259 | { |
1260 | foreach (bool l7 in compileArgUnifications(HeadArgs, CompiledHeadArgs, 1, HeadArgs, BodyCode, ArgUnifications)) | 1260 | foreach (bool l7 in compileArgUnifications(HeadArgs, CompiledHeadArgs, 1, HeadArgs, BodyCode, ArgUnifications)) |
1261 | { | 1261 | { |
1262 | foreach (bool l8 in compileDeclarations(VariableNamesList, HeadArgs, Atom.NIL, ArgAssignments, ArgUnifications, Calls)) | 1262 | foreach (bool l8 in compileDeclarations(VariableNamesList, HeadArgs, Atom.NIL, ArgAssignments, ArgUnifications, Calls)) |
1263 | { | 1263 | { |
1264 | yield return true; | 1264 | yield return true; |
1265 | yield break; | 1265 | yield break; |
1266 | } | 1266 | } |
1267 | } | 1267 | } |
1268 | } | 1268 | } |
1269 | } | 1269 | } |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | } | 1273 | } |
1274 | { | 1274 | { |
1275 | foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(@":-", Rule, Atom.a(@"true")), VariableNameSuggestions, State, ArgAssignments, Calls)) | 1275 | foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(@":-", Rule, Atom.a(@"true")), VariableNameSuggestions, State, ArgAssignments, Calls)) |
1276 | { | 1276 | { |
1277 | yield return true; | 1277 | yield return true; |
1278 | yield break; | 1278 | yield break; |
1279 | } | 1279 | } |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | public static IEnumerable<bool> compileArgUnifications(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) | 1283 | public static IEnumerable<bool> compileArgUnifications(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) |
1284 | { | 1284 | { |
1285 | { | 1285 | { |
1286 | object x1 = arg2; | 1286 | object x1 = arg2; |
1287 | object x2 = arg3; | 1287 | object x2 = arg3; |
1288 | object x3 = arg4; | 1288 | object x3 = arg4; |
1289 | Variable BodyCode = new Variable(); | 1289 | Variable BodyCode = new Variable(); |
1290 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1290 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1291 | { | 1291 | { |
1292 | foreach (bool l3 in YP.unify(arg5, BodyCode)) | 1292 | foreach (bool l3 in YP.unify(arg5, BodyCode)) |
1293 | { | 1293 | { |
1294 | foreach (bool l4 in YP.unify(arg6, BodyCode)) | 1294 | foreach (bool l4 in YP.unify(arg6, BodyCode)) |
1295 | { | 1295 | { |
1296 | yield return true; | 1296 | yield return true; |
1297 | yield break; | 1297 | yield break; |
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | } | 1300 | } |
1301 | } | 1301 | } |
1302 | { | 1302 | { |
1303 | object Index = arg3; | 1303 | object Index = arg3; |
1304 | object AllHeadArgs = arg4; | 1304 | object AllHeadArgs = arg4; |
1305 | object BodyCode = arg5; | 1305 | object BodyCode = arg5; |
1306 | object ArgUnifications = arg6; | 1306 | object ArgUnifications = arg6; |
1307 | Variable HeadArg = new Variable(); | 1307 | Variable HeadArg = new Variable(); |
1308 | Variable RestHeadArgs = new Variable(); | 1308 | Variable RestHeadArgs = new Variable(); |
1309 | Variable x3 = new Variable(); | 1309 | Variable x3 = new Variable(); |
1310 | Variable RestCompiledHeadArgs = new Variable(); | 1310 | Variable RestCompiledHeadArgs = new Variable(); |
1311 | Variable _ArgIndex1 = new Variable(); | 1311 | Variable _ArgIndex1 = new Variable(); |
1312 | Variable NextIndex = new Variable(); | 1312 | Variable NextIndex = new Variable(); |
1313 | foreach (bool l2 in YP.unify(arg1, new ListPair(HeadArg, RestHeadArgs))) | 1313 | foreach (bool l2 in YP.unify(arg1, new ListPair(HeadArg, RestHeadArgs))) |
1314 | { | 1314 | { |
1315 | foreach (bool l3 in YP.unify(arg2, new ListPair(x3, RestCompiledHeadArgs))) | 1315 | foreach (bool l3 in YP.unify(arg2, new ListPair(x3, RestCompiledHeadArgs))) |
1316 | { | 1316 | { |
1317 | foreach (bool l4 in getVariableArgIndex1(HeadArg, AllHeadArgs, _ArgIndex1)) | 1317 | foreach (bool l4 in getVariableArgIndex1(HeadArg, AllHeadArgs, _ArgIndex1)) |
1318 | { | 1318 | { |
1319 | foreach (bool l5 in YP.unify(NextIndex, YP.add(Index, 1))) | 1319 | foreach (bool l5 in YP.unify(NextIndex, YP.add(Index, 1))) |
1320 | { | 1320 | { |
1321 | foreach (bool l6 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, ArgUnifications)) | 1321 | foreach (bool l6 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, ArgUnifications)) |
1322 | { | 1322 | { |
1323 | yield return true; | 1323 | yield return true; |
1324 | yield break; | 1324 | yield break; |
1325 | } | 1325 | } |
1326 | } | 1326 | } |
1327 | } | 1327 | } |
1328 | } | 1328 | } |
1329 | } | 1329 | } |
1330 | } | 1330 | } |
1331 | { | 1331 | { |
1332 | object Index = arg3; | 1332 | object Index = arg3; |
1333 | object AllHeadArgs = arg4; | 1333 | object AllHeadArgs = arg4; |
1334 | object BodyCode = arg5; | 1334 | object BodyCode = arg5; |
1335 | Variable _HeadArg = new Variable(); | 1335 | Variable _HeadArg = new Variable(); |
1336 | Variable RestHeadArgs = new Variable(); | 1336 | Variable RestHeadArgs = new Variable(); |
1337 | Variable CompiledHeadArg = new Variable(); | 1337 | Variable CompiledHeadArg = new Variable(); |
1338 | Variable RestCompiledHeadArgs = new Variable(); | 1338 | Variable RestCompiledHeadArgs = new Variable(); |
1339 | Variable ArgName = new Variable(); | 1339 | Variable ArgName = new Variable(); |
1340 | Variable RestArgUnifications = new Variable(); | 1340 | Variable RestArgUnifications = new Variable(); |
1341 | Variable NumberCodes = new Variable(); | 1341 | Variable NumberCodes = new Variable(); |
1342 | Variable NumberAtom = new Variable(); | 1342 | Variable NumberAtom = new Variable(); |
1343 | Variable NextIndex = new Variable(); | 1343 | Variable NextIndex = new Variable(); |
1344 | foreach (bool l2 in YP.unify(arg1, new ListPair(_HeadArg, RestHeadArgs))) | 1344 | foreach (bool l2 in YP.unify(arg1, new ListPair(_HeadArg, RestHeadArgs))) |
1345 | { | 1345 | { |
1346 | foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs))) | 1346 | foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs))) |
1347 | { | 1347 | { |
1348 | foreach (bool l4 in YP.unify(arg6, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(new Functor1(@"var", ArgName), new ListPair(CompiledHeadArg, Atom.NIL))), RestArgUnifications), Atom.NIL))) | 1348 | foreach (bool l4 in YP.unify(arg6, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(new Functor1(@"var", ArgName), new ListPair(CompiledHeadArg, Atom.NIL))), RestArgUnifications), Atom.NIL))) |
1349 | { | 1349 | { |
1350 | foreach (bool l5 in YP.number_codes(Index, NumberCodes)) | 1350 | foreach (bool l5 in YP.number_codes(Index, NumberCodes)) |
1351 | { | 1351 | { |
1352 | foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes)) | 1352 | foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes)) |
1353 | { | 1353 | { |
1354 | foreach (bool l7 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) | 1354 | foreach (bool l7 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) |
1355 | { | 1355 | { |
1356 | foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1))) | 1356 | foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1))) |
1357 | { | 1357 | { |
1358 | foreach (bool l9 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, RestArgUnifications)) | 1358 | foreach (bool l9 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, RestArgUnifications)) |
1359 | { | 1359 | { |
1360 | yield return true; | 1360 | yield return true; |
1361 | yield break; | 1361 | yield break; |
1362 | } | 1362 | } |
1363 | } | 1363 | } |
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | } | 1366 | } |
1367 | } | 1367 | } |
1368 | } | 1368 | } |
1369 | } | 1369 | } |
1370 | } | 1370 | } |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | public static IEnumerable<bool> compileDeclarations(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) | 1373 | public static IEnumerable<bool> compileDeclarations(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) |
1374 | { | 1374 | { |
1375 | { | 1375 | { |
1376 | object _HeadArgs = arg2; | 1376 | object _HeadArgs = arg2; |
1377 | Variable ArgAssignmentsIn = new Variable(); | 1377 | Variable ArgAssignmentsIn = new Variable(); |
1378 | Variable DeclarationsIn = new Variable(); | 1378 | Variable DeclarationsIn = new Variable(); |
1379 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 1379 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
1380 | { | 1380 | { |
1381 | foreach (bool l3 in YP.unify(arg3, ArgAssignmentsIn)) | 1381 | foreach (bool l3 in YP.unify(arg3, ArgAssignmentsIn)) |
1382 | { | 1382 | { |
1383 | foreach (bool l4 in YP.unify(arg4, ArgAssignmentsIn)) | 1383 | foreach (bool l4 in YP.unify(arg4, ArgAssignmentsIn)) |
1384 | { | 1384 | { |
1385 | foreach (bool l5 in YP.unify(arg5, DeclarationsIn)) | 1385 | foreach (bool l5 in YP.unify(arg5, DeclarationsIn)) |
1386 | { | 1386 | { |
1387 | foreach (bool l6 in YP.unify(arg6, DeclarationsIn)) | 1387 | foreach (bool l6 in YP.unify(arg6, DeclarationsIn)) |
1388 | { | 1388 | { |
1389 | yield return true; | 1389 | yield return true; |
1390 | yield break; | 1390 | yield break; |
1391 | } | 1391 | } |
1392 | } | 1392 | } |
1393 | } | 1393 | } |
1394 | } | 1394 | } |
1395 | } | 1395 | } |
1396 | } | 1396 | } |
1397 | { | 1397 | { |
1398 | object HeadArgs = arg2; | 1398 | object HeadArgs = arg2; |
1399 | object ArgAssignmentsIn = arg3; | 1399 | object ArgAssignmentsIn = arg3; |
1400 | object ArgAssignmentsOut = arg4; | 1400 | object ArgAssignmentsOut = arg4; |
1401 | object DeclarationsIn = arg5; | 1401 | object DeclarationsIn = arg5; |
1402 | object DeclarationsOut = arg6; | 1402 | object DeclarationsOut = arg6; |
1403 | Variable VariableName = new Variable(); | 1403 | Variable VariableName = new Variable(); |
1404 | Variable Var = new Variable(); | 1404 | Variable Var = new Variable(); |
1405 | Variable RestVariableNames = new Variable(); | 1405 | Variable RestVariableNames = new Variable(); |
1406 | Variable ArgIndex1 = new Variable(); | 1406 | Variable ArgIndex1 = new Variable(); |
1407 | Variable NumberCodes = new Variable(); | 1407 | Variable NumberCodes = new Variable(); |
1408 | Variable NumberAtom = new Variable(); | 1408 | Variable NumberAtom = new Variable(); |
1409 | Variable ArgName = new Variable(); | 1409 | Variable ArgName = new Variable(); |
1410 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, Var), RestVariableNames))) | 1410 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, Var), RestVariableNames))) |
1411 | { | 1411 | { |
1412 | foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1)) | 1412 | foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1)) |
1413 | { | 1413 | { |
1414 | foreach (bool l4 in YP.number_codes(ArgIndex1, NumberCodes)) | 1414 | foreach (bool l4 in YP.number_codes(ArgIndex1, NumberCodes)) |
1415 | { | 1415 | { |
1416 | foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) | 1416 | foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes)) |
1417 | { | 1417 | { |
1418 | foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) | 1418 | foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName)) |
1419 | { | 1419 | { |
1420 | foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2(@"f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut)) | 1420 | foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2(@"f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut)) |
1421 | { | 1421 | { |
1422 | yield return true; | 1422 | yield return true; |
1423 | yield break; | 1423 | yield break; |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | } | 1428 | } |
1429 | } | 1429 | } |
1430 | } | 1430 | } |
1431 | { | 1431 | { |
1432 | object HeadArgs = arg2; | 1432 | object HeadArgs = arg2; |
1433 | object ArgAssignmentsIn = arg3; | 1433 | object ArgAssignmentsIn = arg3; |
1434 | object ArgAssignmentsOut = arg4; | 1434 | object ArgAssignmentsOut = arg4; |
1435 | object DeclarationsIn = arg5; | 1435 | object DeclarationsIn = arg5; |
1436 | Variable VariableName = new Variable(); | 1436 | Variable VariableName = new Variable(); |
1437 | Variable _Var = new Variable(); | 1437 | Variable _Var = new Variable(); |
1438 | Variable RestVariableNames = new Variable(); | 1438 | Variable RestVariableNames = new Variable(); |
1439 | Variable DeclarationsOut = new Variable(); | 1439 | Variable DeclarationsOut = new Variable(); |
1440 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, _Var), RestVariableNames))) | 1440 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, _Var), RestVariableNames))) |
1441 | { | 1441 | { |
1442 | foreach (bool l3 in YP.unify(arg6, new ListPair(new Functor3(@"declare", Atom.a(@"Variable"), VariableName, new Functor2(@"new", Atom.a(@"Variable"), Atom.NIL)), DeclarationsOut))) | 1442 | foreach (bool l3 in YP.unify(arg6, new ListPair(new Functor3(@"declare", Atom.a(@"Variable"), VariableName, new Functor2(@"new", Atom.a(@"Variable"), Atom.NIL)), DeclarationsOut))) |
1443 | { | 1443 | { |
1444 | foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut)) | 1444 | foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut)) |
1445 | { | 1445 | { |
1446 | yield return true; | 1446 | yield return true; |
1447 | yield break; | 1447 | yield break; |
1448 | } | 1448 | } |
1449 | } | 1449 | } |
1450 | } | 1450 | } |
1451 | } | 1451 | } |
1452 | } | 1452 | } |
1453 | 1453 | ||
1454 | public static IEnumerable<bool> getVariableArgIndex1(object Var, object arg2, object arg3) | 1454 | public static IEnumerable<bool> getVariableArgIndex1(object Var, object arg2, object arg3) |
1455 | { | 1455 | { |
1456 | { | 1456 | { |
1457 | Variable FirstHeadArgs = new Variable(); | 1457 | Variable FirstHeadArgs = new Variable(); |
1458 | Variable RestHeadArgs = new Variable(); | 1458 | Variable RestHeadArgs = new Variable(); |
1459 | Variable x4 = new Variable(); | 1459 | Variable x4 = new Variable(); |
1460 | foreach (bool l2 in YP.unify(arg2, new ListPair(FirstHeadArgs, RestHeadArgs))) | 1460 | foreach (bool l2 in YP.unify(arg2, new ListPair(FirstHeadArgs, RestHeadArgs))) |
1461 | { | 1461 | { |
1462 | foreach (bool l3 in YP.unify(arg3, 1)) | 1462 | foreach (bool l3 in YP.unify(arg3, 1)) |
1463 | { | 1463 | { |
1464 | if (sameVariable(Var, FirstHeadArgs)) | 1464 | if (sameVariable(Var, FirstHeadArgs)) |
1465 | { | 1465 | { |
1466 | foreach (bool l5 in getVariableArgIndex1(Var, RestHeadArgs, x4)) | 1466 | foreach (bool l5 in getVariableArgIndex1(Var, RestHeadArgs, x4)) |
1467 | { | 1467 | { |
1468 | goto cutIf1; | 1468 | goto cutIf1; |
1469 | } | 1469 | } |
1470 | yield return false; | 1470 | yield return false; |
1471 | cutIf1: | 1471 | cutIf1: |
1472 | yield break; | 1472 | yield break; |
1473 | } | 1473 | } |
1474 | } | 1474 | } |
1475 | } | 1475 | } |
1476 | } | 1476 | } |
1477 | { | 1477 | { |
1478 | object Index = arg3; | 1478 | object Index = arg3; |
1479 | Variable x2 = new Variable(); | 1479 | Variable x2 = new Variable(); |
1480 | Variable RestHeadArgs = new Variable(); | 1480 | Variable RestHeadArgs = new Variable(); |
1481 | Variable RestIndex = new Variable(); | 1481 | Variable RestIndex = new Variable(); |
1482 | foreach (bool l2 in YP.unify(arg2, new ListPair(x2, RestHeadArgs))) | 1482 | foreach (bool l2 in YP.unify(arg2, new ListPair(x2, RestHeadArgs))) |
1483 | { | 1483 | { |
1484 | foreach (bool l3 in getVariableArgIndex1(Var, RestHeadArgs, RestIndex)) | 1484 | foreach (bool l3 in getVariableArgIndex1(Var, RestHeadArgs, RestIndex)) |
1485 | { | 1485 | { |
1486 | foreach (bool l4 in YP.unify(Index, YP.add(1, RestIndex))) | 1486 | foreach (bool l4 in YP.unify(Index, YP.add(1, RestIndex))) |
1487 | { | 1487 | { |
1488 | yield return true; | 1488 | yield return true; |
1489 | yield break; | 1489 | yield break; |
1490 | } | 1490 | } |
1491 | } | 1491 | } |
1492 | } | 1492 | } |
1493 | } | 1493 | } |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | public static IEnumerable<bool> compileRuleBody(object arg1, object arg2, object arg3) | 1496 | public static IEnumerable<bool> compileRuleBody(object arg1, object arg2, object arg3) |
1497 | { | 1497 | { |
1498 | { | 1498 | { |
1499 | object A = arg1; | 1499 | object A = arg1; |
1500 | object State = arg2; | 1500 | object State = arg2; |
1501 | object PseudoCode = arg3; | 1501 | object PseudoCode = arg3; |
1502 | if (YP.var(A)) | 1502 | if (YP.var(A)) |
1503 | { | 1503 | { |
1504 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), Atom.a(@"true")), State, PseudoCode)) | 1504 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), Atom.a(@"true")), State, PseudoCode)) |
1505 | { | 1505 | { |
1506 | yield return true; | 1506 | yield return true; |
1507 | yield break; | 1507 | yield break; |
1508 | } | 1508 | } |
1509 | } | 1509 | } |
1510 | } | 1510 | } |
1511 | { | 1511 | { |
1512 | object State = arg2; | 1512 | object State = arg2; |
1513 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) | 1513 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) |
1514 | { | 1514 | { |
1515 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) | 1515 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) |
1516 | { | 1516 | { |
1517 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) | 1517 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
1518 | { | 1518 | { |
1519 | yield return true; | 1519 | yield return true; |
1520 | yield break; | 1520 | yield break; |
1521 | } | 1521 | } |
1522 | } | 1522 | } |
1523 | } | 1523 | } |
1524 | } | 1524 | } |
1525 | { | 1525 | { |
1526 | object State = arg2; | 1526 | object State = arg2; |
1527 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) | 1527 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) |
1528 | { | 1528 | { |
1529 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL))) | 1529 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL))) |
1530 | { | 1530 | { |
1531 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 1531 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
1532 | { | 1532 | { |
1533 | yield return true; | 1533 | yield return true; |
1534 | yield break; | 1534 | yield break; |
1535 | } | 1535 | } |
1536 | } | 1536 | } |
1537 | } | 1537 | } |
1538 | } | 1538 | } |
1539 | { | 1539 | { |
1540 | object _State = arg2; | 1540 | object _State = arg2; |
1541 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) | 1541 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"!"))) |
1542 | { | 1542 | { |
1543 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL)))) | 1543 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL)))) |
1544 | { | 1544 | { |
1545 | yield return true; | 1545 | yield return true; |
1546 | yield break; | 1546 | yield break; |
1547 | } | 1547 | } |
1548 | } | 1548 | } |
1549 | } | 1549 | } |
1550 | { | 1550 | { |
1551 | object _State = arg2; | 1551 | object _State = arg2; |
1552 | Variable Name = new Variable(); | 1552 | Variable Name = new Variable(); |
1553 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name))) | 1553 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name))) |
1554 | { | 1554 | { |
1555 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL))) | 1555 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL))) |
1556 | { | 1556 | { |
1557 | yield return true; | 1557 | yield return true; |
1558 | yield break; | 1558 | yield break; |
1559 | } | 1559 | } |
1560 | } | 1560 | } |
1561 | } | 1561 | } |
1562 | { | 1562 | { |
1563 | object State = arg2; | 1563 | object State = arg2; |
1564 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) | 1564 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) |
1565 | { | 1565 | { |
1566 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) | 1566 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL))) |
1567 | { | 1567 | { |
1568 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) | 1568 | if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut"))) |
1569 | { | 1569 | { |
1570 | yield return true; | 1570 | yield return true; |
1571 | yield break; | 1571 | yield break; |
1572 | } | 1572 | } |
1573 | } | 1573 | } |
1574 | } | 1574 | } |
1575 | } | 1575 | } |
1576 | { | 1576 | { |
1577 | object State = arg2; | 1577 | object State = arg2; |
1578 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) | 1578 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) |
1579 | { | 1579 | { |
1580 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL))) | 1580 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL))) |
1581 | { | 1581 | { |
1582 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) | 1582 | if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut"))) |
1583 | { | 1583 | { |
1584 | yield return true; | 1584 | yield return true; |
1585 | yield break; | 1585 | yield break; |
1586 | } | 1586 | } |
1587 | } | 1587 | } |
1588 | } | 1588 | } |
1589 | } | 1589 | } |
1590 | { | 1590 | { |
1591 | object _State = arg2; | 1591 | object _State = arg2; |
1592 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) | 1592 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"true"))) |
1593 | { | 1593 | { |
1594 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL))) | 1594 | foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL))) |
1595 | { | 1595 | { |
1596 | yield return true; | 1596 | yield return true; |
1597 | yield break; | 1597 | yield break; |
1598 | } | 1598 | } |
1599 | } | 1599 | } |
1600 | } | 1600 | } |
1601 | { | 1601 | { |
1602 | object State = arg2; | 1602 | object State = arg2; |
1603 | object PseudoCode = arg3; | 1603 | object PseudoCode = arg3; |
1604 | Variable A = new Variable(); | 1604 | Variable A = new Variable(); |
1605 | Variable B = new Variable(); | 1605 | Variable B = new Variable(); |
1606 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) | 1606 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) |
1607 | { | 1607 | { |
1608 | if (YP.var(A)) | 1608 | if (YP.var(A)) |
1609 | { | 1609 | { |
1610 | foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode)) | 1610 | foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode)) |
1611 | { | 1611 | { |
1612 | yield return true; | 1612 | yield return true; |
1613 | yield break; | 1613 | yield break; |
1614 | } | 1614 | } |
1615 | } | 1615 | } |
1616 | } | 1616 | } |
1617 | } | 1617 | } |
1618 | { | 1618 | { |
1619 | object State = arg2; | 1619 | object State = arg2; |
1620 | object PseudoCode = arg3; | 1620 | object PseudoCode = arg3; |
1621 | Variable A = new Variable(); | 1621 | Variable A = new Variable(); |
1622 | Variable T = new Variable(); | 1622 | Variable T = new Variable(); |
1623 | Variable B = new Variable(); | 1623 | Variable B = new Variable(); |
1624 | Variable C = new Variable(); | 1624 | Variable C = new Variable(); |
1625 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), B), C))) | 1625 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), B), C))) |
1626 | { | 1626 | { |
1627 | foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@"->", A, new Functor2(@",", T, C)), new Functor2(@",", B, C)), State, PseudoCode)) | 1627 | foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@"->", A, new Functor2(@",", T, C)), new Functor2(@",", B, C)), State, PseudoCode)) |
1628 | { | 1628 | { |
1629 | yield return true; | 1629 | yield return true; |
1630 | yield break; | 1630 | yield break; |
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | } | 1633 | } |
1634 | { | 1634 | { |
1635 | object State = arg2; | 1635 | object State = arg2; |
1636 | object PseudoCode = arg3; | 1636 | object PseudoCode = arg3; |
1637 | Variable A = new Variable(); | 1637 | Variable A = new Variable(); |
1638 | Variable B = new Variable(); | 1638 | Variable B = new Variable(); |
1639 | Variable C = new Variable(); | 1639 | Variable C = new Variable(); |
1640 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", A, B), C))) | 1640 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", A, B), C))) |
1641 | { | 1641 | { |
1642 | foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, C), new Functor2(@",", B, C)), State, PseudoCode)) | 1642 | foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, C), new Functor2(@",", B, C)), State, PseudoCode)) |
1643 | { | 1643 | { |
1644 | yield return true; | 1644 | yield return true; |
1645 | yield break; | 1645 | yield break; |
1646 | } | 1646 | } |
1647 | } | 1647 | } |
1648 | } | 1648 | } |
1649 | { | 1649 | { |
1650 | object State = arg2; | 1650 | object State = arg2; |
1651 | Variable A = new Variable(); | 1651 | Variable A = new Variable(); |
1652 | Variable B = new Variable(); | 1652 | Variable B = new Variable(); |
1653 | Variable ACode = new Variable(); | 1653 | Variable ACode = new Variable(); |
1654 | Variable BCode = new Variable(); | 1654 | Variable BCode = new Variable(); |
1655 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B))) | 1655 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B))) |
1656 | { | 1656 | { |
1657 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor1(@"not", ACode), BCode), Atom.NIL))) | 1657 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor1(@"not", ACode), BCode), Atom.NIL))) |
1658 | { | 1658 | { |
1659 | if (CompilerState.isSemidetNoneOut(State, A)) | 1659 | if (CompilerState.isSemidetNoneOut(State, A)) |
1660 | { | 1660 | { |
1661 | foreach (bool l5 in compileFunctorCall(A, State, ACode)) | 1661 | foreach (bool l5 in compileFunctorCall(A, State, ACode)) |
1662 | { | 1662 | { |
1663 | foreach (bool l6 in compileRuleBody(B, State, BCode)) | 1663 | foreach (bool l6 in compileRuleBody(B, State, BCode)) |
1664 | { | 1664 | { |
1665 | yield return true; | 1665 | yield return true; |
1666 | yield break; | 1666 | yield break; |
1667 | } | 1667 | } |
1668 | } | 1668 | } |
1669 | } | 1669 | } |
1670 | } | 1670 | } |
1671 | } | 1671 | } |
1672 | } | 1672 | } |
1673 | { | 1673 | { |
1674 | object State = arg2; | 1674 | object State = arg2; |
1675 | object PseudoCode = arg3; | 1675 | object PseudoCode = arg3; |
1676 | Variable A = new Variable(); | 1676 | Variable A = new Variable(); |
1677 | Variable B = new Variable(); | 1677 | Variable B = new Variable(); |
1678 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B))) | 1678 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B))) |
1679 | { | 1679 | { |
1680 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"fail")), Atom.a(@"true")), B), State, PseudoCode)) | 1680 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"fail")), Atom.a(@"true")), B), State, PseudoCode)) |
1681 | { | 1681 | { |
1682 | yield return true; | 1682 | yield return true; |
1683 | yield break; | 1683 | yield break; |
1684 | } | 1684 | } |
1685 | } | 1685 | } |
1686 | } | 1686 | } |
1687 | { | 1687 | { |
1688 | object State = arg2; | 1688 | object State = arg2; |
1689 | object PseudoCode = arg3; | 1689 | object PseudoCode = arg3; |
1690 | Variable A = new Variable(); | 1690 | Variable A = new Variable(); |
1691 | Variable B = new Variable(); | 1691 | Variable B = new Variable(); |
1692 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"once", A), B))) | 1692 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"once", A), B))) |
1693 | { | 1693 | { |
1694 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"true")), Atom.a(@"fail")), B), State, PseudoCode)) | 1694 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"true")), Atom.a(@"fail")), B), State, PseudoCode)) |
1695 | { | 1695 | { |
1696 | yield return true; | 1696 | yield return true; |
1697 | yield break; | 1697 | yield break; |
1698 | } | 1698 | } |
1699 | } | 1699 | } |
1700 | } | 1700 | } |
1701 | { | 1701 | { |
1702 | object State = arg2; | 1702 | object State = arg2; |
1703 | object PseudoCode = arg3; | 1703 | object PseudoCode = arg3; |
1704 | Variable A = new Variable(); | 1704 | Variable A = new Variable(); |
1705 | Variable T = new Variable(); | 1705 | Variable T = new Variable(); |
1706 | Variable B = new Variable(); | 1706 | Variable B = new Variable(); |
1707 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"->", A, T), B))) | 1707 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"->", A, T), B))) |
1708 | { | 1708 | { |
1709 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), Atom.a(@"fail")), B), State, PseudoCode)) | 1709 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), Atom.a(@"fail")), B), State, PseudoCode)) |
1710 | { | 1710 | { |
1711 | yield return true; | 1711 | yield return true; |
1712 | yield break; | 1712 | yield break; |
1713 | } | 1713 | } |
1714 | } | 1714 | } |
1715 | } | 1715 | } |
1716 | { | 1716 | { |
1717 | object State = arg2; | 1717 | object State = arg2; |
1718 | object PseudoCode = arg3; | 1718 | object PseudoCode = arg3; |
1719 | Variable A = new Variable(); | 1719 | Variable A = new Variable(); |
1720 | Variable B = new Variable(); | 1720 | Variable B = new Variable(); |
1721 | Variable C = new Variable(); | 1721 | Variable C = new Variable(); |
1722 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"\=", A, B), C))) | 1722 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"\=", A, B), C))) |
1723 | { | 1723 | { |
1724 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"\+", new Functor2(@"=", A, B)), C), State, PseudoCode)) | 1724 | foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"\+", new Functor2(@"=", A, B)), C), State, PseudoCode)) |
1725 | { | 1725 | { |
1726 | yield return true; | 1726 | yield return true; |
1727 | yield break; | 1727 | yield break; |
1728 | } | 1728 | } |
1729 | } | 1729 | } |
1730 | } | 1730 | } |
1731 | { | 1731 | { |
1732 | object State = arg2; | 1732 | object State = arg2; |
1733 | object PseudoCode = arg3; | 1733 | object PseudoCode = arg3; |
1734 | Variable A = new Variable(); | 1734 | Variable A = new Variable(); |
1735 | Variable ACode = new Variable(); | 1735 | Variable ACode = new Variable(); |
1736 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"!"), A))) | 1736 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"!"), A))) |
1737 | { | 1737 | { |
1738 | foreach (bool l3 in compileRuleBody(A, State, ACode)) | 1738 | foreach (bool l3 in compileRuleBody(A, State, ACode)) |
1739 | { | 1739 | { |
1740 | foreach (bool l4 in append(ACode, new ListPair(Atom.a(@"yieldbreak"), Atom.NIL), PseudoCode)) | 1740 | foreach (bool l4 in append(ACode, new ListPair(Atom.a(@"yieldbreak"), Atom.NIL), PseudoCode)) |
1741 | { | 1741 | { |
1742 | yield return true; | 1742 | yield return true; |
1743 | yield break; | 1743 | yield break; |
1744 | } | 1744 | } |
1745 | } | 1745 | } |
1746 | } | 1746 | } |
1747 | } | 1747 | } |
1748 | { | 1748 | { |
1749 | object State = arg2; | 1749 | object State = arg2; |
1750 | object PseudoCode = arg3; | 1750 | object PseudoCode = arg3; |
1751 | Variable Name = new Variable(); | 1751 | Variable Name = new Variable(); |
1752 | Variable A = new Variable(); | 1752 | Variable A = new Variable(); |
1753 | Variable ACode = new Variable(); | 1753 | Variable ACode = new Variable(); |
1754 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$CUTIF", Name), A))) | 1754 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$CUTIF", Name), A))) |
1755 | { | 1755 | { |
1756 | foreach (bool l3 in compileRuleBody(A, State, ACode)) | 1756 | foreach (bool l3 in compileRuleBody(A, State, ACode)) |
1757 | { | 1757 | { |
1758 | foreach (bool l4 in append(ACode, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL), PseudoCode)) | 1758 | foreach (bool l4 in append(ACode, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL), PseudoCode)) |
1759 | { | 1759 | { |
1760 | yield return true; | 1760 | yield return true; |
1761 | yield break; | 1761 | yield break; |
1762 | } | 1762 | } |
1763 | } | 1763 | } |
1764 | } | 1764 | } |
1765 | } | 1765 | } |
1766 | { | 1766 | { |
1767 | object _State = arg2; | 1767 | object _State = arg2; |
1768 | Variable x1 = new Variable(); | 1768 | Variable x1 = new Variable(); |
1769 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"fail"), x1))) | 1769 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"fail"), x1))) |
1770 | { | 1770 | { |
1771 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) | 1771 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) |
1772 | { | 1772 | { |
1773 | yield return true; | 1773 | yield return true; |
1774 | yield break; | 1774 | yield break; |
1775 | } | 1775 | } |
1776 | } | 1776 | } |
1777 | } | 1777 | } |
1778 | { | 1778 | { |
1779 | object State = arg2; | 1779 | object State = arg2; |
1780 | object PseudoCode = arg3; | 1780 | object PseudoCode = arg3; |
1781 | Variable A = new Variable(); | 1781 | Variable A = new Variable(); |
1782 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"true"), A))) | 1782 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"true"), A))) |
1783 | { | 1783 | { |
1784 | foreach (bool l3 in compileRuleBody(A, State, PseudoCode)) | 1784 | foreach (bool l3 in compileRuleBody(A, State, PseudoCode)) |
1785 | { | 1785 | { |
1786 | yield return true; | 1786 | yield return true; |
1787 | yield break; | 1787 | yield break; |
1788 | } | 1788 | } |
1789 | } | 1789 | } |
1790 | } | 1790 | } |
1791 | { | 1791 | { |
1792 | object State = arg2; | 1792 | object State = arg2; |
1793 | Variable A = new Variable(); | 1793 | Variable A = new Variable(); |
1794 | Variable Term = new Variable(); | 1794 | Variable Term = new Variable(); |
1795 | Variable B = new Variable(); | 1795 | Variable B = new Variable(); |
1796 | Variable ACode = new Variable(); | 1796 | Variable ACode = new Variable(); |
1797 | Variable TermCode = new Variable(); | 1797 | Variable TermCode = new Variable(); |
1798 | Variable BCode = new Variable(); | 1798 | Variable BCode = new Variable(); |
1799 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"is", A, Term), B))) | 1799 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"is", A, Term), B))) |
1800 | { | 1800 | { |
1801 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(ACode, new ListPair(TermCode, Atom.NIL))), BCode), Atom.NIL))) | 1801 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(ACode, new ListPair(TermCode, Atom.NIL))), BCode), Atom.NIL))) |
1802 | { | 1802 | { |
1803 | foreach (bool l4 in compileTerm(A, State, ACode)) | 1803 | foreach (bool l4 in compileTerm(A, State, ACode)) |
1804 | { | 1804 | { |
1805 | foreach (bool l5 in compileExpression(Term, State, TermCode)) | 1805 | foreach (bool l5 in compileExpression(Term, State, TermCode)) |
1806 | { | 1806 | { |
1807 | foreach (bool l6 in compileRuleBody(B, State, BCode)) | 1807 | foreach (bool l6 in compileRuleBody(B, State, BCode)) |
1808 | { | 1808 | { |
1809 | yield return true; | 1809 | yield return true; |
1810 | yield break; | 1810 | yield break; |
1811 | } | 1811 | } |
1812 | } | 1812 | } |
1813 | } | 1813 | } |
1814 | } | 1814 | } |
1815 | } | 1815 | } |
1816 | } | 1816 | } |
1817 | { | 1817 | { |
1818 | object State = arg2; | 1818 | object State = arg2; |
1819 | Variable A = new Variable(); | 1819 | Variable A = new Variable(); |
1820 | Variable B = new Variable(); | 1820 | Variable B = new Variable(); |
1821 | Variable ACode = new Variable(); | 1821 | Variable ACode = new Variable(); |
1822 | Variable BCode = new Variable(); | 1822 | Variable BCode = new Variable(); |
1823 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) | 1823 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) |
1824 | { | 1824 | { |
1825 | foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode))) | 1825 | foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode))) |
1826 | { | 1826 | { |
1827 | if (CompilerState.isDetNoneOut(State, A)) | 1827 | if (CompilerState.isDetNoneOut(State, A)) |
1828 | { | 1828 | { |
1829 | foreach (bool l5 in compileFunctorCall(A, State, ACode)) | 1829 | foreach (bool l5 in compileFunctorCall(A, State, ACode)) |
1830 | { | 1830 | { |
1831 | foreach (bool l6 in compileRuleBody(B, State, BCode)) | 1831 | foreach (bool l6 in compileRuleBody(B, State, BCode)) |
1832 | { | 1832 | { |
1833 | yield return true; | 1833 | yield return true; |
1834 | yield break; | 1834 | yield break; |
1835 | } | 1835 | } |
1836 | } | 1836 | } |
1837 | } | 1837 | } |
1838 | } | 1838 | } |
1839 | } | 1839 | } |
1840 | } | 1840 | } |
1841 | { | 1841 | { |
1842 | object State = arg2; | 1842 | object State = arg2; |
1843 | Variable A = new Variable(); | 1843 | Variable A = new Variable(); |
1844 | Variable B = new Variable(); | 1844 | Variable B = new Variable(); |
1845 | Variable ACode = new Variable(); | 1845 | Variable ACode = new Variable(); |
1846 | Variable BCode = new Variable(); | 1846 | Variable BCode = new Variable(); |
1847 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) | 1847 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) |
1848 | { | 1848 | { |
1849 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL))) | 1849 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL))) |
1850 | { | 1850 | { |
1851 | if (CompilerState.isSemidetNoneOut(State, A)) | 1851 | if (CompilerState.isSemidetNoneOut(State, A)) |
1852 | { | 1852 | { |
1853 | foreach (bool l5 in compileFunctorCall(A, State, ACode)) | 1853 | foreach (bool l5 in compileFunctorCall(A, State, ACode)) |
1854 | { | 1854 | { |
1855 | foreach (bool l6 in compileRuleBody(B, State, BCode)) | 1855 | foreach (bool l6 in compileRuleBody(B, State, BCode)) |
1856 | { | 1856 | { |
1857 | yield return true; | 1857 | yield return true; |
1858 | yield break; | 1858 | yield break; |
1859 | } | 1859 | } |
1860 | } | 1860 | } |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | } | 1864 | } |
1865 | { | 1865 | { |
1866 | object State = arg2; | 1866 | object State = arg2; |
1867 | Variable ACode = new Variable(); | 1867 | Variable ACode = new Variable(); |
1868 | Variable B = new Variable(); | 1868 | Variable B = new Variable(); |
1869 | Variable BCode = new Variable(); | 1869 | Variable BCode = new Variable(); |
1870 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B))) | 1870 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B))) |
1871 | { | 1871 | { |
1872 | foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode))) | 1872 | foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode))) |
1873 | { | 1873 | { |
1874 | foreach (bool l4 in compileRuleBody(B, State, BCode)) | 1874 | foreach (bool l4 in compileRuleBody(B, State, BCode)) |
1875 | { | 1875 | { |
1876 | yield return true; | 1876 | yield return true; |
1877 | yield break; | 1877 | yield break; |
1878 | } | 1878 | } |
1879 | } | 1879 | } |
1880 | } | 1880 | } |
1881 | } | 1881 | } |
1882 | { | 1882 | { |
1883 | object State = arg2; | 1883 | object State = arg2; |
1884 | Variable A = new Variable(); | 1884 | Variable A = new Variable(); |
1885 | Variable B = new Variable(); | 1885 | Variable B = new Variable(); |
1886 | Variable FunctionName = new Variable(); | 1886 | Variable FunctionName = new Variable(); |
1887 | Variable X1Code = new Variable(); | 1887 | Variable X1Code = new Variable(); |
1888 | Variable X2Code = new Variable(); | 1888 | Variable X2Code = new Variable(); |
1889 | Variable BCode = new Variable(); | 1889 | Variable BCode = new Variable(); |
1890 | Variable Name = new Variable(); | 1890 | Variable Name = new Variable(); |
1891 | Variable X1 = new Variable(); | 1891 | Variable X1 = new Variable(); |
1892 | Variable X2 = new Variable(); | 1892 | Variable X2 = new Variable(); |
1893 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) | 1893 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) |
1894 | { | 1894 | { |
1895 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor2(@"call", FunctionName, new ListPair(X1Code, new ListPair(X2Code, Atom.NIL))), BCode), Atom.NIL))) | 1895 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor2(@"call", FunctionName, new ListPair(X1Code, new ListPair(X2Code, Atom.NIL))), BCode), Atom.NIL))) |
1896 | { | 1896 | { |
1897 | foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL))))) | 1897 | foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL))))) |
1898 | { | 1898 | { |
1899 | foreach (bool l5 in binaryExpressionConditional(Name, FunctionName)) | 1899 | foreach (bool l5 in binaryExpressionConditional(Name, FunctionName)) |
1900 | { | 1900 | { |
1901 | foreach (bool l6 in compileExpression(X1, State, X1Code)) | 1901 | foreach (bool l6 in compileExpression(X1, State, X1Code)) |
1902 | { | 1902 | { |
1903 | foreach (bool l7 in compileExpression(X2, State, X2Code)) | 1903 | foreach (bool l7 in compileExpression(X2, State, X2Code)) |
1904 | { | 1904 | { |
1905 | foreach (bool l8 in compileRuleBody(B, State, BCode)) | 1905 | foreach (bool l8 in compileRuleBody(B, State, BCode)) |
1906 | { | 1906 | { |
1907 | yield return true; | 1907 | yield return true; |
1908 | yield break; | 1908 | yield break; |
1909 | } | 1909 | } |
1910 | } | 1910 | } |
1911 | } | 1911 | } |
1912 | } | 1912 | } |
1913 | } | 1913 | } |
1914 | } | 1914 | } |
1915 | } | 1915 | } |
1916 | } | 1916 | } |
1917 | { | 1917 | { |
1918 | object State = arg2; | 1918 | object State = arg2; |
1919 | object PseudoCode = arg3; | 1919 | object PseudoCode = arg3; |
1920 | Variable A = new Variable(); | 1920 | Variable A = new Variable(); |
1921 | Variable B = new Variable(); | 1921 | Variable B = new Variable(); |
1922 | Variable C = new Variable(); | 1922 | Variable C = new Variable(); |
1923 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C))) | 1923 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C))) |
1924 | { | 1924 | { |
1925 | foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode)) | 1925 | foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode)) |
1926 | { | 1926 | { |
1927 | yield return true; | 1927 | yield return true; |
1928 | yield break; | 1928 | yield break; |
1929 | } | 1929 | } |
1930 | } | 1930 | } |
1931 | } | 1931 | } |
1932 | { | 1932 | { |
1933 | object State = arg2; | 1933 | object State = arg2; |
1934 | object PseudoCode = arg3; | 1934 | object PseudoCode = arg3; |
1935 | Variable Template = new Variable(); | 1935 | Variable Template = new Variable(); |
1936 | Variable Goal = new Variable(); | 1936 | Variable Goal = new Variable(); |
1937 | Variable Bag = new Variable(); | 1937 | Variable Bag = new Variable(); |
1938 | Variable B = new Variable(); | 1938 | Variable B = new Variable(); |
1939 | Variable TemplateCode = new Variable(); | 1939 | Variable TemplateCode = new Variable(); |
1940 | Variable FindallAnswers = new Variable(); | 1940 | Variable FindallAnswers = new Variable(); |
1941 | Variable GoalAndAddCode = new Variable(); | 1941 | Variable GoalAndAddCode = new Variable(); |
1942 | Variable BagCode = new Variable(); | 1942 | Variable BagCode = new Variable(); |
1943 | Variable BCode = new Variable(); | 1943 | Variable BCode = new Variable(); |
1944 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"findall", Template, Goal, Bag), B))) | 1944 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"findall", Template, Goal, Bag), B))) |
1945 | { | 1945 | { |
1946 | foreach (bool l3 in compileTerm(Template, State, TemplateCode)) | 1946 | foreach (bool l3 in compileTerm(Template, State, TemplateCode)) |
1947 | { | 1947 | { |
1948 | foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers)) | 1948 | foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers)) |
1949 | { | 1949 | { |
1950 | foreach (bool l5 in compileRuleBody(new Functor2(@",", Goal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode)) | 1950 | foreach (bool l5 in compileRuleBody(new Functor2(@",", Goal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode)) |
1951 | { | 1951 | { |
1952 | foreach (bool l6 in compileTerm(Bag, State, BagCode)) | 1952 | foreach (bool l6 in compileTerm(Bag, State, BagCode)) |
1953 | { | 1953 | { |
1954 | foreach (bool l7 in compileRuleBody(B, State, BCode)) | 1954 | foreach (bool l7 in compileRuleBody(B, State, BCode)) |
1955 | { | 1955 | { |
1956 | foreach (bool l8 in append(new ListPair(new Functor3(@"declare", Atom.a(@"FindallAnswers"), FindallAnswers, new Functor2(@"new", Atom.a(@"FindallAnswers"), new ListPair(TemplateCode, Atom.NIL))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"result"), new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode)) | 1956 | foreach (bool l8 in append(new ListPair(new Functor3(@"declare", Atom.a(@"FindallAnswers"), FindallAnswers, new Functor2(@"new", Atom.a(@"FindallAnswers"), new ListPair(TemplateCode, Atom.NIL))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"result"), new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode)) |
1957 | { | 1957 | { |
1958 | yield return true; | 1958 | yield return true; |
1959 | yield break; | 1959 | yield break; |
1960 | } | 1960 | } |
1961 | } | 1961 | } |
1962 | } | 1962 | } |
1963 | } | 1963 | } |
1964 | } | 1964 | } |
1965 | } | 1965 | } |
1966 | } | 1966 | } |
1967 | } | 1967 | } |
1968 | { | 1968 | { |
1969 | object State = arg2; | 1969 | object State = arg2; |
1970 | object PseudoCode = arg3; | 1970 | object PseudoCode = arg3; |
1971 | Variable Template = new Variable(); | 1971 | Variable Template = new Variable(); |
1972 | Variable Goal = new Variable(); | 1972 | Variable Goal = new Variable(); |
1973 | Variable Bag = new Variable(); | 1973 | Variable Bag = new Variable(); |
1974 | Variable B = new Variable(); | 1974 | Variable B = new Variable(); |
1975 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"bagof", Template, Goal, Bag), B))) | 1975 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"bagof", Template, Goal, Bag), B))) |
1976 | { | 1976 | { |
1977 | foreach (bool l3 in compileBagof(Atom.a(@"result"), Template, Goal, Bag, B, State, PseudoCode)) | 1977 | foreach (bool l3 in compileBagof(Atom.a(@"result"), Template, Goal, Bag, B, State, PseudoCode)) |
1978 | { | 1978 | { |
1979 | yield return true; | 1979 | yield return true; |
1980 | yield break; | 1980 | yield break; |
1981 | } | 1981 | } |
1982 | } | 1982 | } |
1983 | } | 1983 | } |
1984 | { | 1984 | { |
1985 | object State = arg2; | 1985 | object State = arg2; |
1986 | object PseudoCode = arg3; | 1986 | object PseudoCode = arg3; |
1987 | Variable Template = new Variable(); | 1987 | Variable Template = new Variable(); |
1988 | Variable Goal = new Variable(); | 1988 | Variable Goal = new Variable(); |
1989 | Variable Bag = new Variable(); | 1989 | Variable Bag = new Variable(); |
1990 | Variable B = new Variable(); | 1990 | Variable B = new Variable(); |
1991 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"setof", Template, Goal, Bag), B))) | 1991 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"setof", Template, Goal, Bag), B))) |
1992 | { | 1992 | { |
1993 | foreach (bool l3 in compileBagof(Atom.a(@"resultSet"), Template, Goal, Bag, B, State, PseudoCode)) | 1993 | foreach (bool l3 in compileBagof(Atom.a(@"resultSet"), Template, Goal, Bag, B, State, PseudoCode)) |
1994 | { | 1994 | { |
1995 | yield return true; | 1995 | yield return true; |
1996 | yield break; | 1996 | yield break; |
1997 | } | 1997 | } |
1998 | } | 1998 | } |
1999 | } | 1999 | } |
2000 | { | 2000 | { |
2001 | object State = arg2; | 2001 | object State = arg2; |
2002 | Variable A = new Variable(); | 2002 | Variable A = new Variable(); |
2003 | Variable B = new Variable(); | 2003 | Variable B = new Variable(); |
2004 | Variable ATermCode = new Variable(); | 2004 | Variable ATermCode = new Variable(); |
2005 | Variable BCode = new Variable(); | 2005 | Variable BCode = new Variable(); |
2006 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"call", A), B))) | 2006 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"call", A), B))) |
2007 | { | 2007 | { |
2008 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode), Atom.NIL))) | 2008 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode), Atom.NIL))) |
2009 | { | 2009 | { |
2010 | foreach (bool l4 in compileTerm(A, State, ATermCode)) | 2010 | foreach (bool l4 in compileTerm(A, State, ATermCode)) |
2011 | { | 2011 | { |
2012 | foreach (bool l5 in compileRuleBody(B, State, BCode)) | 2012 | foreach (bool l5 in compileRuleBody(B, State, BCode)) |
2013 | { | 2013 | { |
2014 | yield return true; | 2014 | yield return true; |
2015 | yield break; | 2015 | yield break; |
2016 | } | 2016 | } |
2017 | } | 2017 | } |
2018 | } | 2018 | } |
2019 | } | 2019 | } |
2020 | } | 2020 | } |
2021 | { | 2021 | { |
2022 | object State = arg2; | 2022 | object State = arg2; |
2023 | Variable A = new Variable(); | 2023 | Variable A = new Variable(); |
2024 | Variable B = new Variable(); | 2024 | Variable B = new Variable(); |
2025 | Variable ACode = new Variable(); | 2025 | Variable ACode = new Variable(); |
2026 | Variable BCode = new Variable(); | 2026 | Variable BCode = new Variable(); |
2027 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) | 2027 | foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) |
2028 | { | 2028 | { |
2029 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", ACode, BCode), Atom.NIL))) | 2029 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", ACode, BCode), Atom.NIL))) |
2030 | { | 2030 | { |
2031 | foreach (bool l4 in compileFunctorCall(A, State, ACode)) | 2031 | foreach (bool l4 in compileFunctorCall(A, State, ACode)) |
2032 | { | 2032 | { |
2033 | foreach (bool l5 in compileRuleBody(B, State, BCode)) | 2033 | foreach (bool l5 in compileRuleBody(B, State, BCode)) |
2034 | { | 2034 | { |
2035 | yield return true; | 2035 | yield return true; |
2036 | yield break; | 2036 | yield break; |
2037 | } | 2037 | } |
2038 | } | 2038 | } |
2039 | } | 2039 | } |
2040 | } | 2040 | } |
2041 | } | 2041 | } |
2042 | { | 2042 | { |
2043 | object State = arg2; | 2043 | object State = arg2; |
2044 | object PseudoCode = arg3; | 2044 | object PseudoCode = arg3; |
2045 | Variable A = new Variable(); | 2045 | Variable A = new Variable(); |
2046 | Variable B = new Variable(); | 2046 | Variable B = new Variable(); |
2047 | foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) | 2047 | foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) |
2048 | { | 2048 | { |
2049 | if (YP.var(A)) | 2049 | if (YP.var(A)) |
2050 | { | 2050 | { |
2051 | foreach (bool l4 in compileRuleBody(new Functor2(@";", new Functor1(@"call", A), B), State, PseudoCode)) | 2051 | foreach (bool l4 in compileRuleBody(new Functor2(@";", new Functor1(@"call", A), B), State, PseudoCode)) |
2052 | { | 2052 | { |
2053 | yield return true; | 2053 | yield return true; |
2054 | yield break; | 2054 | yield break; |
2055 | } | 2055 | } |
2056 | } | 2056 | } |
2057 | } | 2057 | } |
2058 | } | 2058 | } |
2059 | { | 2059 | { |
2060 | object State = arg2; | 2060 | object State = arg2; |
2061 | Variable A = new Variable(); | 2061 | Variable A = new Variable(); |
2062 | Variable T = new Variable(); | 2062 | Variable T = new Variable(); |
2063 | Variable B = new Variable(); | 2063 | Variable B = new Variable(); |
2064 | Variable CutIfLabel = new Variable(); | 2064 | Variable CutIfLabel = new Variable(); |
2065 | Variable Code = new Variable(); | 2065 | Variable Code = new Variable(); |
2066 | foreach (bool l2 in YP.unify(arg1, new Functor2(@";", new Functor2(@"->", A, T), B))) | 2066 | foreach (bool l2 in YP.unify(arg1, new Functor2(@";", new Functor2(@"->", A, T), B))) |
2067 | { | 2067 | { |
2068 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"breakableBlock", CutIfLabel, Code), Atom.NIL))) | 2068 | foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"breakableBlock", CutIfLabel, Code), Atom.NIL))) |
2069 | { | 2069 | { |
2070 | foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel)) | 2070 | foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel)) |
2071 | { | 2071 | { |
2072 | foreach (bool l5 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, new Functor2(@",", new Functor1(@"$CUTIF", CutIfLabel), T)), B), State, Code)) | 2072 | foreach (bool l5 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, new Functor2(@",", new Functor1(@"$CUTIF", CutIfLabel), T)), B), State, Code)) |
2073 | { | 2073 | { |
2074 | yield return true; | 2074 | yield return true; |
2075 | yield break; | 2075 | yield break; |
2076 | } | 2076 | } |
2077 | } | 2077 | } |
2078 | } | 2078 | } |
2079 | } | 2079 | } |
2080 | } | 2080 | } |
2081 | { | 2081 | { |
2082 | object State = arg2; | 2082 | object State = arg2; |
2083 | object PseudoCode = arg3; | 2083 | object PseudoCode = arg3; |
2084 | Variable A = new Variable(); | 2084 | Variable A = new Variable(); |
2085 | Variable B = new Variable(); | 2085 | Variable B = new Variable(); |
2086 | Variable ACode = new Variable(); | 2086 | Variable ACode = new Variable(); |
2087 | Variable BCode = new Variable(); | 2087 | Variable BCode = new Variable(); |
2088 | foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) | 2088 | foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B))) |
2089 | { | 2089 | { |
2090 | foreach (bool l3 in compileRuleBody(A, State, ACode)) | 2090 | foreach (bool l3 in compileRuleBody(A, State, ACode)) |
2091 | { | 2091 | { |
2092 | foreach (bool l4 in compileRuleBody(B, State, BCode)) | 2092 | foreach (bool l4 in compileRuleBody(B, State, BCode)) |
2093 | { | 2093 | { |
2094 | foreach (bool l5 in append(ACode, BCode, PseudoCode)) | 2094 | foreach (bool l5 in append(ACode, BCode, PseudoCode)) |
2095 | { | 2095 | { |
2096 | yield return true; | 2096 | yield return true; |
2097 | yield break; | 2097 | yield break; |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | } | 2101 | } |
2102 | } | 2102 | } |
2103 | { | 2103 | { |
2104 | object A = arg1; | 2104 | object A = arg1; |
2105 | object State = arg2; | 2105 | object State = arg2; |
2106 | object PseudoCode = arg3; | 2106 | object PseudoCode = arg3; |
2107 | foreach (bool l2 in compileRuleBody(new Functor2(@",", A, Atom.a(@"true")), State, PseudoCode)) | 2107 | foreach (bool l2 in compileRuleBody(new Functor2(@",", A, Atom.a(@"true")), State, PseudoCode)) |
2108 | { | 2108 | { |
2109 | yield return true; | 2109 | yield return true; |
2110 | yield break; | 2110 | yield break; |
2111 | } | 2111 | } |
2112 | } | 2112 | } |
2113 | } | 2113 | } |
2114 | 2114 | ||
2115 | public static IEnumerable<bool> compileBagof(object ResultMethod, object Template, object Goal, object Bag, object B, object State, object PseudoCode) | 2115 | public static IEnumerable<bool> compileBagof(object ResultMethod, object Template, object Goal, object Bag, object B, object State, object PseudoCode) |
2116 | { | 2116 | { |
2117 | { | 2117 | { |
2118 | Variable TemplateCode = new Variable(); | 2118 | Variable TemplateCode = new Variable(); |
2119 | Variable GoalTermCode = new Variable(); | 2119 | Variable GoalTermCode = new Variable(); |
2120 | Variable UnqualifiedGoal = new Variable(); | 2120 | Variable UnqualifiedGoal = new Variable(); |
2121 | Variable BagofAnswers = new Variable(); | 2121 | Variable BagofAnswers = new Variable(); |
2122 | Variable GoalAndAddCode = new Variable(); | 2122 | Variable GoalAndAddCode = new Variable(); |
2123 | Variable BagCode = new Variable(); | 2123 | Variable BagCode = new Variable(); |
2124 | Variable BCode = new Variable(); | 2124 | Variable BCode = new Variable(); |
2125 | foreach (bool l2 in compileTerm(Template, State, TemplateCode)) | 2125 | foreach (bool l2 in compileTerm(Template, State, TemplateCode)) |
2126 | { | 2126 | { |
2127 | foreach (bool l3 in compileTerm(Goal, State, GoalTermCode)) | 2127 | foreach (bool l3 in compileTerm(Goal, State, GoalTermCode)) |
2128 | { | 2128 | { |
2129 | foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal)) | 2129 | foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal)) |
2130 | { | 2130 | { |
2131 | foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers)) | 2131 | foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers)) |
2132 | { | 2132 | { |
2133 | foreach (bool l6 in compileRuleBody(new Functor2(@",", UnqualifiedGoal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode)) | 2133 | foreach (bool l6 in compileRuleBody(new Functor2(@",", UnqualifiedGoal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode)) |
2134 | { | 2134 | { |
2135 | foreach (bool l7 in compileTerm(Bag, State, BagCode)) | 2135 | foreach (bool l7 in compileTerm(Bag, State, BagCode)) |
2136 | { | 2136 | { |
2137 | foreach (bool l8 in compileRuleBody(B, State, BCode)) | 2137 | foreach (bool l8 in compileRuleBody(B, State, BCode)) |
2138 | { | 2138 | { |
2139 | foreach (bool l9 in append(new ListPair(new Functor3(@"declare", Atom.a(@"BagofAnswers"), BagofAnswers, new Functor2(@"new", Atom.a(@"BagofAnswers"), new ListPair(TemplateCode, new ListPair(GoalTermCode, Atom.NIL)))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), ResultMethod, new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode)) | 2139 | foreach (bool l9 in append(new ListPair(new Functor3(@"declare", Atom.a(@"BagofAnswers"), BagofAnswers, new Functor2(@"new", Atom.a(@"BagofAnswers"), new ListPair(TemplateCode, new ListPair(GoalTermCode, Atom.NIL)))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), ResultMethod, new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode)) |
2140 | { | 2140 | { |
2141 | yield return true; | 2141 | yield return true; |
2142 | yield break; | 2142 | yield break; |
2143 | } | 2143 | } |
2144 | } | 2144 | } |
2145 | } | 2145 | } |
2146 | } | 2146 | } |
2147 | } | 2147 | } |
2148 | } | 2148 | } |
2149 | } | 2149 | } |
2150 | } | 2150 | } |
2151 | } | 2151 | } |
2152 | } | 2152 | } |
2153 | 2153 | ||
2154 | public static IEnumerable<bool> unqualifiedGoal(object arg1, object arg2) | 2154 | public static IEnumerable<bool> unqualifiedGoal(object arg1, object arg2) |
2155 | { | 2155 | { |
2156 | { | 2156 | { |
2157 | object Goal = arg1; | 2157 | object Goal = arg1; |
2158 | foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal))) | 2158 | foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal))) |
2159 | { | 2159 | { |
2160 | if (YP.var(Goal)) | 2160 | if (YP.var(Goal)) |
2161 | { | 2161 | { |
2162 | yield return true; | 2162 | yield return true; |
2163 | yield break; | 2163 | yield break; |
2164 | } | 2164 | } |
2165 | } | 2165 | } |
2166 | } | 2166 | } |
2167 | { | 2167 | { |
2168 | object UnqualifiedGoal = arg2; | 2168 | object UnqualifiedGoal = arg2; |
2169 | Variable x1 = new Variable(); | 2169 | Variable x1 = new Variable(); |
2170 | Variable Goal = new Variable(); | 2170 | Variable Goal = new Variable(); |
2171 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal))) | 2171 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal))) |
2172 | { | 2172 | { |
2173 | foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal)) | 2173 | foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal)) |
2174 | { | 2174 | { |
2175 | yield return true; | 2175 | yield return true; |
2176 | yield break; | 2176 | yield break; |
2177 | } | 2177 | } |
2178 | } | 2178 | } |
2179 | } | 2179 | } |
2180 | { | 2180 | { |
2181 | Variable UnqualifiedGoal = new Variable(); | 2181 | Variable UnqualifiedGoal = new Variable(); |
2182 | foreach (bool l2 in YP.unify(arg1, UnqualifiedGoal)) | 2182 | foreach (bool l2 in YP.unify(arg1, UnqualifiedGoal)) |
2183 | { | 2183 | { |
2184 | foreach (bool l3 in YP.unify(arg2, UnqualifiedGoal)) | 2184 | foreach (bool l3 in YP.unify(arg2, UnqualifiedGoal)) |
2185 | { | 2185 | { |
2186 | yield return true; | 2186 | yield return true; |
2187 | yield break; | 2187 | yield break; |
2188 | } | 2188 | } |
2189 | } | 2189 | } |
2190 | } | 2190 | } |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2) | 2193 | public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2) |
2194 | { | 2194 | { |
2195 | { | 2195 | { |
2196 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:="))) | 2196 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:="))) |
2197 | { | 2197 | { |
2198 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal"))) | 2198 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal"))) |
2199 | { | 2199 | { |
2200 | yield return true; | 2200 | yield return true; |
2201 | yield break; | 2201 | yield break; |
2202 | } | 2202 | } |
2203 | } | 2203 | } |
2204 | } | 2204 | } |
2205 | { | 2205 | { |
2206 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\="))) | 2206 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\="))) |
2207 | { | 2207 | { |
2208 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual"))) | 2208 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual"))) |
2209 | { | 2209 | { |
2210 | yield return true; | 2210 | yield return true; |
2211 | yield break; | 2211 | yield break; |
2212 | } | 2212 | } |
2213 | } | 2213 | } |
2214 | } | 2214 | } |
2215 | { | 2215 | { |
2216 | foreach (bool l2 in YP.unify(arg1, Atom.a(@">"))) | 2216 | foreach (bool l2 in YP.unify(arg1, Atom.a(@">"))) |
2217 | { | 2217 | { |
2218 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan"))) | 2218 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan"))) |
2219 | { | 2219 | { |
2220 | yield return true; | 2220 | yield return true; |
2221 | yield break; | 2221 | yield break; |
2222 | } | 2222 | } |
2223 | } | 2223 | } |
2224 | } | 2224 | } |
2225 | { | 2225 | { |
2226 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"<"))) | 2226 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"<"))) |
2227 | { | 2227 | { |
2228 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan"))) | 2228 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan"))) |
2229 | { | 2229 | { |
2230 | yield return true; | 2230 | yield return true; |
2231 | yield break; | 2231 | yield break; |
2232 | } | 2232 | } |
2233 | } | 2233 | } |
2234 | } | 2234 | } |
2235 | { | 2235 | { |
2236 | foreach (bool l2 in YP.unify(arg1, Atom.a(@">="))) | 2236 | foreach (bool l2 in YP.unify(arg1, Atom.a(@">="))) |
2237 | { | 2237 | { |
2238 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual"))) | 2238 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual"))) |
2239 | { | 2239 | { |
2240 | yield return true; | 2240 | yield return true; |
2241 | yield break; | 2241 | yield break; |
2242 | } | 2242 | } |
2243 | } | 2243 | } |
2244 | } | 2244 | } |
2245 | { | 2245 | { |
2246 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<"))) | 2246 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<"))) |
2247 | { | 2247 | { |
2248 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual"))) | 2248 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual"))) |
2249 | { | 2249 | { |
2250 | yield return true; | 2250 | yield return true; |
2251 | yield break; | 2251 | yield break; |
2252 | } | 2252 | } |
2253 | } | 2253 | } |
2254 | } | 2254 | } |
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object arg3) | 2257 | public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object arg3) |
2258 | { | 2258 | { |
2259 | { | 2259 | { |
2260 | Variable FunctionName = new Variable(); | 2260 | Variable FunctionName = new Variable(); |
2261 | Variable CompiledArgs = new Variable(); | 2261 | Variable CompiledArgs = new Variable(); |
2262 | Variable FunctorName = new Variable(); | 2262 | Variable FunctorName = new Variable(); |
2263 | Variable FunctorArgs = new Variable(); | 2263 | Variable FunctorArgs = new Variable(); |
2264 | Variable x7 = new Variable(); | 2264 | Variable x7 = new Variable(); |
2265 | Variable Arity = new Variable(); | 2265 | Variable Arity = new Variable(); |
2266 | foreach (bool l2 in YP.unify(arg3, new Functor2(@"call", FunctionName, CompiledArgs))) | 2266 | foreach (bool l2 in YP.unify(arg3, new Functor2(@"call", FunctionName, CompiledArgs))) |
2267 | { | 2267 | { |
2268 | foreach (bool l3 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs))) | 2268 | foreach (bool l3 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs))) |
2269 | { | 2269 | { |
2270 | foreach (bool l4 in YP.functor(Functor_1, x7, Arity)) | 2270 | foreach (bool l4 in YP.functor(Functor_1, x7, Arity)) |
2271 | { | 2271 | { |
2272 | foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName)) | 2272 | foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName)) |
2273 | { | 2273 | { |
2274 | foreach (bool l6 in maplist_compileTerm(FunctorArgs, State, CompiledArgs)) | 2274 | foreach (bool l6 in maplist_compileTerm(FunctorArgs, State, CompiledArgs)) |
2275 | { | 2275 | { |
2276 | yield return true; | 2276 | yield return true; |
2277 | yield break; | 2277 | yield break; |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | } | 2280 | } |
2281 | } | 2281 | } |
2282 | } | 2282 | } |
2283 | } | 2283 | } |
2284 | } | 2284 | } |
2285 | 2285 | ||
2286 | public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4) | 2286 | public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4) |
2287 | { | 2287 | { |
2288 | { | 2288 | { |
2289 | object x1 = arg1; | 2289 | object x1 = arg1; |
2290 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"="))) | 2290 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"="))) |
2291 | { | 2291 | { |
2292 | foreach (bool l3 in YP.unify(arg3, 2)) | 2292 | foreach (bool l3 in YP.unify(arg3, 2)) |
2293 | { | 2293 | { |
2294 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.unify"))) | 2294 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.unify"))) |
2295 | { | 2295 | { |
2296 | yield return true; | 2296 | yield return true; |
2297 | yield break; | 2297 | yield break; |
2298 | } | 2298 | } |
2299 | } | 2299 | } |
2300 | } | 2300 | } |
2301 | } | 2301 | } |
2302 | { | 2302 | { |
2303 | object x1 = arg1; | 2303 | object x1 = arg1; |
2304 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"=.."))) | 2304 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"=.."))) |
2305 | { | 2305 | { |
2306 | foreach (bool l3 in YP.unify(arg3, 2)) | 2306 | foreach (bool l3 in YP.unify(arg3, 2)) |
2307 | { | 2307 | { |
2308 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.univ"))) | 2308 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.univ"))) |
2309 | { | 2309 | { |
2310 | yield return true; | 2310 | yield return true; |
2311 | yield break; | 2311 | yield break; |
2312 | } | 2312 | } |
2313 | } | 2313 | } |
2314 | } | 2314 | } |
2315 | } | 2315 | } |
2316 | { | 2316 | { |
2317 | object x1 = arg1; | 2317 | object x1 = arg1; |
2318 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"var"))) | 2318 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"var"))) |
2319 | { | 2319 | { |
2320 | foreach (bool l3 in YP.unify(arg3, 1)) | 2320 | foreach (bool l3 in YP.unify(arg3, 1)) |
2321 | { | 2321 | { |
2322 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.var"))) | 2322 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.var"))) |
2323 | { | 2323 | { |
2324 | yield return true; | 2324 | yield return true; |
2325 | yield break; | 2325 | yield break; |
2326 | } | 2326 | } |
2327 | } | 2327 | } |
2328 | } | 2328 | } |
2329 | } | 2329 | } |
2330 | { | 2330 | { |
2331 | object x1 = arg1; | 2331 | object x1 = arg1; |
2332 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"nonvar"))) | 2332 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"nonvar"))) |
2333 | { | 2333 | { |
2334 | foreach (bool l3 in YP.unify(arg3, 1)) | 2334 | foreach (bool l3 in YP.unify(arg3, 1)) |
2335 | { | 2335 | { |
2336 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.nonvar"))) | 2336 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.nonvar"))) |
2337 | { | 2337 | { |
2338 | yield return true; | 2338 | yield return true; |
2339 | yield break; | 2339 | yield break; |
2340 | } | 2340 | } |
2341 | } | 2341 | } |
2342 | } | 2342 | } |
2343 | } | 2343 | } |
2344 | { | 2344 | { |
2345 | object x1 = arg1; | 2345 | object x1 = arg1; |
2346 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"arg"))) | 2346 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"arg"))) |
2347 | { | 2347 | { |
2348 | foreach (bool l3 in YP.unify(arg3, 3)) | 2348 | foreach (bool l3 in YP.unify(arg3, 3)) |
2349 | { | 2349 | { |
2350 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.arg"))) | 2350 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.arg"))) |
2351 | { | 2351 | { |
2352 | yield return true; | 2352 | yield return true; |
2353 | yield break; | 2353 | yield break; |
2354 | } | 2354 | } |
2355 | } | 2355 | } |
2356 | } | 2356 | } |
2357 | } | 2357 | } |
2358 | { | 2358 | { |
2359 | object x1 = arg1; | 2359 | object x1 = arg1; |
2360 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"functor"))) | 2360 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"functor"))) |
2361 | { | 2361 | { |
2362 | foreach (bool l3 in YP.unify(arg3, 3)) | 2362 | foreach (bool l3 in YP.unify(arg3, 3)) |
2363 | { | 2363 | { |
2364 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.functor"))) | 2364 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.functor"))) |
2365 | { | 2365 | { |
2366 | yield return true; | 2366 | yield return true; |
2367 | yield break; | 2367 | yield break; |
2368 | } | 2368 | } |
2369 | } | 2369 | } |
2370 | } | 2370 | } |
2371 | } | 2371 | } |
2372 | { | 2372 | { |
2373 | object x1 = arg1; | 2373 | object x1 = arg1; |
2374 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"repeat"))) | 2374 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"repeat"))) |
2375 | { | 2375 | { |
2376 | foreach (bool l3 in YP.unify(arg3, 0)) | 2376 | foreach (bool l3 in YP.unify(arg3, 0)) |
2377 | { | 2377 | { |
2378 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.repeat"))) | 2378 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.repeat"))) |
2379 | { | 2379 | { |
2380 | yield return true; | 2380 | yield return true; |
2381 | yield break; | 2381 | yield break; |
2382 | } | 2382 | } |
2383 | } | 2383 | } |
2384 | } | 2384 | } |
2385 | } | 2385 | } |
2386 | { | 2386 | { |
2387 | object x1 = arg1; | 2387 | object x1 = arg1; |
2388 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"get_code"))) | 2388 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"get_code"))) |
2389 | { | 2389 | { |
2390 | foreach (bool l3 in YP.unify(arg3, 1)) | 2390 | foreach (bool l3 in YP.unify(arg3, 1)) |
2391 | { | 2391 | { |
2392 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.get_code"))) | 2392 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.get_code"))) |
2393 | { | 2393 | { |
2394 | yield return true; | 2394 | yield return true; |
2395 | yield break; | 2395 | yield break; |
2396 | } | 2396 | } |
2397 | } | 2397 | } |
2398 | } | 2398 | } |
2399 | } | 2399 | } |
2400 | { | 2400 | { |
2401 | object x1 = arg1; | 2401 | object x1 = arg1; |
2402 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"current_op"))) | 2402 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"current_op"))) |
2403 | { | 2403 | { |
2404 | foreach (bool l3 in YP.unify(arg3, 3)) | 2404 | foreach (bool l3 in YP.unify(arg3, 3)) |
2405 | { | 2405 | { |
2406 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.current_op"))) | 2406 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.current_op"))) |
2407 | { | 2407 | { |
2408 | yield return true; | 2408 | yield return true; |
2409 | yield break; | 2409 | yield break; |
2410 | } | 2410 | } |
2411 | } | 2411 | } |
2412 | } | 2412 | } |
2413 | } | 2413 | } |
2414 | { | 2414 | { |
2415 | object x1 = arg1; | 2415 | object x1 = arg1; |
2416 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_length"))) | 2416 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_length"))) |
2417 | { | 2417 | { |
2418 | foreach (bool l3 in YP.unify(arg3, 2)) | 2418 | foreach (bool l3 in YP.unify(arg3, 2)) |
2419 | { | 2419 | { |
2420 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_length"))) | 2420 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_length"))) |
2421 | { | 2421 | { |
2422 | yield return true; | 2422 | yield return true; |
2423 | yield break; | 2423 | yield break; |
2424 | } | 2424 | } |
2425 | } | 2425 | } |
2426 | } | 2426 | } |
2427 | } | 2427 | } |
2428 | { | 2428 | { |
2429 | object x1 = arg1; | 2429 | object x1 = arg1; |
2430 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_concat"))) | 2430 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_concat"))) |
2431 | { | 2431 | { |
2432 | foreach (bool l3 in YP.unify(arg3, 3)) | 2432 | foreach (bool l3 in YP.unify(arg3, 3)) |
2433 | { | 2433 | { |
2434 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_concat"))) | 2434 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_concat"))) |
2435 | { | 2435 | { |
2436 | yield return true; | 2436 | yield return true; |
2437 | yield break; | 2437 | yield break; |
2438 | } | 2438 | } |
2439 | } | 2439 | } |
2440 | } | 2440 | } |
2441 | } | 2441 | } |
2442 | { | 2442 | { |
2443 | object x1 = arg1; | 2443 | object x1 = arg1; |
2444 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"sub_atom"))) | 2444 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"sub_atom"))) |
2445 | { | 2445 | { |
2446 | foreach (bool l3 in YP.unify(arg3, 5)) | 2446 | foreach (bool l3 in YP.unify(arg3, 5)) |
2447 | { | 2447 | { |
2448 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.sub_atom"))) | 2448 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.sub_atom"))) |
2449 | { | 2449 | { |
2450 | yield return true; | 2450 | yield return true; |
2451 | yield break; | 2451 | yield break; |
2452 | } | 2452 | } |
2453 | } | 2453 | } |
2454 | } | 2454 | } |
2455 | } | 2455 | } |
2456 | { | 2456 | { |
2457 | object x1 = arg1; | 2457 | object x1 = arg1; |
2458 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_codes"))) | 2458 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom_codes"))) |
2459 | { | 2459 | { |
2460 | foreach (bool l3 in YP.unify(arg3, 2)) | 2460 | foreach (bool l3 in YP.unify(arg3, 2)) |
2461 | { | 2461 | { |
2462 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_codes"))) | 2462 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom_codes"))) |
2463 | { | 2463 | { |
2464 | yield return true; | 2464 | yield return true; |
2465 | yield break; | 2465 | yield break; |
2466 | } | 2466 | } |
2467 | } | 2467 | } |
2468 | } | 2468 | } |
2469 | } | 2469 | } |
2470 | { | 2470 | { |
2471 | object x1 = arg1; | 2471 | object x1 = arg1; |
2472 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"number_codes"))) | 2472 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"number_codes"))) |
2473 | { | 2473 | { |
2474 | foreach (bool l3 in YP.unify(arg3, 2)) | 2474 | foreach (bool l3 in YP.unify(arg3, 2)) |
2475 | { | 2475 | { |
2476 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.number_codes"))) | 2476 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.number_codes"))) |
2477 | { | 2477 | { |
2478 | yield return true; | 2478 | yield return true; |
2479 | yield break; | 2479 | yield break; |
2480 | } | 2480 | } |
2481 | } | 2481 | } |
2482 | } | 2482 | } |
2483 | } | 2483 | } |
2484 | { | 2484 | { |
2485 | object x1 = arg1; | 2485 | object x1 = arg1; |
2486 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"copy_term"))) | 2486 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"copy_term"))) |
2487 | { | 2487 | { |
2488 | foreach (bool l3 in YP.unify(arg3, 2)) | 2488 | foreach (bool l3 in YP.unify(arg3, 2)) |
2489 | { | 2489 | { |
2490 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.copy_term"))) | 2490 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.copy_term"))) |
2491 | { | 2491 | { |
2492 | yield return true; | 2492 | yield return true; |
2493 | yield break; | 2493 | yield break; |
2494 | } | 2494 | } |
2495 | } | 2495 | } |
2496 | } | 2496 | } |
2497 | } | 2497 | } |
2498 | { | 2498 | { |
2499 | object x1 = arg1; | 2499 | object x1 = arg1; |
2500 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"sort"))) | 2500 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"sort"))) |
2501 | { | 2501 | { |
2502 | foreach (bool l3 in YP.unify(arg3, 2)) | 2502 | foreach (bool l3 in YP.unify(arg3, 2)) |
2503 | { | 2503 | { |
2504 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.sort"))) | 2504 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.sort"))) |
2505 | { | 2505 | { |
2506 | yield return true; | 2506 | yield return true; |
2507 | yield break; | 2507 | yield break; |
2508 | } | 2508 | } |
2509 | } | 2509 | } |
2510 | } | 2510 | } |
2511 | } | 2511 | } |
2512 | { | 2512 | { |
2513 | object x1 = arg1; | 2513 | object x1 = arg1; |
2514 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"script_event"))) | 2514 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"script_event"))) |
2515 | { | 2515 | { |
2516 | foreach (bool l3 in YP.unify(arg3, 2)) | 2516 | foreach (bool l3 in YP.unify(arg3, 2)) |
2517 | { | 2517 | { |
2518 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.script_event"))) | 2518 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.script_event"))) |
2519 | { | 2519 | { |
2520 | yield return true; | 2520 | yield return true; |
2521 | yield break; | 2521 | yield break; |
2522 | } | 2522 | } |
2523 | } | 2523 | } |
2524 | } | 2524 | } |
2525 | } | 2525 | } |
2526 | { | 2526 | { |
2527 | object x1 = arg1; | 2527 | object x1 = arg1; |
2528 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"nl"))) | 2528 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"nl"))) |
2529 | { | 2529 | { |
2530 | foreach (bool l3 in YP.unify(arg3, 0)) | 2530 | foreach (bool l3 in YP.unify(arg3, 0)) |
2531 | { | 2531 | { |
2532 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.nl"))) | 2532 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.nl"))) |
2533 | { | 2533 | { |
2534 | yield return true; | 2534 | yield return true; |
2535 | yield break; | 2535 | yield break; |
2536 | } | 2536 | } |
2537 | } | 2537 | } |
2538 | } | 2538 | } |
2539 | } | 2539 | } |
2540 | { | 2540 | { |
2541 | object x1 = arg1; | 2541 | object x1 = arg1; |
2542 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"write"))) | 2542 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"write"))) |
2543 | { | 2543 | { |
2544 | foreach (bool l3 in YP.unify(arg3, 1)) | 2544 | foreach (bool l3 in YP.unify(arg3, 1)) |
2545 | { | 2545 | { |
2546 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.write"))) | 2546 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.write"))) |
2547 | { | 2547 | { |
2548 | yield return true; | 2548 | yield return true; |
2549 | yield break; | 2549 | yield break; |
2550 | } | 2550 | } |
2551 | } | 2551 | } |
2552 | } | 2552 | } |
2553 | } | 2553 | } |
2554 | { | 2554 | { |
2555 | object x1 = arg1; | 2555 | object x1 = arg1; |
2556 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"put_code"))) | 2556 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"put_code"))) |
2557 | { | 2557 | { |
2558 | foreach (bool l3 in YP.unify(arg3, 1)) | 2558 | foreach (bool l3 in YP.unify(arg3, 1)) |
2559 | { | 2559 | { |
2560 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.put_code"))) | 2560 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.put_code"))) |
2561 | { | 2561 | { |
2562 | yield return true; | 2562 | yield return true; |
2563 | yield break; | 2563 | yield break; |
2564 | } | 2564 | } |
2565 | } | 2565 | } |
2566 | } | 2566 | } |
2567 | } | 2567 | } |
2568 | { | 2568 | { |
2569 | object x1 = arg1; | 2569 | object x1 = arg1; |
2570 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom"))) | 2570 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"atom"))) |
2571 | { | 2571 | { |
2572 | foreach (bool l3 in YP.unify(arg3, 1)) | 2572 | foreach (bool l3 in YP.unify(arg3, 1)) |
2573 | { | 2573 | { |
2574 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom"))) | 2574 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.atom"))) |
2575 | { | 2575 | { |
2576 | yield return true; | 2576 | yield return true; |
2577 | yield break; | 2577 | yield break; |
2578 | } | 2578 | } |
2579 | } | 2579 | } |
2580 | } | 2580 | } |
2581 | } | 2581 | } |
2582 | { | 2582 | { |
2583 | object x1 = arg1; | 2583 | object x1 = arg1; |
2584 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"number"))) | 2584 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"number"))) |
2585 | { | 2585 | { |
2586 | foreach (bool l3 in YP.unify(arg3, 1)) | 2586 | foreach (bool l3 in YP.unify(arg3, 1)) |
2587 | { | 2587 | { |
2588 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.number"))) | 2588 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.number"))) |
2589 | { | 2589 | { |
2590 | yield return true; | 2590 | yield return true; |
2591 | yield break; | 2591 | yield break; |
2592 | } | 2592 | } |
2593 | } | 2593 | } |
2594 | } | 2594 | } |
2595 | } | 2595 | } |
2596 | { | 2596 | { |
2597 | object x1 = arg1; | 2597 | object x1 = arg1; |
2598 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"=="))) | 2598 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"=="))) |
2599 | { | 2599 | { |
2600 | foreach (bool l3 in YP.unify(arg3, 2)) | 2600 | foreach (bool l3 in YP.unify(arg3, 2)) |
2601 | { | 2601 | { |
2602 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termEqual"))) | 2602 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termEqual"))) |
2603 | { | 2603 | { |
2604 | yield return true; | 2604 | yield return true; |
2605 | yield break; | 2605 | yield break; |
2606 | } | 2606 | } |
2607 | } | 2607 | } |
2608 | } | 2608 | } |
2609 | } | 2609 | } |
2610 | { | 2610 | { |
2611 | object x1 = arg1; | 2611 | object x1 = arg1; |
2612 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"\=="))) | 2612 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"\=="))) |
2613 | { | 2613 | { |
2614 | foreach (bool l3 in YP.unify(arg3, 2)) | 2614 | foreach (bool l3 in YP.unify(arg3, 2)) |
2615 | { | 2615 | { |
2616 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termNotEqual"))) | 2616 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termNotEqual"))) |
2617 | { | 2617 | { |
2618 | yield return true; | 2618 | yield return true; |
2619 | yield break; | 2619 | yield break; |
2620 | } | 2620 | } |
2621 | } | 2621 | } |
2622 | } | 2622 | } |
2623 | } | 2623 | } |
2624 | { | 2624 | { |
2625 | object x1 = arg1; | 2625 | object x1 = arg1; |
2626 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@<"))) | 2626 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@<"))) |
2627 | { | 2627 | { |
2628 | foreach (bool l3 in YP.unify(arg3, 2)) | 2628 | foreach (bool l3 in YP.unify(arg3, 2)) |
2629 | { | 2629 | { |
2630 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termLessThan"))) | 2630 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termLessThan"))) |
2631 | { | 2631 | { |
2632 | yield return true; | 2632 | yield return true; |
2633 | yield break; | 2633 | yield break; |
2634 | } | 2634 | } |
2635 | } | 2635 | } |
2636 | } | 2636 | } |
2637 | } | 2637 | } |
2638 | { | 2638 | { |
2639 | object x1 = arg1; | 2639 | object x1 = arg1; |
2640 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@=<"))) | 2640 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@=<"))) |
2641 | { | 2641 | { |
2642 | foreach (bool l3 in YP.unify(arg3, 2)) | 2642 | foreach (bool l3 in YP.unify(arg3, 2)) |
2643 | { | 2643 | { |
2644 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termLessThanOrEqual"))) | 2644 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termLessThanOrEqual"))) |
2645 | { | 2645 | { |
2646 | yield return true; | 2646 | yield return true; |
2647 | yield break; | 2647 | yield break; |
2648 | } | 2648 | } |
2649 | } | 2649 | } |
2650 | } | 2650 | } |
2651 | } | 2651 | } |
2652 | { | 2652 | { |
2653 | object x1 = arg1; | 2653 | object x1 = arg1; |
2654 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@>"))) | 2654 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@>"))) |
2655 | { | 2655 | { |
2656 | foreach (bool l3 in YP.unify(arg3, 2)) | 2656 | foreach (bool l3 in YP.unify(arg3, 2)) |
2657 | { | 2657 | { |
2658 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termGreaterThan"))) | 2658 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termGreaterThan"))) |
2659 | { | 2659 | { |
2660 | yield return true; | 2660 | yield return true; |
2661 | yield break; | 2661 | yield break; |
2662 | } | 2662 | } |
2663 | } | 2663 | } |
2664 | } | 2664 | } |
2665 | } | 2665 | } |
2666 | { | 2666 | { |
2667 | object x1 = arg1; | 2667 | object x1 = arg1; |
2668 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@>="))) | 2668 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"@>="))) |
2669 | { | 2669 | { |
2670 | foreach (bool l3 in YP.unify(arg3, 2)) | 2670 | foreach (bool l3 in YP.unify(arg3, 2)) |
2671 | { | 2671 | { |
2672 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termGreaterThanOrEqual"))) | 2672 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.termGreaterThanOrEqual"))) |
2673 | { | 2673 | { |
2674 | yield return true; | 2674 | yield return true; |
2675 | yield break; | 2675 | yield break; |
2676 | } | 2676 | } |
2677 | } | 2677 | } |
2678 | } | 2678 | } |
2679 | } | 2679 | } |
2680 | { | 2680 | { |
2681 | object x1 = arg1; | 2681 | object x1 = arg1; |
2682 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"throw"))) | 2682 | foreach (bool l2 in YP.unify(arg2, Atom.a(@"throw"))) |
2683 | { | 2683 | { |
2684 | foreach (bool l3 in YP.unify(arg3, 1)) | 2684 | foreach (bool l3 in YP.unify(arg3, 1)) |
2685 | { | 2685 | { |
2686 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.throwException"))) | 2686 | foreach (bool l4 in YP.unify(arg4, Atom.a(@"YP.throwException"))) |
2687 | { | 2687 | { |
2688 | yield return true; | 2688 | yield return true; |
2689 | yield break; | 2689 | yield break; |
2690 | } | 2690 | } |
2691 | } | 2691 | } |
2692 | } | 2692 | } |
2693 | } | 2693 | } |
2694 | { | 2694 | { |
2695 | object State = arg1; | 2695 | object State = arg1; |
2696 | object Arity = arg3; | 2696 | object Arity = arg3; |
2697 | Variable Name = new Variable(); | 2697 | Variable Name = new Variable(); |
2698 | foreach (bool l2 in YP.unify(arg2, Name)) | 2698 | foreach (bool l2 in YP.unify(arg2, Name)) |
2699 | { | 2699 | { |
2700 | foreach (bool l3 in YP.unify(arg4, Name)) | 2700 | foreach (bool l3 in YP.unify(arg4, Name)) |
2701 | { | 2701 | { |
2702 | if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) | 2702 | if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) |
2703 | { | 2703 | { |
2704 | yield return true; | 2704 | yield return true; |
2705 | yield break; | 2705 | yield break; |
2706 | } | 2706 | } |
2707 | } | 2707 | } |
2708 | } | 2708 | } |
2709 | } | 2709 | } |
2710 | { | 2710 | { |
2711 | object _State = arg1; | 2711 | object _State = arg1; |
2712 | object _Arity = arg3; | 2712 | object _Arity = arg3; |
2713 | Variable Name = new Variable(); | 2713 | Variable Name = new Variable(); |
2714 | foreach (bool l2 in YP.unify(arg2, Name)) | 2714 | foreach (bool l2 in YP.unify(arg2, Name)) |
2715 | { | 2715 | { |
2716 | foreach (bool l3 in YP.unify(arg4, Name)) | 2716 | foreach (bool l3 in YP.unify(arg4, Name)) |
2717 | { | 2717 | { |
2718 | foreach (bool l4 in Atom.module(Name, Atom.a(@""))) | 2718 | foreach (bool l4 in Atom.module(Name, Atom.a(@""))) |
2719 | { | 2719 | { |
2720 | yield return true; | 2720 | yield return true; |
2721 | yield break; | 2721 | yield break; |
2722 | } | 2722 | } |
2723 | } | 2723 | } |
2724 | } | 2724 | } |
2725 | } | 2725 | } |
2726 | { | 2726 | { |
2727 | object _State = arg1; | 2727 | object _State = arg1; |
2728 | object Name = arg2; | 2728 | object Name = arg2; |
2729 | object Arity = arg3; | 2729 | object Arity = arg3; |
2730 | object x4 = arg4; | 2730 | object x4 = arg4; |
2731 | foreach (bool l2 in Atom.module(Name, Atom.NIL)) | 2731 | foreach (bool l2 in Atom.module(Name, Atom.NIL)) |
2732 | { | 2732 | { |
2733 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Calls to dynamic predicates not supported"))); | 2733 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Calls to dynamic predicates not supported"))); |
2734 | yield return true; | 2734 | yield return true; |
2735 | yield break; | 2735 | yield break; |
2736 | } | 2736 | } |
2737 | } | 2737 | } |
2738 | { | 2738 | { |
2739 | object _State = arg1; | 2739 | object _State = arg1; |
2740 | object Name = arg2; | 2740 | object Name = arg2; |
2741 | object Arity = arg3; | 2741 | object Arity = arg3; |
2742 | object x4 = arg4; | 2742 | object x4 = arg4; |
2743 | Variable Module = new Variable(); | 2743 | Variable Module = new Variable(); |
2744 | Variable Message = new Variable(); | 2744 | Variable Message = new Variable(); |
2745 | foreach (bool l2 in Atom.module(Name, Module)) | 2745 | foreach (bool l2 in Atom.module(Name, Module)) |
2746 | { | 2746 | { |
2747 | foreach (bool l3 in Atom.module(Name, Atom.NIL)) | 2747 | foreach (bool l3 in Atom.module(Name, Atom.NIL)) |
2748 | { | 2748 | { |
2749 | foreach (bool l4 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message)) | 2749 | foreach (bool l4 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message)) |
2750 | { | 2750 | { |
2751 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message)); | 2751 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message)); |
2752 | yield return true; | 2752 | yield return true; |
2753 | yield break; | 2753 | yield break; |
2754 | } | 2754 | } |
2755 | } | 2755 | } |
2756 | } | 2756 | } |
2757 | } | 2757 | } |
2758 | } | 2758 | } |
2759 | 2759 | ||
2760 | public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3) | 2760 | public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3) |
2761 | { | 2761 | { |
2762 | { | 2762 | { |
2763 | object Term = arg1; | 2763 | object Term = arg1; |
2764 | object State = arg2; | 2764 | object State = arg2; |
2765 | Variable VariableName = new Variable(); | 2765 | Variable VariableName = new Variable(); |
2766 | foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName))) | 2766 | foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName))) |
2767 | { | 2767 | { |
2768 | if (YP.var(Term)) | 2768 | if (YP.var(Term)) |
2769 | { | 2769 | { |
2770 | foreach (bool l4 in CompilerState.getVariableName(State, Term, VariableName)) | 2770 | foreach (bool l4 in CompilerState.getVariableName(State, Term, VariableName)) |
2771 | { | 2771 | { |
2772 | yield return true; | 2772 | yield return true; |
2773 | yield break; | 2773 | yield break; |
2774 | } | 2774 | } |
2775 | } | 2775 | } |
2776 | } | 2776 | } |
2777 | } | 2777 | } |
2778 | { | 2778 | { |
2779 | object _State = arg2; | 2779 | object _State = arg2; |
2780 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 2780 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
2781 | { | 2781 | { |
2782 | foreach (bool l3 in YP.unify(arg3, new Functor1(@"var", Atom.a(@"Atom.NIL")))) | 2782 | foreach (bool l3 in YP.unify(arg3, new Functor1(@"var", Atom.a(@"Atom.NIL")))) |
2783 | { | 2783 | { |
2784 | yield return true; | 2784 | yield return true; |
2785 | yield break; | 2785 | yield break; |
2786 | } | 2786 | } |
2787 | } | 2787 | } |
2788 | } | 2788 | } |
2789 | { | 2789 | { |
2790 | object Term = arg1; | 2790 | object Term = arg1; |
2791 | object State = arg2; | 2791 | object State = arg2; |
2792 | object Code = arg3; | 2792 | object Code = arg3; |
2793 | Variable ModuleCode = new Variable(); | 2793 | Variable ModuleCode = new Variable(); |
2794 | if (YP.atom(Term)) | 2794 | if (YP.atom(Term)) |
2795 | { | 2795 | { |
2796 | foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode)) | 2796 | foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode)) |
2797 | { | 2797 | { |
2798 | foreach (bool l4 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), new ListPair(ModuleCode, Atom.NIL))))) | 2798 | foreach (bool l4 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), new ListPair(ModuleCode, Atom.NIL))))) |
2799 | { | 2799 | { |
2800 | yield return true; | 2800 | yield return true; |
2801 | yield break; | 2801 | yield break; |
2802 | } | 2802 | } |
2803 | goto cutIf1; | 2803 | goto cutIf1; |
2804 | } | 2804 | } |
2805 | foreach (bool l3 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), Atom.NIL)))) | 2805 | foreach (bool l3 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), Atom.NIL)))) |
2806 | { | 2806 | { |
2807 | yield return true; | 2807 | yield return true; |
2808 | yield break; | 2808 | yield break; |
2809 | } | 2809 | } |
2810 | cutIf1: | 2810 | cutIf1: |
2811 | { } | 2811 | { } |
2812 | } | 2812 | } |
2813 | } | 2813 | } |
2814 | { | 2814 | { |
2815 | object State = arg2; | 2815 | object State = arg2; |
2816 | Variable First = new Variable(); | 2816 | Variable First = new Variable(); |
2817 | Variable Rest = new Variable(); | 2817 | Variable Rest = new Variable(); |
2818 | Variable Arg1 = new Variable(); | 2818 | Variable Arg1 = new Variable(); |
2819 | Variable Arg2 = new Variable(); | 2819 | Variable Arg2 = new Variable(); |
2820 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) | 2820 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) |
2821 | { | 2821 | { |
2822 | foreach (bool l3 in YP.unify(arg3, new Functor2(@"new", Atom.a(@"ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))) | 2822 | foreach (bool l3 in YP.unify(arg3, new Functor2(@"new", Atom.a(@"ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))) |
2823 | { | 2823 | { |
2824 | foreach (bool l4 in compileTerm(First, State, Arg1)) | 2824 | foreach (bool l4 in compileTerm(First, State, Arg1)) |
2825 | { | 2825 | { |
2826 | foreach (bool l5 in compileTerm(Rest, State, Arg2)) | 2826 | foreach (bool l5 in compileTerm(Rest, State, Arg2)) |
2827 | { | 2827 | { |
2828 | yield return true; | 2828 | yield return true; |
2829 | yield break; | 2829 | yield break; |
2830 | } | 2830 | } |
2831 | } | 2831 | } |
2832 | } | 2832 | } |
2833 | } | 2833 | } |
2834 | } | 2834 | } |
2835 | { | 2835 | { |
2836 | object Term = arg1; | 2836 | object Term = arg1; |
2837 | object State = arg2; | 2837 | object State = arg2; |
2838 | object Result = arg3; | 2838 | object Result = arg3; |
2839 | Variable Name = new Variable(); | 2839 | Variable Name = new Variable(); |
2840 | Variable TermArgs = new Variable(); | 2840 | Variable TermArgs = new Variable(); |
2841 | Variable x6 = new Variable(); | 2841 | Variable x6 = new Variable(); |
2842 | Variable Arity = new Variable(); | 2842 | Variable Arity = new Variable(); |
2843 | Variable ModuleCode = new Variable(); | 2843 | Variable ModuleCode = new Variable(); |
2844 | Variable NameCode = new Variable(); | 2844 | Variable NameCode = new Variable(); |
2845 | Variable X1 = new Variable(); | 2845 | Variable X1 = new Variable(); |
2846 | Variable Arg1 = new Variable(); | 2846 | Variable Arg1 = new Variable(); |
2847 | Variable X2 = new Variable(); | 2847 | Variable X2 = new Variable(); |
2848 | Variable Arg2 = new Variable(); | 2848 | Variable Arg2 = new Variable(); |
2849 | Variable X3 = new Variable(); | 2849 | Variable X3 = new Variable(); |
2850 | Variable Arg3 = new Variable(); | 2850 | Variable Arg3 = new Variable(); |
2851 | Variable Args = new Variable(); | 2851 | Variable Args = new Variable(); |
2852 | foreach (bool l2 in YP.univ(Term, new ListPair(Name, TermArgs))) | 2852 | foreach (bool l2 in YP.univ(Term, new ListPair(Name, TermArgs))) |
2853 | { | 2853 | { |
2854 | if (YP.termEqual(TermArgs, Atom.NIL)) | 2854 | if (YP.termEqual(TermArgs, Atom.NIL)) |
2855 | { | 2855 | { |
2856 | foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name))) | 2856 | foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name))) |
2857 | { | 2857 | { |
2858 | yield return true; | 2858 | yield return true; |
2859 | yield break; | 2859 | yield break; |
2860 | } | 2860 | } |
2861 | goto cutIf2; | 2861 | goto cutIf2; |
2862 | } | 2862 | } |
2863 | foreach (bool l3 in YP.functor(Term, x6, Arity)) | 2863 | foreach (bool l3 in YP.functor(Term, x6, Arity)) |
2864 | { | 2864 | { |
2865 | foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode)) | 2865 | foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode)) |
2866 | { | 2866 | { |
2867 | foreach (bool l5 in YP.unify(NameCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Name), new ListPair(ModuleCode, Atom.NIL))))) | 2867 | foreach (bool l5 in YP.unify(NameCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Name), new ListPair(ModuleCode, Atom.NIL))))) |
2868 | { | 2868 | { |
2869 | foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) | 2869 | foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) |
2870 | { | 2870 | { |
2871 | foreach (bool l7 in compileTerm(X1, State, Arg1)) | 2871 | foreach (bool l7 in compileTerm(X1, State, Arg1)) |
2872 | { | 2872 | { |
2873 | foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL))))) | 2873 | foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL))))) |
2874 | { | 2874 | { |
2875 | yield return true; | 2875 | yield return true; |
2876 | yield break; | 2876 | yield break; |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | goto cutIf4; | 2879 | goto cutIf4; |
2880 | } | 2880 | } |
2881 | foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL)))) | 2881 | foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL)))) |
2882 | { | 2882 | { |
2883 | foreach (bool l7 in compileTerm(X1, State, Arg1)) | 2883 | foreach (bool l7 in compileTerm(X1, State, Arg1)) |
2884 | { | 2884 | { |
2885 | foreach (bool l8 in compileTerm(X2, State, Arg2)) | 2885 | foreach (bool l8 in compileTerm(X2, State, Arg2)) |
2886 | { | 2886 | { |
2887 | foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) | 2887 | foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) |
2888 | { | 2888 | { |
2889 | yield return true; | 2889 | yield return true; |
2890 | yield break; | 2890 | yield break; |
2891 | } | 2891 | } |
2892 | } | 2892 | } |
2893 | } | 2893 | } |
2894 | goto cutIf5; | 2894 | goto cutIf5; |
2895 | } | 2895 | } |
2896 | foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) | 2896 | foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) |
2897 | { | 2897 | { |
2898 | foreach (bool l7 in compileTerm(X1, State, Arg1)) | 2898 | foreach (bool l7 in compileTerm(X1, State, Arg1)) |
2899 | { | 2899 | { |
2900 | foreach (bool l8 in compileTerm(X2, State, Arg2)) | 2900 | foreach (bool l8 in compileTerm(X2, State, Arg2)) |
2901 | { | 2901 | { |
2902 | foreach (bool l9 in compileTerm(X3, State, Arg3)) | 2902 | foreach (bool l9 in compileTerm(X3, State, Arg3)) |
2903 | { | 2903 | { |
2904 | foreach (bool l10 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL))))))) | 2904 | foreach (bool l10 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL))))))) |
2905 | { | 2905 | { |
2906 | yield return true; | 2906 | yield return true; |
2907 | yield break; | 2907 | yield break; |
2908 | } | 2908 | } |
2909 | } | 2909 | } |
2910 | } | 2910 | } |
2911 | } | 2911 | } |
2912 | } | 2912 | } |
2913 | foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args)) | 2913 | foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args)) |
2914 | { | 2914 | { |
2915 | foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL))))) | 2915 | foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL))))) |
2916 | { | 2916 | { |
2917 | yield return true; | 2917 | yield return true; |
2918 | yield break; | 2918 | yield break; |
2919 | } | 2919 | } |
2920 | } | 2920 | } |
2921 | cutIf5: | 2921 | cutIf5: |
2922 | cutIf4: | 2922 | cutIf4: |
2923 | { } | 2923 | { } |
2924 | } | 2924 | } |
2925 | goto cutIf3; | 2925 | goto cutIf3; |
2926 | } | 2926 | } |
2927 | foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name))) | 2927 | foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name))) |
2928 | { | 2928 | { |
2929 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) | 2929 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) |
2930 | { | 2930 | { |
2931 | foreach (bool l6 in compileTerm(X1, State, Arg1)) | 2931 | foreach (bool l6 in compileTerm(X1, State, Arg1)) |
2932 | { | 2932 | { |
2933 | foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL))))) | 2933 | foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL))))) |
2934 | { | 2934 | { |
2935 | yield return true; | 2935 | yield return true; |
2936 | yield break; | 2936 | yield break; |
2937 | } | 2937 | } |
2938 | } | 2938 | } |
2939 | goto cutIf6; | 2939 | goto cutIf6; |
2940 | } | 2940 | } |
2941 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL)))) | 2941 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL)))) |
2942 | { | 2942 | { |
2943 | foreach (bool l6 in compileTerm(X1, State, Arg1)) | 2943 | foreach (bool l6 in compileTerm(X1, State, Arg1)) |
2944 | { | 2944 | { |
2945 | foreach (bool l7 in compileTerm(X2, State, Arg2)) | 2945 | foreach (bool l7 in compileTerm(X2, State, Arg2)) |
2946 | { | 2946 | { |
2947 | foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) | 2947 | foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) |
2948 | { | 2948 | { |
2949 | yield return true; | 2949 | yield return true; |
2950 | yield break; | 2950 | yield break; |
2951 | } | 2951 | } |
2952 | } | 2952 | } |
2953 | } | 2953 | } |
2954 | goto cutIf7; | 2954 | goto cutIf7; |
2955 | } | 2955 | } |
2956 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) | 2956 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) |
2957 | { | 2957 | { |
2958 | foreach (bool l6 in compileTerm(X1, State, Arg1)) | 2958 | foreach (bool l6 in compileTerm(X1, State, Arg1)) |
2959 | { | 2959 | { |
2960 | foreach (bool l7 in compileTerm(X2, State, Arg2)) | 2960 | foreach (bool l7 in compileTerm(X2, State, Arg2)) |
2961 | { | 2961 | { |
2962 | foreach (bool l8 in compileTerm(X3, State, Arg3)) | 2962 | foreach (bool l8 in compileTerm(X3, State, Arg3)) |
2963 | { | 2963 | { |
2964 | foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL))))))) | 2964 | foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL))))))) |
2965 | { | 2965 | { |
2966 | yield return true; | 2966 | yield return true; |
2967 | yield break; | 2967 | yield break; |
2968 | } | 2968 | } |
2969 | } | 2969 | } |
2970 | } | 2970 | } |
2971 | } | 2971 | } |
2972 | } | 2972 | } |
2973 | foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args)) | 2973 | foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args)) |
2974 | { | 2974 | { |
2975 | foreach (bool l6 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL))))) | 2975 | foreach (bool l6 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL))))) |
2976 | { | 2976 | { |
2977 | yield return true; | 2977 | yield return true; |
2978 | yield break; | 2978 | yield break; |
2979 | } | 2979 | } |
2980 | } | 2980 | } |
2981 | cutIf7: | 2981 | cutIf7: |
2982 | cutIf6: | 2982 | cutIf6: |
2983 | { } | 2983 | { } |
2984 | } | 2984 | } |
2985 | cutIf3: | 2985 | cutIf3: |
2986 | { } | 2986 | { } |
2987 | } | 2987 | } |
2988 | cutIf2: | 2988 | cutIf2: |
2989 | { } | 2989 | { } |
2990 | } | 2990 | } |
2991 | } | 2991 | } |
2992 | } | 2992 | } |
2993 | 2993 | ||
2994 | public static IEnumerable<bool> compileAtomModule(object Name, object Arity, object State, object ModuleCode) | 2994 | public static IEnumerable<bool> compileAtomModule(object Name, object Arity, object State, object ModuleCode) |
2995 | { | 2995 | { |
2996 | { | 2996 | { |
2997 | if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) | 2997 | if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@""))) |
2998 | { | 2998 | { |
2999 | foreach (bool l3 in YP.unify(ModuleCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Atom.a(@"")), Atom.NIL)))) | 2999 | foreach (bool l3 in YP.unify(ModuleCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Atom.a(@"")), Atom.NIL)))) |
3000 | { | 3000 | { |
3001 | yield return true; | 3001 | yield return true; |
3002 | yield break; | 3002 | yield break; |
3003 | } | 3003 | } |
3004 | } | 3004 | } |
3005 | } | 3005 | } |
3006 | } | 3006 | } |
3007 | 3007 | ||
3008 | public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3) | 3008 | public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3) |
3009 | { | 3009 | { |
3010 | { | 3010 | { |
3011 | object _State = arg2; | 3011 | object _State = arg2; |
3012 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 3012 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
3013 | { | 3013 | { |
3014 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) | 3014 | foreach (bool l3 in YP.unify(arg3, Atom.NIL)) |
3015 | { | 3015 | { |
3016 | yield return true; | 3016 | yield return true; |
3017 | yield break; | 3017 | yield break; |
3018 | } | 3018 | } |
3019 | } | 3019 | } |
3020 | } | 3020 | } |
3021 | { | 3021 | { |
3022 | object State = arg2; | 3022 | object State = arg2; |
3023 | Variable First = new Variable(); | 3023 | Variable First = new Variable(); |
3024 | Variable Rest = new Variable(); | 3024 | Variable Rest = new Variable(); |
3025 | Variable FirstResult = new Variable(); | 3025 | Variable FirstResult = new Variable(); |
3026 | Variable RestResults = new Variable(); | 3026 | Variable RestResults = new Variable(); |
3027 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) | 3027 | foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) |
3028 | { | 3028 | { |
3029 | foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults))) | 3029 | foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults))) |
3030 | { | 3030 | { |
3031 | foreach (bool l4 in compileTerm(First, State, FirstResult)) | 3031 | foreach (bool l4 in compileTerm(First, State, FirstResult)) |
3032 | { | 3032 | { |
3033 | foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults)) | 3033 | foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults)) |
3034 | { | 3034 | { |
3035 | yield return true; | 3035 | yield return true; |
3036 | yield break; | 3036 | yield break; |
3037 | } | 3037 | } |
3038 | } | 3038 | } |
3039 | } | 3039 | } |
3040 | } | 3040 | } |
3041 | } | 3041 | } |
3042 | } | 3042 | } |
3043 | 3043 | ||
3044 | public static IEnumerable<bool> compileExpression(object Term, object State, object Result) | 3044 | public static IEnumerable<bool> compileExpression(object Term, object State, object Result) |
3045 | { | 3045 | { |
3046 | { | 3046 | { |
3047 | Variable Name = new Variable(); | 3047 | Variable Name = new Variable(); |
3048 | Variable TermArgs = new Variable(); | 3048 | Variable TermArgs = new Variable(); |
3049 | Variable X1 = new Variable(); | 3049 | Variable X1 = new Variable(); |
3050 | Variable FunctionName = new Variable(); | 3050 | Variable FunctionName = new Variable(); |
3051 | Variable Arg1 = new Variable(); | 3051 | Variable Arg1 = new Variable(); |
3052 | Variable x9 = new Variable(); | 3052 | Variable x9 = new Variable(); |
3053 | Variable X2 = new Variable(); | 3053 | Variable X2 = new Variable(); |
3054 | Variable Arg2 = new Variable(); | 3054 | Variable Arg2 = new Variable(); |
3055 | if (YP.nonvar(Term)) | 3055 | if (YP.nonvar(Term)) |
3056 | { | 3056 | { |
3057 | foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs))) | 3057 | foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs))) |
3058 | { | 3058 | { |
3059 | if (YP.atom(Name)) | 3059 | if (YP.atom(Name)) |
3060 | { | 3060 | { |
3061 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) | 3061 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL))) |
3062 | { | 3062 | { |
3063 | foreach (bool l6 in unaryFunction(Name, FunctionName)) | 3063 | foreach (bool l6 in unaryFunction(Name, FunctionName)) |
3064 | { | 3064 | { |
3065 | foreach (bool l7 in compileExpression(X1, State, Arg1)) | 3065 | foreach (bool l7 in compileExpression(X1, State, Arg1)) |
3066 | { | 3066 | { |
3067 | foreach (bool l8 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, Atom.NIL)))) | 3067 | foreach (bool l8 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, Atom.NIL)))) |
3068 | { | 3068 | { |
3069 | yield return true; | 3069 | yield return true; |
3070 | yield break; | 3070 | yield break; |
3071 | } | 3071 | } |
3072 | } | 3072 | } |
3073 | goto cutIf1; | 3073 | goto cutIf1; |
3074 | } | 3074 | } |
3075 | } | 3075 | } |
3076 | foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL))) | 3076 | foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL))) |
3077 | { | 3077 | { |
3078 | foreach (bool l6 in compileTerm(Term, State, Result)) | 3078 | foreach (bool l6 in compileTerm(Term, State, Result)) |
3079 | { | 3079 | { |
3080 | yield return true; | 3080 | yield return true; |
3081 | yield break; | 3081 | yield break; |
3082 | } | 3082 | } |
3083 | goto cutIf2; | 3083 | goto cutIf2; |
3084 | } | 3084 | } |
3085 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL)))) | 3085 | foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL)))) |
3086 | { | 3086 | { |
3087 | foreach (bool l6 in binaryFunction(Name, FunctionName)) | 3087 | foreach (bool l6 in binaryFunction(Name, FunctionName)) |
3088 | { | 3088 | { |
3089 | foreach (bool l7 in compileExpression(X1, State, Arg1)) | 3089 | foreach (bool l7 in compileExpression(X1, State, Arg1)) |
3090 | { | 3090 | { |
3091 | foreach (bool l8 in compileExpression(X2, State, Arg2)) | 3091 | foreach (bool l8 in compileExpression(X2, State, Arg2)) |
3092 | { | 3092 | { |
3093 | foreach (bool l9 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))) | 3093 | foreach (bool l9 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))) |
3094 | { | 3094 | { |
3095 | yield return true; | 3095 | yield return true; |
3096 | yield break; | 3096 | yield break; |
3097 | } | 3097 | } |
3098 | } | 3098 | } |
3099 | } | 3099 | } |
3100 | goto cutIf3; | 3100 | goto cutIf3; |
3101 | } | 3101 | } |
3102 | } | 3102 | } |
3103 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), Name), Atom.a(@"Not an expression function"))); | 3103 | YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), Name), Atom.a(@"Not an expression function"))); |
3104 | yield return false; | 3104 | yield return false; |
3105 | cutIf3: | 3105 | cutIf3: |
3106 | cutIf2: | 3106 | cutIf2: |
3107 | cutIf1: | 3107 | cutIf1: |
3108 | { } | 3108 | { } |
3109 | } | 3109 | } |
3110 | } | 3110 | } |
3111 | } | 3111 | } |
3112 | } | 3112 | } |
3113 | { | 3113 | { |
3114 | foreach (bool l2 in compileTerm(Term, State, Result)) | 3114 | foreach (bool l2 in compileTerm(Term, State, Result)) |
3115 | { | 3115 | { |
3116 | yield return true; | 3116 | yield return true; |
3117 | yield break; | 3117 | yield break; |
3118 | } | 3118 | } |
3119 | } | 3119 | } |
3120 | } | 3120 | } |
3121 | 3121 | ||
3122 | public static IEnumerable<bool> unaryFunction(object arg1, object arg2) | 3122 | public static IEnumerable<bool> unaryFunction(object arg1, object arg2) |
3123 | { | 3123 | { |
3124 | { | 3124 | { |
3125 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) | 3125 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) |
3126 | { | 3126 | { |
3127 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate"))) | 3127 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate"))) |
3128 | { | 3128 | { |
3129 | yield return true; | 3129 | yield return true; |
3130 | yield break; | 3130 | yield break; |
3131 | } | 3131 | } |
3132 | } | 3132 | } |
3133 | } | 3133 | } |
3134 | { | 3134 | { |
3135 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs"))) | 3135 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs"))) |
3136 | { | 3136 | { |
3137 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs"))) | 3137 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs"))) |
3138 | { | 3138 | { |
3139 | yield return true; | 3139 | yield return true; |
3140 | yield break; | 3140 | yield break; |
3141 | } | 3141 | } |
3142 | } | 3142 | } |
3143 | } | 3143 | } |
3144 | { | 3144 | { |
3145 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign"))) | 3145 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign"))) |
3146 | { | 3146 | { |
3147 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign"))) | 3147 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign"))) |
3148 | { | 3148 | { |
3149 | yield return true; | 3149 | yield return true; |
3150 | yield break; | 3150 | yield break; |
3151 | } | 3151 | } |
3152 | } | 3152 | } |
3153 | } | 3153 | } |
3154 | { | 3154 | { |
3155 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) | 3155 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) |
3156 | { | 3156 | { |
3157 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor"))) | 3157 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor"))) |
3158 | { | 3158 | { |
3159 | yield return true; | 3159 | yield return true; |
3160 | yield break; | 3160 | yield break; |
3161 | } | 3161 | } |
3162 | } | 3162 | } |
3163 | } | 3163 | } |
3164 | { | 3164 | { |
3165 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate"))) | 3165 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate"))) |
3166 | { | 3166 | { |
3167 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate"))) | 3167 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate"))) |
3168 | { | 3168 | { |
3169 | yield return true; | 3169 | yield return true; |
3170 | yield break; | 3170 | yield break; |
3171 | } | 3171 | } |
3172 | } | 3172 | } |
3173 | } | 3173 | } |
3174 | { | 3174 | { |
3175 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"round"))) | 3175 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"round"))) |
3176 | { | 3176 | { |
3177 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round"))) | 3177 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round"))) |
3178 | { | 3178 | { |
3179 | yield return true; | 3179 | yield return true; |
3180 | yield break; | 3180 | yield break; |
3181 | } | 3181 | } |
3182 | } | 3182 | } |
3183 | } | 3183 | } |
3184 | { | 3184 | { |
3185 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) | 3185 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor"))) |
3186 | { | 3186 | { |
3187 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling"))) | 3187 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling"))) |
3188 | { | 3188 | { |
3189 | yield return true; | 3189 | yield return true; |
3190 | yield break; | 3190 | yield break; |
3191 | } | 3191 | } |
3192 | } | 3192 | } |
3193 | } | 3193 | } |
3194 | { | 3194 | { |
3195 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin"))) | 3195 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin"))) |
3196 | { | 3196 | { |
3197 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin"))) | 3197 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin"))) |
3198 | { | 3198 | { |
3199 | yield return true; | 3199 | yield return true; |
3200 | yield break; | 3200 | yield break; |
3201 | } | 3201 | } |
3202 | } | 3202 | } |
3203 | } | 3203 | } |
3204 | { | 3204 | { |
3205 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos"))) | 3205 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos"))) |
3206 | { | 3206 | { |
3207 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos"))) | 3207 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos"))) |
3208 | { | 3208 | { |
3209 | yield return true; | 3209 | yield return true; |
3210 | yield break; | 3210 | yield break; |
3211 | } | 3211 | } |
3212 | } | 3212 | } |
3213 | } | 3213 | } |
3214 | { | 3214 | { |
3215 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan"))) | 3215 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan"))) |
3216 | { | 3216 | { |
3217 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan"))) | 3217 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan"))) |
3218 | { | 3218 | { |
3219 | yield return true; | 3219 | yield return true; |
3220 | yield break; | 3220 | yield break; |
3221 | } | 3221 | } |
3222 | } | 3222 | } |
3223 | } | 3223 | } |
3224 | { | 3224 | { |
3225 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp"))) | 3225 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp"))) |
3226 | { | 3226 | { |
3227 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp"))) | 3227 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp"))) |
3228 | { | 3228 | { |
3229 | yield return true; | 3229 | yield return true; |
3230 | yield break; | 3230 | yield break; |
3231 | } | 3231 | } |
3232 | } | 3232 | } |
3233 | } | 3233 | } |
3234 | { | 3234 | { |
3235 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"log"))) | 3235 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"log"))) |
3236 | { | 3236 | { |
3237 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log"))) | 3237 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log"))) |
3238 | { | 3238 | { |
3239 | yield return true; | 3239 | yield return true; |
3240 | yield break; | 3240 | yield break; |
3241 | } | 3241 | } |
3242 | } | 3242 | } |
3243 | } | 3243 | } |
3244 | { | 3244 | { |
3245 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt"))) | 3245 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt"))) |
3246 | { | 3246 | { |
3247 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt"))) | 3247 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt"))) |
3248 | { | 3248 | { |
3249 | yield return true; | 3249 | yield return true; |
3250 | yield break; | 3250 | yield break; |
3251 | } | 3251 | } |
3252 | } | 3252 | } |
3253 | } | 3253 | } |
3254 | { | 3254 | { |
3255 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"\"))) | 3255 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"\"))) |
3256 | { | 3256 | { |
3257 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseComplement"))) | 3257 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseComplement"))) |
3258 | { | 3258 | { |
3259 | yield return true; | 3259 | yield return true; |
3260 | yield break; | 3260 | yield break; |
3261 | } | 3261 | } |
3262 | } | 3262 | } |
3263 | } | 3263 | } |
3264 | } | 3264 | } |
3265 | 3265 | ||
3266 | public static IEnumerable<bool> binaryFunction(object arg1, object arg2) | 3266 | public static IEnumerable<bool> binaryFunction(object arg1, object arg2) |
3267 | { | 3267 | { |
3268 | { | 3268 | { |
3269 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"+"))) | 3269 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"+"))) |
3270 | { | 3270 | { |
3271 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add"))) | 3271 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add"))) |
3272 | { | 3272 | { |
3273 | yield return true; | 3273 | yield return true; |
3274 | yield break; | 3274 | yield break; |
3275 | } | 3275 | } |
3276 | } | 3276 | } |
3277 | } | 3277 | } |
3278 | { | 3278 | { |
3279 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) | 3279 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"-"))) |
3280 | { | 3280 | { |
3281 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract"))) | 3281 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract"))) |
3282 | { | 3282 | { |
3283 | yield return true; | 3283 | yield return true; |
3284 | yield break; | 3284 | yield break; |
3285 | } | 3285 | } |
3286 | } | 3286 | } |
3287 | } | 3287 | } |
3288 | { | 3288 | { |
3289 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"*"))) | 3289 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"*"))) |
3290 | { | 3290 | { |
3291 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply"))) | 3291 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply"))) |
3292 | { | 3292 | { |
3293 | yield return true; | 3293 | yield return true; |
3294 | yield break; | 3294 | yield break; |
3295 | } | 3295 | } |
3296 | } | 3296 | } |
3297 | } | 3297 | } |
3298 | { | 3298 | { |
3299 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"/"))) | 3299 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"/"))) |
3300 | { | 3300 | { |
3301 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide"))) | 3301 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide"))) |
3302 | { | 3302 | { |
3303 | yield return true; | 3303 | yield return true; |
3304 | yield break; | 3304 | yield break; |
3305 | } | 3305 | } |
3306 | } | 3306 | } |
3307 | } | 3307 | } |
3308 | { | 3308 | { |
3309 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"//"))) | 3309 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"//"))) |
3310 | { | 3310 | { |
3311 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide"))) | 3311 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide"))) |
3312 | { | 3312 | { |
3313 | yield return true; | 3313 | yield return true; |
3314 | yield break; | 3314 | yield break; |
3315 | } | 3315 | } |
3316 | } | 3316 | } |
3317 | } | 3317 | } |
3318 | { | 3318 | { |
3319 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod"))) | 3319 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod"))) |
3320 | { | 3320 | { |
3321 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod"))) | 3321 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod"))) |
3322 | { | 3322 | { |
3323 | yield return true; | 3323 | yield return true; |
3324 | yield break; | 3324 | yield break; |
3325 | } | 3325 | } |
3326 | } | 3326 | } |
3327 | } | 3327 | } |
3328 | { | 3328 | { |
3329 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"**"))) | 3329 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"**"))) |
3330 | { | 3330 | { |
3331 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow"))) | 3331 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow"))) |
3332 | { | 3332 | { |
3333 | yield return true; | 3333 | yield return true; |
3334 | yield break; | 3334 | yield break; |
3335 | } | 3335 | } |
3336 | } | 3336 | } |
3337 | } | 3337 | } |
3338 | { | 3338 | { |
3339 | foreach (bool l2 in YP.unify(arg1, Atom.a(@">>"))) | 3339 | foreach (bool l2 in YP.unify(arg1, Atom.a(@">>"))) |
3340 | { | 3340 | { |
3341 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight"))) | 3341 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight"))) |
3342 | { | 3342 | { |
3343 | yield return true; | 3343 | yield return true; |
3344 | yield break; | 3344 | yield break; |
3345 | } | 3345 | } |
3346 | } | 3346 | } |
3347 | } | 3347 | } |
3348 | { | 3348 | { |
3349 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<"))) | 3349 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<"))) |
3350 | { | 3350 | { |
3351 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft"))) | 3351 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft"))) |
3352 | { | 3352 | { |
3353 | yield return true; | 3353 | yield return true; |
3354 | yield break; | 3354 | yield break; |
3355 | } | 3355 | } |
3356 | } | 3356 | } |
3357 | } | 3357 | } |
3358 | { | 3358 | { |
3359 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\"))) | 3359 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\"))) |
3360 | { | 3360 | { |
3361 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd"))) | 3361 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd"))) |
3362 | { | 3362 | { |
3363 | yield return true; | 3363 | yield return true; |
3364 | yield break; | 3364 | yield break; |
3365 | } | 3365 | } |
3366 | } | 3366 | } |
3367 | } | 3367 | } |
3368 | { | 3368 | { |
3369 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/"))) | 3369 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/"))) |
3370 | { | 3370 | { |
3371 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr"))) | 3371 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr"))) |
3372 | { | 3372 | { |
3373 | yield return true; | 3373 | yield return true; |
3374 | yield break; | 3374 | yield break; |
3375 | } | 3375 | } |
3376 | } | 3376 | } |
3377 | } | 3377 | } |
3378 | { | 3378 | { |
3379 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"min"))) | 3379 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"min"))) |
3380 | { | 3380 | { |
3381 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min"))) | 3381 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min"))) |
3382 | { | 3382 | { |
3383 | yield return true; | 3383 | yield return true; |
3384 | yield break; | 3384 | yield break; |
3385 | } | 3385 | } |
3386 | } | 3386 | } |
3387 | } | 3387 | } |
3388 | { | 3388 | { |
3389 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"max"))) | 3389 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"max"))) |
3390 | { | 3390 | { |
3391 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max"))) | 3391 | foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max"))) |
3392 | { | 3392 | { |
3393 | yield return true; | 3393 | yield return true; |
3394 | yield break; | 3394 | yield break; |
3395 | } | 3395 | } |
3396 | } | 3396 | } |
3397 | } | 3397 | } |
3398 | } | 3398 | } |
3399 | 3399 | ||
3400 | public static void convertFunctionCSharp(object arg1) | 3400 | public static void convertFunctionCSharp(object arg1) |
3401 | { | 3401 | { |
3402 | { | 3402 | { |
3403 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) | 3403 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) |
3404 | { | 3404 | { |
3405 | YP.write(Atom.a(@"class YPInnerClass {}")); | 3405 | YP.write(Atom.a(@"class YPInnerClass {}")); |
3406 | YP.nl(); | 3406 | YP.nl(); |
3407 | YP.write(Atom.a(@"static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }")); | 3407 | YP.write(Atom.a(@"static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }")); |
3408 | YP.nl(); | 3408 | YP.nl(); |
3409 | YP.nl(); | 3409 | YP.nl(); |
3410 | return; | 3410 | return; |
3411 | } | 3411 | } |
3412 | } | 3412 | } |
3413 | { | 3413 | { |
3414 | Variable ReturnType = new Variable(); | 3414 | Variable ReturnType = new Variable(); |
3415 | Variable Name = new Variable(); | 3415 | Variable Name = new Variable(); |
3416 | Variable ArgList = new Variable(); | 3416 | Variable ArgList = new Variable(); |
3417 | Variable Body = new Variable(); | 3417 | Variable Body = new Variable(); |
3418 | Variable Level = new Variable(); | 3418 | Variable Level = new Variable(); |
3419 | foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { ReturnType, Name, ArgList, Body }))) | 3419 | foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { ReturnType, Name, ArgList, Body }))) |
3420 | { | 3420 | { |
3421 | YP.write(Atom.a(@"public static ")); | 3421 | YP.write(Atom.a(@"public static ")); |
3422 | YP.write(ReturnType); | 3422 | YP.write(ReturnType); |
3423 | YP.write(Atom.a(@" ")); | 3423 | YP.write(Atom.a(@" ")); |
3424 | YP.write(Name); | 3424 | YP.write(Name); |
3425 | YP.write(Atom.a(@"(")); | 3425 | YP.write(Atom.a(@"(")); |
3426 | convertArgListCSharp(ArgList); | 3426 | convertArgListCSharp(ArgList); |
3427 | YP.write(Atom.a(@") {")); | 3427 | YP.write(Atom.a(@") {")); |
3428 | YP.nl(); | 3428 | YP.nl(); |
3429 | foreach (bool l3 in YP.unify(Level, 1)) | 3429 | foreach (bool l3 in YP.unify(Level, 1)) |
3430 | { | 3430 | { |
3431 | convertStatementListCSharp(Body, Level); | 3431 | convertStatementListCSharp(Body, Level); |
3432 | YP.write(Atom.a(@"}")); | 3432 | YP.write(Atom.a(@"}")); |
3433 | YP.nl(); | 3433 | YP.nl(); |
3434 | YP.nl(); | 3434 | YP.nl(); |
3435 | return; | 3435 | return; |
3436 | } | 3436 | } |
3437 | } | 3437 | } |
3438 | } | 3438 | } |
3439 | } | 3439 | } |
3440 | 3440 | ||
3441 | public static IEnumerable<bool> convertStatementListCSharp(object arg1, object x1, object x2) | 3441 | public static IEnumerable<bool> convertStatementListCSharp(object arg1, object x1, object x2) |
3442 | { | 3442 | { |
3443 | { | 3443 | { |
3444 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 3444 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
3445 | { | 3445 | { |
3446 | yield return true; | 3446 | yield return true; |
3447 | yield break; | 3447 | yield break; |
3448 | } | 3448 | } |
3449 | } | 3449 | } |
3450 | } | 3450 | } |
3451 | 3451 | ||
3452 | public static void convertStatementListCSharp(object arg1, object Level) | 3452 | public static void convertStatementListCSharp(object arg1, object Level) |
3453 | { | 3453 | { |
3454 | { | 3454 | { |
3455 | Variable Name = new Variable(); | 3455 | Variable Name = new Variable(); |
3456 | Variable Body = new Variable(); | 3456 | Variable Body = new Variable(); |
3457 | Variable RestStatements = new Variable(); | 3457 | Variable RestStatements = new Variable(); |
3458 | Variable NewStatements = new Variable(); | 3458 | Variable NewStatements = new Variable(); |
3459 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) | 3459 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) |
3460 | { | 3460 | { |
3461 | foreach (bool l3 in append(Body, new ListPair(new Functor1(@"label", Name), RestStatements), NewStatements)) | 3461 | foreach (bool l3 in append(Body, new ListPair(new Functor1(@"label", Name), RestStatements), NewStatements)) |
3462 | { | 3462 | { |
3463 | convertStatementListCSharp(NewStatements, Level); | 3463 | convertStatementListCSharp(NewStatements, Level); |
3464 | return; | 3464 | return; |
3465 | } | 3465 | } |
3466 | } | 3466 | } |
3467 | } | 3467 | } |
3468 | { | 3468 | { |
3469 | Variable Type = new Variable(); | 3469 | Variable Type = new Variable(); |
3470 | Variable Name = new Variable(); | 3470 | Variable Name = new Variable(); |
3471 | Variable Expression = new Variable(); | 3471 | Variable Expression = new Variable(); |
3472 | Variable RestStatements = new Variable(); | 3472 | Variable RestStatements = new Variable(); |
3473 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", Type, Name, Expression), RestStatements))) | 3473 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", Type, Name, Expression), RestStatements))) |
3474 | { | 3474 | { |
3475 | convertIndentationCSharp(Level); | 3475 | convertIndentationCSharp(Level); |
3476 | YP.write(Type); | 3476 | YP.write(Type); |
3477 | YP.write(Atom.a(@" ")); | 3477 | YP.write(Atom.a(@" ")); |
3478 | YP.write(Name); | 3478 | YP.write(Name); |
3479 | YP.write(Atom.a(@" = ")); | 3479 | YP.write(Atom.a(@" = ")); |
3480 | convertExpressionCSharp(Expression); | 3480 | convertExpressionCSharp(Expression); |
3481 | YP.write(Atom.a(@";")); | 3481 | YP.write(Atom.a(@";")); |
3482 | YP.nl(); | 3482 | YP.nl(); |
3483 | convertStatementListCSharp(RestStatements, Level); | 3483 | convertStatementListCSharp(RestStatements, Level); |
3484 | return; | 3484 | return; |
3485 | } | 3485 | } |
3486 | } | 3486 | } |
3487 | { | 3487 | { |
3488 | Variable Name = new Variable(); | 3488 | Variable Name = new Variable(); |
3489 | Variable Expression = new Variable(); | 3489 | Variable Expression = new Variable(); |
3490 | Variable RestStatements = new Variable(); | 3490 | Variable RestStatements = new Variable(); |
3491 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) | 3491 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) |
3492 | { | 3492 | { |
3493 | convertIndentationCSharp(Level); | 3493 | convertIndentationCSharp(Level); |
3494 | YP.write(Name); | 3494 | YP.write(Name); |
3495 | YP.write(Atom.a(@" = ")); | 3495 | YP.write(Atom.a(@" = ")); |
3496 | convertExpressionCSharp(Expression); | 3496 | convertExpressionCSharp(Expression); |
3497 | YP.write(Atom.a(@";")); | 3497 | YP.write(Atom.a(@";")); |
3498 | YP.nl(); | 3498 | YP.nl(); |
3499 | convertStatementListCSharp(RestStatements, Level); | 3499 | convertStatementListCSharp(RestStatements, Level); |
3500 | return; | 3500 | return; |
3501 | } | 3501 | } |
3502 | } | 3502 | } |
3503 | { | 3503 | { |
3504 | Variable RestStatements = new Variable(); | 3504 | Variable RestStatements = new Variable(); |
3505 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) | 3505 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) |
3506 | { | 3506 | { |
3507 | convertIndentationCSharp(Level); | 3507 | convertIndentationCSharp(Level); |
3508 | YP.write(Atom.a(@"yield return true;")); | 3508 | YP.write(Atom.a(@"yield return true;")); |
3509 | YP.nl(); | 3509 | YP.nl(); |
3510 | convertStatementListCSharp(RestStatements, Level); | 3510 | convertStatementListCSharp(RestStatements, Level); |
3511 | return; | 3511 | return; |
3512 | } | 3512 | } |
3513 | } | 3513 | } |
3514 | { | 3514 | { |
3515 | Variable RestStatements = new Variable(); | 3515 | Variable RestStatements = new Variable(); |
3516 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) | 3516 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) |
3517 | { | 3517 | { |
3518 | convertIndentationCSharp(Level); | 3518 | convertIndentationCSharp(Level); |
3519 | YP.write(Atom.a(@"yield return false;")); | 3519 | YP.write(Atom.a(@"yield return false;")); |
3520 | YP.nl(); | 3520 | YP.nl(); |
3521 | convertStatementListCSharp(RestStatements, Level); | 3521 | convertStatementListCSharp(RestStatements, Level); |
3522 | return; | 3522 | return; |
3523 | } | 3523 | } |
3524 | } | 3524 | } |
3525 | { | 3525 | { |
3526 | Variable RestStatements = new Variable(); | 3526 | Variable RestStatements = new Variable(); |
3527 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) | 3527 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) |
3528 | { | 3528 | { |
3529 | convertIndentationCSharp(Level); | 3529 | convertIndentationCSharp(Level); |
3530 | YP.write(Atom.a(@"yield break;")); | 3530 | YP.write(Atom.a(@"yield break;")); |
3531 | YP.nl(); | 3531 | YP.nl(); |
3532 | convertStatementListCSharp(RestStatements, Level); | 3532 | convertStatementListCSharp(RestStatements, Level); |
3533 | return; | 3533 | return; |
3534 | } | 3534 | } |
3535 | } | 3535 | } |
3536 | { | 3536 | { |
3537 | Variable RestStatements = new Variable(); | 3537 | Variable RestStatements = new Variable(); |
3538 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) | 3538 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) |
3539 | { | 3539 | { |
3540 | convertIndentationCSharp(Level); | 3540 | convertIndentationCSharp(Level); |
3541 | YP.write(Atom.a(@"return;")); | 3541 | YP.write(Atom.a(@"return;")); |
3542 | YP.nl(); | 3542 | YP.nl(); |
3543 | convertStatementListCSharp(RestStatements, Level); | 3543 | convertStatementListCSharp(RestStatements, Level); |
3544 | return; | 3544 | return; |
3545 | } | 3545 | } |
3546 | } | 3546 | } |
3547 | { | 3547 | { |
3548 | Variable RestStatements = new Variable(); | 3548 | Variable RestStatements = new Variable(); |
3549 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) | 3549 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) |
3550 | { | 3550 | { |
3551 | convertIndentationCSharp(Level); | 3551 | convertIndentationCSharp(Level); |
3552 | YP.write(Atom.a(@"return true;")); | 3552 | YP.write(Atom.a(@"return true;")); |
3553 | YP.nl(); | 3553 | YP.nl(); |
3554 | convertStatementListCSharp(RestStatements, Level); | 3554 | convertStatementListCSharp(RestStatements, Level); |
3555 | return; | 3555 | return; |
3556 | } | 3556 | } |
3557 | } | 3557 | } |
3558 | { | 3558 | { |
3559 | Variable RestStatements = new Variable(); | 3559 | Variable RestStatements = new Variable(); |
3560 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) | 3560 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) |
3561 | { | 3561 | { |
3562 | convertIndentationCSharp(Level); | 3562 | convertIndentationCSharp(Level); |
3563 | YP.write(Atom.a(@"return false;")); | 3563 | YP.write(Atom.a(@"return false;")); |
3564 | YP.nl(); | 3564 | YP.nl(); |
3565 | convertStatementListCSharp(RestStatements, Level); | 3565 | convertStatementListCSharp(RestStatements, Level); |
3566 | return; | 3566 | return; |
3567 | } | 3567 | } |
3568 | } | 3568 | } |
3569 | { | 3569 | { |
3570 | Variable Name = new Variable(); | 3570 | Variable Name = new Variable(); |
3571 | Variable RestStatements = new Variable(); | 3571 | Variable RestStatements = new Variable(); |
3572 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"label", Name), RestStatements))) | 3572 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"label", Name), RestStatements))) |
3573 | { | 3573 | { |
3574 | convertIndentationCSharp(Level); | 3574 | convertIndentationCSharp(Level); |
3575 | YP.write(Name); | 3575 | YP.write(Name); |
3576 | YP.write(Atom.a(@":")); | 3576 | YP.write(Atom.a(@":")); |
3577 | YP.nl(); | 3577 | YP.nl(); |
3578 | if (YP.termEqual(RestStatements, Atom.NIL)) | 3578 | if (YP.termEqual(RestStatements, Atom.NIL)) |
3579 | { | 3579 | { |
3580 | convertIndentationCSharp(Level); | 3580 | convertIndentationCSharp(Level); |
3581 | YP.write(Atom.a(@"{}")); | 3581 | YP.write(Atom.a(@"{}")); |
3582 | YP.nl(); | 3582 | YP.nl(); |
3583 | convertStatementListCSharp(RestStatements, Level); | 3583 | convertStatementListCSharp(RestStatements, Level); |
3584 | return; | 3584 | return; |
3585 | goto cutIf1; | 3585 | goto cutIf1; |
3586 | } | 3586 | } |
3587 | convertStatementListCSharp(RestStatements, Level); | 3587 | convertStatementListCSharp(RestStatements, Level); |
3588 | return; | 3588 | return; |
3589 | cutIf1: | 3589 | cutIf1: |
3590 | { } | 3590 | { } |
3591 | } | 3591 | } |
3592 | } | 3592 | } |
3593 | { | 3593 | { |
3594 | Variable Name = new Variable(); | 3594 | Variable Name = new Variable(); |
3595 | Variable RestStatements = new Variable(); | 3595 | Variable RestStatements = new Variable(); |
3596 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) | 3596 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) |
3597 | { | 3597 | { |
3598 | convertIndentationCSharp(Level); | 3598 | convertIndentationCSharp(Level); |
3599 | YP.write(Atom.a(@"goto ")); | 3599 | YP.write(Atom.a(@"goto ")); |
3600 | YP.write(Name); | 3600 | YP.write(Name); |
3601 | YP.write(Atom.a(@";")); | 3601 | YP.write(Atom.a(@";")); |
3602 | YP.nl(); | 3602 | YP.nl(); |
3603 | convertStatementListCSharp(RestStatements, Level); | 3603 | convertStatementListCSharp(RestStatements, Level); |
3604 | return; | 3604 | return; |
3605 | } | 3605 | } |
3606 | } | 3606 | } |
3607 | { | 3607 | { |
3608 | Variable Name = new Variable(); | 3608 | Variable Name = new Variable(); |
3609 | Variable ArgList = new Variable(); | 3609 | Variable ArgList = new Variable(); |
3610 | Variable RestStatements = new Variable(); | 3610 | Variable RestStatements = new Variable(); |
3611 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) | 3611 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) |
3612 | { | 3612 | { |
3613 | convertIndentationCSharp(Level); | 3613 | convertIndentationCSharp(Level); |
3614 | YP.write(Name); | 3614 | YP.write(Name); |
3615 | YP.write(Atom.a(@"(")); | 3615 | YP.write(Atom.a(@"(")); |
3616 | convertArgListCSharp(ArgList); | 3616 | convertArgListCSharp(ArgList); |
3617 | YP.write(Atom.a(@");")); | 3617 | YP.write(Atom.a(@");")); |
3618 | YP.nl(); | 3618 | YP.nl(); |
3619 | convertStatementListCSharp(RestStatements, Level); | 3619 | convertStatementListCSharp(RestStatements, Level); |
3620 | return; | 3620 | return; |
3621 | } | 3621 | } |
3622 | } | 3622 | } |
3623 | { | 3623 | { |
3624 | Variable Obj = new Variable(); | 3624 | Variable Obj = new Variable(); |
3625 | Variable Name = new Variable(); | 3625 | Variable Name = new Variable(); |
3626 | Variable ArgList = new Variable(); | 3626 | Variable ArgList = new Variable(); |
3627 | Variable RestStatements = new Variable(); | 3627 | Variable RestStatements = new Variable(); |
3628 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) | 3628 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) |
3629 | { | 3629 | { |
3630 | convertIndentationCSharp(Level); | 3630 | convertIndentationCSharp(Level); |
3631 | YP.write(Obj); | 3631 | YP.write(Obj); |
3632 | YP.write(Atom.a(@".")); | 3632 | YP.write(Atom.a(@".")); |
3633 | YP.write(Name); | 3633 | YP.write(Name); |
3634 | YP.write(Atom.a(@"(")); | 3634 | YP.write(Atom.a(@"(")); |
3635 | convertArgListCSharp(ArgList); | 3635 | convertArgListCSharp(ArgList); |
3636 | YP.write(Atom.a(@");")); | 3636 | YP.write(Atom.a(@");")); |
3637 | YP.nl(); | 3637 | YP.nl(); |
3638 | convertStatementListCSharp(RestStatements, Level); | 3638 | convertStatementListCSharp(RestStatements, Level); |
3639 | return; | 3639 | return; |
3640 | } | 3640 | } |
3641 | } | 3641 | } |
3642 | { | 3642 | { |
3643 | Variable Body = new Variable(); | 3643 | Variable Body = new Variable(); |
3644 | Variable RestStatements = new Variable(); | 3644 | Variable RestStatements = new Variable(); |
3645 | Variable NextLevel = new Variable(); | 3645 | Variable NextLevel = new Variable(); |
3646 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) | 3646 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) |
3647 | { | 3647 | { |
3648 | convertIndentationCSharp(Level); | 3648 | convertIndentationCSharp(Level); |
3649 | YP.write(Atom.a(@"{")); | 3649 | YP.write(Atom.a(@"{")); |
3650 | YP.nl(); | 3650 | YP.nl(); |
3651 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 3651 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
3652 | { | 3652 | { |
3653 | convertStatementListCSharp(Body, NextLevel); | 3653 | convertStatementListCSharp(Body, NextLevel); |
3654 | convertIndentationCSharp(Level); | 3654 | convertIndentationCSharp(Level); |
3655 | YP.write(Atom.a(@"}")); | 3655 | YP.write(Atom.a(@"}")); |
3656 | YP.nl(); | 3656 | YP.nl(); |
3657 | convertStatementListCSharp(RestStatements, Level); | 3657 | convertStatementListCSharp(RestStatements, Level); |
3658 | return; | 3658 | return; |
3659 | } | 3659 | } |
3660 | } | 3660 | } |
3661 | } | 3661 | } |
3662 | { | 3662 | { |
3663 | Variable Expression = new Variable(); | 3663 | Variable Expression = new Variable(); |
3664 | Variable Body = new Variable(); | 3664 | Variable Body = new Variable(); |
3665 | Variable RestStatements = new Variable(); | 3665 | Variable RestStatements = new Variable(); |
3666 | Variable NextLevel = new Variable(); | 3666 | Variable NextLevel = new Variable(); |
3667 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) | 3667 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) |
3668 | { | 3668 | { |
3669 | convertIndentationCSharp(Level); | 3669 | convertIndentationCSharp(Level); |
3670 | YP.write(Atom.a(@"if (")); | 3670 | YP.write(Atom.a(@"if (")); |
3671 | convertExpressionCSharp(Expression); | 3671 | convertExpressionCSharp(Expression); |
3672 | YP.write(Atom.a(@") {")); | 3672 | YP.write(Atom.a(@") {")); |
3673 | YP.nl(); | 3673 | YP.nl(); |
3674 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 3674 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
3675 | { | 3675 | { |
3676 | convertStatementListCSharp(Body, NextLevel); | 3676 | convertStatementListCSharp(Body, NextLevel); |
3677 | convertIndentationCSharp(Level); | 3677 | convertIndentationCSharp(Level); |
3678 | YP.write(Atom.a(@"}")); | 3678 | YP.write(Atom.a(@"}")); |
3679 | YP.nl(); | 3679 | YP.nl(); |
3680 | convertStatementListCSharp(RestStatements, Level); | 3680 | convertStatementListCSharp(RestStatements, Level); |
3681 | return; | 3681 | return; |
3682 | } | 3682 | } |
3683 | } | 3683 | } |
3684 | } | 3684 | } |
3685 | { | 3685 | { |
3686 | Variable Expression = new Variable(); | 3686 | Variable Expression = new Variable(); |
3687 | Variable Body = new Variable(); | 3687 | Variable Body = new Variable(); |
3688 | Variable RestStatements = new Variable(); | 3688 | Variable RestStatements = new Variable(); |
3689 | Variable NextLevel = new Variable(); | 3689 | Variable NextLevel = new Variable(); |
3690 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) | 3690 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) |
3691 | { | 3691 | { |
3692 | convertIndentationCSharp(Level); | 3692 | convertIndentationCSharp(Level); |
3693 | YP.write(Atom.a(@"foreach (bool l")); | 3693 | YP.write(Atom.a(@"foreach (bool l")); |
3694 | YP.write(Level); | 3694 | YP.write(Level); |
3695 | YP.write(Atom.a(@" in ")); | 3695 | YP.write(Atom.a(@" in ")); |
3696 | convertExpressionCSharp(Expression); | 3696 | convertExpressionCSharp(Expression); |
3697 | YP.write(Atom.a(@") {")); | 3697 | YP.write(Atom.a(@") {")); |
3698 | YP.nl(); | 3698 | YP.nl(); |
3699 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 3699 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
3700 | { | 3700 | { |
3701 | convertStatementListCSharp(Body, NextLevel); | 3701 | convertStatementListCSharp(Body, NextLevel); |
3702 | convertIndentationCSharp(Level); | 3702 | convertIndentationCSharp(Level); |
3703 | YP.write(Atom.a(@"}")); | 3703 | YP.write(Atom.a(@"}")); |
3704 | YP.nl(); | 3704 | YP.nl(); |
3705 | convertStatementListCSharp(RestStatements, Level); | 3705 | convertStatementListCSharp(RestStatements, Level); |
3706 | return; | 3706 | return; |
3707 | } | 3707 | } |
3708 | } | 3708 | } |
3709 | } | 3709 | } |
3710 | } | 3710 | } |
3711 | 3711 | ||
3712 | public static void convertIndentationCSharp(object Level) | 3712 | public static void convertIndentationCSharp(object Level) |
3713 | { | 3713 | { |
3714 | { | 3714 | { |
3715 | Variable N = new Variable(); | 3715 | Variable N = new Variable(); |
3716 | foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) | 3716 | foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) |
3717 | { | 3717 | { |
3718 | repeatWrite(Atom.a(@" "), N); | 3718 | repeatWrite(Atom.a(@" "), N); |
3719 | return; | 3719 | return; |
3720 | } | 3720 | } |
3721 | } | 3721 | } |
3722 | } | 3722 | } |
3723 | 3723 | ||
3724 | public static void convertArgListCSharp(object arg1) | 3724 | public static void convertArgListCSharp(object arg1) |
3725 | { | 3725 | { |
3726 | { | 3726 | { |
3727 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 3727 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
3728 | { | 3728 | { |
3729 | return; | 3729 | return; |
3730 | } | 3730 | } |
3731 | } | 3731 | } |
3732 | { | 3732 | { |
3733 | Variable Head = new Variable(); | 3733 | Variable Head = new Variable(); |
3734 | Variable Tail = new Variable(); | 3734 | Variable Tail = new Variable(); |
3735 | foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail))) | 3735 | foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail))) |
3736 | { | 3736 | { |
3737 | convertExpressionCSharp(Head); | 3737 | convertExpressionCSharp(Head); |
3738 | if (YP.termNotEqual(Tail, Atom.NIL)) | 3738 | if (YP.termNotEqual(Tail, Atom.NIL)) |
3739 | { | 3739 | { |
3740 | YP.write(Atom.a(@", ")); | 3740 | YP.write(Atom.a(@", ")); |
3741 | convertArgListCSharp(Tail); | 3741 | convertArgListCSharp(Tail); |
3742 | return; | 3742 | return; |
3743 | goto cutIf1; | 3743 | goto cutIf1; |
3744 | } | 3744 | } |
3745 | convertArgListCSharp(Tail); | 3745 | convertArgListCSharp(Tail); |
3746 | return; | 3746 | return; |
3747 | cutIf1: | 3747 | cutIf1: |
3748 | { } | 3748 | { } |
3749 | } | 3749 | } |
3750 | } | 3750 | } |
3751 | } | 3751 | } |
3752 | 3752 | ||
3753 | public static void convertExpressionCSharp(object arg1) | 3753 | public static void convertExpressionCSharp(object arg1) |
3754 | { | 3754 | { |
3755 | { | 3755 | { |
3756 | Variable X = new Variable(); | 3756 | Variable X = new Variable(); |
3757 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) | 3757 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) |
3758 | { | 3758 | { |
3759 | YP.write(Atom.a(@"object ")); | 3759 | YP.write(Atom.a(@"object ")); |
3760 | YP.write(X); | 3760 | YP.write(X); |
3761 | return; | 3761 | return; |
3762 | } | 3762 | } |
3763 | } | 3763 | } |
3764 | { | 3764 | { |
3765 | Variable Name = new Variable(); | 3765 | Variable Name = new Variable(); |
3766 | Variable ArgList = new Variable(); | 3766 | Variable ArgList = new Variable(); |
3767 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) | 3767 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) |
3768 | { | 3768 | { |
3769 | YP.write(Name); | 3769 | YP.write(Name); |
3770 | YP.write(Atom.a(@"(")); | 3770 | YP.write(Atom.a(@"(")); |
3771 | convertArgListCSharp(ArgList); | 3771 | convertArgListCSharp(ArgList); |
3772 | YP.write(Atom.a(@")")); | 3772 | YP.write(Atom.a(@")")); |
3773 | return; | 3773 | return; |
3774 | } | 3774 | } |
3775 | } | 3775 | } |
3776 | { | 3776 | { |
3777 | Variable Obj = new Variable(); | 3777 | Variable Obj = new Variable(); |
3778 | Variable Name = new Variable(); | 3778 | Variable Name = new Variable(); |
3779 | Variable ArgList = new Variable(); | 3779 | Variable ArgList = new Variable(); |
3780 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) | 3780 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) |
3781 | { | 3781 | { |
3782 | YP.write(Obj); | 3782 | YP.write(Obj); |
3783 | YP.write(Atom.a(@".")); | 3783 | YP.write(Atom.a(@".")); |
3784 | YP.write(Name); | 3784 | YP.write(Name); |
3785 | YP.write(Atom.a(@"(")); | 3785 | YP.write(Atom.a(@"(")); |
3786 | convertArgListCSharp(ArgList); | 3786 | convertArgListCSharp(ArgList); |
3787 | YP.write(Atom.a(@")")); | 3787 | YP.write(Atom.a(@")")); |
3788 | return; | 3788 | return; |
3789 | } | 3789 | } |
3790 | } | 3790 | } |
3791 | { | 3791 | { |
3792 | Variable Name = new Variable(); | 3792 | Variable Name = new Variable(); |
3793 | Variable ArgList = new Variable(); | 3793 | Variable ArgList = new Variable(); |
3794 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) | 3794 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) |
3795 | { | 3795 | { |
3796 | YP.write(Atom.a(@"new ")); | 3796 | YP.write(Atom.a(@"new ")); |
3797 | YP.write(Name); | 3797 | YP.write(Name); |
3798 | YP.write(Atom.a(@"(")); | 3798 | YP.write(Atom.a(@"(")); |
3799 | convertArgListCSharp(ArgList); | 3799 | convertArgListCSharp(ArgList); |
3800 | YP.write(Atom.a(@")")); | 3800 | YP.write(Atom.a(@")")); |
3801 | return; | 3801 | return; |
3802 | } | 3802 | } |
3803 | } | 3803 | } |
3804 | { | 3804 | { |
3805 | Variable Name = new Variable(); | 3805 | Variable Name = new Variable(); |
3806 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) | 3806 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) |
3807 | { | 3807 | { |
3808 | YP.write(Name); | 3808 | YP.write(Name); |
3809 | return; | 3809 | return; |
3810 | } | 3810 | } |
3811 | } | 3811 | } |
3812 | { | 3812 | { |
3813 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) | 3813 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) |
3814 | { | 3814 | { |
3815 | YP.write(Atom.a(@"null")); | 3815 | YP.write(Atom.a(@"null")); |
3816 | return; | 3816 | return; |
3817 | } | 3817 | } |
3818 | } | 3818 | } |
3819 | { | 3819 | { |
3820 | Variable X = new Variable(); | 3820 | Variable X = new Variable(); |
3821 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) | 3821 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) |
3822 | { | 3822 | { |
3823 | YP.write(Atom.a(@"!(")); | 3823 | YP.write(Atom.a(@"!(")); |
3824 | convertExpressionCSharp(X); | 3824 | convertExpressionCSharp(X); |
3825 | YP.write(Atom.a(@")")); | 3825 | YP.write(Atom.a(@")")); |
3826 | return; | 3826 | return; |
3827 | } | 3827 | } |
3828 | } | 3828 | } |
3829 | { | 3829 | { |
3830 | Variable X = new Variable(); | 3830 | Variable X = new Variable(); |
3831 | Variable Y = new Variable(); | 3831 | Variable Y = new Variable(); |
3832 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) | 3832 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) |
3833 | { | 3833 | { |
3834 | YP.write(Atom.a(@"(")); | 3834 | YP.write(Atom.a(@"(")); |
3835 | convertExpressionCSharp(X); | 3835 | convertExpressionCSharp(X); |
3836 | YP.write(Atom.a(@") && (")); | 3836 | YP.write(Atom.a(@") && (")); |
3837 | convertExpressionCSharp(Y); | 3837 | convertExpressionCSharp(Y); |
3838 | YP.write(Atom.a(@")")); | 3838 | YP.write(Atom.a(@")")); |
3839 | return; | 3839 | return; |
3840 | } | 3840 | } |
3841 | } | 3841 | } |
3842 | { | 3842 | { |
3843 | Variable ArgList = new Variable(); | 3843 | Variable ArgList = new Variable(); |
3844 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) | 3844 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) |
3845 | { | 3845 | { |
3846 | YP.write(Atom.a(@"new object[] {")); | 3846 | YP.write(Atom.a(@"new object[] {")); |
3847 | convertArgListCSharp(ArgList); | 3847 | convertArgListCSharp(ArgList); |
3848 | YP.write(Atom.a(@"}")); | 3848 | YP.write(Atom.a(@"}")); |
3849 | return; | 3849 | return; |
3850 | } | 3850 | } |
3851 | } | 3851 | } |
3852 | { | 3852 | { |
3853 | Variable X = new Variable(); | 3853 | Variable X = new Variable(); |
3854 | Variable Codes = new Variable(); | 3854 | Variable Codes = new Variable(); |
3855 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) | 3855 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) |
3856 | { | 3856 | { |
3857 | if (YP.atom(X)) | 3857 | if (YP.atom(X)) |
3858 | { | 3858 | { |
3859 | YP.write(Atom.a(@"@""")); | 3859 | YP.write(Atom.a(@"@""")); |
3860 | foreach (bool l4 in YP.atom_codes(X, Codes)) | 3860 | foreach (bool l4 in YP.atom_codes(X, Codes)) |
3861 | { | 3861 | { |
3862 | convertStringCodesCSharp(Codes); | 3862 | convertStringCodesCSharp(Codes); |
3863 | YP.write(Atom.a(@"""")); | 3863 | YP.write(Atom.a(@"""")); |
3864 | return; | 3864 | return; |
3865 | } | 3865 | } |
3866 | } | 3866 | } |
3867 | } | 3867 | } |
3868 | } | 3868 | } |
3869 | { | 3869 | { |
3870 | Variable X = new Variable(); | 3870 | Variable X = new Variable(); |
3871 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) | 3871 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) |
3872 | { | 3872 | { |
3873 | YP.write(X); | 3873 | YP.write(X); |
3874 | return; | 3874 | return; |
3875 | } | 3875 | } |
3876 | } | 3876 | } |
3877 | } | 3877 | } |
3878 | 3878 | ||
3879 | public static void convertStringCodesCSharp(object arg1) | 3879 | public static void convertStringCodesCSharp(object arg1) |
3880 | { | 3880 | { |
3881 | { | 3881 | { |
3882 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 3882 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
3883 | { | 3883 | { |
3884 | return; | 3884 | return; |
3885 | } | 3885 | } |
3886 | } | 3886 | } |
3887 | { | 3887 | { |
3888 | Variable Code = new Variable(); | 3888 | Variable Code = new Variable(); |
3889 | Variable RestCodes = new Variable(); | 3889 | Variable RestCodes = new Variable(); |
3890 | foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) | 3890 | foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) |
3891 | { | 3891 | { |
3892 | if (YP.termEqual(Code, 34)) | 3892 | if (YP.termEqual(Code, 34)) |
3893 | { | 3893 | { |
3894 | YP.put_code(34); | 3894 | YP.put_code(34); |
3895 | YP.put_code(Code); | 3895 | YP.put_code(Code); |
3896 | convertStringCodesCSharp(RestCodes); | 3896 | convertStringCodesCSharp(RestCodes); |
3897 | return; | 3897 | return; |
3898 | goto cutIf1; | 3898 | goto cutIf1; |
3899 | } | 3899 | } |
3900 | YP.put_code(Code); | 3900 | YP.put_code(Code); |
3901 | convertStringCodesCSharp(RestCodes); | 3901 | convertStringCodesCSharp(RestCodes); |
3902 | return; | 3902 | return; |
3903 | cutIf1: | 3903 | cutIf1: |
3904 | { } | 3904 | { } |
3905 | } | 3905 | } |
3906 | } | 3906 | } |
3907 | } | 3907 | } |
3908 | 3908 | ||
3909 | public static void convertFunctionJavascript(object arg1) | 3909 | public static void convertFunctionJavascript(object arg1) |
3910 | { | 3910 | { |
3911 | { | 3911 | { |
3912 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) | 3912 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) |
3913 | { | 3913 | { |
3914 | YP.write(Atom.a(@"function getDeclaringClass() { return null; }")); | 3914 | YP.write(Atom.a(@"function getDeclaringClass() { return null; }")); |
3915 | YP.nl(); | 3915 | YP.nl(); |
3916 | return; | 3916 | return; |
3917 | } | 3917 | } |
3918 | } | 3918 | } |
3919 | { | 3919 | { |
3920 | Variable x1 = new Variable(); | 3920 | Variable x1 = new Variable(); |
3921 | Variable Name = new Variable(); | 3921 | Variable Name = new Variable(); |
3922 | Variable ArgList = new Variable(); | 3922 | Variable ArgList = new Variable(); |
3923 | Variable Body = new Variable(); | 3923 | Variable Body = new Variable(); |
3924 | foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body }))) | 3924 | foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body }))) |
3925 | { | 3925 | { |
3926 | YP.write(Atom.a(@"function ")); | 3926 | YP.write(Atom.a(@"function ")); |
3927 | YP.write(Name); | 3927 | YP.write(Name); |
3928 | YP.write(Atom.a(@"(")); | 3928 | YP.write(Atom.a(@"(")); |
3929 | convertArgListJavascript(ArgList); | 3929 | convertArgListJavascript(ArgList); |
3930 | YP.write(Atom.a(@") {")); | 3930 | YP.write(Atom.a(@") {")); |
3931 | YP.nl(); | 3931 | YP.nl(); |
3932 | convertStatementListJavascript(Body, 1); | 3932 | convertStatementListJavascript(Body, 1); |
3933 | YP.write(Atom.a(@"}")); | 3933 | YP.write(Atom.a(@"}")); |
3934 | YP.nl(); | 3934 | YP.nl(); |
3935 | YP.nl(); | 3935 | YP.nl(); |
3936 | return; | 3936 | return; |
3937 | } | 3937 | } |
3938 | } | 3938 | } |
3939 | } | 3939 | } |
3940 | 3940 | ||
3941 | public static void convertStatementListJavascript(object arg1, object arg2) | 3941 | public static void convertStatementListJavascript(object arg1, object arg2) |
3942 | { | 3942 | { |
3943 | { | 3943 | { |
3944 | object x1 = arg2; | 3944 | object x1 = arg2; |
3945 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 3945 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
3946 | { | 3946 | { |
3947 | return; | 3947 | return; |
3948 | } | 3948 | } |
3949 | } | 3949 | } |
3950 | { | 3950 | { |
3951 | object Level = arg2; | 3951 | object Level = arg2; |
3952 | Variable Name = new Variable(); | 3952 | Variable Name = new Variable(); |
3953 | Variable Body = new Variable(); | 3953 | Variable Body = new Variable(); |
3954 | Variable RestStatements = new Variable(); | 3954 | Variable RestStatements = new Variable(); |
3955 | Variable NextLevel = new Variable(); | 3955 | Variable NextLevel = new Variable(); |
3956 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) | 3956 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) |
3957 | { | 3957 | { |
3958 | convertIndentationJavascript(Level); | 3958 | convertIndentationJavascript(Level); |
3959 | YP.write(Name); | 3959 | YP.write(Name); |
3960 | YP.write(Atom.a(@":")); | 3960 | YP.write(Atom.a(@":")); |
3961 | YP.nl(); | 3961 | YP.nl(); |
3962 | convertIndentationJavascript(Level); | 3962 | convertIndentationJavascript(Level); |
3963 | YP.write(Atom.a(@"{")); | 3963 | YP.write(Atom.a(@"{")); |
3964 | YP.nl(); | 3964 | YP.nl(); |
3965 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 3965 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
3966 | { | 3966 | { |
3967 | convertStatementListJavascript(Body, NextLevel); | 3967 | convertStatementListJavascript(Body, NextLevel); |
3968 | convertIndentationJavascript(Level); | 3968 | convertIndentationJavascript(Level); |
3969 | YP.write(Atom.a(@"}")); | 3969 | YP.write(Atom.a(@"}")); |
3970 | YP.nl(); | 3970 | YP.nl(); |
3971 | convertStatementListJavascript(RestStatements, Level); | 3971 | convertStatementListJavascript(RestStatements, Level); |
3972 | return; | 3972 | return; |
3973 | } | 3973 | } |
3974 | } | 3974 | } |
3975 | } | 3975 | } |
3976 | { | 3976 | { |
3977 | object Level = arg2; | 3977 | object Level = arg2; |
3978 | Variable _Type = new Variable(); | 3978 | Variable _Type = new Variable(); |
3979 | Variable Name = new Variable(); | 3979 | Variable Name = new Variable(); |
3980 | Variable Expression = new Variable(); | 3980 | Variable Expression = new Variable(); |
3981 | Variable RestStatements = new Variable(); | 3981 | Variable RestStatements = new Variable(); |
3982 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements))) | 3982 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements))) |
3983 | { | 3983 | { |
3984 | convertIndentationJavascript(Level); | 3984 | convertIndentationJavascript(Level); |
3985 | YP.write(Atom.a(@"var ")); | 3985 | YP.write(Atom.a(@"var ")); |
3986 | YP.write(Name); | 3986 | YP.write(Name); |
3987 | YP.write(Atom.a(@" = ")); | 3987 | YP.write(Atom.a(@" = ")); |
3988 | convertExpressionJavascript(Expression); | 3988 | convertExpressionJavascript(Expression); |
3989 | YP.write(Atom.a(@";")); | 3989 | YP.write(Atom.a(@";")); |
3990 | YP.nl(); | 3990 | YP.nl(); |
3991 | convertStatementListJavascript(RestStatements, Level); | 3991 | convertStatementListJavascript(RestStatements, Level); |
3992 | return; | 3992 | return; |
3993 | } | 3993 | } |
3994 | } | 3994 | } |
3995 | { | 3995 | { |
3996 | object Level = arg2; | 3996 | object Level = arg2; |
3997 | Variable Name = new Variable(); | 3997 | Variable Name = new Variable(); |
3998 | Variable Expression = new Variable(); | 3998 | Variable Expression = new Variable(); |
3999 | Variable RestStatements = new Variable(); | 3999 | Variable RestStatements = new Variable(); |
4000 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) | 4000 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) |
4001 | { | 4001 | { |
4002 | convertIndentationJavascript(Level); | 4002 | convertIndentationJavascript(Level); |
4003 | YP.write(Name); | 4003 | YP.write(Name); |
4004 | YP.write(Atom.a(@" = ")); | 4004 | YP.write(Atom.a(@" = ")); |
4005 | convertExpressionJavascript(Expression); | 4005 | convertExpressionJavascript(Expression); |
4006 | YP.write(Atom.a(@";")); | 4006 | YP.write(Atom.a(@";")); |
4007 | YP.nl(); | 4007 | YP.nl(); |
4008 | convertStatementListJavascript(RestStatements, Level); | 4008 | convertStatementListJavascript(RestStatements, Level); |
4009 | return; | 4009 | return; |
4010 | } | 4010 | } |
4011 | } | 4011 | } |
4012 | { | 4012 | { |
4013 | object Level = arg2; | 4013 | object Level = arg2; |
4014 | Variable RestStatements = new Variable(); | 4014 | Variable RestStatements = new Variable(); |
4015 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) | 4015 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) |
4016 | { | 4016 | { |
4017 | convertIndentationJavascript(Level); | 4017 | convertIndentationJavascript(Level); |
4018 | YP.write(Atom.a(@"yield true;")); | 4018 | YP.write(Atom.a(@"yield true;")); |
4019 | YP.nl(); | 4019 | YP.nl(); |
4020 | convertStatementListJavascript(RestStatements, Level); | 4020 | convertStatementListJavascript(RestStatements, Level); |
4021 | return; | 4021 | return; |
4022 | } | 4022 | } |
4023 | } | 4023 | } |
4024 | { | 4024 | { |
4025 | object Level = arg2; | 4025 | object Level = arg2; |
4026 | Variable RestStatements = new Variable(); | 4026 | Variable RestStatements = new Variable(); |
4027 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) | 4027 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) |
4028 | { | 4028 | { |
4029 | convertIndentationJavascript(Level); | 4029 | convertIndentationJavascript(Level); |
4030 | YP.write(Atom.a(@"yield false;")); | 4030 | YP.write(Atom.a(@"yield false;")); |
4031 | YP.nl(); | 4031 | YP.nl(); |
4032 | convertStatementListJavascript(RestStatements, Level); | 4032 | convertStatementListJavascript(RestStatements, Level); |
4033 | return; | 4033 | return; |
4034 | } | 4034 | } |
4035 | } | 4035 | } |
4036 | { | 4036 | { |
4037 | object Level = arg2; | 4037 | object Level = arg2; |
4038 | Variable RestStatements = new Variable(); | 4038 | Variable RestStatements = new Variable(); |
4039 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) | 4039 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) |
4040 | { | 4040 | { |
4041 | convertIndentationJavascript(Level); | 4041 | convertIndentationJavascript(Level); |
4042 | YP.write(Atom.a(@"return;")); | 4042 | YP.write(Atom.a(@"return;")); |
4043 | YP.nl(); | 4043 | YP.nl(); |
4044 | convertStatementListJavascript(RestStatements, Level); | 4044 | convertStatementListJavascript(RestStatements, Level); |
4045 | return; | 4045 | return; |
4046 | } | 4046 | } |
4047 | } | 4047 | } |
4048 | { | 4048 | { |
4049 | object Level = arg2; | 4049 | object Level = arg2; |
4050 | Variable RestStatements = new Variable(); | 4050 | Variable RestStatements = new Variable(); |
4051 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) | 4051 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) |
4052 | { | 4052 | { |
4053 | convertIndentationJavascript(Level); | 4053 | convertIndentationJavascript(Level); |
4054 | YP.write(Atom.a(@"return;")); | 4054 | YP.write(Atom.a(@"return;")); |
4055 | YP.nl(); | 4055 | YP.nl(); |
4056 | convertStatementListJavascript(RestStatements, Level); | 4056 | convertStatementListJavascript(RestStatements, Level); |
4057 | return; | 4057 | return; |
4058 | } | 4058 | } |
4059 | } | 4059 | } |
4060 | { | 4060 | { |
4061 | object Level = arg2; | 4061 | object Level = arg2; |
4062 | Variable RestStatements = new Variable(); | 4062 | Variable RestStatements = new Variable(); |
4063 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) | 4063 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) |
4064 | { | 4064 | { |
4065 | convertIndentationJavascript(Level); | 4065 | convertIndentationJavascript(Level); |
4066 | YP.write(Atom.a(@"return true;")); | 4066 | YP.write(Atom.a(@"return true;")); |
4067 | YP.nl(); | 4067 | YP.nl(); |
4068 | convertStatementListJavascript(RestStatements, Level); | 4068 | convertStatementListJavascript(RestStatements, Level); |
4069 | return; | 4069 | return; |
4070 | } | 4070 | } |
4071 | } | 4071 | } |
4072 | { | 4072 | { |
4073 | object Level = arg2; | 4073 | object Level = arg2; |
4074 | Variable RestStatements = new Variable(); | 4074 | Variable RestStatements = new Variable(); |
4075 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) | 4075 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) |
4076 | { | 4076 | { |
4077 | convertIndentationJavascript(Level); | 4077 | convertIndentationJavascript(Level); |
4078 | YP.write(Atom.a(@"return false;")); | 4078 | YP.write(Atom.a(@"return false;")); |
4079 | YP.nl(); | 4079 | YP.nl(); |
4080 | convertStatementListJavascript(RestStatements, Level); | 4080 | convertStatementListJavascript(RestStatements, Level); |
4081 | return; | 4081 | return; |
4082 | } | 4082 | } |
4083 | } | 4083 | } |
4084 | { | 4084 | { |
4085 | object Level = arg2; | 4085 | object Level = arg2; |
4086 | Variable Name = new Variable(); | 4086 | Variable Name = new Variable(); |
4087 | Variable RestStatements = new Variable(); | 4087 | Variable RestStatements = new Variable(); |
4088 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) | 4088 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) |
4089 | { | 4089 | { |
4090 | convertIndentationJavascript(Level); | 4090 | convertIndentationJavascript(Level); |
4091 | YP.write(Atom.a(@"break ")); | 4091 | YP.write(Atom.a(@"break ")); |
4092 | YP.write(Name); | 4092 | YP.write(Name); |
4093 | YP.write(Atom.a(@";")); | 4093 | YP.write(Atom.a(@";")); |
4094 | YP.nl(); | 4094 | YP.nl(); |
4095 | convertStatementListJavascript(RestStatements, Level); | 4095 | convertStatementListJavascript(RestStatements, Level); |
4096 | return; | 4096 | return; |
4097 | } | 4097 | } |
4098 | } | 4098 | } |
4099 | { | 4099 | { |
4100 | object Level = arg2; | 4100 | object Level = arg2; |
4101 | Variable Name = new Variable(); | 4101 | Variable Name = new Variable(); |
4102 | Variable ArgList = new Variable(); | 4102 | Variable ArgList = new Variable(); |
4103 | Variable RestStatements = new Variable(); | 4103 | Variable RestStatements = new Variable(); |
4104 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) | 4104 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) |
4105 | { | 4105 | { |
4106 | convertIndentationJavascript(Level); | 4106 | convertIndentationJavascript(Level); |
4107 | YP.write(Name); | 4107 | YP.write(Name); |
4108 | YP.write(Atom.a(@"(")); | 4108 | YP.write(Atom.a(@"(")); |
4109 | convertArgListJavascript(ArgList); | 4109 | convertArgListJavascript(ArgList); |
4110 | YP.write(Atom.a(@");")); | 4110 | YP.write(Atom.a(@");")); |
4111 | YP.nl(); | 4111 | YP.nl(); |
4112 | convertStatementListJavascript(RestStatements, Level); | 4112 | convertStatementListJavascript(RestStatements, Level); |
4113 | return; | 4113 | return; |
4114 | } | 4114 | } |
4115 | } | 4115 | } |
4116 | { | 4116 | { |
4117 | object Level = arg2; | 4117 | object Level = arg2; |
4118 | Variable Obj = new Variable(); | 4118 | Variable Obj = new Variable(); |
4119 | Variable Name = new Variable(); | 4119 | Variable Name = new Variable(); |
4120 | Variable ArgList = new Variable(); | 4120 | Variable ArgList = new Variable(); |
4121 | Variable RestStatements = new Variable(); | 4121 | Variable RestStatements = new Variable(); |
4122 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) | 4122 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) |
4123 | { | 4123 | { |
4124 | convertIndentationJavascript(Level); | 4124 | convertIndentationJavascript(Level); |
4125 | YP.write(Obj); | 4125 | YP.write(Obj); |
4126 | YP.write(Atom.a(@".")); | 4126 | YP.write(Atom.a(@".")); |
4127 | YP.write(Name); | 4127 | YP.write(Name); |
4128 | YP.write(Atom.a(@"(")); | 4128 | YP.write(Atom.a(@"(")); |
4129 | convertArgListJavascript(ArgList); | 4129 | convertArgListJavascript(ArgList); |
4130 | YP.write(Atom.a(@");")); | 4130 | YP.write(Atom.a(@");")); |
4131 | YP.nl(); | 4131 | YP.nl(); |
4132 | convertStatementListJavascript(RestStatements, Level); | 4132 | convertStatementListJavascript(RestStatements, Level); |
4133 | return; | 4133 | return; |
4134 | } | 4134 | } |
4135 | } | 4135 | } |
4136 | { | 4136 | { |
4137 | object Level = arg2; | 4137 | object Level = arg2; |
4138 | Variable Body = new Variable(); | 4138 | Variable Body = new Variable(); |
4139 | Variable RestStatements = new Variable(); | 4139 | Variable RestStatements = new Variable(); |
4140 | Variable NextLevel = new Variable(); | 4140 | Variable NextLevel = new Variable(); |
4141 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) | 4141 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) |
4142 | { | 4142 | { |
4143 | convertIndentationJavascript(Level); | 4143 | convertIndentationJavascript(Level); |
4144 | YP.write(Atom.a(@"{")); | 4144 | YP.write(Atom.a(@"{")); |
4145 | YP.nl(); | 4145 | YP.nl(); |
4146 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 4146 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
4147 | { | 4147 | { |
4148 | convertStatementListJavascript(Body, NextLevel); | 4148 | convertStatementListJavascript(Body, NextLevel); |
4149 | convertIndentationJavascript(Level); | 4149 | convertIndentationJavascript(Level); |
4150 | YP.write(Atom.a(@"}")); | 4150 | YP.write(Atom.a(@"}")); |
4151 | YP.nl(); | 4151 | YP.nl(); |
4152 | convertStatementListJavascript(RestStatements, Level); | 4152 | convertStatementListJavascript(RestStatements, Level); |
4153 | return; | 4153 | return; |
4154 | } | 4154 | } |
4155 | } | 4155 | } |
4156 | } | 4156 | } |
4157 | { | 4157 | { |
4158 | object Level = arg2; | 4158 | object Level = arg2; |
4159 | Variable Expression = new Variable(); | 4159 | Variable Expression = new Variable(); |
4160 | Variable Body = new Variable(); | 4160 | Variable Body = new Variable(); |
4161 | Variable RestStatements = new Variable(); | 4161 | Variable RestStatements = new Variable(); |
4162 | Variable NextLevel = new Variable(); | 4162 | Variable NextLevel = new Variable(); |
4163 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) | 4163 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) |
4164 | { | 4164 | { |
4165 | convertIndentationJavascript(Level); | 4165 | convertIndentationJavascript(Level); |
4166 | YP.write(Atom.a(@"if (")); | 4166 | YP.write(Atom.a(@"if (")); |
4167 | convertExpressionJavascript(Expression); | 4167 | convertExpressionJavascript(Expression); |
4168 | YP.write(Atom.a(@") {")); | 4168 | YP.write(Atom.a(@") {")); |
4169 | YP.nl(); | 4169 | YP.nl(); |
4170 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 4170 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
4171 | { | 4171 | { |
4172 | convertStatementListJavascript(Body, NextLevel); | 4172 | convertStatementListJavascript(Body, NextLevel); |
4173 | convertIndentationJavascript(Level); | 4173 | convertIndentationJavascript(Level); |
4174 | YP.write(Atom.a(@"}")); | 4174 | YP.write(Atom.a(@"}")); |
4175 | YP.nl(); | 4175 | YP.nl(); |
4176 | convertStatementListJavascript(RestStatements, Level); | 4176 | convertStatementListJavascript(RestStatements, Level); |
4177 | return; | 4177 | return; |
4178 | } | 4178 | } |
4179 | } | 4179 | } |
4180 | } | 4180 | } |
4181 | { | 4181 | { |
4182 | object Level = arg2; | 4182 | object Level = arg2; |
4183 | Variable Expression = new Variable(); | 4183 | Variable Expression = new Variable(); |
4184 | Variable Body = new Variable(); | 4184 | Variable Body = new Variable(); |
4185 | Variable RestStatements = new Variable(); | 4185 | Variable RestStatements = new Variable(); |
4186 | Variable NextLevel = new Variable(); | 4186 | Variable NextLevel = new Variable(); |
4187 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) | 4187 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) |
4188 | { | 4188 | { |
4189 | convertIndentationJavascript(Level); | 4189 | convertIndentationJavascript(Level); |
4190 | YP.write(Atom.a(@"for each (var l")); | 4190 | YP.write(Atom.a(@"for each (var l")); |
4191 | YP.write(Level); | 4191 | YP.write(Level); |
4192 | YP.write(Atom.a(@" in ")); | 4192 | YP.write(Atom.a(@" in ")); |
4193 | convertExpressionJavascript(Expression); | 4193 | convertExpressionJavascript(Expression); |
4194 | YP.write(Atom.a(@") {")); | 4194 | YP.write(Atom.a(@") {")); |
4195 | YP.nl(); | 4195 | YP.nl(); |
4196 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 4196 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
4197 | { | 4197 | { |
4198 | convertStatementListJavascript(Body, NextLevel); | 4198 | convertStatementListJavascript(Body, NextLevel); |
4199 | convertIndentationJavascript(Level); | 4199 | convertIndentationJavascript(Level); |
4200 | YP.write(Atom.a(@"}")); | 4200 | YP.write(Atom.a(@"}")); |
4201 | YP.nl(); | 4201 | YP.nl(); |
4202 | convertStatementListJavascript(RestStatements, Level); | 4202 | convertStatementListJavascript(RestStatements, Level); |
4203 | return; | 4203 | return; |
4204 | } | 4204 | } |
4205 | } | 4205 | } |
4206 | } | 4206 | } |
4207 | } | 4207 | } |
4208 | 4208 | ||
4209 | public static void convertIndentationJavascript(object Level) | 4209 | public static void convertIndentationJavascript(object Level) |
4210 | { | 4210 | { |
4211 | { | 4211 | { |
4212 | Variable N = new Variable(); | 4212 | Variable N = new Variable(); |
4213 | foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) | 4213 | foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) |
4214 | { | 4214 | { |
4215 | repeatWrite(Atom.a(@" "), N); | 4215 | repeatWrite(Atom.a(@" "), N); |
4216 | return; | 4216 | return; |
4217 | } | 4217 | } |
4218 | } | 4218 | } |
4219 | } | 4219 | } |
4220 | 4220 | ||
4221 | public static void convertArgListJavascript(object arg1) | 4221 | public static void convertArgListJavascript(object arg1) |
4222 | { | 4222 | { |
4223 | { | 4223 | { |
4224 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 4224 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
4225 | { | 4225 | { |
4226 | return; | 4226 | return; |
4227 | } | 4227 | } |
4228 | } | 4228 | } |
4229 | { | 4229 | { |
4230 | Variable Head = new Variable(); | 4230 | Variable Head = new Variable(); |
4231 | Variable Tail = new Variable(); | 4231 | Variable Tail = new Variable(); |
4232 | foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail))) | 4232 | foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail))) |
4233 | { | 4233 | { |
4234 | convertExpressionJavascript(Head); | 4234 | convertExpressionJavascript(Head); |
4235 | if (YP.termNotEqual(Tail, Atom.NIL)) | 4235 | if (YP.termNotEqual(Tail, Atom.NIL)) |
4236 | { | 4236 | { |
4237 | YP.write(Atom.a(@", ")); | 4237 | YP.write(Atom.a(@", ")); |
4238 | convertArgListJavascript(Tail); | 4238 | convertArgListJavascript(Tail); |
4239 | return; | 4239 | return; |
4240 | goto cutIf1; | 4240 | goto cutIf1; |
4241 | } | 4241 | } |
4242 | convertArgListJavascript(Tail); | 4242 | convertArgListJavascript(Tail); |
4243 | return; | 4243 | return; |
4244 | cutIf1: | 4244 | cutIf1: |
4245 | { } | 4245 | { } |
4246 | } | 4246 | } |
4247 | } | 4247 | } |
4248 | } | 4248 | } |
4249 | 4249 | ||
4250 | public static void convertExpressionJavascript(object arg1) | 4250 | public static void convertExpressionJavascript(object arg1) |
4251 | { | 4251 | { |
4252 | { | 4252 | { |
4253 | Variable X = new Variable(); | 4253 | Variable X = new Variable(); |
4254 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) | 4254 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) |
4255 | { | 4255 | { |
4256 | YP.write(X); | 4256 | YP.write(X); |
4257 | return; | 4257 | return; |
4258 | } | 4258 | } |
4259 | } | 4259 | } |
4260 | { | 4260 | { |
4261 | Variable Name = new Variable(); | 4261 | Variable Name = new Variable(); |
4262 | Variable ArgList = new Variable(); | 4262 | Variable ArgList = new Variable(); |
4263 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) | 4263 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) |
4264 | { | 4264 | { |
4265 | YP.write(Name); | 4265 | YP.write(Name); |
4266 | YP.write(Atom.a(@"(")); | 4266 | YP.write(Atom.a(@"(")); |
4267 | convertArgListJavascript(ArgList); | 4267 | convertArgListJavascript(ArgList); |
4268 | YP.write(Atom.a(@")")); | 4268 | YP.write(Atom.a(@")")); |
4269 | return; | 4269 | return; |
4270 | } | 4270 | } |
4271 | } | 4271 | } |
4272 | { | 4272 | { |
4273 | Variable Obj = new Variable(); | 4273 | Variable Obj = new Variable(); |
4274 | Variable Name = new Variable(); | 4274 | Variable Name = new Variable(); |
4275 | Variable ArgList = new Variable(); | 4275 | Variable ArgList = new Variable(); |
4276 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) | 4276 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) |
4277 | { | 4277 | { |
4278 | YP.write(Obj); | 4278 | YP.write(Obj); |
4279 | YP.write(Atom.a(@".")); | 4279 | YP.write(Atom.a(@".")); |
4280 | YP.write(Name); | 4280 | YP.write(Name); |
4281 | YP.write(Atom.a(@"(")); | 4281 | YP.write(Atom.a(@"(")); |
4282 | convertArgListJavascript(ArgList); | 4282 | convertArgListJavascript(ArgList); |
4283 | YP.write(Atom.a(@")")); | 4283 | YP.write(Atom.a(@")")); |
4284 | return; | 4284 | return; |
4285 | } | 4285 | } |
4286 | } | 4286 | } |
4287 | { | 4287 | { |
4288 | Variable Name = new Variable(); | 4288 | Variable Name = new Variable(); |
4289 | Variable ArgList = new Variable(); | 4289 | Variable ArgList = new Variable(); |
4290 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) | 4290 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) |
4291 | { | 4291 | { |
4292 | YP.write(Atom.a(@"new ")); | 4292 | YP.write(Atom.a(@"new ")); |
4293 | YP.write(Name); | 4293 | YP.write(Name); |
4294 | YP.write(Atom.a(@"(")); | 4294 | YP.write(Atom.a(@"(")); |
4295 | convertArgListJavascript(ArgList); | 4295 | convertArgListJavascript(ArgList); |
4296 | YP.write(Atom.a(@")")); | 4296 | YP.write(Atom.a(@")")); |
4297 | return; | 4297 | return; |
4298 | } | 4298 | } |
4299 | } | 4299 | } |
4300 | { | 4300 | { |
4301 | Variable Name = new Variable(); | 4301 | Variable Name = new Variable(); |
4302 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) | 4302 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) |
4303 | { | 4303 | { |
4304 | YP.write(Name); | 4304 | YP.write(Name); |
4305 | return; | 4305 | return; |
4306 | } | 4306 | } |
4307 | } | 4307 | } |
4308 | { | 4308 | { |
4309 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) | 4309 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) |
4310 | { | 4310 | { |
4311 | YP.write(Atom.a(@"null")); | 4311 | YP.write(Atom.a(@"null")); |
4312 | return; | 4312 | return; |
4313 | } | 4313 | } |
4314 | } | 4314 | } |
4315 | { | 4315 | { |
4316 | Variable X = new Variable(); | 4316 | Variable X = new Variable(); |
4317 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) | 4317 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) |
4318 | { | 4318 | { |
4319 | YP.write(Atom.a(@"!(")); | 4319 | YP.write(Atom.a(@"!(")); |
4320 | convertExpressionJavascript(X); | 4320 | convertExpressionJavascript(X); |
4321 | YP.write(Atom.a(@")")); | 4321 | YP.write(Atom.a(@")")); |
4322 | return; | 4322 | return; |
4323 | } | 4323 | } |
4324 | } | 4324 | } |
4325 | { | 4325 | { |
4326 | Variable X = new Variable(); | 4326 | Variable X = new Variable(); |
4327 | Variable Y = new Variable(); | 4327 | Variable Y = new Variable(); |
4328 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) | 4328 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) |
4329 | { | 4329 | { |
4330 | YP.write(Atom.a(@"(")); | 4330 | YP.write(Atom.a(@"(")); |
4331 | convertExpressionJavascript(X); | 4331 | convertExpressionJavascript(X); |
4332 | YP.write(Atom.a(@") && (")); | 4332 | YP.write(Atom.a(@") && (")); |
4333 | convertExpressionJavascript(Y); | 4333 | convertExpressionJavascript(Y); |
4334 | YP.write(Atom.a(@")")); | 4334 | YP.write(Atom.a(@")")); |
4335 | return; | 4335 | return; |
4336 | } | 4336 | } |
4337 | } | 4337 | } |
4338 | { | 4338 | { |
4339 | Variable ArgList = new Variable(); | 4339 | Variable ArgList = new Variable(); |
4340 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) | 4340 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) |
4341 | { | 4341 | { |
4342 | YP.write(Atom.a(@"[")); | 4342 | YP.write(Atom.a(@"[")); |
4343 | convertArgListJavascript(ArgList); | 4343 | convertArgListJavascript(ArgList); |
4344 | YP.write(Atom.a(@"]")); | 4344 | YP.write(Atom.a(@"]")); |
4345 | return; | 4345 | return; |
4346 | } | 4346 | } |
4347 | } | 4347 | } |
4348 | { | 4348 | { |
4349 | Variable X = new Variable(); | 4349 | Variable X = new Variable(); |
4350 | Variable Codes = new Variable(); | 4350 | Variable Codes = new Variable(); |
4351 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) | 4351 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) |
4352 | { | 4352 | { |
4353 | if (YP.atom(X)) | 4353 | if (YP.atom(X)) |
4354 | { | 4354 | { |
4355 | YP.write(Atom.a(@"""")); | 4355 | YP.write(Atom.a(@"""")); |
4356 | foreach (bool l4 in YP.atom_codes(X, Codes)) | 4356 | foreach (bool l4 in YP.atom_codes(X, Codes)) |
4357 | { | 4357 | { |
4358 | convertStringCodesJavascript(Codes); | 4358 | convertStringCodesJavascript(Codes); |
4359 | YP.write(Atom.a(@"""")); | 4359 | YP.write(Atom.a(@"""")); |
4360 | return; | 4360 | return; |
4361 | } | 4361 | } |
4362 | } | 4362 | } |
4363 | } | 4363 | } |
4364 | } | 4364 | } |
4365 | { | 4365 | { |
4366 | Variable X = new Variable(); | 4366 | Variable X = new Variable(); |
4367 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) | 4367 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) |
4368 | { | 4368 | { |
4369 | YP.write(X); | 4369 | YP.write(X); |
4370 | return; | 4370 | return; |
4371 | } | 4371 | } |
4372 | } | 4372 | } |
4373 | } | 4373 | } |
4374 | 4374 | ||
4375 | public static void convertStringCodesJavascript(object arg1) | 4375 | public static void convertStringCodesJavascript(object arg1) |
4376 | { | 4376 | { |
4377 | { | 4377 | { |
4378 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 4378 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
4379 | { | 4379 | { |
4380 | return; | 4380 | return; |
4381 | } | 4381 | } |
4382 | } | 4382 | } |
4383 | { | 4383 | { |
4384 | Variable Code = new Variable(); | 4384 | Variable Code = new Variable(); |
4385 | Variable RestCodes = new Variable(); | 4385 | Variable RestCodes = new Variable(); |
4386 | foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) | 4386 | foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) |
4387 | { | 4387 | { |
4388 | if (YP.termEqual(Code, 34)) | 4388 | if (YP.termEqual(Code, 34)) |
4389 | { | 4389 | { |
4390 | YP.put_code(92); | 4390 | YP.put_code(92); |
4391 | YP.put_code(Code); | 4391 | YP.put_code(Code); |
4392 | convertStringCodesJavascript(RestCodes); | 4392 | convertStringCodesJavascript(RestCodes); |
4393 | return; | 4393 | return; |
4394 | goto cutIf1; | 4394 | goto cutIf1; |
4395 | } | 4395 | } |
4396 | if (YP.termEqual(Code, 92)) | 4396 | if (YP.termEqual(Code, 92)) |
4397 | { | 4397 | { |
4398 | YP.put_code(92); | 4398 | YP.put_code(92); |
4399 | YP.put_code(Code); | 4399 | YP.put_code(Code); |
4400 | convertStringCodesJavascript(RestCodes); | 4400 | convertStringCodesJavascript(RestCodes); |
4401 | return; | 4401 | return; |
4402 | goto cutIf1; | 4402 | goto cutIf1; |
4403 | } | 4403 | } |
4404 | YP.put_code(Code); | 4404 | YP.put_code(Code); |
4405 | convertStringCodesJavascript(RestCodes); | 4405 | convertStringCodesJavascript(RestCodes); |
4406 | return; | 4406 | return; |
4407 | cutIf1: | 4407 | cutIf1: |
4408 | { } | 4408 | { } |
4409 | } | 4409 | } |
4410 | } | 4410 | } |
4411 | } | 4411 | } |
4412 | 4412 | ||
4413 | public static void convertFunctionPython(object arg1) | 4413 | public static void convertFunctionPython(object arg1) |
4414 | { | 4414 | { |
4415 | { | 4415 | { |
4416 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) | 4416 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass"))) |
4417 | { | 4417 | { |
4418 | YP.write(Atom.a(@"def getDeclaringClass():")); | 4418 | YP.write(Atom.a(@"def getDeclaringClass():")); |
4419 | YP.nl(); | 4419 | YP.nl(); |
4420 | YP.write(Atom.a(@" return None")); | 4420 | YP.write(Atom.a(@" return None")); |
4421 | YP.nl(); | 4421 | YP.nl(); |
4422 | YP.nl(); | 4422 | YP.nl(); |
4423 | return; | 4423 | return; |
4424 | } | 4424 | } |
4425 | } | 4425 | } |
4426 | { | 4426 | { |
4427 | Variable x1 = new Variable(); | 4427 | Variable x1 = new Variable(); |
4428 | Variable Name = new Variable(); | 4428 | Variable Name = new Variable(); |
4429 | Variable ArgList = new Variable(); | 4429 | Variable ArgList = new Variable(); |
4430 | Variable Body = new Variable(); | 4430 | Variable Body = new Variable(); |
4431 | Variable Level = new Variable(); | 4431 | Variable Level = new Variable(); |
4432 | Variable HasBreakableBlock = new Variable(); | 4432 | Variable HasBreakableBlock = new Variable(); |
4433 | foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body }))) | 4433 | foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body }))) |
4434 | { | 4434 | { |
4435 | YP.write(Atom.a(@"def ")); | 4435 | YP.write(Atom.a(@"def ")); |
4436 | YP.write(Name); | 4436 | YP.write(Name); |
4437 | YP.write(Atom.a(@"(")); | 4437 | YP.write(Atom.a(@"(")); |
4438 | convertArgListPython(ArgList); | 4438 | convertArgListPython(ArgList); |
4439 | YP.write(Atom.a(@"):")); | 4439 | YP.write(Atom.a(@"):")); |
4440 | YP.nl(); | 4440 | YP.nl(); |
4441 | foreach (bool l3 in YP.unify(Level, 1)) | 4441 | foreach (bool l3 in YP.unify(Level, 1)) |
4442 | { | 4442 | { |
4443 | if (hasBreakableBlockPython(Body)) | 4443 | if (hasBreakableBlockPython(Body)) |
4444 | { | 4444 | { |
4445 | foreach (bool l5 in YP.unify(HasBreakableBlock, 1)) | 4445 | foreach (bool l5 in YP.unify(HasBreakableBlock, 1)) |
4446 | { | 4446 | { |
4447 | if (YP.termEqual(HasBreakableBlock, 1)) | 4447 | if (YP.termEqual(HasBreakableBlock, 1)) |
4448 | { | 4448 | { |
4449 | convertIndentationPython(Level); | 4449 | convertIndentationPython(Level); |
4450 | YP.write(Atom.a(@"doBreak = False")); | 4450 | YP.write(Atom.a(@"doBreak = False")); |
4451 | YP.nl(); | 4451 | YP.nl(); |
4452 | foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock)) | 4452 | foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock)) |
4453 | { | 4453 | { |
4454 | YP.nl(); | 4454 | YP.nl(); |
4455 | return; | 4455 | return; |
4456 | } | 4456 | } |
4457 | goto cutIf2; | 4457 | goto cutIf2; |
4458 | } | 4458 | } |
4459 | foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock)) | 4459 | foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock)) |
4460 | { | 4460 | { |
4461 | YP.nl(); | 4461 | YP.nl(); |
4462 | return; | 4462 | return; |
4463 | } | 4463 | } |
4464 | cutIf2: | 4464 | cutIf2: |
4465 | { } | 4465 | { } |
4466 | } | 4466 | } |
4467 | goto cutIf1; | 4467 | goto cutIf1; |
4468 | } | 4468 | } |
4469 | foreach (bool l4 in YP.unify(HasBreakableBlock, 0)) | 4469 | foreach (bool l4 in YP.unify(HasBreakableBlock, 0)) |
4470 | { | 4470 | { |
4471 | if (YP.termEqual(HasBreakableBlock, 1)) | 4471 | if (YP.termEqual(HasBreakableBlock, 1)) |
4472 | { | 4472 | { |
4473 | convertIndentationPython(Level); | 4473 | convertIndentationPython(Level); |
4474 | YP.write(Atom.a(@"doBreak = False")); | 4474 | YP.write(Atom.a(@"doBreak = False")); |
4475 | YP.nl(); | 4475 | YP.nl(); |
4476 | foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock)) | 4476 | foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock)) |
4477 | { | 4477 | { |
4478 | YP.nl(); | 4478 | YP.nl(); |
4479 | return; | 4479 | return; |
4480 | } | 4480 | } |
4481 | goto cutIf3; | 4481 | goto cutIf3; |
4482 | } | 4482 | } |
4483 | foreach (bool l5 in convertStatementListPython(Body, Level, HasBreakableBlock)) | 4483 | foreach (bool l5 in convertStatementListPython(Body, Level, HasBreakableBlock)) |
4484 | { | 4484 | { |
4485 | YP.nl(); | 4485 | YP.nl(); |
4486 | return; | 4486 | return; |
4487 | } | 4487 | } |
4488 | cutIf3: | 4488 | cutIf3: |
4489 | { } | 4489 | { } |
4490 | } | 4490 | } |
4491 | cutIf1: | 4491 | cutIf1: |
4492 | { } | 4492 | { } |
4493 | } | 4493 | } |
4494 | } | 4494 | } |
4495 | } | 4495 | } |
4496 | } | 4496 | } |
4497 | 4497 | ||
4498 | public static bool hasBreakableBlockPython(object arg1) | 4498 | public static bool hasBreakableBlockPython(object arg1) |
4499 | { | 4499 | { |
4500 | { | 4500 | { |
4501 | Variable _Name = new Variable(); | 4501 | Variable _Name = new Variable(); |
4502 | Variable _Body = new Variable(); | 4502 | Variable _Body = new Variable(); |
4503 | Variable _RestStatements = new Variable(); | 4503 | Variable _RestStatements = new Variable(); |
4504 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", _Name, _Body), _RestStatements))) | 4504 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", _Name, _Body), _RestStatements))) |
4505 | { | 4505 | { |
4506 | return true; | 4506 | return true; |
4507 | } | 4507 | } |
4508 | } | 4508 | } |
4509 | { | 4509 | { |
4510 | Variable Body = new Variable(); | 4510 | Variable Body = new Variable(); |
4511 | Variable _RestStatements = new Variable(); | 4511 | Variable _RestStatements = new Variable(); |
4512 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), _RestStatements))) | 4512 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), _RestStatements))) |
4513 | { | 4513 | { |
4514 | if (hasBreakableBlockPython(Body)) | 4514 | if (hasBreakableBlockPython(Body)) |
4515 | { | 4515 | { |
4516 | return true; | 4516 | return true; |
4517 | } | 4517 | } |
4518 | } | 4518 | } |
4519 | } | 4519 | } |
4520 | { | 4520 | { |
4521 | Variable _Expression = new Variable(); | 4521 | Variable _Expression = new Variable(); |
4522 | Variable Body = new Variable(); | 4522 | Variable Body = new Variable(); |
4523 | Variable _RestStatements = new Variable(); | 4523 | Variable _RestStatements = new Variable(); |
4524 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", _Expression, Body), _RestStatements))) | 4524 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", _Expression, Body), _RestStatements))) |
4525 | { | 4525 | { |
4526 | if (hasBreakableBlockPython(Body)) | 4526 | if (hasBreakableBlockPython(Body)) |
4527 | { | 4527 | { |
4528 | return true; | 4528 | return true; |
4529 | } | 4529 | } |
4530 | } | 4530 | } |
4531 | } | 4531 | } |
4532 | { | 4532 | { |
4533 | Variable _Expression = new Variable(); | 4533 | Variable _Expression = new Variable(); |
4534 | Variable Body = new Variable(); | 4534 | Variable Body = new Variable(); |
4535 | Variable _RestStatements = new Variable(); | 4535 | Variable _RestStatements = new Variable(); |
4536 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", _Expression, Body), _RestStatements))) | 4536 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", _Expression, Body), _RestStatements))) |
4537 | { | 4537 | { |
4538 | if (hasBreakableBlockPython(Body)) | 4538 | if (hasBreakableBlockPython(Body)) |
4539 | { | 4539 | { |
4540 | return true; | 4540 | return true; |
4541 | } | 4541 | } |
4542 | } | 4542 | } |
4543 | } | 4543 | } |
4544 | { | 4544 | { |
4545 | Variable x1 = new Variable(); | 4545 | Variable x1 = new Variable(); |
4546 | Variable RestStatements = new Variable(); | 4546 | Variable RestStatements = new Variable(); |
4547 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestStatements))) | 4547 | foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestStatements))) |
4548 | { | 4548 | { |
4549 | if (hasBreakableBlockPython(RestStatements)) | 4549 | if (hasBreakableBlockPython(RestStatements)) |
4550 | { | 4550 | { |
4551 | return true; | 4551 | return true; |
4552 | } | 4552 | } |
4553 | } | 4553 | } |
4554 | } | 4554 | } |
4555 | return false; | 4555 | return false; |
4556 | } | 4556 | } |
4557 | 4557 | ||
4558 | public static IEnumerable<bool> convertStatementListPython(object arg1, object arg2, object arg3) | 4558 | public static IEnumerable<bool> convertStatementListPython(object arg1, object arg2, object arg3) |
4559 | { | 4559 | { |
4560 | { | 4560 | { |
4561 | object x1 = arg2; | 4561 | object x1 = arg2; |
4562 | object x2 = arg3; | 4562 | object x2 = arg3; |
4563 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 4563 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
4564 | { | 4564 | { |
4565 | yield return true; | 4565 | yield return true; |
4566 | yield break; | 4566 | yield break; |
4567 | } | 4567 | } |
4568 | } | 4568 | } |
4569 | { | 4569 | { |
4570 | object Level = arg2; | 4570 | object Level = arg2; |
4571 | object HasBreakableBlock = arg3; | 4571 | object HasBreakableBlock = arg3; |
4572 | Variable Name = new Variable(); | 4572 | Variable Name = new Variable(); |
4573 | Variable Body = new Variable(); | 4573 | Variable Body = new Variable(); |
4574 | Variable RestStatements = new Variable(); | 4574 | Variable RestStatements = new Variable(); |
4575 | Variable NextLevel = new Variable(); | 4575 | Variable NextLevel = new Variable(); |
4576 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) | 4576 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements))) |
4577 | { | 4577 | { |
4578 | convertIndentationPython(Level); | 4578 | convertIndentationPython(Level); |
4579 | YP.write(Name); | 4579 | YP.write(Name); |
4580 | YP.write(Atom.a(@" = False")); | 4580 | YP.write(Atom.a(@" = False")); |
4581 | YP.nl(); | 4581 | YP.nl(); |
4582 | convertIndentationPython(Level); | 4582 | convertIndentationPython(Level); |
4583 | YP.write(Atom.a(@"for _ in [1]:")); | 4583 | YP.write(Atom.a(@"for _ in [1]:")); |
4584 | YP.nl(); | 4584 | YP.nl(); |
4585 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 4585 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
4586 | { | 4586 | { |
4587 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) | 4587 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) |
4588 | { | 4588 | { |
4589 | convertIndentationPython(Level); | 4589 | convertIndentationPython(Level); |
4590 | YP.write(Atom.a(@"if ")); | 4590 | YP.write(Atom.a(@"if ")); |
4591 | YP.write(Name); | 4591 | YP.write(Name); |
4592 | YP.write(Atom.a(@":")); | 4592 | YP.write(Atom.a(@":")); |
4593 | YP.nl(); | 4593 | YP.nl(); |
4594 | convertIndentationPython(NextLevel); | 4594 | convertIndentationPython(NextLevel); |
4595 | YP.write(Atom.a(@"doBreak = False")); | 4595 | YP.write(Atom.a(@"doBreak = False")); |
4596 | YP.nl(); | 4596 | YP.nl(); |
4597 | convertIndentationPython(Level); | 4597 | convertIndentationPython(Level); |
4598 | YP.write(Atom.a(@"if doBreak:")); | 4598 | YP.write(Atom.a(@"if doBreak:")); |
4599 | YP.nl(); | 4599 | YP.nl(); |
4600 | convertIndentationPython(NextLevel); | 4600 | convertIndentationPython(NextLevel); |
4601 | YP.write(Atom.a(@"break")); | 4601 | YP.write(Atom.a(@"break")); |
4602 | YP.nl(); | 4602 | YP.nl(); |
4603 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4603 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4604 | { | 4604 | { |
4605 | yield return true; | 4605 | yield return true; |
4606 | yield break; | 4606 | yield break; |
4607 | } | 4607 | } |
4608 | } | 4608 | } |
4609 | } | 4609 | } |
4610 | } | 4610 | } |
4611 | } | 4611 | } |
4612 | { | 4612 | { |
4613 | object Level = arg2; | 4613 | object Level = arg2; |
4614 | object HasBreakableBlock = arg3; | 4614 | object HasBreakableBlock = arg3; |
4615 | Variable _Type = new Variable(); | 4615 | Variable _Type = new Variable(); |
4616 | Variable Name = new Variable(); | 4616 | Variable Name = new Variable(); |
4617 | Variable Expression = new Variable(); | 4617 | Variable Expression = new Variable(); |
4618 | Variable RestStatements = new Variable(); | 4618 | Variable RestStatements = new Variable(); |
4619 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements))) | 4619 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements))) |
4620 | { | 4620 | { |
4621 | convertIndentationPython(Level); | 4621 | convertIndentationPython(Level); |
4622 | YP.write(Name); | 4622 | YP.write(Name); |
4623 | YP.write(Atom.a(@" = ")); | 4623 | YP.write(Atom.a(@" = ")); |
4624 | convertExpressionPython(Expression); | 4624 | convertExpressionPython(Expression); |
4625 | YP.nl(); | 4625 | YP.nl(); |
4626 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4626 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4627 | { | 4627 | { |
4628 | yield return true; | 4628 | yield return true; |
4629 | yield break; | 4629 | yield break; |
4630 | } | 4630 | } |
4631 | } | 4631 | } |
4632 | } | 4632 | } |
4633 | { | 4633 | { |
4634 | object Level = arg2; | 4634 | object Level = arg2; |
4635 | object HasBreakableBlock = arg3; | 4635 | object HasBreakableBlock = arg3; |
4636 | Variable Name = new Variable(); | 4636 | Variable Name = new Variable(); |
4637 | Variable Expression = new Variable(); | 4637 | Variable Expression = new Variable(); |
4638 | Variable RestStatements = new Variable(); | 4638 | Variable RestStatements = new Variable(); |
4639 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) | 4639 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements))) |
4640 | { | 4640 | { |
4641 | convertIndentationPython(Level); | 4641 | convertIndentationPython(Level); |
4642 | YP.write(Name); | 4642 | YP.write(Name); |
4643 | YP.write(Atom.a(@" = ")); | 4643 | YP.write(Atom.a(@" = ")); |
4644 | convertExpressionPython(Expression); | 4644 | convertExpressionPython(Expression); |
4645 | YP.nl(); | 4645 | YP.nl(); |
4646 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4646 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4647 | { | 4647 | { |
4648 | yield return true; | 4648 | yield return true; |
4649 | yield break; | 4649 | yield break; |
4650 | } | 4650 | } |
4651 | } | 4651 | } |
4652 | } | 4652 | } |
4653 | { | 4653 | { |
4654 | object Level = arg2; | 4654 | object Level = arg2; |
4655 | object HasBreakableBlock = arg3; | 4655 | object HasBreakableBlock = arg3; |
4656 | Variable RestStatements = new Variable(); | 4656 | Variable RestStatements = new Variable(); |
4657 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) | 4657 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements))) |
4658 | { | 4658 | { |
4659 | convertIndentationPython(Level); | 4659 | convertIndentationPython(Level); |
4660 | YP.write(Atom.a(@"yield True")); | 4660 | YP.write(Atom.a(@"yield True")); |
4661 | YP.nl(); | 4661 | YP.nl(); |
4662 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4662 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4663 | { | 4663 | { |
4664 | yield return true; | 4664 | yield return true; |
4665 | yield break; | 4665 | yield break; |
4666 | } | 4666 | } |
4667 | } | 4667 | } |
4668 | } | 4668 | } |
4669 | { | 4669 | { |
4670 | object Level = arg2; | 4670 | object Level = arg2; |
4671 | object HasBreakableBlock = arg3; | 4671 | object HasBreakableBlock = arg3; |
4672 | Variable RestStatements = new Variable(); | 4672 | Variable RestStatements = new Variable(); |
4673 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) | 4673 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements))) |
4674 | { | 4674 | { |
4675 | convertIndentationPython(Level); | 4675 | convertIndentationPython(Level); |
4676 | YP.write(Atom.a(@"yield False")); | 4676 | YP.write(Atom.a(@"yield False")); |
4677 | YP.nl(); | 4677 | YP.nl(); |
4678 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4678 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4679 | { | 4679 | { |
4680 | yield return true; | 4680 | yield return true; |
4681 | yield break; | 4681 | yield break; |
4682 | } | 4682 | } |
4683 | } | 4683 | } |
4684 | } | 4684 | } |
4685 | { | 4685 | { |
4686 | object Level = arg2; | 4686 | object Level = arg2; |
4687 | object HasBreakableBlock = arg3; | 4687 | object HasBreakableBlock = arg3; |
4688 | Variable RestStatements = new Variable(); | 4688 | Variable RestStatements = new Variable(); |
4689 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) | 4689 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements))) |
4690 | { | 4690 | { |
4691 | convertIndentationPython(Level); | 4691 | convertIndentationPython(Level); |
4692 | YP.write(Atom.a(@"return")); | 4692 | YP.write(Atom.a(@"return")); |
4693 | YP.nl(); | 4693 | YP.nl(); |
4694 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4694 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4695 | { | 4695 | { |
4696 | yield return true; | 4696 | yield return true; |
4697 | yield break; | 4697 | yield break; |
4698 | } | 4698 | } |
4699 | } | 4699 | } |
4700 | } | 4700 | } |
4701 | { | 4701 | { |
4702 | object Level = arg2; | 4702 | object Level = arg2; |
4703 | object HasBreakableBlock = arg3; | 4703 | object HasBreakableBlock = arg3; |
4704 | Variable RestStatements = new Variable(); | 4704 | Variable RestStatements = new Variable(); |
4705 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) | 4705 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements))) |
4706 | { | 4706 | { |
4707 | convertIndentationPython(Level); | 4707 | convertIndentationPython(Level); |
4708 | YP.write(Atom.a(@"return")); | 4708 | YP.write(Atom.a(@"return")); |
4709 | YP.nl(); | 4709 | YP.nl(); |
4710 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4710 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4711 | { | 4711 | { |
4712 | yield return true; | 4712 | yield return true; |
4713 | yield break; | 4713 | yield break; |
4714 | } | 4714 | } |
4715 | } | 4715 | } |
4716 | } | 4716 | } |
4717 | { | 4717 | { |
4718 | object Level = arg2; | 4718 | object Level = arg2; |
4719 | object HasBreakableBlock = arg3; | 4719 | object HasBreakableBlock = arg3; |
4720 | Variable RestStatements = new Variable(); | 4720 | Variable RestStatements = new Variable(); |
4721 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) | 4721 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements))) |
4722 | { | 4722 | { |
4723 | convertIndentationPython(Level); | 4723 | convertIndentationPython(Level); |
4724 | YP.write(Atom.a(@"return True")); | 4724 | YP.write(Atom.a(@"return True")); |
4725 | YP.nl(); | 4725 | YP.nl(); |
4726 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4726 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4727 | { | 4727 | { |
4728 | yield return true; | 4728 | yield return true; |
4729 | yield break; | 4729 | yield break; |
4730 | } | 4730 | } |
4731 | } | 4731 | } |
4732 | } | 4732 | } |
4733 | { | 4733 | { |
4734 | object Level = arg2; | 4734 | object Level = arg2; |
4735 | object HasBreakableBlock = arg3; | 4735 | object HasBreakableBlock = arg3; |
4736 | Variable RestStatements = new Variable(); | 4736 | Variable RestStatements = new Variable(); |
4737 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) | 4737 | foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements))) |
4738 | { | 4738 | { |
4739 | convertIndentationPython(Level); | 4739 | convertIndentationPython(Level); |
4740 | YP.write(Atom.a(@"return False")); | 4740 | YP.write(Atom.a(@"return False")); |
4741 | YP.nl(); | 4741 | YP.nl(); |
4742 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4742 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4743 | { | 4743 | { |
4744 | yield return true; | 4744 | yield return true; |
4745 | yield break; | 4745 | yield break; |
4746 | } | 4746 | } |
4747 | } | 4747 | } |
4748 | } | 4748 | } |
4749 | { | 4749 | { |
4750 | object Level = arg2; | 4750 | object Level = arg2; |
4751 | object HasBreakableBlock = arg3; | 4751 | object HasBreakableBlock = arg3; |
4752 | Variable Name = new Variable(); | 4752 | Variable Name = new Variable(); |
4753 | Variable RestStatements = new Variable(); | 4753 | Variable RestStatements = new Variable(); |
4754 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) | 4754 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements))) |
4755 | { | 4755 | { |
4756 | convertIndentationPython(Level); | 4756 | convertIndentationPython(Level); |
4757 | YP.write(Name); | 4757 | YP.write(Name); |
4758 | YP.write(Atom.a(@" = True")); | 4758 | YP.write(Atom.a(@" = True")); |
4759 | YP.nl(); | 4759 | YP.nl(); |
4760 | convertIndentationPython(Level); | 4760 | convertIndentationPython(Level); |
4761 | YP.write(Atom.a(@"doBreak = True")); | 4761 | YP.write(Atom.a(@"doBreak = True")); |
4762 | YP.nl(); | 4762 | YP.nl(); |
4763 | convertIndentationPython(Level); | 4763 | convertIndentationPython(Level); |
4764 | YP.write(Atom.a(@"break")); | 4764 | YP.write(Atom.a(@"break")); |
4765 | YP.nl(); | 4765 | YP.nl(); |
4766 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4766 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4767 | { | 4767 | { |
4768 | yield return true; | 4768 | yield return true; |
4769 | yield break; | 4769 | yield break; |
4770 | } | 4770 | } |
4771 | } | 4771 | } |
4772 | } | 4772 | } |
4773 | { | 4773 | { |
4774 | object Level = arg2; | 4774 | object Level = arg2; |
4775 | object HasBreakableBlock = arg3; | 4775 | object HasBreakableBlock = arg3; |
4776 | Variable Name = new Variable(); | 4776 | Variable Name = new Variable(); |
4777 | Variable ArgList = new Variable(); | 4777 | Variable ArgList = new Variable(); |
4778 | Variable RestStatements = new Variable(); | 4778 | Variable RestStatements = new Variable(); |
4779 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) | 4779 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements))) |
4780 | { | 4780 | { |
4781 | convertIndentationPython(Level); | 4781 | convertIndentationPython(Level); |
4782 | YP.write(Name); | 4782 | YP.write(Name); |
4783 | YP.write(Atom.a(@"(")); | 4783 | YP.write(Atom.a(@"(")); |
4784 | convertArgListPython(ArgList); | 4784 | convertArgListPython(ArgList); |
4785 | YP.write(Atom.a(@")")); | 4785 | YP.write(Atom.a(@")")); |
4786 | YP.nl(); | 4786 | YP.nl(); |
4787 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4787 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4788 | { | 4788 | { |
4789 | yield return true; | 4789 | yield return true; |
4790 | yield break; | 4790 | yield break; |
4791 | } | 4791 | } |
4792 | } | 4792 | } |
4793 | } | 4793 | } |
4794 | { | 4794 | { |
4795 | object Level = arg2; | 4795 | object Level = arg2; |
4796 | object HasBreakableBlock = arg3; | 4796 | object HasBreakableBlock = arg3; |
4797 | Variable Obj = new Variable(); | 4797 | Variable Obj = new Variable(); |
4798 | Variable Name = new Variable(); | 4798 | Variable Name = new Variable(); |
4799 | Variable ArgList = new Variable(); | 4799 | Variable ArgList = new Variable(); |
4800 | Variable RestStatements = new Variable(); | 4800 | Variable RestStatements = new Variable(); |
4801 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) | 4801 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements))) |
4802 | { | 4802 | { |
4803 | convertIndentationPython(Level); | 4803 | convertIndentationPython(Level); |
4804 | YP.write(Obj); | 4804 | YP.write(Obj); |
4805 | YP.write(Atom.a(@".")); | 4805 | YP.write(Atom.a(@".")); |
4806 | YP.write(Name); | 4806 | YP.write(Name); |
4807 | YP.write(Atom.a(@"(")); | 4807 | YP.write(Atom.a(@"(")); |
4808 | convertArgListPython(ArgList); | 4808 | convertArgListPython(ArgList); |
4809 | YP.write(Atom.a(@")")); | 4809 | YP.write(Atom.a(@")")); |
4810 | YP.nl(); | 4810 | YP.nl(); |
4811 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4811 | foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4812 | { | 4812 | { |
4813 | yield return true; | 4813 | yield return true; |
4814 | yield break; | 4814 | yield break; |
4815 | } | 4815 | } |
4816 | } | 4816 | } |
4817 | } | 4817 | } |
4818 | { | 4818 | { |
4819 | object Level = arg2; | 4819 | object Level = arg2; |
4820 | object HasBreakableBlock = arg3; | 4820 | object HasBreakableBlock = arg3; |
4821 | Variable Body = new Variable(); | 4821 | Variable Body = new Variable(); |
4822 | Variable RestStatements = new Variable(); | 4822 | Variable RestStatements = new Variable(); |
4823 | Variable NextLevel = new Variable(); | 4823 | Variable NextLevel = new Variable(); |
4824 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) | 4824 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements))) |
4825 | { | 4825 | { |
4826 | if (YP.termEqual(HasBreakableBlock, 1)) | 4826 | if (YP.termEqual(HasBreakableBlock, 1)) |
4827 | { | 4827 | { |
4828 | convertIndentationPython(Level); | 4828 | convertIndentationPython(Level); |
4829 | YP.write(Atom.a(@"for _ in [1]:")); | 4829 | YP.write(Atom.a(@"for _ in [1]:")); |
4830 | YP.nl(); | 4830 | YP.nl(); |
4831 | foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1))) | 4831 | foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1))) |
4832 | { | 4832 | { |
4833 | foreach (bool l5 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) | 4833 | foreach (bool l5 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) |
4834 | { | 4834 | { |
4835 | if (YP.termEqual(HasBreakableBlock, 1)) | 4835 | if (YP.termEqual(HasBreakableBlock, 1)) |
4836 | { | 4836 | { |
4837 | if (YP.greaterThan(Level, 1)) | 4837 | if (YP.greaterThan(Level, 1)) |
4838 | { | 4838 | { |
4839 | convertIndentationPython(Level); | 4839 | convertIndentationPython(Level); |
4840 | YP.write(Atom.a(@"if doBreak:")); | 4840 | YP.write(Atom.a(@"if doBreak:")); |
4841 | YP.nl(); | 4841 | YP.nl(); |
4842 | convertIndentationPython(NextLevel); | 4842 | convertIndentationPython(NextLevel); |
4843 | YP.write(Atom.a(@"break")); | 4843 | YP.write(Atom.a(@"break")); |
4844 | YP.nl(); | 4844 | YP.nl(); |
4845 | foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4845 | foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4846 | { | 4846 | { |
4847 | yield return true; | 4847 | yield return true; |
4848 | yield break; | 4848 | yield break; |
4849 | } | 4849 | } |
4850 | goto cutIf3; | 4850 | goto cutIf3; |
4851 | } | 4851 | } |
4852 | foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4852 | foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4853 | { | 4853 | { |
4854 | yield return true; | 4854 | yield return true; |
4855 | yield break; | 4855 | yield break; |
4856 | } | 4856 | } |
4857 | cutIf3: | 4857 | cutIf3: |
4858 | goto cutIf2; | 4858 | goto cutIf2; |
4859 | } | 4859 | } |
4860 | foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4860 | foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4861 | { | 4861 | { |
4862 | yield return true; | 4862 | yield return true; |
4863 | yield break; | 4863 | yield break; |
4864 | } | 4864 | } |
4865 | cutIf2: | 4865 | cutIf2: |
4866 | { } | 4866 | { } |
4867 | } | 4867 | } |
4868 | } | 4868 | } |
4869 | goto cutIf1; | 4869 | goto cutIf1; |
4870 | } | 4870 | } |
4871 | foreach (bool l3 in YP.unify(NextLevel, Level)) | 4871 | foreach (bool l3 in YP.unify(NextLevel, Level)) |
4872 | { | 4872 | { |
4873 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) | 4873 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) |
4874 | { | 4874 | { |
4875 | if (YP.termEqual(HasBreakableBlock, 1)) | 4875 | if (YP.termEqual(HasBreakableBlock, 1)) |
4876 | { | 4876 | { |
4877 | if (YP.greaterThan(Level, 1)) | 4877 | if (YP.greaterThan(Level, 1)) |
4878 | { | 4878 | { |
4879 | convertIndentationPython(Level); | 4879 | convertIndentationPython(Level); |
4880 | YP.write(Atom.a(@"if doBreak:")); | 4880 | YP.write(Atom.a(@"if doBreak:")); |
4881 | YP.nl(); | 4881 | YP.nl(); |
4882 | convertIndentationPython(NextLevel); | 4882 | convertIndentationPython(NextLevel); |
4883 | YP.write(Atom.a(@"break")); | 4883 | YP.write(Atom.a(@"break")); |
4884 | YP.nl(); | 4884 | YP.nl(); |
4885 | foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4885 | foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4886 | { | 4886 | { |
4887 | yield return true; | 4887 | yield return true; |
4888 | yield break; | 4888 | yield break; |
4889 | } | 4889 | } |
4890 | goto cutIf5; | 4890 | goto cutIf5; |
4891 | } | 4891 | } |
4892 | foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4892 | foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4893 | { | 4893 | { |
4894 | yield return true; | 4894 | yield return true; |
4895 | yield break; | 4895 | yield break; |
4896 | } | 4896 | } |
4897 | cutIf5: | 4897 | cutIf5: |
4898 | goto cutIf4; | 4898 | goto cutIf4; |
4899 | } | 4899 | } |
4900 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4900 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4901 | { | 4901 | { |
4902 | yield return true; | 4902 | yield return true; |
4903 | yield break; | 4903 | yield break; |
4904 | } | 4904 | } |
4905 | cutIf4: | 4905 | cutIf4: |
4906 | { } | 4906 | { } |
4907 | } | 4907 | } |
4908 | } | 4908 | } |
4909 | cutIf1: | 4909 | cutIf1: |
4910 | { } | 4910 | { } |
4911 | } | 4911 | } |
4912 | } | 4912 | } |
4913 | { | 4913 | { |
4914 | object Level = arg2; | 4914 | object Level = arg2; |
4915 | object HasBreakableBlock = arg3; | 4915 | object HasBreakableBlock = arg3; |
4916 | Variable Expression = new Variable(); | 4916 | Variable Expression = new Variable(); |
4917 | Variable Body = new Variable(); | 4917 | Variable Body = new Variable(); |
4918 | Variable RestStatements = new Variable(); | 4918 | Variable RestStatements = new Variable(); |
4919 | Variable NextLevel = new Variable(); | 4919 | Variable NextLevel = new Variable(); |
4920 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) | 4920 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements))) |
4921 | { | 4921 | { |
4922 | convertIndentationPython(Level); | 4922 | convertIndentationPython(Level); |
4923 | YP.write(Atom.a(@"if ")); | 4923 | YP.write(Atom.a(@"if ")); |
4924 | convertExpressionPython(Expression); | 4924 | convertExpressionPython(Expression); |
4925 | YP.write(Atom.a(@":")); | 4925 | YP.write(Atom.a(@":")); |
4926 | YP.nl(); | 4926 | YP.nl(); |
4927 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 4927 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
4928 | { | 4928 | { |
4929 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) | 4929 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) |
4930 | { | 4930 | { |
4931 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4931 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4932 | { | 4932 | { |
4933 | yield return true; | 4933 | yield return true; |
4934 | yield break; | 4934 | yield break; |
4935 | } | 4935 | } |
4936 | } | 4936 | } |
4937 | } | 4937 | } |
4938 | } | 4938 | } |
4939 | } | 4939 | } |
4940 | { | 4940 | { |
4941 | object Level = arg2; | 4941 | object Level = arg2; |
4942 | object HasBreakableBlock = arg3; | 4942 | object HasBreakableBlock = arg3; |
4943 | Variable Expression = new Variable(); | 4943 | Variable Expression = new Variable(); |
4944 | Variable Body = new Variable(); | 4944 | Variable Body = new Variable(); |
4945 | Variable RestStatements = new Variable(); | 4945 | Variable RestStatements = new Variable(); |
4946 | Variable NextLevel = new Variable(); | 4946 | Variable NextLevel = new Variable(); |
4947 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) | 4947 | foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements))) |
4948 | { | 4948 | { |
4949 | convertIndentationPython(Level); | 4949 | convertIndentationPython(Level); |
4950 | YP.write(Atom.a(@"for l")); | 4950 | YP.write(Atom.a(@"for l")); |
4951 | YP.write(Level); | 4951 | YP.write(Level); |
4952 | YP.write(Atom.a(@" in ")); | 4952 | YP.write(Atom.a(@" in ")); |
4953 | convertExpressionPython(Expression); | 4953 | convertExpressionPython(Expression); |
4954 | YP.write(Atom.a(@":")); | 4954 | YP.write(Atom.a(@":")); |
4955 | YP.nl(); | 4955 | YP.nl(); |
4956 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) | 4956 | foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1))) |
4957 | { | 4957 | { |
4958 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) | 4958 | foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock)) |
4959 | { | 4959 | { |
4960 | if (YP.termEqual(HasBreakableBlock, 1)) | 4960 | if (YP.termEqual(HasBreakableBlock, 1)) |
4961 | { | 4961 | { |
4962 | convertIndentationPython(Level); | 4962 | convertIndentationPython(Level); |
4963 | YP.write(Atom.a(@"if doBreak:")); | 4963 | YP.write(Atom.a(@"if doBreak:")); |
4964 | YP.nl(); | 4964 | YP.nl(); |
4965 | convertIndentationPython(NextLevel); | 4965 | convertIndentationPython(NextLevel); |
4966 | YP.write(Atom.a(@"break")); | 4966 | YP.write(Atom.a(@"break")); |
4967 | YP.nl(); | 4967 | YP.nl(); |
4968 | foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4968 | foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4969 | { | 4969 | { |
4970 | yield return true; | 4970 | yield return true; |
4971 | yield break; | 4971 | yield break; |
4972 | } | 4972 | } |
4973 | goto cutIf6; | 4973 | goto cutIf6; |
4974 | } | 4974 | } |
4975 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) | 4975 | foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock)) |
4976 | { | 4976 | { |
4977 | yield return true; | 4977 | yield return true; |
4978 | yield break; | 4978 | yield break; |
4979 | } | 4979 | } |
4980 | cutIf6: | 4980 | cutIf6: |
4981 | { } | 4981 | { } |
4982 | } | 4982 | } |
4983 | } | 4983 | } |
4984 | } | 4984 | } |
4985 | } | 4985 | } |
4986 | } | 4986 | } |
4987 | 4987 | ||
4988 | public static void convertIndentationPython(object Level) | 4988 | public static void convertIndentationPython(object Level) |
4989 | { | 4989 | { |
4990 | { | 4990 | { |
4991 | Variable N = new Variable(); | 4991 | Variable N = new Variable(); |
4992 | foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) | 4992 | foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2))) |
4993 | { | 4993 | { |
4994 | repeatWrite(Atom.a(@" "), N); | 4994 | repeatWrite(Atom.a(@" "), N); |
4995 | return; | 4995 | return; |
4996 | } | 4996 | } |
4997 | } | 4997 | } |
4998 | } | 4998 | } |
4999 | 4999 | ||
5000 | public static void convertArgListPython(object arg1) | 5000 | public static void convertArgListPython(object arg1) |
5001 | { | 5001 | { |
5002 | { | 5002 | { |
5003 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 5003 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
5004 | { | 5004 | { |
5005 | return; | 5005 | return; |
5006 | } | 5006 | } |
5007 | } | 5007 | } |
5008 | { | 5008 | { |
5009 | Variable Head = new Variable(); | 5009 | Variable Head = new Variable(); |
5010 | Variable Tail = new Variable(); | 5010 | Variable Tail = new Variable(); |
5011 | foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail))) | 5011 | foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail))) |
5012 | { | 5012 | { |
5013 | convertExpressionPython(Head); | 5013 | convertExpressionPython(Head); |
5014 | if (YP.termNotEqual(Tail, Atom.NIL)) | 5014 | if (YP.termNotEqual(Tail, Atom.NIL)) |
5015 | { | 5015 | { |
5016 | YP.write(Atom.a(@", ")); | 5016 | YP.write(Atom.a(@", ")); |
5017 | convertArgListPython(Tail); | 5017 | convertArgListPython(Tail); |
5018 | return; | 5018 | return; |
5019 | goto cutIf1; | 5019 | goto cutIf1; |
5020 | } | 5020 | } |
5021 | convertArgListPython(Tail); | 5021 | convertArgListPython(Tail); |
5022 | return; | 5022 | return; |
5023 | cutIf1: | 5023 | cutIf1: |
5024 | { } | 5024 | { } |
5025 | } | 5025 | } |
5026 | } | 5026 | } |
5027 | } | 5027 | } |
5028 | 5028 | ||
5029 | public static void convertExpressionPython(object arg1) | 5029 | public static void convertExpressionPython(object arg1) |
5030 | { | 5030 | { |
5031 | { | 5031 | { |
5032 | Variable X = new Variable(); | 5032 | Variable X = new Variable(); |
5033 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) | 5033 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X))) |
5034 | { | 5034 | { |
5035 | YP.write(X); | 5035 | YP.write(X); |
5036 | return; | 5036 | return; |
5037 | } | 5037 | } |
5038 | } | 5038 | } |
5039 | { | 5039 | { |
5040 | Variable Name = new Variable(); | 5040 | Variable Name = new Variable(); |
5041 | Variable ArgList = new Variable(); | 5041 | Variable ArgList = new Variable(); |
5042 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) | 5042 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList))) |
5043 | { | 5043 | { |
5044 | YP.write(Name); | 5044 | YP.write(Name); |
5045 | YP.write(Atom.a(@"(")); | 5045 | YP.write(Atom.a(@"(")); |
5046 | convertArgListPython(ArgList); | 5046 | convertArgListPython(ArgList); |
5047 | YP.write(Atom.a(@")")); | 5047 | YP.write(Atom.a(@")")); |
5048 | return; | 5048 | return; |
5049 | } | 5049 | } |
5050 | } | 5050 | } |
5051 | { | 5051 | { |
5052 | Variable Obj = new Variable(); | 5052 | Variable Obj = new Variable(); |
5053 | Variable Name = new Variable(); | 5053 | Variable Name = new Variable(); |
5054 | Variable ArgList = new Variable(); | 5054 | Variable ArgList = new Variable(); |
5055 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) | 5055 | foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList))) |
5056 | { | 5056 | { |
5057 | YP.write(Obj); | 5057 | YP.write(Obj); |
5058 | YP.write(Atom.a(@".")); | 5058 | YP.write(Atom.a(@".")); |
5059 | YP.write(Name); | 5059 | YP.write(Name); |
5060 | YP.write(Atom.a(@"(")); | 5060 | YP.write(Atom.a(@"(")); |
5061 | convertArgListPython(ArgList); | 5061 | convertArgListPython(ArgList); |
5062 | YP.write(Atom.a(@")")); | 5062 | YP.write(Atom.a(@")")); |
5063 | return; | 5063 | return; |
5064 | } | 5064 | } |
5065 | } | 5065 | } |
5066 | { | 5066 | { |
5067 | Variable Name = new Variable(); | 5067 | Variable Name = new Variable(); |
5068 | Variable ArgList = new Variable(); | 5068 | Variable ArgList = new Variable(); |
5069 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) | 5069 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList))) |
5070 | { | 5070 | { |
5071 | YP.write(Name); | 5071 | YP.write(Name); |
5072 | YP.write(Atom.a(@"(")); | 5072 | YP.write(Atom.a(@"(")); |
5073 | convertArgListPython(ArgList); | 5073 | convertArgListPython(ArgList); |
5074 | YP.write(Atom.a(@")")); | 5074 | YP.write(Atom.a(@")")); |
5075 | return; | 5075 | return; |
5076 | } | 5076 | } |
5077 | } | 5077 | } |
5078 | { | 5078 | { |
5079 | Variable Name = new Variable(); | 5079 | Variable Name = new Variable(); |
5080 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) | 5080 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name))) |
5081 | { | 5081 | { |
5082 | YP.write(Name); | 5082 | YP.write(Name); |
5083 | return; | 5083 | return; |
5084 | } | 5084 | } |
5085 | } | 5085 | } |
5086 | { | 5086 | { |
5087 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) | 5087 | foreach (bool l2 in YP.unify(arg1, Atom.a(@"null"))) |
5088 | { | 5088 | { |
5089 | YP.write(Atom.a(@"None")); | 5089 | YP.write(Atom.a(@"None")); |
5090 | return; | 5090 | return; |
5091 | } | 5091 | } |
5092 | } | 5092 | } |
5093 | { | 5093 | { |
5094 | Variable X = new Variable(); | 5094 | Variable X = new Variable(); |
5095 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) | 5095 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X))) |
5096 | { | 5096 | { |
5097 | YP.write(Atom.a(@"not (")); | 5097 | YP.write(Atom.a(@"not (")); |
5098 | convertExpressionPython(X); | 5098 | convertExpressionPython(X); |
5099 | YP.write(Atom.a(@")")); | 5099 | YP.write(Atom.a(@")")); |
5100 | return; | 5100 | return; |
5101 | } | 5101 | } |
5102 | } | 5102 | } |
5103 | { | 5103 | { |
5104 | Variable X = new Variable(); | 5104 | Variable X = new Variable(); |
5105 | Variable Y = new Variable(); | 5105 | Variable Y = new Variable(); |
5106 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) | 5106 | foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y))) |
5107 | { | 5107 | { |
5108 | YP.write(Atom.a(@"(")); | 5108 | YP.write(Atom.a(@"(")); |
5109 | convertExpressionPython(X); | 5109 | convertExpressionPython(X); |
5110 | YP.write(Atom.a(@") and (")); | 5110 | YP.write(Atom.a(@") and (")); |
5111 | convertExpressionPython(Y); | 5111 | convertExpressionPython(Y); |
5112 | YP.write(Atom.a(@")")); | 5112 | YP.write(Atom.a(@")")); |
5113 | return; | 5113 | return; |
5114 | } | 5114 | } |
5115 | } | 5115 | } |
5116 | { | 5116 | { |
5117 | Variable ArgList = new Variable(); | 5117 | Variable ArgList = new Variable(); |
5118 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) | 5118 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList))) |
5119 | { | 5119 | { |
5120 | YP.write(Atom.a(@"[")); | 5120 | YP.write(Atom.a(@"[")); |
5121 | convertArgListPython(ArgList); | 5121 | convertArgListPython(ArgList); |
5122 | YP.write(Atom.a(@"]")); | 5122 | YP.write(Atom.a(@"]")); |
5123 | return; | 5123 | return; |
5124 | } | 5124 | } |
5125 | } | 5125 | } |
5126 | { | 5126 | { |
5127 | Variable X = new Variable(); | 5127 | Variable X = new Variable(); |
5128 | Variable Codes = new Variable(); | 5128 | Variable Codes = new Variable(); |
5129 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) | 5129 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) |
5130 | { | 5130 | { |
5131 | if (YP.atom(X)) | 5131 | if (YP.atom(X)) |
5132 | { | 5132 | { |
5133 | YP.write(Atom.a(@"""")); | 5133 | YP.write(Atom.a(@"""")); |
5134 | foreach (bool l4 in YP.atom_codes(X, Codes)) | 5134 | foreach (bool l4 in YP.atom_codes(X, Codes)) |
5135 | { | 5135 | { |
5136 | convertStringCodesPython(Codes); | 5136 | convertStringCodesPython(Codes); |
5137 | YP.write(Atom.a(@"""")); | 5137 | YP.write(Atom.a(@"""")); |
5138 | return; | 5138 | return; |
5139 | } | 5139 | } |
5140 | } | 5140 | } |
5141 | } | 5141 | } |
5142 | } | 5142 | } |
5143 | { | 5143 | { |
5144 | Variable X = new Variable(); | 5144 | Variable X = new Variable(); |
5145 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) | 5145 | foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X))) |
5146 | { | 5146 | { |
5147 | YP.write(X); | 5147 | YP.write(X); |
5148 | return; | 5148 | return; |
5149 | } | 5149 | } |
5150 | } | 5150 | } |
5151 | } | 5151 | } |
5152 | 5152 | ||
5153 | public static void convertStringCodesPython(object arg1) | 5153 | public static void convertStringCodesPython(object arg1) |
5154 | { | 5154 | { |
5155 | { | 5155 | { |
5156 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 5156 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
5157 | { | 5157 | { |
5158 | return; | 5158 | return; |
5159 | } | 5159 | } |
5160 | } | 5160 | } |
5161 | { | 5161 | { |
5162 | Variable Code = new Variable(); | 5162 | Variable Code = new Variable(); |
5163 | Variable RestCodes = new Variable(); | 5163 | Variable RestCodes = new Variable(); |
5164 | foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) | 5164 | foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes))) |
5165 | { | 5165 | { |
5166 | if (YP.termEqual(Code, 34)) | 5166 | if (YP.termEqual(Code, 34)) |
5167 | { | 5167 | { |
5168 | YP.put_code(92); | 5168 | YP.put_code(92); |
5169 | YP.put_code(Code); | 5169 | YP.put_code(Code); |
5170 | convertStringCodesPython(RestCodes); | 5170 | convertStringCodesPython(RestCodes); |
5171 | return; | 5171 | return; |
5172 | goto cutIf1; | 5172 | goto cutIf1; |
5173 | } | 5173 | } |
5174 | if (YP.termEqual(Code, 92)) | 5174 | if (YP.termEqual(Code, 92)) |
5175 | { | 5175 | { |
5176 | YP.put_code(92); | 5176 | YP.put_code(92); |
5177 | YP.put_code(Code); | 5177 | YP.put_code(Code); |
5178 | convertStringCodesPython(RestCodes); | 5178 | convertStringCodesPython(RestCodes); |
5179 | return; | 5179 | return; |
5180 | goto cutIf1; | 5180 | goto cutIf1; |
5181 | } | 5181 | } |
5182 | YP.put_code(Code); | 5182 | YP.put_code(Code); |
5183 | convertStringCodesPython(RestCodes); | 5183 | convertStringCodesPython(RestCodes); |
5184 | return; | 5184 | return; |
5185 | cutIf1: | 5185 | cutIf1: |
5186 | { } | 5186 | { } |
5187 | } | 5187 | } |
5188 | } | 5188 | } |
5189 | } | 5189 | } |
5190 | 5190 | ||
5191 | public static IEnumerable<bool> member(object X, object arg2) | 5191 | public static IEnumerable<bool> member(object X, object arg2) |
5192 | { | 5192 | { |
5193 | { | 5193 | { |
5194 | Variable x2 = new Variable(); | 5194 | Variable x2 = new Variable(); |
5195 | foreach (bool l2 in YP.unify(arg2, new ListPair(X, x2))) | 5195 | foreach (bool l2 in YP.unify(arg2, new ListPair(X, x2))) |
5196 | { | 5196 | { |
5197 | yield return false; | 5197 | yield return false; |
5198 | } | 5198 | } |
5199 | } | 5199 | } |
5200 | { | 5200 | { |
5201 | Variable x2 = new Variable(); | 5201 | Variable x2 = new Variable(); |
5202 | Variable Rest = new Variable(); | 5202 | Variable Rest = new Variable(); |
5203 | foreach (bool l2 in YP.unify(arg2, new ListPair(x2, Rest))) | 5203 | foreach (bool l2 in YP.unify(arg2, new ListPair(x2, Rest))) |
5204 | { | 5204 | { |
5205 | foreach (bool l3 in member(X, Rest)) | 5205 | foreach (bool l3 in member(X, Rest)) |
5206 | { | 5206 | { |
5207 | yield return false; | 5207 | yield return false; |
5208 | } | 5208 | } |
5209 | } | 5209 | } |
5210 | } | 5210 | } |
5211 | } | 5211 | } |
5212 | 5212 | ||
5213 | public static IEnumerable<bool> append(object arg1, object arg2, object arg3) | 5213 | public static IEnumerable<bool> append(object arg1, object arg2, object arg3) |
5214 | { | 5214 | { |
5215 | { | 5215 | { |
5216 | Variable List = new Variable(); | 5216 | Variable List = new Variable(); |
5217 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) | 5217 | foreach (bool l2 in YP.unify(arg1, Atom.NIL)) |
5218 | { | 5218 | { |
5219 | foreach (bool l3 in YP.unify(arg2, List)) | 5219 | foreach (bool l3 in YP.unify(arg2, List)) |
5220 | { | 5220 | { |
5221 | foreach (bool l4 in YP.unify(arg3, List)) | 5221 | foreach (bool l4 in YP.unify(arg3, List)) |
5222 | { | 5222 | { |
5223 | yield return false; | 5223 | yield return false; |
5224 | } | 5224 | } |
5225 | } | 5225 | } |
5226 | } | 5226 | } |
5227 | } | 5227 | } |
5228 | { | 5228 | { |
5229 | object List2 = arg2; | 5229 | object List2 = arg2; |
5230 | Variable X = new Variable(); | 5230 | Variable X = new Variable(); |
5231 | Variable List1 = new Variable(); | 5231 | Variable List1 = new Variable(); |
5232 | Variable List12 = new Variable(); | 5232 | Variable List12 = new Variable(); |
5233 | foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1))) | 5233 | foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1))) |
5234 | { | 5234 | { |
5235 | foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12))) | 5235 | foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12))) |
5236 | { | 5236 | { |
5237 | foreach (bool l4 in append(List1, List2, List12)) | 5237 | foreach (bool l4 in append(List1, List2, List12)) |
5238 | { | 5238 | { |
5239 | yield return false; | 5239 | yield return false; |
5240 | } | 5240 | } |
5241 | } | 5241 | } |
5242 | } | 5242 | } |
5243 | } | 5243 | } |
5244 | } | 5244 | } |
5245 | 5245 | ||
5246 | } | 5246 | } |
5247 | } | 5247 | } |