aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCharles Krinke2008-08-13 14:13:49 +0000
committerCharles Krinke2008-08-13 14:13:49 +0000
commit323ada012d3bed0c6f7a6d5d0ee14b409b7457c7 (patch)
treed5a2e30707baba7804aefb341774d6d51ca7b439
parentThank you, tyre, for a patch that fixes a null reference in LSL (diff)
downloadopensim-SC_OLD-323ada012d3bed0c6f7a6d5d0ee14b409b7457c7.zip
opensim-SC_OLD-323ada012d3bed0c6f7a6d5d0ee14b409b7457c7.tar.gz
opensim-SC_OLD-323ada012d3bed0c6f7a6d5d0ee14b409b7457c7.tar.bz2
opensim-SC_OLD-323ada012d3bed0c6f7a6d5d0ee14b409b7457c7.tar.xz
Mantis#1931. Thank you kindly, Kinoc for a patch that:
* Yield Prolog 1.0.1 Released : it passes all but 9 of the 421 tests in the ISO Prolog test suite (97.8%) . * support dynamic predicates and rules. * support 'import' to use external static functions improves connection to C# functions * Matches Yield Prolog r831
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs514
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT109
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs317
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs318
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs22
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs514
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs319
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs326
23 files changed, 2060 insertions, 584 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs
index 07993ea..4aa4ce4 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor.cs
@@ -98,6 +98,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
98 return make(Atom.a(name), args); 98 return make(Atom.a(name), args);
99 } 99 }
100 100
101 /// <summary>
102 /// If arg is another Functor, then succeed (yield once) if this and arg have the
103 /// same name and all functor args unify, otherwise fail (don't yield).
104 /// If arg is a Variable, then call its unify to unify with this.
105 /// Otherwise fail (don't yield).
106 /// </summary>
107 /// <param name="arg"></param>
108 /// <returns></returns>
101 public IEnumerable<bool> unify(object arg) 109 public IEnumerable<bool> unify(object arg)
102 { 110 {
103 arg = YP.getValue(arg); 111 arg = YP.getValue(arg);
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs
index e023984..fa05270 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs
@@ -52,6 +52,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
52 // disable warning on l1, don't see how we can 52 // disable warning on l1, don't see how we can
53 // code this differently 53 // code this differently
54 #pragma warning disable 0168 54 #pragma warning disable 0168
55 /// <summary>
56 /// If arg is another Functor1, then succeed (yield once) if this and arg have the
57 /// same name and the functor args unify, otherwise fail (don't yield).
58 /// If arg is a Variable, then call its unify to unify with this.
59 /// Otherwise fail (don't yield).
60 /// </summary>
61 /// <param name="arg"></param>
62 /// <returns></returns>
55 public IEnumerable<bool> unify(object arg) 63 public IEnumerable<bool> unify(object arg)
56 { 64 {
57 arg = YP.getValue(arg); 65 arg = YP.getValue(arg);
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs
index 432d328..a65022f 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor2.cs
@@ -54,6 +54,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
54 // disable warning on l1, don't see how we can 54 // disable warning on l1, don't see how we can
55 // code this differently 55 // code this differently
56 #pragma warning disable 0168 56 #pragma warning disable 0168
57 /// If arg is another Functor2, then succeed (yield once) if this and arg have the
58 /// same name and all functor args unify, otherwise fail (don't yield).
59 /// If arg is a Variable, then call its unify to unify with this.
60 /// Otherwise fail (don't yield).
57 public IEnumerable<bool> unify(object arg) 61 public IEnumerable<bool> unify(object arg)
58 { 62 {
59 arg = YP.getValue(arg); 63 arg = YP.getValue(arg);
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs
index b429608..b9738da 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs
@@ -56,6 +56,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
56 // disable warning on l1, don't see how we can 56 // disable warning on l1, don't see how we can
57 // code this differently 57 // code this differently
58 #pragma warning disable 0168 58 #pragma warning disable 0168
59 /// If arg is another Functor3, then succeed (yield once) if this and arg have the
60 /// same name and all functor args unify, otherwise fail (don't yield).
61 /// If arg is a Variable, then call its unify to unify with this.
62 /// Otherwise fail (don't yield).
59 public IEnumerable<bool> unify(object arg) 63 public IEnumerable<bool> unify(object arg)
60 { 64 {
61 arg = YP.getValue(arg); 65 arg = YP.getValue(arg);
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs
index 5810c0b..999208d 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/IndexedAnswers.cs
@@ -270,8 +270,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
270 throw new PrologException("instantiation_error", "Head is an unbound variable"); 270 throw new PrologException("instantiation_error", "Head is an unbound variable");
271 object[] arguments = YP.getFunctorArgs(Head); 271 object[] arguments = YP.getFunctorArgs(Head);
272 272
273 // We always match Head from _allAnswers, and the Body is 273 // We always match Head from _allAnswers, and the Body is Atom.a("true").
274 // Atom.a("true").
275 #pragma warning disable 0168 274 #pragma warning disable 0168
276 foreach (bool l1 in YP.unify(Body, Atom.a("true"))) 275 foreach (bool l1 in YP.unify(Body, Atom.a("true")))
277 { 276 {
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs
index f0669f6..c00a556 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/ListPair.cs
@@ -132,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
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 /// If the list or one of the tails of the list is Variable, raise an instantiation_error.
135 /// This does not call YP.getValue on each element. 136 /// This does not call YP.getValue on each element.
136 /// </summary> 137 /// </summary>
137 /// <param name="list"></param> 138 /// <param name="list"></param>
@@ -143,10 +144,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
143 return new object[0]; 144 return new object[0];
144 145
145 List<object> result = new List<object>(); 146 List<object> result = new List<object>();
146 for (object element = list; 147 object element = list;
147 element is Functor2 && ((Functor2)element)._name == Atom.DOT; 148 while (true) {
148 element = YP.getValue(((Functor2)element)._arg2)) 149 if (element == Atom.NIL)
150 break;
151 if (element is Variable)
152 throw new PrologException(Atom.a("instantiation_error"),
153 "List tail is an unbound variable");
154 if (!(element is Functor2 && ((Functor2)element)._name == Atom.DOT))
155 // Not a proper list.
156 return null;
149 result.Add(((Functor2)element)._arg1); 157 result.Add(((Functor2)element)._arg1);
158 element = YP.getValue(((Functor2)element)._arg2);
159 }
150 160
151 if (result.Count <= 0) 161 if (result.Count <= 0)
152 return null; 162 return null;
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs
index 3ceb0df..d1c060b 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Parser.cs
@@ -31,10 +31,86 @@
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33 33
34 // disable warning on l1, don't see how we can
35 // code this differently
36 #pragma warning disable 0168, 0219, 0162
37
34namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog 38namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
35{ 39{
36 public class Parser 40 public class Parser
37 { 41 {
42 public static IEnumerable<bool> read_term2(object Term, object Options)
43 {
44 Variable Answer = new Variable();
45 Variable Variables = new Variable();
46 foreach (bool l1 in read_termOptions(Options, Variables))
47 {
48 foreach (bool l2 in portable_read3(Answer, Variables, new Variable()))
49 {
50 foreach (bool l3 in remove_pos(Answer, Term))
51 yield return false;
52 }
53 }
54 }
55
56 public static IEnumerable<bool> read_term3(object Input, object Term, object Options)
57 {
58 Variable SaveInput = new Variable();
59 Variable Answer = new Variable();
60 Variable Variables = new Variable();
61 foreach (bool l1 in read_termOptions(Options, Variables))
62 {
63 foreach (bool l2 in YP.current_input(SaveInput))
64 {
65 try
66 {
67 YP.see(Input);
68 foreach (bool l3 in portable_read3(Answer, Variables, new Variable()))
69 {
70 foreach (bool l4 in remove_pos(Answer, Term))
71 yield return false;
72 }
73 }
74 finally
75 {
76 YP.see(SaveInput);
77 }
78 }
79 }
80 }
81
82 /// <summary>
83 /// For read_term, check if Options has variable_names(Variables).
84 /// Otherwise, ignore Options.
85 /// </summary>
86 /// <param name="Options"></param>
87 /// <param name="Variables"></param>
88 /// <returns></returns>
89 private static IEnumerable<bool> read_termOptions(object Options, object Variables)
90 {
91 Options = YP.getValue(Options);
92 if (Options is Variable)
93 throw new PrologException(Atom.a("instantiation_error"), "Options is an unbound variable");
94 // First try to match Options = [variable_names(Variables)]
95 foreach (bool l1 in YP.unify(Options, ListPair.make(new Functor1("variable_names", Variables))))
96 {
97 yield return false;
98 yield break;
99 }
100 // Default: Ignore Options.
101 yield return false;
102 }
103
104 public static IEnumerable<bool> read1(object Term)
105 {
106 return read_term2(Term, Atom.NIL);
107 }
108
109 public static IEnumerable<bool> read2(object Input, object Term)
110 {
111 return read_term3(Input, Term, Atom.NIL);
112 }
113
38 public static IEnumerable<bool> formatError(object Output, object Format, object Arguments) 114 public static IEnumerable<bool> formatError(object Output, object Format, object Arguments)
39 { 115 {
40 // Debug: Simple implementation for now. 116 // Debug: Simple implementation for now.
@@ -44,9 +120,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
44 yield return false; 120 yield return false;
45 } 121 }
46 122
47 // disable warning on l1, don't see how we can
48 // code this differently
49 #pragma warning disable 0168, 0219
50 123
51 // Debug: Hand-modify this central predicate to do tail recursion. 124 // Debug: Hand-modify this central predicate to do tail recursion.
52 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3) 125 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3)
@@ -217,7 +290,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
217 Variable Variables = new Variable(); 290 Variable Variables = new Variable();
218 Variable Answer = new Variable(); 291 Variable Answer = new Variable();
219 Variable x4 = new Variable(); 292 Variable x4 = new Variable();
220 foreach (bool l2 in YP.unify(arg1, new Functor2(@"f", Term, Variables))) 293 foreach (bool l2 in YP.unify(arg1, new Functor2("f", Term, Variables)))
221 { 294 {
222 foreach (bool l3 in YP.repeat()) 295 foreach (bool l3 in YP.repeat())
223 { 296 {
@@ -225,14 +298,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
225 { 298 {
226 foreach (bool l5 in remove_pos(Answer, Term)) 299 foreach (bool l5 in remove_pos(Answer, Term))
227 { 300 {
228 if (YP.termEqual(Term, Atom.a(@"end_of_file"))) 301 if (YP.termEqual(Term, Atom.a("end_of_file")))
229 { 302 {
230 yield break; 303 yield break;
231 // goto cutIf1; 304 goto cutIf1;
232 } 305 }
233 yield return false; 306 yield return false;
234 // cutIf1: 307 cutIf1:
235 // { } 308 { }
236 } 309 }
237 } 310 }
238 } 311 }
@@ -267,7 +340,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
267 object X = arg2; 340 object X = arg2;
268 Variable _Pos = new Variable(); 341 Variable _Pos = new Variable();
269 Variable _Name = new Variable(); 342 Variable _Name = new Variable();
270 foreach (bool l2 in YP.unify(arg1, new Functor3(@"$VAR", _Pos, _Name, X))) 343 foreach (bool l2 in YP.unify(arg1, new Functor3("$VAR", _Pos, _Name, X)))
271 { 344 {
272 if (YP.var(X)) 345 if (YP.var(X))
273 { 346 {
@@ -311,9 +384,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
311 Variable B = new Variable(); 384 Variable B = new Variable();
312 Variable NA = new Variable(); 385 Variable NA = new Variable();
313 Variable NB = new Variable(); 386 Variable NB = new Variable();
314 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) 387 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
315 { 388 {
316 foreach (bool l3 in YP.unify(arg2, new Functor2(@",", NA, NB))) 389 foreach (bool l3 in YP.unify(arg2, new Functor2(",", NA, NB)))
317 { 390 {
318 foreach (bool l4 in remove_pos(A, NA)) 391 foreach (bool l4 in remove_pos(A, NA))
319 { 392 {
@@ -432,9 +505,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
432 Variable E = new Variable(); 505 Variable E = new Variable();
433 Variable Xs = new Variable(); 506 Variable Xs = new Variable();
434 Variable Zs = new Variable(); 507 Variable Zs = new Variable();
435 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"comment", S, E), Xs))) 508 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("comment", S, E), Xs)))
436 { 509 {
437 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", S, E), Zs))) 510 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("comment", S, E), Zs)))
438 { 511 {
439 foreach (bool l4 in remove_comments(Xs, Ys, Zs)) 512 foreach (bool l4 in remove_comments(Xs, Ys, Zs))
440 { 513 {
@@ -450,11 +523,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
450 Variable Ys = new Variable(); 523 Variable Ys = new Variable();
451 Variable Pos2 = new Variable(); 524 Variable Pos2 = new Variable();
452 Variable Zs = new Variable(); 525 Variable Zs = new Variable();
453 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Xs))) 526 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("["), Pos), Xs)))
454 { 527 {
455 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"["), Ys))) 528 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("["), Ys)))
456 { 529 {
457 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) 530 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
458 { 531 {
459 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) 532 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
460 { 533 {
@@ -474,11 +547,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
474 Variable Ys = new Variable(); 547 Variable Ys = new Variable();
475 Variable Pos2 = new Variable(); 548 Variable Pos2 = new Variable();
476 Variable Zs = new Variable(); 549 Variable Zs = new Variable();
477 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Xs))) 550 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("]"), Pos), Xs)))
478 { 551 {
479 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), Ys))) 552 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), Ys)))
480 { 553 {
481 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) 554 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
482 { 555 {
483 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) 556 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
484 { 557 {
@@ -523,7 +596,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
523 { 596 {
524 object S0 = arg2; 597 object S0 = arg2;
525 object x3 = arg3; 598 object x3 = arg3;
526 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)) 599 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("or"), Atom.a("operator"), Atom.a("expected") }), S0))
527 { 600 {
528 yield return false; 601 yield return false;
529 } 602 }
@@ -569,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
569 Variable S = new Variable(); 642 Variable S = new Variable();
570 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S))) 643 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S)))
571 { 644 {
572 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))) 645 foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a("operator"), Atom.a("expected"), Atom.a("after"), Atom.a("expression") }), new ListPair(Token, S)))
573 { 646 {
574 yield return false; 647 yield return false;
575 } 648 }
@@ -585,7 +658,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
585 object x3 = arg4; 658 object x3 = arg4;
586 foreach (bool l2 in YP.unify(arg1, Atom.NIL)) 659 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
587 { 660 {
588 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"expression"), new ListPair(Atom.a(@"expected"), Atom.NIL)), Atom.NIL)) 661 foreach (bool l3 in syntax_error(new ListPair(Atom.a("expression"), new ListPair(Atom.a("expected"), Atom.NIL)), Atom.NIL))
589 { 662 {
590 yield return false; 663 yield return false;
591 } 664 }
@@ -614,9 +687,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
614 object x2 = arg3; 687 object x2 = arg3;
615 object x3 = arg4; 688 object x3 = arg4;
616 object x4 = arg5; 689 object x4 = arg5;
617 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 690 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
618 { 691 {
619 foreach (bool l3 in cannot_start(Atom.a(@"}"), S0)) 692 foreach (bool l3 in cannot_start(Atom.a("}"), S0))
620 { 693 {
621 yield return false; 694 yield return false;
622 } 695 }
@@ -627,9 +700,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
627 object x2 = arg3; 700 object x2 = arg3;
628 object x3 = arg4; 701 object x3 = arg4;
629 object x4 = arg5; 702 object x4 = arg5;
630 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 703 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
631 { 704 {
632 foreach (bool l3 in cannot_start(Atom.a(@"]"), S0)) 705 foreach (bool l3 in cannot_start(Atom.a("]"), S0))
633 { 706 {
634 yield return false; 707 yield return false;
635 } 708 }
@@ -640,9 +713,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
640 object x2 = arg3; 713 object x2 = arg3;
641 object x3 = arg4; 714 object x3 = arg4;
642 object x4 = arg5; 715 object x4 = arg5;
643 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 716 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
644 { 717 {
645 foreach (bool l3 in cannot_start(Atom.a(@")"), S0)) 718 foreach (bool l3 in cannot_start(Atom.a(")"), S0))
646 { 719 {
647 yield return false; 720 yield return false;
648 } 721 }
@@ -653,9 +726,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
653 object x2 = arg3; 726 object x2 = arg3;
654 object x3 = arg4; 727 object x3 = arg4;
655 object x4 = arg5; 728 object x4 = arg5;
656 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 729 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
657 { 730 {
658 foreach (bool l3 in cannot_start(Atom.a(@","), S0)) 731 foreach (bool l3 in cannot_start(Atom.a(","), S0))
659 { 732 {
660 yield return false; 733 yield return false;
661 } 734 }
@@ -666,9 +739,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
666 object x2 = arg3; 739 object x2 = arg3;
667 object x3 = arg4; 740 object x3 = arg4;
668 object x4 = arg5; 741 object x4 = arg5;
669 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 742 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
670 { 743 {
671 foreach (bool l3 in cannot_start(Atom.a(@"|"), S0)) 744 foreach (bool l3 in cannot_start(Atom.a("|"), S0))
672 { 745 {
673 yield return false; 746 yield return false;
674 } 747 }
@@ -679,14 +752,47 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
679 object Precedence = arg3; 752 object Precedence = arg3;
680 object Answer = arg4; 753 object Answer = arg4;
681 object S = arg5; 754 object S = arg5;
682 Variable Chars = new Variable(); 755 Variable Codes = new Variable();
683 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", Chars))) 756 Variable Term = new Variable();
757 Variable A = new Variable();
758 foreach (bool l2 in YP.unify(arg1, new Functor1("string", Codes)))
759 {
760 foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("atom")))
761 {
762 foreach (bool l4 in YP.atom_codes(Term, Codes))
763 {
764 foreach (bool l5 in exprtl0(S0, Term, Precedence, Answer, S))
765 {
766 yield return false;
767 }
768 }
769 goto cutIf1;
770 }
771 foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("chars")))
772 {
773 foreach (bool l4 in YP.atom_codes(A, Codes))
774 {
775 foreach (bool l5 in YP.atom_chars(A, Term))
776 {
777 foreach (bool l6 in exprtl0(S0, Term, Precedence, Answer, S))
778 {
779 yield return false;
780 }
781 }
782 }
783 goto cutIf2;
784 }
785 foreach (bool l3 in YP.unify(Term, Codes))
684 { 786 {
685 foreach (bool l3 in exprtl0(S0, Chars, Precedence, Answer, S)) 787 foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
686 { 788 {
687 yield return false; 789 yield return false;
688 } 790 }
689 } 791 }
792 cutIf2:
793 cutIf1:
794 { }
795 }
690 } 796 }
691 { 797 {
692 object S0 = arg2; 798 object S0 = arg2;
@@ -694,7 +800,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
694 object Answer = arg4; 800 object Answer = arg4;
695 object S = arg5; 801 object S = arg5;
696 Variable Number = new Variable(); 802 Variable Number = new Variable();
697 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", Number))) 803 foreach (bool l2 in YP.unify(arg1, new Functor1("number", Number)))
698 { 804 {
699 foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S)) 805 foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S))
700 { 806 {
@@ -707,11 +813,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
707 object Answer = arg4; 813 object Answer = arg4;
708 object S = arg5; 814 object S = arg5;
709 Variable S1 = new Variable(); 815 Variable S1 = new Variable();
710 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 816 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
711 { 817 {
712 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), S1))) 818 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), S1)))
713 { 819 {
714 foreach (bool l4 in read_atom(new Functor2(@"/", Atom.NIL, 0), S1, Precedence, Answer, S)) 820 foreach (bool l4 in read_atom(new Functor2("/", Atom.NIL, 0), S1, Precedence, Answer, S))
715 { 821 {
716 yield return false; 822 yield return false;
717 } 823 }
@@ -728,7 +834,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
728 Variable S2 = new Variable(); 834 Variable S2 = new Variable();
729 Variable RestArgs = new Variable(); 835 Variable RestArgs = new Variable();
730 Variable S3 = new Variable(); 836 Variable S3 = new Variable();
731 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 837 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
732 { 838 {
733 foreach (bool l3 in parse(S1, 999, Arg1, S2)) 839 foreach (bool l3 in parse(S1, 999, Arg1, S2))
734 { 840 {
@@ -751,11 +857,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
751 Variable Term = new Variable(); 857 Variable Term = new Variable();
752 Variable S2 = new Variable(); 858 Variable S2 = new Variable();
753 Variable S3 = new Variable(); 859 Variable S3 = new Variable();
754 foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) 860 foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
755 { 861 {
756 foreach (bool l3 in parse(S1, 1200, Term, S2)) 862 foreach (bool l3 in parse(S1, 1200, Term, S2))
757 { 863 {
758 foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) 864 foreach (bool l4 in expect(Atom.a(")"), S2, S3))
759 { 865 {
760 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) 866 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
761 { 867 {
@@ -774,11 +880,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
774 Variable Term = new Variable(); 880 Variable Term = new Variable();
775 Variable S2 = new Variable(); 881 Variable S2 = new Variable();
776 Variable S3 = new Variable(); 882 Variable S3 = new Variable();
777 foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) 883 foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
778 { 884 {
779 foreach (bool l3 in parse(S1, 1200, Term, S2)) 885 foreach (bool l3 in parse(S1, 1200, Term, S2))
780 { 886 {
781 foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) 887 foreach (bool l4 in expect(Atom.a(")"), S2, S3))
782 { 888 {
783 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) 889 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
784 { 890 {
@@ -795,11 +901,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
795 object S = arg5; 901 object S = arg5;
796 Variable _Pos = new Variable(); 902 Variable _Pos = new Variable();
797 Variable S1 = new Variable(); 903 Variable S1 = new Variable();
798 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), _Pos))) 904 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), _Pos)))
799 { 905 {
800 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"}"), S1))) 906 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("}"), S1)))
801 { 907 {
802 foreach (bool l4 in read_atom(Atom.a(@"{}"), S1, Precedence, Answer, S)) 908 foreach (bool l4 in read_atom(Atom.a("{}"), S1, Precedence, Answer, S))
803 { 909 {
804 yield return false; 910 yield return false;
805 } 911 }
@@ -816,13 +922,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
816 Variable Term = new Variable(); 922 Variable Term = new Variable();
817 Variable S2 = new Variable(); 923 Variable S2 = new Variable();
818 Variable S3 = new Variable(); 924 Variable S3 = new Variable();
819 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), Pos))) 925 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), Pos)))
820 { 926 {
821 foreach (bool l3 in parse(S1, 1200, Term, S2)) 927 foreach (bool l3 in parse(S1, 1200, Term, S2))
822 { 928 {
823 foreach (bool l4 in expect(Atom.a(@"}"), S2, S3)) 929 foreach (bool l4 in expect(Atom.a("}"), S2, S3))
824 { 930 {
825 foreach (bool l5 in exprtl0(S3, new Functor2(@"{}", Pos, Term), Precedence, Answer, S)) 931 foreach (bool l5 in exprtl0(S3, new Functor2("{}", Pos, Term), Precedence, Answer, S))
826 { 932 {
827 yield return false; 933 yield return false;
828 } 934 }
@@ -844,15 +950,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
844 Variable RestArgs = new Variable(); 950 Variable RestArgs = new Variable();
845 Variable S3 = new Variable(); 951 Variable S3 = new Variable();
846 Variable Term = new Variable(); 952 Variable Term = new Variable();
847 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) 953 foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
848 { 954 {
849 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) 955 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
850 { 956 {
851 foreach (bool l4 in parse(S1, 999, Arg1, S2)) 957 foreach (bool l4 in parse(S1, 999, Arg1, S2))
852 { 958 {
853 foreach (bool l5 in read_args(S2, RestArgs, S3)) 959 foreach (bool l5 in read_args(S2, RestArgs, S3))
854 { 960 {
855 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))))) 961 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)))))
856 { 962 {
857 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S)) 963 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
858 { 964 {
@@ -874,9 +980,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
874 Variable Variable_1 = new Variable(); 980 Variable Variable_1 = new Variable();
875 Variable Name = new Variable(); 981 Variable Name = new Variable();
876 Variable Pos = new Variable(); 982 Variable Pos = new Variable();
877 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) 983 foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
878 { 984 {
879 foreach (bool l3 in exprtl0(S0, new Functor3(@"$VAR", Pos, Name, Variable_1), Precedence, Answer, S)) 985 foreach (bool l3 in exprtl0(S0, new Functor3("$VAR", Pos, Name, Variable_1), Precedence, Answer, S))
880 { 986 {
881 yield return false; 987 yield return false;
882 } 988 }
@@ -889,9 +995,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
889 object S = arg5; 995 object S = arg5;
890 Variable Atom_1 = new Variable(); 996 Variable Atom_1 = new Variable();
891 Variable P = new Variable(); 997 Variable P = new Variable();
892 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", Atom_1, P))) 998 foreach (bool l2 in YP.unify(arg1, new Functor2("atom", Atom_1, P)))
893 { 999 {
894 foreach (bool l3 in read_atom(new Functor2(@"/", Atom_1, P), S0, Precedence, Answer, S)) 1000 foreach (bool l3 in read_atom(new Functor2("/", Atom_1, P), S0, Precedence, Answer, S))
895 { 1001 {
896 yield return false; 1002 yield return false;
897 } 1003 }
@@ -906,9 +1012,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
906 Variable Number = new Variable(); 1012 Variable Number = new Variable();
907 Variable S1 = new Variable(); 1013 Variable S1 = new Variable();
908 Variable Negative = new Variable(); 1014 Variable Negative = new Variable();
909 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"-"), _Pos))) 1015 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("-"), _Pos)))
910 { 1016 {
911 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"number", Number), S1))) 1017 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1("number", Number), S1)))
912 { 1018 {
913 foreach (bool l4 in YP.unify(Negative, YP.negate(Number))) 1019 foreach (bool l4 in YP.unify(Negative, YP.negate(Number)))
914 { 1020 {
@@ -930,9 +1036,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
930 Variable RestArgs = new Variable(); 1036 Variable RestArgs = new Variable();
931 Variable S3 = new Variable(); 1037 Variable S3 = new Variable();
932 Variable Term = new Variable(); 1038 Variable Term = new Variable();
933 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Functor_1, Pos))) 1039 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Functor_1, Pos)))
934 { 1040 {
935 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) 1041 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
936 { 1042 {
937 foreach (bool l4 in parse(S1, 999, Arg1, S2)) 1043 foreach (bool l4 in parse(S1, 999, Arg1, S2))
938 { 1044 {
@@ -962,7 +1068,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
962 Variable Term = new Variable(); 1068 Variable Term = new Variable();
963 Variable Arg = new Variable(); 1069 Variable Arg = new Variable();
964 Variable S1 = new Variable(); 1070 Variable S1 = new Variable();
965 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Op, Pos))) 1071 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Op, Pos)))
966 { 1072 {
967 foreach (bool l3 in prefixop(Op, Oprec, Aprec)) 1073 foreach (bool l3 in prefixop(Op, Oprec, Aprec))
968 { 1074 {
@@ -981,7 +1087,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
981 } 1087 }
982 if (YP.greaterThan(Oprec, Precedence)) 1088 if (YP.greaterThan(Oprec, Precedence))
983 { 1089 {
984 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)) 1090 foreach (bool l6 in syntax_error(ListPair.make(new object[] { Atom.a("prefix"), Atom.a("operator"), Op, Atom.a("in"), Atom.a("context"), Atom.a("with"), Atom.a("precedence"), Precedence }), S0))
985 { 1091 {
986 yield return false; 1092 yield return false;
987 } 1093 }
@@ -991,7 +1097,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
991 { 1097 {
992 foreach (bool l6 in parse(S0, Aprec, Arg, S1)) 1098 foreach (bool l6 in parse(S0, Aprec, Arg, S1))
993 { 1099 {
994 foreach (bool l7 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) 1100 foreach (bool l7 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
995 { 1101 {
996 foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) 1102 foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
997 { 1103 {
@@ -1006,7 +1112,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1006 { 1112 {
1007 foreach (bool l6 in prefix_is_atom(S1, Oprec)) 1113 foreach (bool l6 in prefix_is_atom(S1, Oprec))
1008 { 1114 {
1009 foreach (bool l7 in exprtl(S1, Oprec, new Functor2(@"/", Op, Pos), Precedence, Answer, S)) 1115 foreach (bool l7 in exprtl(S1, Oprec, new Functor2("/", Op, Pos), Precedence, Answer, S))
1010 { 1116 {
1011 yield return false; 1117 yield return false;
1012 } 1118 }
@@ -1014,7 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1014 } 1120 }
1015 foreach (bool l5 in parse(S0, Aprec, Arg, S1)) 1121 foreach (bool l5 in parse(S0, Aprec, Arg, S1))
1016 { 1122 {
1017 foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) 1123 foreach (bool l6 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
1018 { 1124 {
1019 foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) 1125 foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
1020 { 1126 {
@@ -1037,7 +1143,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1037 Variable Atom_1 = new Variable(); 1143 Variable Atom_1 = new Variable();
1038 Variable Pos = new Variable(); 1144 Variable Pos = new Variable();
1039 Variable Term = new Variable(); 1145 Variable Term = new Variable();
1040 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom_1, Pos))) 1146 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom_1, Pos)))
1041 { 1147 {
1042 foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL)))) 1148 foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL))))
1043 { 1149 {
@@ -1053,7 +1159,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1053 public static IEnumerable<bool> cannot_start(object Token, object S0) 1159 public static IEnumerable<bool> cannot_start(object Token, object S0)
1054 { 1160 {
1055 { 1161 {
1056 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)) 1162 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("cannot"), Atom.a("start"), Atom.a("an"), Atom.a("expression") }), S0))
1057 { 1163 {
1058 yield return false; 1164 yield return false;
1059 } 1165 }
@@ -1068,7 +1174,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1068 Variable Term = new Variable(); 1174 Variable Term = new Variable();
1069 Variable Rest = new Variable(); 1175 Variable Rest = new Variable();
1070 Variable S2 = new Variable(); 1176 Variable S2 = new Variable();
1071 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@","), S1))) 1177 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(","), S1)))
1072 { 1178 {
1073 foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest))) 1179 foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest)))
1074 { 1180 {
@@ -1086,7 +1192,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1086 } 1192 }
1087 { 1193 {
1088 object S = arg3; 1194 object S = arg3;
1089 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@")"), S))) 1195 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(")"), S)))
1090 { 1196 {
1091 foreach (bool l3 in YP.unify(arg2, Atom.NIL)) 1197 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1092 { 1198 {
@@ -1099,7 +1205,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1099 object S = arg1; 1205 object S = arg1;
1100 object x2 = arg2; 1206 object x2 = arg2;
1101 object x3 = arg3; 1207 object x3 = arg3;
1102 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)) 1208 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Atom.a(", or )"), Atom.a("expected"), Atom.a("in"), Atom.a("arguments") }), S))
1103 { 1209 {
1104 yield return false; 1210 yield return false;
1105 } 1211 }
@@ -1113,7 +1219,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1113 object x2 = arg3; 1219 object x2 = arg3;
1114 foreach (bool l2 in YP.unify(arg1, Atom.NIL)) 1220 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1115 { 1221 {
1116 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)) 1222 foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a(", | or ]"), Atom.a("expected"), Atom.a("in"), Atom.a("list") }), Atom.NIL))
1117 { 1223 {
1118 yield return false; 1224 yield return false;
1119 } 1225 }
@@ -1142,7 +1248,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1142 Variable Term = new Variable(); 1248 Variable Term = new Variable();
1143 Variable Rest = new Variable(); 1249 Variable Rest = new Variable();
1144 Variable S2 = new Variable(); 1250 Variable S2 = new Variable();
1145 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1251 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1146 { 1252 {
1147 foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest))) 1253 foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest)))
1148 { 1254 {
@@ -1163,11 +1269,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1163 object Rest = arg3; 1269 object Rest = arg3;
1164 object S = arg4; 1270 object S = arg4;
1165 Variable S2 = new Variable(); 1271 Variable S2 = new Variable();
1166 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1272 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1167 { 1273 {
1168 foreach (bool l3 in parse(S1, 999, Rest, S2)) 1274 foreach (bool l3 in parse(S1, 999, Rest, S2))
1169 { 1275 {
1170 foreach (bool l4 in expect(Atom.a(@"]"), S2, S)) 1276 foreach (bool l4 in expect(Atom.a("]"), S2, S))
1171 { 1277 {
1172 yield return false; 1278 yield return false;
1173 } 1279 }
@@ -1178,7 +1284,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1178 } 1284 }
1179 { 1285 {
1180 Variable S1 = new Variable(); 1286 Variable S1 = new Variable();
1181 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1287 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1182 { 1288 {
1183 foreach (bool l3 in YP.unify(arg2, S1)) 1289 foreach (bool l3 in YP.unify(arg2, S1))
1184 { 1290 {
@@ -1198,7 +1304,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1198 object S1 = arg2; 1304 object S1 = arg2;
1199 object x3 = arg3; 1305 object x3 = arg3;
1200 object x4 = arg4; 1306 object x4 = arg4;
1201 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))) 1307 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Atom.a(", | or ]"), Atom.a("expected"), Atom.a("in"), Atom.a("list") }), new ListPair(Token, S1)))
1202 { 1308 {
1203 yield return false; 1309 yield return false;
1204 } 1310 }
@@ -1237,7 +1343,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1237 Variable x1 = new Variable(); 1343 Variable x1 = new Variable();
1238 Variable x2 = new Variable(); 1344 Variable x2 = new Variable();
1239 Variable x3 = new Variable(); 1345 Variable x3 = new Variable();
1240 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", x1, x2, x3))) 1346 foreach (bool l2 in YP.unify(arg1, new Functor3("var", x1, x2, x3)))
1241 { 1347 {
1242 foreach (bool l3 in YP.unify(arg2, 1)) 1348 foreach (bool l3 in YP.unify(arg2, 1))
1243 { 1349 {
@@ -1248,7 +1354,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1248 { 1354 {
1249 object x2 = arg3; 1355 object x2 = arg3;
1250 Variable x1 = new Variable(); 1356 Variable x1 = new Variable();
1251 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", x1))) 1357 foreach (bool l2 in YP.unify(arg1, new Functor1("number", x1)))
1252 { 1358 {
1253 foreach (bool l3 in YP.unify(arg2, 1)) 1359 foreach (bool l3 in YP.unify(arg2, 1))
1254 { 1360 {
@@ -1259,7 +1365,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1259 { 1365 {
1260 object x2 = arg3; 1366 object x2 = arg3;
1261 Variable x1 = new Variable(); 1367 Variable x1 = new Variable();
1262 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", x1))) 1368 foreach (bool l2 in YP.unify(arg1, new Functor1("string", x1)))
1263 { 1369 {
1264 foreach (bool l3 in YP.unify(arg2, 1)) 1370 foreach (bool l3 in YP.unify(arg2, 1))
1265 { 1371 {
@@ -1269,7 +1375,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1269 } 1375 }
1270 { 1376 {
1271 object x1 = arg3; 1377 object x1 = arg3;
1272 foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) 1378 foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
1273 { 1379 {
1274 foreach (bool l3 in YP.unify(arg2, 1)) 1380 foreach (bool l3 in YP.unify(arg2, 1))
1275 { 1381 {
@@ -1279,7 +1385,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1279 } 1385 }
1280 { 1386 {
1281 object x1 = arg3; 1387 object x1 = arg3;
1282 foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) 1388 foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
1283 { 1389 {
1284 foreach (bool l3 in YP.unify(arg2, 0)) 1390 foreach (bool l3 in YP.unify(arg2, 0))
1285 { 1391 {
@@ -1289,7 +1395,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1289 } 1395 }
1290 { 1396 {
1291 object x1 = arg3; 1397 object x1 = arg3;
1292 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 1398 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
1293 { 1399 {
1294 foreach (bool l3 in YP.unify(arg2, -1)) 1400 foreach (bool l3 in YP.unify(arg2, -1))
1295 { 1401 {
@@ -1299,11 +1405,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1299 } 1405 }
1300 { 1406 {
1301 Variable x1 = new Variable(); 1407 Variable x1 = new Variable();
1302 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1408 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1303 { 1409 {
1304 foreach (bool l3 in YP.unify(arg2, 0)) 1410 foreach (bool l3 in YP.unify(arg2, 0))
1305 { 1411 {
1306 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"]"), x1))) 1412 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a("]"), x1)))
1307 { 1413 {
1308 yield return true; 1414 yield return true;
1309 yield break; 1415 yield break;
@@ -1313,7 +1419,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1313 } 1419 }
1314 { 1420 {
1315 object x1 = arg3; 1421 object x1 = arg3;
1316 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1422 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1317 { 1423 {
1318 foreach (bool l3 in YP.unify(arg2, 1)) 1424 foreach (bool l3 in YP.unify(arg2, 1))
1319 { 1425 {
@@ -1323,7 +1429,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1323 } 1429 }
1324 { 1430 {
1325 object x1 = arg3; 1431 object x1 = arg3;
1326 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1432 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1327 { 1433 {
1328 foreach (bool l3 in YP.unify(arg2, -1)) 1434 foreach (bool l3 in YP.unify(arg2, -1))
1329 { 1435 {
@@ -1333,11 +1439,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1333 } 1439 }
1334 { 1440 {
1335 Variable x1 = new Variable(); 1441 Variable x1 = new Variable();
1336 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1442 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1337 { 1443 {
1338 foreach (bool l3 in YP.unify(arg2, 0)) 1444 foreach (bool l3 in YP.unify(arg2, 0))
1339 { 1445 {
1340 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"}"), x1))) 1446 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a("}"), x1)))
1341 { 1447 {
1342 yield return true; 1448 yield return true;
1343 yield break; 1449 yield break;
@@ -1347,7 +1453,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1347 } 1453 }
1348 { 1454 {
1349 object x1 = arg3; 1455 object x1 = arg3;
1350 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1456 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1351 { 1457 {
1352 foreach (bool l3 in YP.unify(arg2, 1)) 1458 foreach (bool l3 in YP.unify(arg2, 1))
1353 { 1459 {
@@ -1357,7 +1463,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1357 } 1463 }
1358 { 1464 {
1359 object x1 = arg3; 1465 object x1 = arg3;
1360 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 1466 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
1361 { 1467 {
1362 foreach (bool l3 in YP.unify(arg2, -1)) 1468 foreach (bool l3 in YP.unify(arg2, -1))
1363 { 1469 {
@@ -1367,7 +1473,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1367 } 1473 }
1368 { 1474 {
1369 object x1 = arg3; 1475 object x1 = arg3;
1370 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1476 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1371 { 1477 {
1372 foreach (bool l3 in YP.unify(arg2, -1)) 1478 foreach (bool l3 in YP.unify(arg2, -1))
1373 { 1479 {
@@ -1377,7 +1483,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1377 } 1483 }
1378 { 1484 {
1379 object x1 = arg3; 1485 object x1 = arg3;
1380 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1486 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1381 { 1487 {
1382 foreach (bool l3 in YP.unify(arg2, -1)) 1488 foreach (bool l3 in YP.unify(arg2, -1))
1383 { 1489 {
@@ -1389,7 +1495,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1389 object x3 = arg3; 1495 object x3 = arg3;
1390 Variable x1 = new Variable(); 1496 Variable x1 = new Variable();
1391 Variable x2 = new Variable(); 1497 Variable x2 = new Variable();
1392 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", x1, x2))) 1498 foreach (bool l2 in YP.unify(arg1, new Functor2("atom", x1, x2)))
1393 { 1499 {
1394 foreach (bool l3 in YP.unify(arg2, 0)) 1500 foreach (bool l3 in YP.unify(arg2, 0))
1395 { 1501 {
@@ -1405,9 +1511,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1405 Variable F = new Variable(); 1511 Variable F = new Variable();
1406 Variable Pos = new Variable(); 1512 Variable Pos = new Variable();
1407 Variable S1 = new Variable(); 1513 Variable S1 = new Variable();
1408 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) 1514 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", F, Pos), new ListPair(Atom.a("("), S1))))
1409 { 1515 {
1410 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) 1516 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2("atom", F, Pos), new ListPair(Atom.a("("), S1))))
1411 { 1517 {
1412 yield return true; 1518 yield return true;
1413 yield break; 1519 yield break;
@@ -1421,9 +1527,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1421 Variable L = new Variable(); 1527 Variable L = new Variable();
1422 Variable P = new Variable(); 1528 Variable P = new Variable();
1423 Variable R = new Variable(); 1529 Variable R = new Variable();
1424 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) 1530 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", F, Pos), S1)))
1425 { 1531 {
1426 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))) 1532 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)))
1427 { 1533 {
1428 foreach (bool l4 in infixop(F, L, P, R)) 1534 foreach (bool l4 in infixop(F, L, P, R))
1429 { 1535 {
@@ -1438,9 +1544,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1438 Variable S1 = new Variable(); 1544 Variable S1 = new Variable();
1439 Variable L = new Variable(); 1545 Variable L = new Variable();
1440 Variable P = new Variable(); 1546 Variable P = new Variable();
1441 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) 1547 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", F, Pos), S1)))
1442 { 1548 {
1443 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, P), S1))) 1549 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a("postfixop", Atom.a("")), new Functor2("/", F, Pos), L, P), S1)))
1444 { 1550 {
1445 foreach (bool l4 in postfixop(F, L, P)) 1551 foreach (bool l4 in postfixop(F, L, P))
1446 { 1552 {
@@ -1481,7 +1587,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1481 Variable L = new Variable(); 1587 Variable L = new Variable();
1482 Variable x3 = new Variable(); 1588 Variable x3 = new Variable();
1483 Variable x4 = new Variable(); 1589 Variable x4 = new Variable();
1484 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { x1, L, x3, x4 }))) 1590 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a("infixop", Atom.a("")), new object[] { x1, L, x3, x4 })))
1485 { 1591 {
1486 if (YP.greaterThanOrEqual(L, P)) 1592 if (YP.greaterThanOrEqual(L, P))
1487 { 1593 {
@@ -1494,7 +1600,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1494 Variable x1 = new Variable(); 1600 Variable x1 = new Variable();
1495 Variable L = new Variable(); 1601 Variable L = new Variable();
1496 Variable x3 = new Variable(); 1602 Variable x3 = new Variable();
1497 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), x1, L, x3))) 1603 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a("postfixop", Atom.a("")), x1, L, x3)))
1498 { 1604 {
1499 if (YP.greaterThanOrEqual(L, P)) 1605 if (YP.greaterThanOrEqual(L, P))
1500 { 1606 {
@@ -1504,28 +1610,28 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1504 } 1610 }
1505 { 1611 {
1506 object x1 = arg2; 1612 object x1 = arg2;
1507 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 1613 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
1508 { 1614 {
1509 yield return false; 1615 yield return false;
1510 } 1616 }
1511 } 1617 }
1512 { 1618 {
1513 object x1 = arg2; 1619 object x1 = arg2;
1514 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1620 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1515 { 1621 {
1516 yield return false; 1622 yield return false;
1517 } 1623 }
1518 } 1624 }
1519 { 1625 {
1520 object x1 = arg2; 1626 object x1 = arg2;
1521 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 1627 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
1522 { 1628 {
1523 yield return false; 1629 yield return false;
1524 } 1630 }
1525 } 1631 }
1526 { 1632 {
1527 object P = arg2; 1633 object P = arg2;
1528 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1634 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1529 { 1635 {
1530 if (YP.greaterThanOrEqual(1100, P)) 1636 if (YP.greaterThanOrEqual(1100, P))
1531 { 1637 {
@@ -1535,7 +1641,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1535 } 1641 }
1536 { 1642 {
1537 object P = arg2; 1643 object P = arg2;
1538 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1644 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1539 { 1645 {
1540 if (YP.greaterThanOrEqual(1000, P)) 1646 if (YP.greaterThanOrEqual(1000, P))
1541 { 1647 {
@@ -1594,13 +1700,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1594 object x2 = arg3; 1700 object x2 = arg3;
1595 object S1 = arg6; 1701 object S1 = arg6;
1596 Variable Term = new Variable(); 1702 Variable Term = new Variable();
1597 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 1703 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
1598 { 1704 {
1599 foreach (bool l3 in YP.unify(arg2, Term)) 1705 foreach (bool l3 in YP.unify(arg2, Term))
1600 { 1706 {
1601 foreach (bool l4 in YP.unify(arg4, Term)) 1707 foreach (bool l4 in YP.unify(arg4, Term))
1602 { 1708 {
1603 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"}"), S1))) 1709 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a("}"), S1)))
1604 { 1710 {
1605 yield return false; 1711 yield return false;
1606 } 1712 }
@@ -1612,13 +1718,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1612 object x2 = arg3; 1718 object x2 = arg3;
1613 object S1 = arg6; 1719 object S1 = arg6;
1614 Variable Term = new Variable(); 1720 Variable Term = new Variable();
1615 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1721 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1616 { 1722 {
1617 foreach (bool l3 in YP.unify(arg2, Term)) 1723 foreach (bool l3 in YP.unify(arg2, Term))
1618 { 1724 {
1619 foreach (bool l4 in YP.unify(arg4, Term)) 1725 foreach (bool l4 in YP.unify(arg4, Term))
1620 { 1726 {
1621 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"]"), S1))) 1727 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a("]"), S1)))
1622 { 1728 {
1623 yield return false; 1729 yield return false;
1624 } 1730 }
@@ -1630,13 +1736,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1630 object x2 = arg3; 1736 object x2 = arg3;
1631 object S1 = arg6; 1737 object S1 = arg6;
1632 Variable Term = new Variable(); 1738 Variable Term = new Variable();
1633 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 1739 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
1634 { 1740 {
1635 foreach (bool l3 in YP.unify(arg2, Term)) 1741 foreach (bool l3 in YP.unify(arg2, Term))
1636 { 1742 {
1637 foreach (bool l4 in YP.unify(arg4, Term)) 1743 foreach (bool l4 in YP.unify(arg4, Term))
1638 { 1744 {
1639 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@")"), S1))) 1745 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(")"), S1)))
1640 { 1746 {
1641 yield return false; 1747 yield return false;
1642 } 1748 }
@@ -1652,13 +1758,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1652 object S1 = arg6; 1758 object S1 = arg6;
1653 Variable Next = new Variable(); 1759 Variable Next = new Variable();
1654 Variable S2 = new Variable(); 1760 Variable S2 = new Variable();
1655 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1761 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1656 { 1762 {
1657 if (YP.greaterThanOrEqual(Precedence, 1000)) 1763 if (YP.greaterThanOrEqual(Precedence, 1000))
1658 { 1764 {
1659 foreach (bool l4 in parse(S1, 1000, Next, S2)) 1765 foreach (bool l4 in parse(S1, 1000, Next, S2))
1660 { 1766 {
1661 foreach (bool l5 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) 1767 foreach (bool l5 in exprtl(S2, 1000, new Functor2(",", Term, Next), Precedence, Answer, S))
1662 { 1768 {
1663 yield return false; 1769 yield return false;
1664 } 1770 }
@@ -1668,7 +1774,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1668 } 1774 }
1669 foreach (bool l3 in YP.unify(Answer, Term)) 1775 foreach (bool l3 in YP.unify(Answer, Term))
1670 { 1776 {
1671 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@","), S1))) 1777 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(","), S1)))
1672 { 1778 {
1673 yield return false; 1779 yield return false;
1674 } 1780 }
@@ -1685,13 +1791,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1685 object S1 = arg6; 1791 object S1 = arg6;
1686 Variable Next = new Variable(); 1792 Variable Next = new Variable();
1687 Variable S2 = new Variable(); 1793 Variable S2 = new Variable();
1688 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1794 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1689 { 1795 {
1690 if (YP.greaterThanOrEqual(Precedence, 1100)) 1796 if (YP.greaterThanOrEqual(Precedence, 1100))
1691 { 1797 {
1692 foreach (bool l4 in parse(S1, 1100, Next, S2)) 1798 foreach (bool l4 in parse(S1, 1100, Next, S2))
1693 { 1799 {
1694 foreach (bool l5 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) 1800 foreach (bool l5 in exprtl(S2, 1100, new Functor2(";", Term, Next), Precedence, Answer, S))
1695 { 1801 {
1696 yield return false; 1802 yield return false;
1697 } 1803 }
@@ -1701,7 +1807,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1701 } 1807 }
1702 foreach (bool l3 in YP.unify(Answer, Term)) 1808 foreach (bool l3 in YP.unify(Answer, Term))
1703 { 1809 {
1704 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@"|"), S1))) 1810 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a("|"), S1)))
1705 { 1811 {
1706 yield return false; 1812 yield return false;
1707 } 1813 }
@@ -1717,9 +1823,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1717 object x5 = arg5; 1823 object x5 = arg5;
1718 object S1 = arg6; 1824 object S1 = arg6;
1719 Variable S = new Variable(); 1825 Variable S = new Variable();
1720 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", S))) 1826 foreach (bool l2 in YP.unify(arg1, new Functor1("string", S)))
1721 { 1827 {
1722 foreach (bool l3 in cannot_follow(Atom.a(@"chars"), new Functor1(@"string", S), S1)) 1828 foreach (bool l3 in cannot_follow(Atom.a("chars"), new Functor1("string", S), S1))
1723 { 1829 {
1724 yield return false; 1830 yield return false;
1725 } 1831 }
@@ -1732,9 +1838,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1732 object x5 = arg5; 1838 object x5 = arg5;
1733 object S1 = arg6; 1839 object S1 = arg6;
1734 Variable N = new Variable(); 1840 Variable N = new Variable();
1735 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", N))) 1841 foreach (bool l2 in YP.unify(arg1, new Functor1("number", N)))
1736 { 1842 {
1737 foreach (bool l3 in cannot_follow(Atom.a(@"number"), new Functor1(@"number", N), S1)) 1843 foreach (bool l3 in cannot_follow(Atom.a("number"), new Functor1("number", N), S1))
1738 { 1844 {
1739 yield return false; 1845 yield return false;
1740 } 1846 }
@@ -1746,11 +1852,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1746 object Answer = arg4; 1852 object Answer = arg4;
1747 object S = arg5; 1853 object S = arg5;
1748 Variable S1 = new Variable(); 1854 Variable S1 = new Variable();
1749 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1855 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1750 { 1856 {
1751 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"}"), S1))) 1857 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a("}"), S1)))
1752 { 1858 {
1753 foreach (bool l4 in exprtl0_atom(Atom.a(@"{}"), Term, Precedence, Answer, S, S1)) 1859 foreach (bool l4 in exprtl0_atom(Atom.a("{}"), Term, Precedence, Answer, S, S1))
1754 { 1860 {
1755 yield return false; 1861 yield return false;
1756 } 1862 }
@@ -1764,9 +1870,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1764 object x3 = arg4; 1870 object x3 = arg4;
1765 object x4 = arg5; 1871 object x4 = arg5;
1766 object S1 = arg6; 1872 object S1 = arg6;
1767 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1873 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1768 { 1874 {
1769 foreach (bool l3 in cannot_follow(Atom.a(@"brace"), Atom.a(@"{"), S1)) 1875 foreach (bool l3 in cannot_follow(Atom.a("brace"), Atom.a("{"), S1))
1770 { 1876 {
1771 yield return false; 1877 yield return false;
1772 } 1878 }
@@ -1778,9 +1884,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1778 object Answer = arg4; 1884 object Answer = arg4;
1779 object S = arg5; 1885 object S = arg5;
1780 Variable S1 = new Variable(); 1886 Variable S1 = new Variable();
1781 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1887 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1782 { 1888 {
1783 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"]"), S1))) 1889 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a("]"), S1)))
1784 { 1890 {
1785 foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1)) 1891 foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1))
1786 { 1892 {
@@ -1796,9 +1902,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1796 object x3 = arg4; 1902 object x3 = arg4;
1797 object x4 = arg5; 1903 object x4 = arg5;
1798 object S1 = arg6; 1904 object S1 = arg6;
1799 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1905 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1800 { 1906 {
1801 foreach (bool l3 in cannot_follow(Atom.a(@"bracket"), Atom.a(@"["), S1)) 1907 foreach (bool l3 in cannot_follow(Atom.a("bracket"), Atom.a("["), S1))
1802 { 1908 {
1803 yield return false; 1909 yield return false;
1804 } 1910 }
@@ -1810,9 +1916,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1810 object x3 = arg4; 1916 object x3 = arg4;
1811 object x4 = arg5; 1917 object x4 = arg5;
1812 object S1 = arg6; 1918 object S1 = arg6;
1813 foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) 1919 foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
1814 { 1920 {
1815 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) 1921 foreach (bool l3 in cannot_follow(Atom.a("parenthesis"), Atom.a("("), S1))
1816 { 1922 {
1817 yield return false; 1923 yield return false;
1818 } 1924 }
@@ -1824,9 +1930,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1824 object x3 = arg4; 1930 object x3 = arg4;
1825 object x4 = arg5; 1931 object x4 = arg5;
1826 object S1 = arg6; 1932 object S1 = arg6;
1827 foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) 1933 foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
1828 { 1934 {
1829 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) 1935 foreach (bool l3 in cannot_follow(Atom.a("parenthesis"), Atom.a("("), S1))
1830 { 1936 {
1831 yield return false; 1937 yield return false;
1832 } 1938 }
@@ -1841,9 +1947,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1841 Variable A = new Variable(); 1947 Variable A = new Variable();
1842 Variable B = new Variable(); 1948 Variable B = new Variable();
1843 Variable P = new Variable(); 1949 Variable P = new Variable();
1844 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", A, B, P))) 1950 foreach (bool l2 in YP.unify(arg1, new Functor3("var", A, B, P)))
1845 { 1951 {
1846 foreach (bool l3 in cannot_follow(Atom.a(@"variable"), new Functor3(@"var", A, B, P), S1)) 1952 foreach (bool l3 in cannot_follow(Atom.a("variable"), new Functor3("var", A, B, P), S1))
1847 { 1953 {
1848 yield return false; 1954 yield return false;
1849 } 1955 }
@@ -1857,9 +1963,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1857 object S1 = arg6; 1963 object S1 = arg6;
1858 Variable F = new Variable(); 1964 Variable F = new Variable();
1859 Variable P = new Variable(); 1965 Variable P = new Variable();
1860 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", F, P))) 1966 foreach (bool l2 in YP.unify(arg1, new Functor2("atom", F, P)))
1861 { 1967 {
1862 foreach (bool l3 in exprtl0_atom(new Functor2(@"/", F, P), Term, Precedence, Answer, S, S1)) 1968 foreach (bool l3 in exprtl0_atom(new Functor2("/", F, P), Term, Precedence, Answer, S, S1))
1863 { 1969 {
1864 yield return false; 1970 yield return false;
1865 } 1971 }
@@ -1881,23 +1987,23 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1881 Variable R1 = new Variable(); 1987 Variable R1 = new Variable();
1882 Variable L2 = new Variable(); 1988 Variable L2 = new Variable();
1883 Variable O2 = new Variable(); 1989 Variable O2 = new Variable();
1884 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) 1990 foreach (bool l2 in YP.unify(arg1, new Functor2("/", F, Pos)))
1885 { 1991 {
1886 foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2)) 1992 foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2))
1887 { 1993 {
1888 foreach (bool l4 in prefix_is_atom(S1, Precedence)) 1994 foreach (bool l4 in prefix_is_atom(S1, Precedence))
1889 { 1995 {
1890 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)) 1996 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))
1891 { 1997 {
1892 yield return false; 1998 yield return false;
1893 } 1999 }
1894 yield break; 2000 yield break;
1895 } 2001 }
1896 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)) 2002 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))
1897 { 2003 {
1898 yield return false; 2004 yield return false;
1899 } 2005 }
1900 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)) 2006 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))
1901 { 2007 {
1902 yield return false; 2008 yield return false;
1903 } 2009 }
@@ -1915,11 +2021,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1915 Variable L1 = new Variable(); 2021 Variable L1 = new Variable();
1916 Variable O1 = new Variable(); 2022 Variable O1 = new Variable();
1917 Variable R1 = new Variable(); 2023 Variable R1 = new Variable();
1918 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) 2024 foreach (bool l2 in YP.unify(arg1, new Functor2("/", F, Pos)))
1919 { 2025 {
1920 foreach (bool l3 in infixop(F, L1, O1, R1)) 2026 foreach (bool l3 in infixop(F, L1, O1, R1))
1921 { 2027 {
1922 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)) 2028 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))
1923 { 2029 {
1924 yield return false; 2030 yield return false;
1925 } 2031 }
@@ -1936,11 +2042,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1936 Variable Pos = new Variable(); 2042 Variable Pos = new Variable();
1937 Variable L2 = new Variable(); 2043 Variable L2 = new Variable();
1938 Variable O2 = new Variable(); 2044 Variable O2 = new Variable();
1939 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) 2045 foreach (bool l2 in YP.unify(arg1, new Functor2("/", F, Pos)))
1940 { 2046 {
1941 foreach (bool l3 in postfixop(F, L2, O2)) 2047 foreach (bool l3 in postfixop(F, L2, O2))
1942 { 2048 {
1943 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)) 2049 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))
1944 { 2050 {
1945 yield return false; 2051 yield return false;
1946 } 2052 }
@@ -1955,7 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1955 object x4 = arg4; 2061 object x4 = arg4;
1956 object x5 = arg5; 2062 object x5 = arg5;
1957 Variable x7 = new Variable(); 2063 Variable x7 = new Variable();
1958 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))) 2064 foreach (bool l2 in syntax_error(ListPair.make(new object[] { new Functor2("-", Atom.a("non"), Atom.a("operator")), X, Atom.a("follows"), Atom.a("expression") }), new ListPair(new Functor2("atom", X, x7), S1)))
1959 { 2065 {
1960 yield return false; 2066 yield return false;
1961 } 2067 }
@@ -1966,7 +2072,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1966 public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens) 2072 public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens)
1967 { 2073 {
1968 { 2074 {
1969 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))) 2075 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Type, Atom.a("follows"), Atom.a("expression") }), new ListPair(Token, Tokens)))
1970 { 2076 {
1971 yield return false; 2077 yield return false;
1972 } 2078 }
@@ -2028,7 +2134,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2028 Variable Other = new Variable(); 2134 Variable Other = new Variable();
2029 Variable S2 = new Variable(); 2135 Variable S2 = new Variable();
2030 Variable Expr = new Variable(); 2136 Variable Expr = new Variable();
2031 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, O, R }))) 2137 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a("infixop", Atom.a("")), new object[] { new Functor2("/", F, Pos), L, O, R })))
2032 { 2138 {
2033 if (YP.greaterThanOrEqual(Precedence, O)) 2139 if (YP.greaterThanOrEqual(Precedence, O))
2034 { 2140 {
@@ -2036,7 +2142,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2036 { 2142 {
2037 foreach (bool l5 in parse(S1, R, Other, S2)) 2143 foreach (bool l5 in parse(S1, R, Other, S2))
2038 { 2144 {
2039 foreach (bool l6 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, new ListPair(Other, Atom.NIL)))))) 2145 foreach (bool l6 in YP.univ(Expr, ListPair.make(new object[] { F, Pos, Term, Other })))
2040 { 2146 {
2041 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S)) 2147 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S))
2042 { 2148 {
@@ -2062,13 +2168,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2062 Variable O = new Variable(); 2168 Variable O = new Variable();
2063 Variable Expr = new Variable(); 2169 Variable Expr = new Variable();
2064 Variable S2 = new Variable(); 2170 Variable S2 = new Variable();
2065 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, O))) 2171 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a("postfixop", Atom.a("")), new Functor2("/", F, Pos), L, O)))
2066 { 2172 {
2067 if (YP.greaterThanOrEqual(Precedence, O)) 2173 if (YP.greaterThanOrEqual(Precedence, O))
2068 { 2174 {
2069 if (YP.lessThanOrEqual(C, L)) 2175 if (YP.lessThanOrEqual(C, L))
2070 { 2176 {
2071 foreach (bool l5 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, Atom.NIL))))) 2177 foreach (bool l5 in YP.univ(Expr, ListPair.make(new object[] { F, Pos, Term })))
2072 { 2178 {
2073 foreach (bool l6 in peepop(S1, S2)) 2179 foreach (bool l6 in peepop(S1, S2))
2074 { 2180 {
@@ -2092,7 +2198,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2092 object S1 = arg7; 2198 object S1 = arg7;
2093 Variable Next = new Variable(); 2199 Variable Next = new Variable();
2094 Variable S2 = new Variable(); 2200 Variable S2 = new Variable();
2095 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 2201 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
2096 { 2202 {
2097 if (YP.greaterThanOrEqual(Precedence, 1000)) 2203 if (YP.greaterThanOrEqual(Precedence, 1000))
2098 { 2204 {
@@ -2100,7 +2206,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2100 { 2206 {
2101 foreach (bool l5 in parse(S1, 1000, Next, S2)) 2207 foreach (bool l5 in parse(S1, 1000, Next, S2))
2102 { 2208 {
2103 foreach (bool l6 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) 2209 foreach (bool l6 in exprtl(S2, 1000, new Functor2(",", Term, Next), Precedence, Answer, S))
2104 { 2210 {
2105 yield return false; 2211 yield return false;
2106 } 2212 }
@@ -2119,7 +2225,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2119 object S1 = arg7; 2225 object S1 = arg7;
2120 Variable Next = new Variable(); 2226 Variable Next = new Variable();
2121 Variable S2 = new Variable(); 2227 Variable S2 = new Variable();
2122 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 2228 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
2123 { 2229 {
2124 if (YP.greaterThanOrEqual(Precedence, 1100)) 2230 if (YP.greaterThanOrEqual(Precedence, 1100))
2125 { 2231 {
@@ -2127,7 +2233,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2127 { 2233 {
2128 foreach (bool l5 in parse(S1, 1100, Next, S2)) 2234 foreach (bool l5 in parse(S1, 1100, Next, S2))
2129 { 2235 {
2130 foreach (bool l6 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) 2236 foreach (bool l6 in exprtl(S2, 1100, new Functor2(";", Term, Next), Precedence, Answer, S))
2131 { 2237 {
2132 yield return false; 2238 yield return false;
2133 } 2239 }
@@ -2161,6 +2267,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2161 { 2267 {
2162 yield break; 2268 yield break;
2163 } 2269 }
2270 foreach (bool l1 in YP.fail())
2271 {
2272 yield return false;
2273 }
2164 } 2274 }
2165 2275
2166 public static IEnumerable<bool> syntax_error(object _List) 2276 public static IEnumerable<bool> syntax_error(object _List)
@@ -2168,12 +2278,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2168 { 2278 {
2169 yield break; 2279 yield break;
2170 } 2280 }
2281 foreach (bool l1 in YP.fail())
2282 {
2283 yield return false;
2284 }
2171 } 2285 }
2172 2286
2173 public static IEnumerable<bool> prefixop(object F, object O, object Q) 2287 public static IEnumerable<bool> prefixop(object F, object O, object Q)
2174 { 2288 {
2175 { 2289 {
2176 foreach (bool l2 in YP.current_op(O, Atom.a(@"fx"), F)) 2290 foreach (bool l2 in YP.current_op(O, Atom.a("fx"), F))
2177 { 2291 {
2178 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) 2292 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2179 { 2293 {
@@ -2181,7 +2295,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2181 } 2295 }
2182 goto cutIf1; 2296 goto cutIf1;
2183 } 2297 }
2184 foreach (bool l2 in YP.current_op(O, Atom.a(@"fy"), F)) 2298 foreach (bool l2 in YP.current_op(O, Atom.a("fy"), F))
2185 { 2299 {
2186 foreach (bool l3 in YP.unify(Q, O)) 2300 foreach (bool l3 in YP.unify(Q, O))
2187 { 2301 {
@@ -2198,7 +2312,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2198 public static IEnumerable<bool> postfixop(object F, object P, object O) 2312 public static IEnumerable<bool> postfixop(object F, object P, object O)
2199 { 2313 {
2200 { 2314 {
2201 foreach (bool l2 in YP.current_op(O, Atom.a(@"xf"), F)) 2315 foreach (bool l2 in YP.current_op(O, Atom.a("xf"), F))
2202 { 2316 {
2203 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) 2317 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2204 { 2318 {
@@ -2206,7 +2320,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2206 } 2320 }
2207 goto cutIf1; 2321 goto cutIf1;
2208 } 2322 }
2209 foreach (bool l2 in YP.current_op(O, Atom.a(@"yf"), F)) 2323 foreach (bool l2 in YP.current_op(O, Atom.a("yf"), F))
2210 { 2324 {
2211 foreach (bool l3 in YP.unify(P, O)) 2325 foreach (bool l3 in YP.unify(P, O))
2212 { 2326 {
@@ -2223,7 +2337,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2223 public static IEnumerable<bool> infixop(object F, object P, object O, object Q) 2337 public static IEnumerable<bool> infixop(object F, object P, object O, object Q)
2224 { 2338 {
2225 { 2339 {
2226 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfy"), F)) 2340 foreach (bool l2 in YP.current_op(O, Atom.a("xfy"), F))
2227 { 2341 {
2228 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) 2342 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2229 { 2343 {
@@ -2234,7 +2348,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2234 } 2348 }
2235 goto cutIf1; 2349 goto cutIf1;
2236 } 2350 }
2237 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfx"), F)) 2351 foreach (bool l2 in YP.current_op(O, Atom.a("xfx"), F))
2238 { 2352 {
2239 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) 2353 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2240 { 2354 {
@@ -2245,7 +2359,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2245 } 2359 }
2246 goto cutIf2; 2360 goto cutIf2;
2247 } 2361 }
2248 foreach (bool l2 in YP.current_op(O, Atom.a(@"yfx"), F)) 2362 foreach (bool l2 in YP.current_op(O, Atom.a("yfx"), F))
2249 { 2363 {
2250 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) 2364 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2251 { 2365 {
@@ -2302,7 +2416,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2302 } 2416 }
2303 } 2417 }
2304 { 2418 {
2305 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) 2419 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", Atom.a("end_of_file"), 0), Atom.NIL)))
2306 { 2420 {
2307 yield return false; 2421 yield return false;
2308 } 2422 }
@@ -2336,7 +2450,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2336 } 2450 }
2337 } 2451 }
2338 { 2452 {
2339 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) 2453 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", Atom.a("end_of_file"), 0), Atom.NIL)))
2340 { 2454 {
2341 foreach (bool l3 in YP.unify(arg2, Atom.NIL)) 2455 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
2342 { 2456 {
@@ -2407,7 +2521,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2407 Variable NextCh = new Variable(); 2521 Variable NextCh = new Variable();
2408 foreach (bool l2 in YP.unify(arg1, 37)) 2522 foreach (bool l2 in YP.unify(arg1, 37))
2409 { 2523 {
2410 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) 2524 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("comment", StartPos, EndPos), Tokens)))
2411 { 2525 {
2412 foreach (bool l4 in get_current_position(StartPos)) 2526 foreach (bool l4 in get_current_position(StartPos))
2413 { 2527 {
@@ -2456,7 +2570,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2456 { 2570 {
2457 if (YP.equal(C2, new ListPair(42, Atom.NIL))) 2571 if (YP.equal(C2, new ListPair(42, Atom.NIL)))
2458 { 2572 {
2459 foreach (bool l5 in YP.unify(T, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) 2573 foreach (bool l5 in YP.unify(T, new ListPair(new Functor2("comment", StartPos, EndPos), Tokens)))
2460 { 2574 {
2461 foreach (bool l6 in get_current_position(StartPos1)) 2575 foreach (bool l6 in get_current_position(StartPos1))
2462 { 2576 {
@@ -2498,7 +2612,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2498 Variable NextCh = new Variable(); 2612 Variable NextCh = new Variable();
2499 foreach (bool l2 in YP.unify(arg1, 33)) 2613 foreach (bool l2 in YP.unify(arg1, 33))
2500 { 2614 {
2501 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@"!"), Pos), Tokens))) 2615 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("atom", Atom.a("!"), Pos), Tokens)))
2502 { 2616 {
2503 foreach (bool l4 in get_current_position(Pos)) 2617 foreach (bool l4 in get_current_position(Pos))
2504 { 2618 {
@@ -2518,7 +2632,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2518 Variable NextCh = new Variable(); 2632 Variable NextCh = new Variable();
2519 foreach (bool l2 in YP.unify(arg1, 40)) 2633 foreach (bool l2 in YP.unify(arg1, 40))
2520 { 2634 {
2521 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@" ("), Tokens))) 2635 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(" ("), Tokens)))
2522 { 2636 {
2523 foreach (bool l4 in YP.get_code(NextCh)) 2637 foreach (bool l4 in YP.get_code(NextCh))
2524 { 2638 {
@@ -2535,7 +2649,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2535 Variable NextCh = new Variable(); 2649 Variable NextCh = new Variable();
2536 foreach (bool l2 in YP.unify(arg1, 41)) 2650 foreach (bool l2 in YP.unify(arg1, 41))
2537 { 2651 {
2538 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)))
2539 { 2653 {
2540 foreach (bool l4 in YP.get_code(NextCh)) 2654 foreach (bool l4 in YP.get_code(NextCh))
2541 { 2655 {
@@ -2552,7 +2666,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2552 Variable NextCh = new Variable(); 2666 Variable NextCh = new Variable();
2553 foreach (bool l2 in YP.unify(arg1, 44)) 2667 foreach (bool l2 in YP.unify(arg1, 44))
2554 { 2668 {
2555 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)))
2556 { 2670 {
2557 foreach (bool l4 in YP.get_code(NextCh)) 2671 foreach (bool l4 in YP.get_code(NextCh))
2558 { 2672 {
@@ -2570,7 +2684,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2570 Variable NextCh = new Variable(); 2684 Variable NextCh = new Variable();
2571 foreach (bool l2 in YP.unify(arg1, 59)) 2685 foreach (bool l2 in YP.unify(arg1, 59))
2572 { 2686 {
2573 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@";"), Pos), Tokens))) 2687 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("atom", Atom.a(";"), Pos), Tokens)))
2574 { 2688 {
2575 foreach (bool l4 in get_current_position(Pos)) 2689 foreach (bool l4 in get_current_position(Pos))
2576 { 2690 {
@@ -2591,7 +2705,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2591 Variable NextCh = new Variable(); 2705 Variable NextCh = new Variable();
2592 foreach (bool l2 in YP.unify(arg1, 91)) 2706 foreach (bool l2 in YP.unify(arg1, 91))
2593 { 2707 {
2594 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Tokens))) 2708 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("/", Atom.a("["), Pos), Tokens)))
2595 { 2709 {
2596 foreach (bool l4 in get_current_position(Pos)) 2710 foreach (bool l4 in get_current_position(Pos))
2597 { 2711 {
@@ -2612,7 +2726,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2612 Variable NextCh = new Variable(); 2726 Variable NextCh = new Variable();
2613 foreach (bool l2 in YP.unify(arg1, 93)) 2727 foreach (bool l2 in YP.unify(arg1, 93))
2614 { 2728 {
2615 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Tokens))) 2729 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("/", Atom.a("]"), Pos), Tokens)))
2616 { 2730 {
2617 foreach (bool l4 in get_current_position(Pos)) 2731 foreach (bool l4 in get_current_position(Pos))
2618 { 2732 {
@@ -2633,7 +2747,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2633 Variable NextCh = new Variable(); 2747 Variable NextCh = new Variable();
2634 foreach (bool l2 in YP.unify(arg1, 123)) 2748 foreach (bool l2 in YP.unify(arg1, 123))
2635 { 2749 {
2636 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"{"), Pos), Tokens))) 2750 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("/", Atom.a("{"), Pos), Tokens)))
2637 { 2751 {
2638 foreach (bool l4 in get_current_position(Pos)) 2752 foreach (bool l4 in get_current_position(Pos))
2639 { 2753 {
@@ -2653,7 +2767,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2653 Variable NextCh = new Variable(); 2767 Variable NextCh = new Variable();
2654 foreach (bool l2 in YP.unify(arg1, 124)) 2768 foreach (bool l2 in YP.unify(arg1, 124))
2655 { 2769 {
2656 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"|"), Tokens))) 2770 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("|"), Tokens)))
2657 { 2771 {
2658 foreach (bool l4 in YP.get_code(NextCh)) 2772 foreach (bool l4 in YP.get_code(NextCh))
2659 { 2773 {
@@ -2670,7 +2784,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2670 Variable NextCh = new Variable(); 2784 Variable NextCh = new Variable();
2671 foreach (bool l2 in YP.unify(arg1, 125)) 2785 foreach (bool l2 in YP.unify(arg1, 125))
2672 { 2786 {
2673 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"}"), Tokens))) 2787 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("}"), Tokens)))
2674 { 2788 {
2675 foreach (bool l4 in YP.get_code(NextCh)) 2789 foreach (bool l4 in YP.get_code(NextCh))
2676 { 2790 {
@@ -2702,7 +2816,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2702 Variable NextCh = new Variable(); 2816 Variable NextCh = new Variable();
2703 foreach (bool l2 in YP.unify(arg1, 34)) 2817 foreach (bool l2 in YP.unify(arg1, 34))
2704 { 2818 {
2705 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"string", Chars), Tokens))) 2819 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1("string", Chars), Tokens)))
2706 { 2820 {
2707 foreach (bool l4 in read_string(Chars, 34, NextCh)) 2821 foreach (bool l4 in read_string(Chars, 34, NextCh))
2708 { 2822 {
@@ -3098,7 +3212,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3098 Variable Atom_1 = new Variable(); 3212 Variable Atom_1 = new Variable();
3099 Variable Pos = new Variable(); 3213 Variable Pos = new Variable();
3100 Variable Tokens = new Variable(); 3214 Variable Tokens = new Variable();
3101 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom_1, Pos), Tokens))) 3215 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2("atom", Atom_1, Pos), Tokens)))
3102 { 3216 {
3103 foreach (bool l3 in YP.unify(Pos, 0)) 3217 foreach (bool l3 in YP.unify(Pos, 0))
3104 { 3218 {
@@ -3121,7 +3235,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3121 Variable NextCh = new Variable(); 3235 Variable NextCh = new Variable();
3122 foreach (bool l2 in YP.unify(arg1, 40)) 3236 foreach (bool l2 in YP.unify(arg1, 40))
3123 { 3237 {
3124 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"("), Tokens))) 3238 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("("), Tokens)))
3125 { 3239 {
3126 foreach (bool l4 in YP.get_code(NextCh)) 3240 foreach (bool l4 in YP.get_code(NextCh))
3127 { 3241 {
@@ -3397,7 +3511,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3397 Variable Tokens = new Variable(); 3511 Variable Tokens = new Variable();
3398 Variable Chars = new Variable(); 3512 Variable Chars = new Variable();
3399 Variable NextCh = new Variable(); 3513 Variable NextCh = new Variable();
3400 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3(@"var", Var, Name, StartPos), Tokens))) 3514 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3("var", Var, Name, StartPos), Tokens)))
3401 { 3515 {
3402 foreach (bool l3 in get_current_position(StartPos)) 3516 foreach (bool l3 in get_current_position(StartPos))
3403 { 3517 {
@@ -3405,7 +3519,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3405 { 3519 {
3406 foreach (bool l5 in YP.atom_codes(Name, Chars)) 3520 foreach (bool l5 in YP.atom_codes(Name, Chars))
3407 { 3521 {
3408 if (YP.termEqual(Name, Atom.a(@"_"))) 3522 if (YP.termEqual(Name, Atom.a("_")))
3409 { 3523 {
3410 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens)) 3524 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens))
3411 { 3525 {
@@ -3435,7 +3549,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3435 Variable N = new Variable(); 3549 Variable N = new Variable();
3436 Variable V = new Variable(); 3550 Variable V = new Variable();
3437 Variable L = new Variable(); 3551 Variable L = new Variable();
3438 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", N, V), L))) 3552 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("=", N, V), L)))
3439 { 3553 {
3440 foreach (bool l3 in YP.unify(N, Name)) 3554 foreach (bool l3 in YP.unify(N, Name))
3441 { 3555 {
@@ -3493,7 +3607,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3493 } 3607 }
3494 foreach (bool l2 in YP.unify(LastCh, Ch)) 3608 foreach (bool l2 in YP.unify(LastCh, Ch))
3495 { 3609 {
3496 foreach (bool l3 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in /*comment~n"), Atom.NIL)) 3610 foreach (bool l3 in formatError(Atom.a("user_error"), Atom.a("~N** end of file in /*comment~n"), Atom.NIL))
3497 { 3611 {
3498 yield return false; 3612 yield return false;
3499 } 3613 }
@@ -3633,7 +3747,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3633 { 3747 {
3634 if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL))) 3748 if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL)))
3635 { 3749 {
3636 foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1(@"number", Number), Tokens1))) 3750 foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1("number", Number), Tokens1)))
3637 { 3751 {
3638 foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch)) 3752 foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch))
3639 { 3753 {
@@ -3662,7 +3776,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3662 } 3776 }
3663 goto cutIf3; 3777 goto cutIf3;
3664 } 3778 }
3665 foreach (bool l2 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file just after full stop~n"), Atom.NIL)) 3779 foreach (bool l2 in formatError(Atom.a("user_error"), Atom.a("~N** end of file just after full stop~n"), Atom.NIL))
3666 { 3780 {
3667 } 3781 }
3668 cutIf3: 3782 cutIf3:
@@ -3680,7 +3794,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3680 Variable NextCh = new Variable(); 3794 Variable NextCh = new Variable();
3681 foreach (bool l2 in prepend(Digits, Chars, Rest)) 3795 foreach (bool l2 in prepend(Digits, Chars, Rest))
3682 { 3796 {
3683 foreach (bool l3 in read_float(Digit, Rest, NextCh, Chars)) 3797 foreach (bool l3 in read_float4(Digit, Rest, NextCh, Chars))
3684 { 3798 {
3685 foreach (bool l4 in YP.number_codes(Number, Chars)) 3799 foreach (bool l4 in YP.number_codes(Number, Chars))
3686 { 3800 {
@@ -3724,7 +3838,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3724 } 3838 }
3725 } 3839 }
3726 3840
3727 public static IEnumerable<bool> read_float(object C1, object arg2, object NextCh, object Total) 3841 public static IEnumerable<bool> read_float4(object C1, object arg2, object NextCh, object Total)
3728 { 3842 {
3729 { 3843 {
3730 Variable Chars = new Variable(); 3844 Variable Chars = new Variable();
@@ -3740,7 +3854,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3740 { 3854 {
3741 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) 3855 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3742 { 3856 {
3743 foreach (bool l6 in read_float(C2, Chars, NextCh, Total)) 3857 foreach (bool l6 in read_float4(C2, Chars, NextCh, Total))
3744 { 3858 {
3745 yield return false; 3859 yield return false;
3746 } 3860 }
@@ -3770,7 +3884,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3770 } 3884 }
3771 foreach (bool l9 in YP.unify(More, Atom.NIL)) 3885 foreach (bool l9 in YP.unify(More, Atom.NIL))
3772 { 3886 {
3773 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) 3887 foreach (bool l10 in formatError(Atom.a("user_error"), Atom.a("~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3774 { 3888 {
3775 } 3889 }
3776 } 3890 }
@@ -3806,7 +3920,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3806 } 3920 }
3807 foreach (bool l9 in YP.unify(More, Atom.NIL)) 3921 foreach (bool l9 in YP.unify(More, Atom.NIL))
3808 { 3922 {
3809 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) 3923 foreach (bool l10 in formatError(Atom.a("user_error"), Atom.a("~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3810 { 3924 {
3811 } 3925 }
3812 } 3926 }
@@ -3840,7 +3954,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3840 } 3954 }
3841 foreach (bool l8 in YP.unify(More, Atom.NIL)) 3955 foreach (bool l8 in YP.unify(More, Atom.NIL))
3842 { 3956 {
3843 foreach (bool l9 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) 3957 foreach (bool l9 in formatError(Atom.a("user_error"), Atom.a("~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3844 { 3958 {
3845 } 3959 }
3846 } 3960 }
@@ -3920,7 +4034,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3920 Variable C = new Variable(); 4034 Variable C = new Variable();
3921 Variable C3 = new Variable(); 4035 Variable C3 = new Variable();
3922 Variable Digits = new Variable(); 4036 Variable Digits = new Variable();
3923 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1(@"number", Number), Tokens))) 4037 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1("number", Number), Tokens)))
3924 { 4038 {
3925 foreach (bool l3 in read_number4(C1, C2, 0, N)) 4039 foreach (bool l3 in read_number4(C1, C2, 0, N))
3926 { 4040 {
@@ -3954,7 +4068,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
3954 } 4068 }
3955 goto cutIf3; 4069 goto cutIf3;
3956 } 4070 }
3957 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)))) 4071 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))))
3958 { 4072 {
3959 foreach (bool l6 in YP.unify(Number, N)) 4073 foreach (bool l6 in YP.unify(Number, N))
3960 { 4074 {
@@ -4240,7 +4354,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
4240 { 4354 {
4241 if (YP.lessThan(C1, 0)) 4355 if (YP.lessThan(C1, 0))
4242 { 4356 {
4243 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)))) 4357 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))))
4244 { 4358 {
4245 foreach (bool l6 in YP.unify(Result, -1)) 4359 foreach (bool l6 in YP.unify(Result, -1))
4246 { 4360 {
@@ -4332,7 +4446,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
4332 { 4446 {
4333 if (YP.lessThan(C2, 0)) 4447 if (YP.lessThan(C2, 0))
4334 { 4448 {
4335 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))))) 4449 foreach (bool l7 in formatError(Atom.a("user_error"), Atom.a("~N** end of file in ~c..~c^..~c~n"), ListPair.make(new object[] { Quote, 92, Quote })))
4336 { 4450 {
4337 foreach (bool l8 in YP.unify(Result, -1)) 4451 foreach (bool l8 in YP.unify(Result, -1))
4338 { 4452 {
@@ -4432,7 +4546,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
4432 { 4546 {
4433 foreach (bool l7 in YP.unify(Next, Char)) 4547 foreach (bool l7 in YP.unify(Next, Char))
4434 { 4548 {
4435 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))))) 4549 foreach (bool l8 in formatError(Atom.a("user_error"), Atom.a("~N** Strange character ~d ends ~ctoken~c~n"), ListPair.make(new object[] { Char, Quote, Quote })))
4436 { 4550 {
4437 yield return false; 4551 yield return false;
4438 } 4552 }
@@ -4456,6 +4570,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
4456 { } 4570 { }
4457 } 4571 }
4458 } 4572 }
4459 #pragma warning restore 0168, 0219 4573#pragma warning restore 0168, 0219, 0162
4460 } 4574 }
4461} 4575}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT
index a1beeb6..5e0863f 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT
@@ -29,6 +29,7 @@ FEATURES
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* Yield Prolog 1.0.1 Released : it passes all but 9 of the 421 tests in the ISO Prolog test suite (97.8%).
32 33
33TODO 34TODO
34* Utilize ability to generate Javascript and Python code 35* Utilize ability to generate Javascript and Python code
@@ -117,6 +118,113 @@ void retractdb2(string predicate, string arg1, string arg2)
117 YP.retractFact(name, new object[] { arg1, arg2 }); 118 YP.retractFact(name, new object[] { arg1, arg2 });
118} 119}
119 120
121----------- IMPORT EXTERNAL FUNCTIONS ----------
122Using 'import' to call a static function
123
124Taken mostly from http://yieldprolog.sourceforge.net/tutorial4.html
125
126If we want to call a static function but it is not defined in the Prolog code, we can simply add an import directive.
127(In Prolog, if you start a line with :- it is a directive to the compiler. Don't forget to end with a period.):
128
129:- import('', [parent/2]).
130uncle(Person, Uncle):- parent(Person, Parent), brother(Parent, Uncle).
131
132The import directive has two arguments.
133The first argument is the module where the imported function is found, which is always ''.
134For C#, this means the imported function is in the same class as the calling function.
135For Javascript and Python, this means the imported function is in the global scope.
136The second argument to import is the comma-separated list of imported functions, where each member of the list is 'name/n', where 'name' is the name of the function and 'n' is the number of arguments.
137In this example, parent has two arguments, so we use parent/2.
138
139Note: you can use an imported function in a dynamically defined goal, or a function in another class.
140
141:- import('', [parent/2]).
142uncle(Person, Uncle) :- Goal = parent(Person, Parent), Goal, brother(Parent, Uncle).
143
144:- import('', ['OtherClass.parent'/2]).
145uncle(Person, Uncle) :- 'OtherClass.parent'(Person, Parent), brother(Parent, Uncle).
146
147--------- Round-about Hello Wonderful world ----------
148//yp
149:-import('',[sayit/1]).
150sayhello(X):-sayit(X).
151
152//cs
153public void default_event_state_entry()
154 {
155 llSay(0,"prolog hello.");
156 foreach( bool ans in sayhello(Atom.a(@"wonderful world") )){};
157 }
158
159PrologCallback sayit(object ans)
160 {
161 llSay(0,"sayit1");
162 string msg = "one answer is :"+((Variable)ans).getValue();
163 llSay(0,msg);
164 yield return false;
165 }
166
167------------------ UPDATES -----------------
168Yield Prolog 1.0 Released : It passes all but 15 of the 421 tests in the ISO Prolog test suite.
169
170New Features:
171* Added support for Prolog predicates read and read_term.
172* In see, Added support for a char code list as the input.
173Using this as the input for "fred" makes
174set_prolog_flag(double_quotes, atom) and
175set_prolog_flag(double_quotes, chars) pass the ISO test suite.
176
177Fixed Bugs:
178* In atom_chars, check for unbound tail in the char list.
179This makes atom_chars pass the ISO test suite.
180* In current_predicate, also check for static functions.
181This makes current_predicate pass the ISO test suite.
182
183Known Issues:
184
185Here are the 9 errors of the 421 tests in the ISO test suite in
186YieldProlog\source\prolog\isoTestSuite.P .
187Some of these have a good excuse for why Yield Prolog produces the error. The rest will be addressed in a future maintenance release.
188
189Goal: call((fail, 1))
190Expected: type_error(callable, (fail, 1))
191Extra Solutions found: failure
192
193Goal: call((write(3), 1))
194Expected: type_error(callable, (write(3), 1))
195Extra Solutions found: type_error(callable, 1)
196
197Goal: call((1; true))
198Expected: type_error(callable, (1 ; true))
199Extra Solutions found: type_error(callable, 1)
200
201Goal: (catch(true, C, write('something')), throw(blabla))
202Expected: system_error
203Extra Solutions found: unexpected_ball(blabla)
204
205Goal: catch(number_chars(A,L), error(instantiation_error, _), fail)
206Expected: failure
207Extra Solutions found: instantiation_error
208
209Goal: Goal: (X = 1 + 2, 'is'(Y, X * 3))
210Expected: [[X <-- (1 + 2), Y <-- 9]]
211Extra Solutions found: type_error(evaluable, /(+, 2))
212
213Goal: 'is'(77, N)
214Expected: instantiation_error
215Extra Solutions found: N <-- 77)
216
217Goal: \+(!, fail)
218Expected: success
219Extra Solutions found: failure
220
221((X=1;X=2), \+((!,fail)))
222Expected: [[X <-- 1],[X <-- 2]]
223Extra Solutions found: failure
224
225
226
227
120 228
121========================= APPENDIX A: touch test ================================ 229========================= APPENDIX A: touch test ================================
122 230
@@ -403,3 +511,4 @@ public IEnumerable<bool> prolog_notify(object X) {
403 511
404} } 512} }
405 513
514
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs
index 281fb42..a9bd563 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs
@@ -43,6 +43,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
43 bool ground(); 43 bool ground();
44 } 44 }
45 45
46 /// <summary>
47 /// A Variable is passed to a function so that it can be unified with
48 /// value or another Variable. See getValue and unify for details.
49 /// </summary>
46 public class Variable : IUnifiable 50 public class Variable : IUnifiable
47 { 51 {
48 // Use _isBound separate from _value so that it can be bound to any value, 52 // Use _isBound separate from _value so that it can be bound to any value,
@@ -50,6 +54,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
50 private bool _isBound = false; 54 private bool _isBound = false;
51 private object _value; 55 private object _value;
52 56
57 /// <summary>
58 /// If this Variable is unbound, then just return this Variable.
59 /// Otherwise, if this has been bound to a value with unify, return the value.
60 /// If the bound value is another Variable, this follows the "variable chain"
61 /// to the end and returns the final value, or the final Variable if it is unbound.
62 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
63 /// </summary>
64 /// <returns></returns>
53 public object getValue() 65 public object getValue()
54 { 66 {
55 if (!_isBound) 67 if (!_isBound)
@@ -68,6 +80,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
68 return result; 80 return result;
69 } 81 }
70 82
83 /// <summary>
84 /// If this Variable is bound, then just call YP.unify to unify this with arg.
85 /// (Note that if arg is an unbound Variable, then YP.unify will bind it to
86 /// this Variable's value.)
87 /// Otherwise, bind this Variable to YP.getValue(arg) and yield once. After the
88 /// yield, return this Variable to the unbound state.
89 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
90 /// </summary>
91 /// <param name="arg"></param>
92 /// <returns></returns>
71 public IEnumerable<bool> unify(object arg) 93 public IEnumerable<bool> unify(object arg)
72 { 94 {
73 if (!_isBound) 95 if (!_isBound)
@@ -105,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
105 { 127 {
106 object value = getValue(); 128 object value = getValue();
107 if (value == this) 129 if (value == this)
108 return "Variable"; 130 return "_Variable";
109 else 131 else
110 return getValue().ToString(); 132 return getValue().ToString();
111 } 133 }
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs
index ac56875..b69f9c4 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YP.cs
@@ -52,6 +52,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
52 private static TextWriter _outputStream = System.Console.Out; 52 private static TextWriter _outputStream = System.Console.Out;
53 private static TextReader _inputStream = System.Console.In; 53 private static TextReader _inputStream = System.Console.In;
54 private static IndexedAnswers _operatorTable = null; 54 private static IndexedAnswers _operatorTable = null;
55 private static Dictionary<string, object> _prologFlags = new Dictionary<string, object>();
56 public const int MAX_ARITY = 255;
55 57
56 /// <summary> 58 /// <summary>
57 /// An IClause is used so that dynamic predicates can call match. 59 /// An IClause is used so that dynamic predicates can call match.
@@ -62,6 +64,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
62 IEnumerable<bool> clause(object Head, object Body); 64 IEnumerable<bool> clause(object Head, object Body);
63 } 65 }
64 66
67 /// <summary>
68 /// If value is a Variable, then return its getValue. Otherwise, just
69 /// return value. You should call YP.getValue on any object that
70 /// may be a Variable to get the value to pass to other functions in
71 /// your system that are not part of Yield Prolog, such as math functions
72 /// or file I/O.
73 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
74 /// </summary>
75 /// <param name="value"></param>
76 /// <returns></returns>
65 public static object getValue(object value) 77 public static object getValue(object value)
66 { 78 {
67 if (value is Variable) 79 if (value is Variable)
@@ -70,6 +82,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
70 return value; 82 return value;
71 } 83 }
72 84
85 /// <summary>
86 /// If arg1 or arg2 is an object with a unify method (such as Variable or
87 /// Functor) then just call its unify with the other argument. The object's
88 /// unify method will bind the values or check for equals as needed.
89 /// Otherwise, both arguments are "normal" (atomic) values so if they
90 /// are equal then succeed (yield once), else fail (don't yield).
91 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
92 /// </summary>
93 /// <param name="arg1"></param>
94 /// <param name="arg2"></param>
95 /// <returns></returns>
73 public static IEnumerable<bool> unify(object arg1, object arg2) 96 public static IEnumerable<bool> unify(object arg1, object arg2)
74 { 97 {
75 arg1 = getValue(arg1); 98 arg1 = getValue(arg1);
@@ -622,6 +645,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
622 if (args.Length == 0) 645 if (args.Length == 0)
623 // Return the Name, even if it is not an Atom. 646 // Return the Name, even if it is not an Atom.
624 return YP.unify(Term, Name); 647 return YP.unify(Term, Name);
648 if (args.Length > MAX_ARITY)
649 throw new PrologException
650 (new Functor1("representation_error", Atom.a("max_arity")),
651 "Functor arity " + args.Length + " may not be greater than " + MAX_ARITY);
625 if (!atom(Name)) 652 if (!atom(Name))
626 throw new PrologException 653 throw new PrologException
627 (new Functor2("type_error", Atom.a("atom"), Name), 654 (new Functor2("type_error", Atom.a("atom"), Name),
@@ -666,6 +693,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
666 } 693 }
667 else 694 else
668 { 695 {
696 if ((int)Arity > MAX_ARITY)
697 throw new PrologException
698 (new Functor1("representation_error", Atom.a("max_arity")),
699 "Functor arity " + Arity + " may not be greater than " + MAX_ARITY);
669 if (!(FunctorName is Atom)) 700 if (!(FunctorName is Atom))
670 throw new PrologException 701 throw new PrologException
671 (new Functor2("type_error", Atom.a("atom"), FunctorName), "FunctorName is not an atom"); 702 (new Functor2("type_error", Atom.a("atom"), FunctorName), "FunctorName is not an atom");
@@ -903,8 +934,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
903 _operatorTable.addAnswer(new object[] { 20, Atom.a("xfx"), Atom.a("<--") }); 934 _operatorTable.addAnswer(new object[] { 20, Atom.a("xfx"), Atom.a("<--") });
904 } 935 }
905 936
906 foreach (bool l1 in _operatorTable.match(new object[] { Priority, Specifier, Operator })) 937 return _operatorTable.match(new object[] { Priority, Specifier, Operator });
907 yield return false;
908 } 938 }
909 939
910 public static IEnumerable<bool> atom_length(object atom, object Length) 940 public static IEnumerable<bool> atom_length(object atom, object Length)
@@ -1491,9 +1521,22 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1491 return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor; 1521 return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor;
1492 } 1522 }
1493 1523
1524 /// <summary>
1525 /// If input is a TextReader, use it. If input is an Atom or String, create a StreamReader with the
1526 /// input as the filename. If input is a Prolog list, then read character codes from it.
1527 /// </summary>
1528 /// <param name="input"></param>
1494 public static void see(object input) 1529 public static void see(object input)
1495 { 1530 {
1496 input = YP.getValue(input); 1531 input = YP.getValue(input);
1532 if (input is Variable)
1533 throw new PrologException(Atom.a("instantiation_error"), "Arg is an unbound variable");
1534
1535 if (input == null)
1536 {
1537 _inputStream = null;
1538 return;
1539 }
1497 if (input is TextReader) 1540 if (input is TextReader)
1498 { 1541 {
1499 _inputStream = (TextReader)input; 1542 _inputStream = (TextReader)input;
@@ -1509,21 +1552,48 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1509 _inputStream = new StreamReader((String)input); 1552 _inputStream = new StreamReader((String)input);
1510 return; 1553 return;
1511 } 1554 }
1555 else if (input is Functor2 && ((Functor2)input)._name == Atom.DOT)
1556 {
1557 _inputStream = new CodeListReader(input);
1558 return;
1559 }
1512 else 1560 else
1513 throw new InvalidOperationException("Can't open stream for " + input); 1561 throw new PrologException
1562 (new Functor2("domain_error", Atom.a("stream_or_alias"), input),
1563 "Input stream specifier not recognized");
1514 } 1564 }
1515 1565
1516 public static void seen() 1566 public static void seen()
1517 { 1567 {
1568 if (_inputStream == null)
1569 return;
1518 if (_inputStream == Console.In) 1570 if (_inputStream == Console.In)
1519 return; 1571 return;
1520 _inputStream.Close(); 1572 _inputStream.Close();
1521 _inputStream = Console.In; 1573 _inputStream = Console.In;
1522 } 1574 }
1523 1575
1576 public static IEnumerable<bool> current_input(object Stream)
1577 {
1578 return YP.unify(Stream, _inputStream);
1579 }
1580
1581 /// <summary>
1582 /// If output is a TextWriter, use it. If output is an Atom or a String, create a StreamWriter
1583 /// with the input as the filename.
1584 /// </summary>
1585 /// <param name="output"></param>
1524 public static void tell(object output) 1586 public static void tell(object output)
1525 { 1587 {
1526 output = YP.getValue(output); 1588 output = YP.getValue(output);
1589 if (output is Variable)
1590 throw new PrologException(Atom.a("instantiation_error"), "Arg is an unbound variable");
1591
1592 if (output == null)
1593 {
1594 _outputStream = null;
1595 return;
1596 }
1527 if (output is TextWriter) 1597 if (output is TextWriter)
1528 { 1598 {
1529 _outputStream = (TextWriter)output; 1599 _outputStream = (TextWriter)output;
@@ -1540,11 +1610,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1540 return; 1610 return;
1541 } 1611 }
1542 else 1612 else
1543 throw new InvalidOperationException("Can't open stream for " + output); 1613 throw new PrologException
1614 (new Functor2("domain_error", Atom.a("stream_or_alias"), output),
1615 "Can't open stream for " + output);
1544 } 1616 }
1545 1617
1546 public static void told() 1618 public static void told()
1547 { 1619 {
1620 if (_outputStream == null)
1621 return;
1548 if (_outputStream == Console.Out) 1622 if (_outputStream == Console.Out)
1549 return; 1623 return;
1550 _outputStream.Close(); 1624 _outputStream.Close();
@@ -1558,6 +1632,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1558 1632
1559 public static void write(object x) 1633 public static void write(object x)
1560 { 1634 {
1635 if (_outputStream == null)
1636 return;
1561 x = YP.getValue(x); 1637 x = YP.getValue(x);
1562 if (x is double) 1638 if (x is double)
1563 _outputStream.Write(doubleToString((double)x)); 1639 _outputStream.Write(doubleToString((double)x));
@@ -1591,6 +1667,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1591 1667
1592 public static void put_code(object x) 1668 public static void put_code(object x)
1593 { 1669 {
1670 if (_outputStream == null)
1671 return;
1594 if (var(x)) 1672 if (var(x))
1595 throw new PrologException(Atom.a("instantiation_error"), "Arg 1 is an unbound variable"); 1673 throw new PrologException(Atom.a("instantiation_error"), "Arg 1 is an unbound variable");
1596 int xInt; 1674 int xInt;
@@ -1602,11 +1680,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1602 1680
1603 public static void nl() 1681 public static void nl()
1604 { 1682 {
1683 if (_outputStream == null)
1684 return;
1605 _outputStream.WriteLine(); 1685 _outputStream.WriteLine();
1606 } 1686 }
1607 1687
1608 public static IEnumerable<bool> get_code(object code) 1688 public static IEnumerable<bool> get_code(object code)
1609 { 1689 {
1690 if (_inputStream == null)
1691 return YP.unify(code, -1);
1692 else
1610 return YP.unify(code, _inputStream.Read()); 1693 return YP.unify(code, _inputStream.Read());
1611 } 1694 }
1612 1695
@@ -1763,7 +1846,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1763 /// <summary> 1846 /// <summary>
1764 /// Match all clauses of the dynamic predicate with the name and with arity 1847 /// Match all clauses of the dynamic predicate with the name and with arity
1765 /// arguments.Length. 1848 /// arguments.Length.
1766 /// It is an error if the predicate is not defined. 1849 /// If the predicate is not defined, return the result of YP.unknownPredicate.
1767 /// </summary> 1850 /// </summary>
1768 /// <param name="name">must be an Atom</param> 1851 /// <param name="name">must be an Atom</param>
1769 /// <param name="arguments">an array of arity number of arguments</param> 1852 /// <param name="arguments">an array of arity number of arguments</param>
@@ -1772,11 +1855,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1772 { 1855 {
1773 List<IClause> clauses; 1856 List<IClause> clauses;
1774 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) 1857 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses))
1775 throw new PrologException 1858 return unknownPredicate(name, arguments.Length,
1776 (new Functor2 1859 "Undefined dynamic predicate: " + name + "/" + arguments.Length);
1777 (Atom.a("existence_error"), Atom.a("procedure"),
1778 new Functor2(Atom.SLASH, name, arguments.Length)),
1779 "Undefined predicate: " + name + "/" + arguments.Length);
1780 1860
1781 if (clauses.Count == 1) 1861 if (clauses.Count == 1)
1782 // Usually there is only one clause, so return it without needing to wrap it in an iterator. 1862 // Usually there is only one clause, so return it without needing to wrap it in an iterator.
@@ -1809,6 +1889,34 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1809 } 1889 }
1810 1890
1811 /// <summary> 1891 /// <summary>
1892 /// If _prologFlags["unknown"] is fail then return fail(), else if
1893 /// _prologFlags["unknown"] is warning then write the message to YP.write and
1894 /// return fail(), else throw a PrologException for existence_error. .
1895 /// </summary>
1896 /// <param name="name"></param>
1897 /// <param name="arity"></param>
1898 /// <param name="message"></param>
1899 /// <returns></returns>
1900 public static IEnumerable<bool> unknownPredicate(Atom name, int arity, string message)
1901 {
1902 establishPrologFlags();
1903
1904 if (_prologFlags["unknown"] == Atom.a("fail"))
1905 return fail();
1906 else if (_prologFlags["unknown"] == Atom.a("warning"))
1907 {
1908 write(message);
1909 nl();
1910 return fail();
1911 }
1912 else
1913 throw new PrologException
1914 (new Functor2
1915 (Atom.a("existence_error"), Atom.a("procedure"),
1916 new Functor2(Atom.SLASH, name, arity)), message);
1917 }
1918
1919 /// <summary>
1812 /// This is deprecated and just calls matchDynamic. This matches all clauses, 1920 /// This is deprecated and just calls matchDynamic. This matches all clauses,
1813 /// not just the ones defined with assertFact. 1921 /// not just the ones defined with assertFact.
1814 /// </summary> 1922 /// </summary>
@@ -1951,7 +2059,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1951 _predicatesStore[nameArity] = new List<IClause>(); 2059 _predicatesStore[nameArity] = new List<IClause>();
1952 } 2060 }
1953 2061
1954 public static IEnumerable<bool> current_predicate(object NameSlashArity) 2062 /// <summary>
2063 /// If NameSlashArity is var, match with all the dynamic predicates using the
2064 /// Name/Artity form.
2065 /// If NameSlashArity is not var, check if the Name/Arity exists as a static or
2066 /// dynamic predicate.
2067 /// </summary>
2068 /// <param name="NameSlashArity"></param>
2069 /// <param name="declaringClass">if not null, used to resolve references to the default
2070 /// module Atom.a("")</param>
2071 /// <returns></returns>
2072 public static IEnumerable<bool> current_predicate(object NameSlashArity, Type declaringClass)
1955 { 2073 {
1956 NameSlashArity = YP.getValue(NameSlashArity); 2074 NameSlashArity = YP.getValue(NameSlashArity);
1957 // First check if Name and Arity are nonvar so we can do a direct lookup. 2075 // First check if Name and Arity are nonvar so we can do a direct lookup.
@@ -1976,7 +2094,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1976 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity), 2094 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity),
1977 "Arity may not be less than zero"); 2095 "Arity may not be less than zero");
1978 2096
1979 if (_predicatesStore.ContainsKey(new NameArity((Atom)name, (int)arity))) 2097 if (YPCompiler.isCurrentPredicate((Atom)name, (int)arity, declaringClass))
1980 // The predicate is defined. 2098 // The predicate is defined.
1981 yield return false; 2099 yield return false;
1982 } 2100 }
@@ -1991,6 +2109,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
1991 } 2109 }
1992 } 2110 }
1993 2111
2112 /// <summary>
2113 /// Return true if the dynamic predicate store has an entry for the predicate
2114 /// with name and arity.
2115 /// </summary>
2116 /// <param name="name"></param>
2117 /// <param name="arity"></param>
2118 /// <returns></returns>
2119 public static bool isDynamicCurrentPredicate(Atom name, int arity)
2120 {
2121 return _predicatesStore.ContainsKey(new NameArity(name, arity));
2122 }
2123
1994 public static void abolish(object NameSlashArity) 2124 public static void abolish(object NameSlashArity)
1995 { 2125 {
1996 NameSlashArity = YP.getValue(NameSlashArity); 2126 NameSlashArity = YP.getValue(NameSlashArity);
@@ -2019,6 +2149,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2019 throw new PrologException 2149 throw new PrologException
2020 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity), 2150 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity),
2021 "Arity may not be less than zero"); 2151 "Arity may not be less than zero");
2152 if ((int)arity > MAX_ARITY)
2153 throw new PrologException
2154 (new Functor1("representation_error", Atom.a("max_arity")),
2155 "Arity may not be greater than " + MAX_ARITY);
2022 2156
2023 if (isSystemPredicate((Atom)name, (int)arity)) 2157 if (isSystemPredicate((Atom)name, (int)arity))
2024 throw new PrologException 2158 throw new PrologException
@@ -2077,7 +2211,108 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2077 { 2211 {
2078 throw new PrologException(Term); 2212 throw new PrologException(Term);
2079 } 2213 }
2214 /// <summary>
2215 /// This must be called by any function that uses YP._prologFlags to make sure
2216 /// the initial defaults are loaded.
2217 /// </summary>
2218 private static void establishPrologFlags()
2219 {
2220 if (_prologFlags.Count > 0)
2221 // Already established.
2222 return;
2223
2224 // List these in the order they appear in the ISO standard.
2225 _prologFlags["bounded"] = Atom.a("true");
2226 _prologFlags["max_integer"] = Int32.MaxValue;
2227 _prologFlags["min_integer"] = Int32.MinValue;
2228 _prologFlags["integer_rounding_function"] = Atom.a("toward_zero");
2229 _prologFlags["char_conversion"] = Atom.a("off");
2230 _prologFlags["debug"] = Atom.a("off");
2231 _prologFlags["max_arity"] = MAX_ARITY;
2232 _prologFlags["unknown"] = Atom.a("error");
2233 _prologFlags["double_quotes"] = Atom.a("codes");
2234 }
2235
2236 public static IEnumerable<bool> current_prolog_flag(object Key, object Value)
2237 {
2238 establishPrologFlags();
2239
2240 Key = YP.getValue(Key);
2241 Value = YP.getValue(Value);
2242
2243 if (Key is Variable)
2244 {
2245 // Bind all key values.
2246 foreach (string key in _prologFlags.Keys)
2247 {
2248 foreach (bool l1 in YP.unify(Key, Atom.a(key)))
2249 {
2250 foreach (bool l2 in YP.unify(Value, _prologFlags[key]))
2251 yield return false;
2252 }
2253 }
2254 }
2255 else
2256 {
2257 if (!(Key is Atom))
2258 throw new PrologException
2259 (new Functor2("type_error", Atom.a("atom"), Key), "Arg 1 Key is not an atom");
2260 if (!_prologFlags.ContainsKey(((Atom)Key)._name))
2261 throw new PrologException
2262 (new Functor2("domain_error", Atom.a("prolog_flag"), Key),
2263 "Arg 1 Key is not a recognized flag");
2264
2265 foreach (bool l1 in YP.unify(Value, _prologFlags[((Atom)Key)._name]))
2266 yield return false;
2267 }
2268 }
2269
2270 public static void set_prolog_flag(object Key, object Value)
2271 {
2272 establishPrologFlags();
2273
2274 Key = YP.getValue(Key);
2275 Value = YP.getValue(Value);
2276
2277 if (Key is Variable)
2278 throw new PrologException(Atom.a("instantiation_error"),
2279 "Arg 1 Key is an unbound variable");
2280 if (Value is Variable)
2281 throw new PrologException(Atom.a("instantiation_error"),
2282 "Arg 1 Key is an unbound variable");
2283 if (!(Key is Atom))
2284 throw new PrologException
2285 (new Functor2("type_error", Atom.a("atom"), Key), "Arg 1 Key is not an atom");
2286
2287 string keyName = ((Atom)Key)._name;
2288 if (!_prologFlags.ContainsKey(keyName))
2289 throw new PrologException
2290 (new Functor2("domain_error", Atom.a("prolog_flag"), Key),
2291 "Arg 1 Key " + Key + " is not a recognized flag");
2292
2293 bool valueIsOK = false;
2294 if (keyName == "char_conversion")
2295 valueIsOK = (Value == _prologFlags[keyName]);
2296 else if (keyName == "debug")
2297 valueIsOK = (Value == _prologFlags[keyName]);
2298 else if (keyName == "unknown")
2299 valueIsOK = (Value == Atom.a("fail") || Value == Atom.a("warning") ||
2300 Value == Atom.a("error"));
2301 else if (keyName == "double_quotes")
2302 valueIsOK = (Value == Atom.a("codes") || Value == Atom.a("chars") ||
2303 Value == Atom.a("atom"));
2304 else
2305 throw new PrologException
2306 (new Functor3("permission_error", Atom.a("modify"), Atom.a("flag"), Key),
2307 "May not modify Prolog flag " + Key);
2308
2309 if (!valueIsOK)
2310 throw new PrologException
2311 (new Functor2("domain_error", Atom.a("flag_value"), new Functor2("+", Key, Value)),
2312 "May not set arg 1 Key " + Key + " to arg 2 Value " + Value);
2080 2313
2314 _prologFlags[keyName] = Value;
2315 }
2081 /// <summary> 2316 /// <summary>
2082 /// script_event calls hosting script with events as a callback method. 2317 /// script_event calls hosting script with events as a callback method.
2083 /// </summary> 2318 /// </summary>
@@ -2303,19 +2538,35 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2303 private IEnumerator<bool> _enumerator; 2538 private IEnumerator<bool> _enumerator;
2304 private PrologException _exception = null; 2539 private PrologException _exception = null;
2305 2540
2306 public Catch(IEnumerable<bool> iterator) 2541 /// <summary>
2542 /// Call YP.getIterator(Goal, declaringClass) and save the returned iterator.
2543 /// If getIterator throws an exception, save it the same as MoveNext().
2544 /// </summary>
2545 /// <param name="Goal"></param>
2546 /// <param name="declaringClass"></param>
2547 public Catch(object Goal, Type declaringClass)
2548 {
2549 try
2307 { 2550 {
2308 _enumerator = iterator.GetEnumerator(); 2551 _enumerator = getIterator(Goal, declaringClass).GetEnumerator();
2552 }
2553 catch (PrologException exception)
2554 {
2555 // MoveNext() will check this.
2556 _exception = exception;
2557 }
2309 } 2558 }
2310 2559
2311 /// <summary> 2560 /// <summary>
2312 /// Call _enumerator.MoveNext(). If it throws a PrologException, set _exception 2561 /// Call _enumerator.MoveNext(). If it throws a PrologException, set _exception
2313 /// and return false. After this returns false, call unifyExceptionOrThrow. 2562 /// and return false. After this returns false, call unifyExceptionOrThrow.
2314 /// Assume that, after this returns false, it will not be called again.
2315 /// </summary> 2563 /// </summary>
2316 /// <returns></returns> 2564 /// <returns></returns>
2317 public bool MoveNext() 2565 public bool MoveNext()
2318 { 2566 {
2567 if (_exception != null)
2568 return false;
2569
2319 try 2570 try
2320 { 2571 {
2321 return _enumerator.MoveNext(); 2572 return _enumerator.MoveNext();
@@ -2372,6 +2623,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2372 2623
2373 public void Dispose() 2624 public void Dispose()
2374 { 2625 {
2626 if (_enumerator != null)
2375 _enumerator.Dispose(); 2627 _enumerator.Dispose();
2376 } 2628 }
2377 2629
@@ -2410,5 +2662,40 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
2410 #pragma warning restore 0168 2662 #pragma warning restore 0168
2411 } 2663 }
2412 } 2664 }
2665
2666 /// <summary>
2667 /// CodeListReader extends TextReader and overrides Read to read the next code from
2668 /// the CodeList which is a Prolog list of integer character codes.
2669 /// </summary>
2670 public class CodeListReader : TextReader
2671 {
2672 private object _CodeList;
2673
2674 public CodeListReader(object CodeList)
2675 {
2676 _CodeList = YP.getValue(CodeList);
2677 }
2678
2679 /// <summary>
2680 /// If the head of _CodeList is an integer, return it and advance the list. Otherwise,
2681 /// return -1 for end of file.
2682 /// </summary>
2683 /// <returns></returns>
2684 public override int Read()
2685 {
2686 Functor2 CodeListPair = _CodeList as Functor2;
2687 int code;
2688 if (!(CodeListPair != null && CodeListPair._name == Atom.DOT &&
2689 getInt(CodeListPair._arg1, out code)))
2690 {
2691 _CodeList = Atom.NIL;
2692 return -1;
2693 }
2694
2695 // Advance.
2696 _CodeList = YP.getValue(CodeListPair._arg2);
2697 return code;
2698 }
2699 }
2413 } 2700 }
2414} 2701}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs
index 93b5a1b..1d9c0ef 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/YPCompiler.cs
@@ -405,8 +405,8 @@ namespace Temporary {
405 /// <summary> 405 /// <summary>
406 /// If the functor with name and args can be called directly as determined by 406 /// If the functor with name and args can be called directly as determined by
407 /// functorCallFunctionName, then call it and return its iterator. If the predicate is 407 /// functorCallFunctionName, then call it and return its iterator. If the predicate is
408 /// dynamic and undefined, or if static and the method cannot be found, throw 408 /// dynamic and undefined, or if static and the method cannot be found, return
409 /// a PrologException for existence_error. 409 /// the result of YP.unknownPredicate.
410 /// This returns null if the functor has a special form than needs to be compiled 410 /// This returns null if the functor has a special form than needs to be compiled
411 /// (including ,/2 and ;/2). 411 /// (including ,/2 and ;/2).
412 /// </summary> 412 /// </summary>
@@ -424,13 +424,11 @@ namespace Temporary {
424 { 424 {
425 Atom functionNameAtom = ((Atom)FunctionName.getValue()); 425 Atom functionNameAtom = ((Atom)FunctionName.getValue());
426 if (functionNameAtom == Atom.NIL) 426 if (functionNameAtom == Atom.NIL)
427 {
428 // name is for a dynamic predicate. 427 // name is for a dynamic predicate.
429 return YP.matchDynamic(name, args); 428 return YP.matchDynamic(name, args);
430 }
431 429
432 // Set the default for the method to call.
433 string methodName = functionNameAtom._name; 430 string methodName = functionNameAtom._name;
431 // Set the default for the method to call.
434 Type methodClass = declaringClass; 432 Type methodClass = declaringClass;
435 433
436 bool checkMode = false; 434 bool checkMode = false;
@@ -448,10 +446,8 @@ namespace Temporary {
448 return null; 446 return null;
449 447
450 if (methodClass == null) 448 if (methodClass == null)
451 throw new PrologException 449 return YP.unknownPredicate
452 (new Functor2 450 (name, args.Length,
453 (Atom.a("existence_error"), Atom.a("procedure"),
454 new Functor2(Atom.a("/"), name, args.Length)),
455 "Cannot find predicate function for: " + name + "/" + args.Length + 451 "Cannot find predicate function for: " + name + "/" + args.Length +
456 " because declaringClass is null. Set declaringClass to the class containing " + 452 " because declaringClass is null. Set declaringClass to the class containing " +
457 methodName); 453 methodName);
@@ -486,10 +482,8 @@ namespace Temporary {
486 } 482 }
487 catch (MissingMethodException) 483 catch (MissingMethodException)
488 { 484 {
489 throw new PrologException 485 return YP.unknownPredicate
490 (new Functor2 486 (name, args.Length,
491 (Atom.a("existence_error"), Atom.a("procedure"),
492 new Functor2(Atom.a("/"), name, args.Length)),
493 "Cannot find predicate function " + methodName + " for " + name + "/" + args.Length + 487 "Cannot find predicate function " + methodName + " for " + name + "/" + args.Length +
494 " in " + methodClass.FullName); 488 " in " + methodClass.FullName);
495 } 489 }
@@ -498,6 +492,54 @@ namespace Temporary {
498 return null; 492 return null;
499 } 493 }
500 494
495 /// <summary>
496 /// Return true if there is a dynamic or static predicate with name and arity.
497 /// This returns false for built-in predicates.
498 /// </summary>
499 /// <param name="name"></param>
500 /// <param name="arity"></param>
501 /// <param name="declaringClass">used to resolve references to the default
502 /// module Atom.a(""). If a declaringClass is needed to resolve the reference but it is
503 /// null, return false</param>
504 /// <returns></returns>
505 public static bool isCurrentPredicate(Atom name, int arity, Type declaringClass)
506 {
507 CompilerState state = new CompilerState();
508 Variable FunctionName = new Variable();
509 foreach (bool l1 in functorCallFunctionName(state, name, arity, FunctionName))
510 {
511 Atom functionNameAtom = ((Atom)FunctionName.getValue());
512 if (functionNameAtom == Atom.NIL)
513 // name is for a dynamic predicate.
514 return YP.isDynamicCurrentPredicate(name, arity);
515
516 string methodName = functionNameAtom._name;
517
518 if (methodName.StartsWith("YP."))
519 // current_predicate/1 should fail for built-ins.
520 return false;
521 if (methodName.Contains("."))
522 // We don't support calling inner classes, etc.
523 return false;
524 if (declaringClass == null)
525 return false;
526
527 foreach (MemberInfo member in declaringClass.GetMember(methodName))
528 {
529 MethodInfo method = member as MethodInfo;
530 if (method == null)
531 continue;
532 if ((method.Attributes | MethodAttributes.Static) == 0)
533 // Not a static method.
534 continue;
535 if (method.GetParameters().Length == arity)
536 return true;
537 }
538 }
539
540 return false;
541 }
542
501 // Compiler output follows. 543 // Compiler output follows.
502 544
503 public class YPInnerClass { } 545 public class YPInnerClass { }
@@ -567,9 +609,14 @@ namespace Temporary {
567 CompilerState.assertPred(State, Atom.a("nl"), Atom.a("det")); 609 CompilerState.assertPred(State, Atom.a("nl"), Atom.a("det"));
568 CompilerState.assertPred(State, new Functor1("write", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 610 CompilerState.assertPred(State, new Functor1("write", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
569 CompilerState.assertPred(State, new Functor1("put_code", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 611 CompilerState.assertPred(State, new Functor1("put_code", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
612 CompilerState.assertPred(State, new Functor1("see", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
613 CompilerState.assertPred(State, Atom.a("seen"), Atom.a("det"));
614 CompilerState.assertPred(State, new Functor1("tell", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
615 CompilerState.assertPred(State, Atom.a("told"), Atom.a("det"));
570 CompilerState.assertPred(State, new Functor1("throw", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 616 CompilerState.assertPred(State, new Functor1("throw", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
571 CompilerState.assertPred(State, new Functor1("abolish", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 617 CompilerState.assertPred(State, new Functor1("abolish", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
572 CompilerState.assertPred(State, new Functor1("retractall", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 618 CompilerState.assertPred(State, new Functor1("retractall", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
619 CompilerState.assertPred(State, new Functor2("set_prolog_flag", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
573 CompilerState.assertPred(State, new Functor1("var", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet")); 620 CompilerState.assertPred(State, new Functor1("var", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
574 CompilerState.assertPred(State, new Functor1("nonvar", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet")); 621 CompilerState.assertPred(State, new Functor1("nonvar", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
575 CompilerState.assertPred(State, new Functor1("atom", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet")); 622 CompilerState.assertPred(State, new Functor1("atom", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
@@ -2121,7 +2168,7 @@ namespace Temporary {
2121 { 2168 {
2122 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))) 2169 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)))
2123 { 2170 {
2124 foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL))))) 2171 foreach (bool l4 in YP.univ(A, ListPair.make(new object[] { Name, X1, X2 })))
2125 { 2172 {
2126 foreach (bool l5 in binaryExpressionConditional(Name, FunctionName)) 2173 foreach (bool l5 in binaryExpressionConditional(Name, FunctionName))
2127 { 2174 {
@@ -2236,6 +2283,27 @@ namespace Temporary {
2236 Variable B = new Variable(); 2283 Variable B = new Variable();
2237 Variable ATermCode = new Variable(); 2284 Variable ATermCode = new Variable();
2238 Variable BCode = new Variable(); 2285 Variable BCode = new Variable();
2286 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("current_predicate", A), B)))
2287 {
2288 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.current_predicate"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode), Atom.NIL)))
2289 {
2290 foreach (bool l4 in compileTerm(A, State, ATermCode))
2291 {
2292 foreach (bool l5 in compileRuleBody(B, State, BCode))
2293 {
2294 yield return true;
2295 yield break;
2296 }
2297 }
2298 }
2299 }
2300 }
2301 {
2302 object State = arg2;
2303 Variable A = new Variable();
2304 Variable B = new Variable();
2305 Variable ATermCode = new Variable();
2306 Variable BCode = new Variable();
2239 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("asserta", A), B))) 2307 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("asserta", A), B)))
2240 { 2308 {
2241 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("call", Atom.a("YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode))) 2309 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("call", Atom.a("YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
@@ -2299,7 +2367,7 @@ namespace Temporary {
2299 Variable HandlerAndBCode = new Variable(); 2367 Variable HandlerAndBCode = new Variable();
2300 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("catch", Goal, Catcher, Handler), B))) 2368 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("catch", Goal, Catcher, Handler), B)))
2301 { 2369 {
2302 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3("declare", Atom.a("YP.Catch"), CatchGoal, new Functor2("new", Atom.a("YP.Catch"), new ListPair(new Functor2("call", Atom.a("YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2("foreach", new Functor1("var", CatchGoal), BCode), new ListPair(new Functor2("foreach", new Functor3("callMember", new Functor1("var", CatchGoal), Atom.a("unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL))))) 2370 foreach (bool l3 in YP.unify(arg3, ListPair.make(new object[] { new Functor3("declare", Atom.a("YP.Catch"), CatchGoal, new Functor2("new", Atom.a("YP.Catch"), new ListPair(GoalTermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL)))), new Functor2("foreach", new Functor1("var", CatchGoal), BCode), new Functor2("foreach", new Functor3("callMember", new Functor1("var", CatchGoal), Atom.a("unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode) })))
2303 { 2371 {
2304 foreach (bool l4 in CompilerState.gensym(State, Atom.a("catchGoal"), CatchGoal)) 2372 foreach (bool l4 in CompilerState.gensym(State, Atom.a("catchGoal"), CatchGoal))
2305 { 2373 {
@@ -2833,6 +2901,10 @@ namespace Temporary {
2833 { 2901 {
2834 return true; 2902 return true;
2835 } 2903 }
2904 if (YP.termEqual(Name, Atom.a("current_predicate")))
2905 {
2906 return true;
2907 }
2836 if (YP.termEqual(Name, Atom.a("asserta"))) 2908 if (YP.termEqual(Name, Atom.a("asserta")))
2837 { 2909 {
2838 return true; 2910 return true;
@@ -3016,19 +3088,6 @@ namespace Temporary {
3016 } 3088 }
3017 } 3089 }
3018 { 3090 {
3019 foreach (bool l2 in YP.unify(arg1, Atom.a("current_predicate")))
3020 {
3021 foreach (bool l3 in YP.unify(arg2, 1))
3022 {
3023 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_predicate")))
3024 {
3025 yield return true;
3026 yield break;
3027 }
3028 }
3029 }
3030 }
3031 {
3032 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_length"))) 3091 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_length")))
3033 { 3092 {
3034 foreach (bool l3 in YP.unify(arg2, 2)) 3093 foreach (bool l3 in YP.unify(arg2, 2))
@@ -3214,6 +3273,58 @@ namespace Temporary {
3214 } 3273 }
3215 } 3274 }
3216 { 3275 {
3276 foreach (bool l2 in YP.unify(arg1, Atom.a("see")))
3277 {
3278 foreach (bool l3 in YP.unify(arg2, 1))
3279 {
3280 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.see")))
3281 {
3282 yield return true;
3283 yield break;
3284 }
3285 }
3286 }
3287 }
3288 {
3289 foreach (bool l2 in YP.unify(arg1, Atom.a("seen")))
3290 {
3291 foreach (bool l3 in YP.unify(arg2, 0))
3292 {
3293 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.seen")))
3294 {
3295 yield return true;
3296 yield break;
3297 }
3298 }
3299 }
3300 }
3301 {
3302 foreach (bool l2 in YP.unify(arg1, Atom.a("tell")))
3303 {
3304 foreach (bool l3 in YP.unify(arg2, 1))
3305 {
3306 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.tell")))
3307 {
3308 yield return true;
3309 yield break;
3310 }
3311 }
3312 }
3313 }
3314 {
3315 foreach (bool l2 in YP.unify(arg1, Atom.a("told")))
3316 {
3317 foreach (bool l3 in YP.unify(arg2, 0))
3318 {
3319 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.told")))
3320 {
3321 yield return true;
3322 yield break;
3323 }
3324 }
3325 }
3326 }
3327 {
3217 foreach (bool l2 in YP.unify(arg1, Atom.a("clause"))) 3328 foreach (bool l2 in YP.unify(arg1, Atom.a("clause")))
3218 { 3329 {
3219 foreach (bool l3 in YP.unify(arg2, 2)) 3330 foreach (bool l3 in YP.unify(arg2, 2))
@@ -3434,6 +3545,110 @@ namespace Temporary {
3434 } 3545 }
3435 } 3546 }
3436 } 3547 }
3548 {
3549 foreach (bool l2 in YP.unify(arg1, Atom.a("current_prolog_flag")))
3550 {
3551 foreach (bool l3 in YP.unify(arg2, 2))
3552 {
3553 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_prolog_flag")))
3554 {
3555 yield return true;
3556 yield break;
3557 }
3558 }
3559 }
3560 }
3561 {
3562 foreach (bool l2 in YP.unify(arg1, Atom.a("set_prolog_flag")))
3563 {
3564 foreach (bool l3 in YP.unify(arg2, 2))
3565 {
3566 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.set_prolog_flag")))
3567 {
3568 yield return true;
3569 yield break;
3570 }
3571 }
3572 }
3573 }
3574 {
3575 foreach (bool l2 in YP.unify(arg1, Atom.a("current_input")))
3576 {
3577 foreach (bool l3 in YP.unify(arg2, 1))
3578 {
3579 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_input")))
3580 {
3581 yield return true;
3582 yield break;
3583 }
3584 }
3585 }
3586 }
3587 {
3588 foreach (bool l2 in YP.unify(arg1, Atom.a("current_output")))
3589 {
3590 foreach (bool l3 in YP.unify(arg2, 1))
3591 {
3592 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_output")))
3593 {
3594 yield return true;
3595 yield break;
3596 }
3597 }
3598 }
3599 }
3600 {
3601 foreach (bool l2 in YP.unify(arg1, Atom.a("read_term")))
3602 {
3603 foreach (bool l3 in YP.unify(arg2, 2))
3604 {
3605 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read_term2")))
3606 {
3607 yield return true;
3608 yield break;
3609 }
3610 }
3611 }
3612 }
3613 {
3614 foreach (bool l2 in YP.unify(arg1, Atom.a("read_term")))
3615 {
3616 foreach (bool l3 in YP.unify(arg2, 3))
3617 {
3618 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read_term3")))
3619 {
3620 yield return true;
3621 yield break;
3622 }
3623 }
3624 }
3625 }
3626 {
3627 foreach (bool l2 in YP.unify(arg1, Atom.a("read")))
3628 {
3629 foreach (bool l3 in YP.unify(arg2, 1))
3630 {
3631 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read1")))
3632 {
3633 yield return true;
3634 yield break;
3635 }
3636 }
3637 }
3638 }
3639 {
3640 foreach (bool l2 in YP.unify(arg1, Atom.a("read")))
3641 {
3642 foreach (bool l3 in YP.unify(arg2, 2))
3643 {
3644 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read2")))
3645 {
3646 yield return true;
3647 yield break;
3648 }
3649 }
3650 }
3651 }
3437 } 3652 }
3438 3653
3439 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3) 3654 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
@@ -3494,6 +3709,34 @@ namespace Temporary {
3494 object State = arg2; 3709 object State = arg2;
3495 Variable First = new Variable(); 3710 Variable First = new Variable();
3496 Variable Rest = new Variable(); 3711 Variable Rest = new Variable();
3712 Variable CompiledList = new Variable();
3713 Variable x5 = new Variable();
3714 Variable Rest2 = new Variable();
3715 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3716 {
3717 foreach (bool l3 in YP.unify(arg3, new Functor2("call", Atom.a("ListPair.make"), new ListPair(new Functor1("objectArray", CompiledList), Atom.NIL))))
3718 {
3719 if (YP.nonvar(Rest))
3720 {
3721 foreach (bool l5 in YP.unify(Rest, new ListPair(x5, Rest2)))
3722 {
3723 if (YP.termNotEqual(Rest2, Atom.NIL))
3724 {
3725 foreach (bool l7 in maplist_compileTerm(new ListPair(First, Rest), State, CompiledList))
3726 {
3727 yield return true;
3728 yield break;
3729 }
3730 }
3731 }
3732 }
3733 }
3734 }
3735 }
3736 {
3737 object State = arg2;
3738 Variable First = new Variable();
3739 Variable Rest = new Variable();
3497 Variable Arg1 = new Variable(); 3740 Variable Arg1 = new Variable();
3498 Variable Arg2 = new Variable(); 3741 Variable Arg2 = new Variable();
3499 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 3742 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
@@ -3563,7 +3806,7 @@ namespace Temporary {
3563 { 3806 {
3564 foreach (bool l8 in compileTerm(X2, State, Arg2)) 3807 foreach (bool l8 in compileTerm(X2, State, Arg2))
3565 { 3808 {
3566 foreach (bool l9 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) 3809 foreach (bool l9 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), ListPair.make(new object[] { NameCode, Arg1, Arg2 }))))
3567 { 3810 {
3568 yield return true; 3811 yield return true;
3569 yield break; 3812 yield break;
@@ -3572,7 +3815,7 @@ namespace Temporary {
3572 } 3815 }
3573 goto cutIf5; 3816 goto cutIf5;
3574 } 3817 }
3575 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) 3818 foreach (bool l6 in YP.unify(TermArgs, ListPair.make(new object[] { X1, X2, X3 })))
3576 { 3819 {
3577 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3820 foreach (bool l7 in compileTerm(X1, State, Arg1))
3578 { 3821 {
@@ -3580,7 +3823,7 @@ namespace Temporary {
3580 { 3823 {
3581 foreach (bool l9 in compileTerm(X3, State, Arg3)) 3824 foreach (bool l9 in compileTerm(X3, State, Arg3))
3582 { 3825 {
3583 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))))))) 3826 foreach (bool l10 in YP.unify(Result, new Functor2("new", Atom.a("Functor3"), ListPair.make(new object[] { NameCode, Arg1, Arg2, Arg3 }))))
3584 { 3827 {
3585 yield return true; 3828 yield return true;
3586 yield break; 3829 yield break;
@@ -3623,7 +3866,7 @@ namespace Temporary {
3623 { 3866 {
3624 foreach (bool l7 in compileTerm(X2, State, Arg2)) 3867 foreach (bool l7 in compileTerm(X2, State, Arg2))
3625 { 3868 {
3626 foreach (bool l8 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) 3869 foreach (bool l8 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), ListPair.make(new object[] { NameCode, Arg1, Arg2 }))))
3627 { 3870 {
3628 yield return true; 3871 yield return true;
3629 yield break; 3872 yield break;
@@ -3632,7 +3875,7 @@ namespace Temporary {
3632 } 3875 }
3633 goto cutIf7; 3876 goto cutIf7;
3634 } 3877 }
3635 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) 3878 foreach (bool l5 in YP.unify(TermArgs, ListPair.make(new object[] { X1, X2, X3 })))
3636 { 3879 {
3637 foreach (bool l6 in compileTerm(X1, State, Arg1)) 3880 foreach (bool l6 in compileTerm(X1, State, Arg1))
3638 { 3881 {
@@ -3640,7 +3883,7 @@ namespace Temporary {
3640 { 3883 {
3641 foreach (bool l8 in compileTerm(X3, State, Arg3)) 3884 foreach (bool l8 in compileTerm(X3, State, Arg3))
3642 { 3885 {
3643 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))))))) 3886 foreach (bool l9 in YP.unify(Result, new Functor2("new", Atom.a("Functor3"), ListPair.make(new object[] { NameCode, Arg1, Arg2, Arg3 }))))
3644 { 3887 {
3645 yield return true; 3888 yield return true;
3646 yield break; 3889 yield break;
@@ -3725,9 +3968,11 @@ namespace Temporary {
3725 { 3968 {
3726 foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults))) 3969 foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
3727 { 3970 {
3728 foreach (bool l4 in compileTerm(First, State, FirstResult)) 3971 if (YP.nonvar(Rest))
3972 {
3973 foreach (bool l5 in compileTerm(First, State, FirstResult))
3729 { 3974 {
3730 foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults)) 3975 foreach (bool l6 in maplist_compileTerm(Rest, State, RestResults))
3731 { 3976 {
3732 yield return true; 3977 yield return true;
3733 yield break; 3978 yield break;
@@ -3737,6 +3982,7 @@ namespace Temporary {
3737 } 3982 }
3738 } 3983 }
3739 } 3984 }
3985 }
3740 3986
3741 public static IEnumerable<bool> compileExpression(object Term, object State, object Result) 3987 public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
3742 { 3988 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs
index c2bb0b7..4a4e052 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/BagofAnswers.cs
@@ -113,6 +113,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
113 } 113 }
114 } 114 }
115 115
116 // disable warning on l1, don't see how we can
117 // code this differently
118 #pragma warning disable 0168
119
116 /// <summary> 120 /// <summary>
117 /// For each result, unify the _freeVariables and unify bagArrayVariable with the associated bag. 121 /// For each result, unify the _freeVariables and unify bagArrayVariable with the associated bag.
118 /// </summary> 122 /// </summary>
@@ -127,27 +131,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
127 // No unbound free variables, so we only filled one bag. If empty, bagof fails. 131 // No unbound free variables, so we only filled one bag. If empty, bagof fails.
128 if (_findallBagArray.Count > 0) 132 if (_findallBagArray.Count > 0)
129 { 133 {
130// disable warning: don't see how we can code this differently short
131// of rewriting the whole thing
132#pragma warning disable 0168
133 foreach (bool l1 in bagArrayVariable.unify(_findallBagArray)) 134 foreach (bool l1 in bagArrayVariable.unify(_findallBagArray))
134 yield return false; 135 yield return false;
135#pragma warning restore 0168
136 } 136 }
137 } 137 }
138 else 138 else
139 { 139 {
140 foreach (KeyValuePair<object[], List<object>> valuesAndBag in _bagForFreeVariables) 140 foreach (KeyValuePair<object[], List<object>> valuesAndBag in _bagForFreeVariables)
141 { 141 {
142// disable warning: don't see how we can code this differently short
143// of rewriting the whole thing
144#pragma warning disable 0168
145 foreach (bool l1 in YP.unifyArrays(_freeVariables, valuesAndBag.Key)) 142 foreach (bool l1 in YP.unifyArrays(_freeVariables, valuesAndBag.Key))
146 { 143 {
147 foreach (bool l2 in bagArrayVariable.unify(valuesAndBag.Value)) 144 foreach (bool l2 in bagArrayVariable.unify(valuesAndBag.Value))
148 yield return false; 145 yield return false;
149 } 146 }
150#pragma warning restore 0168
151 // Debug: Should we free memory of the answers already returned? 147 // Debug: Should we free memory of the answers already returned?
152 } 148 }
153 } 149 }
@@ -161,15 +157,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
161 public IEnumerable<bool> result(object Bag) 157 public IEnumerable<bool> result(object Bag)
162 { 158 {
163 Variable bagArrayVariable = new Variable(); 159 Variable bagArrayVariable = new Variable();
164// disable warning: don't see how we can code this differently short
165// of rewriting the whole thing
166#pragma warning disable 0168
167 foreach (bool l1 in resultArray(bagArrayVariable)) 160 foreach (bool l1 in resultArray(bagArrayVariable))
168 { 161 {
169 foreach (bool l2 in YP.unify(Bag, ListPair.make((List<object>)bagArrayVariable.getValue()))) 162 foreach (bool l2 in YP.unify(Bag, ListPair.make((List<object>)bagArrayVariable.getValue())))
170 yield return false; 163 yield return false;
171 } 164 }
172#pragma warning restore 0168
173 } 165 }
174 166
175 /// <summary> 167 /// <summary>
@@ -181,9 +173,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
181 public IEnumerable<bool> resultSet(object Bag) 173 public IEnumerable<bool> resultSet(object Bag)
182 { 174 {
183 Variable bagArrayVariable = new Variable(); 175 Variable bagArrayVariable = new Variable();
184// disable warning: don't see how we can code this differently short
185// of rewriting the whole thing
186#pragma warning disable 0168
187 foreach (bool l1 in resultArray(bagArrayVariable)) 176 foreach (bool l1 in resultArray(bagArrayVariable))
188 { 177 {
189 List<object> bagArray = (List<object>)bagArrayVariable.getValue(); 178 List<object> bagArray = (List<object>)bagArrayVariable.getValue();
@@ -191,19 +180,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
191 foreach (bool l2 in YP.unify(Bag, ListPair.makeWithoutRepeatedTerms(bagArray))) 180 foreach (bool l2 in YP.unify(Bag, ListPair.makeWithoutRepeatedTerms(bagArray)))
192 yield return false; 181 yield return false;
193 } 182 }
194#pragma warning restore 0168
195 } 183 }
196 184
197 public static IEnumerable<bool> bagofArray 185 public static IEnumerable<bool> bagofArray
198 (object Template, object Goal, IEnumerable<bool> goalIterator, Variable bagArrayVariable) 186 (object Template, object Goal, IEnumerable<bool> goalIterator, Variable bagArrayVariable)
199 { 187 {
200 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); 188 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
201// disable warning: don't see how we can code this differently short
202// of rewriting the whole thing
203#pragma warning disable 0168
204 foreach (bool l1 in goalIterator) 189 foreach (bool l1 in goalIterator)
205 bagOfAnswers.add(); 190 bagOfAnswers.add();
206#pragma warning restore 0168
207 return bagOfAnswers.resultArray(bagArrayVariable); 191 return bagOfAnswers.resultArray(bagArrayVariable);
208 } 192 }
209 193
@@ -211,12 +195,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
211 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag) 195 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag)
212 { 196 {
213 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); 197 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
214// disable warning: don't see how we can code this differently short
215// of rewriting the whole thing
216#pragma warning disable 0168
217 foreach (bool l1 in goalIterator) 198 foreach (bool l1 in goalIterator)
218 bagOfAnswers.add(); 199 bagOfAnswers.add();
219#pragma warning restore 0168
220 return bagOfAnswers.result(Bag); 200 return bagOfAnswers.result(Bag);
221 } 201 }
222 202
@@ -224,14 +204,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
224 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag) 204 (object Template, object Goal, IEnumerable<bool> goalIterator, object Bag)
225 { 205 {
226 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal); 206 BagofAnswers bagOfAnswers = new BagofAnswers(Template, Goal);
227// disable warning: don't see how we can code this differently short
228// of rewriting the whole thing
229#pragma warning disable 0168
230 foreach (bool l1 in goalIterator) 207 foreach (bool l1 in goalIterator)
231 bagOfAnswers.add(); 208 bagOfAnswers.add();
232#pragma warning restore 0168
233 return bagOfAnswers.resultSet(Bag); 209 return bagOfAnswers.resultSet(Bag);
234 } 210 }
211 #pragma warning restore 0168
235 212
236 /// <summary> 213 /// <summary>
237 /// A TermArrayEqualityComparer implements IEqualityComparer to compare two object arrays using YP.termEqual. 214 /// A TermArrayEqualityComparer implements IEqualityComparer to compare two object arrays using YP.termEqual.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
index fbb173e..f175494 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
@@ -71,6 +71,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
71 return YP.unify(Bag, result); 71 return YP.unify(Bag, result);
72 } 72 }
73 73
74 // disable warning on l1, don't see how we can
75 // code this differently
76 #pragma warning disable 0168
77
74 /// <summary> 78 /// <summary>
75 /// This is a simplified findall when the goal is a single call. 79 /// This is a simplified findall when the goal is a single call.
76 /// </summary> 80 /// </summary>
@@ -81,12 +85,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
81 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag) 85 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag)
82 { 86 {
83 FindallAnswers findallAnswers = new FindallAnswers(Template); 87 FindallAnswers findallAnswers = new FindallAnswers(Template);
84 // disable warning on l1, don't see how we can
85 // code this differently
86 #pragma warning disable 0168
87 foreach (bool l1 in goal) 88 foreach (bool l1 in goal)
88 findallAnswers.add(); 89 findallAnswers.add();
89 #pragma warning restore 0168
90 return findallAnswers.result(Bag); 90 return findallAnswers.result(Bag);
91 } 91 }
92 92
@@ -99,13 +99,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
99 public static List<object> findallArray(object Template, IEnumerable<bool> goal) 99 public static List<object> findallArray(object Template, IEnumerable<bool> goal)
100 { 100 {
101 FindallAnswers findallAnswers = new FindallAnswers(Template); 101 FindallAnswers findallAnswers = new FindallAnswers(Template);
102 // disable warning on l1, don't see how we can
103 // code this differently
104 #pragma warning disable 0168
105 foreach (bool l1 in goal) 102 foreach (bool l1 in goal)
106 findallAnswers.add(); 103 findallAnswers.add();
107 #pragma warning restore 0168
108 return findallAnswers.resultArray(); 104 return findallAnswers.resultArray();
109 } 105 }
106 #pragma warning restore 0168
110 } 107 }
111} 108}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs
index 8ef8de0..4d65f5b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor.cs
@@ -98,6 +98,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
98 return make(Atom.a(name), args); 98 return make(Atom.a(name), args);
99 } 99 }
100 100
101 /// <summary>
102 /// If arg is another Functor, then succeed (yield once) if this and arg have the
103 /// same name and all functor args unify, otherwise fail (don't yield).
104 /// If arg is a Variable, then call its unify to unify with this.
105 /// Otherwise fail (don't yield).
106 /// </summary>
107 /// <param name="arg"></param>
108 /// <returns></returns>
101 public IEnumerable<bool> unify(object arg) 109 public IEnumerable<bool> unify(object arg)
102 { 110 {
103 arg = YP.getValue(arg); 111 arg = YP.getValue(arg);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs
index 69fbeee..351114d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor1.cs
@@ -49,6 +49,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
49 { 49 {
50 } 50 }
51 51
52 // disable warning on l1, don't see how we can
53 // code this differently
54 #pragma warning disable 0168
55 /// <summary>
56 /// If arg is another Functor1, then succeed (yield once) if this and arg have the
57 /// same name and the functor args unify, otherwise fail (don't yield).
58 /// If arg is a Variable, then call its unify to unify with this.
59 /// Otherwise fail (don't yield).
60 /// </summary>
61 /// <param name="arg"></param>
62 /// <returns></returns>
52 public IEnumerable<bool> unify(object arg) 63 public IEnumerable<bool> unify(object arg)
53 { 64 {
54 arg = YP.getValue(arg); 65 arg = YP.getValue(arg);
@@ -57,25 +68,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
57 Functor1 argFunctor = (Functor1)arg; 68 Functor1 argFunctor = (Functor1)arg;
58 if (_name.Equals(argFunctor._name)) 69 if (_name.Equals(argFunctor._name))
59 { 70 {
60 // disable warning on l1, don't see how we can
61 // code this differently
62 #pragma warning disable 0168
63 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) 71 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
64 yield return false; 72 yield return false;
65 #pragma warning restore 0168
66 } 73 }
67 } 74 }
68 else if (arg is Variable) 75 else if (arg is Variable)
69 { 76 {
70 // disable warning on l1, don't see how we can
71 // code this differently
72 #pragma warning disable 0168
73 foreach (bool l1 in ((Variable)arg).unify(this)) 77 foreach (bool l1 in ((Variable)arg).unify(this))
74 yield return false; 78 yield return false;
75 #pragma warning restore 0168
76
77 } 79 }
78 } 80 }
81 #pragma warning restore 0168
82
79 83
80 public override string ToString() 84 public override string ToString()
81 { 85 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs
index 4ae325e..6817d11 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor2.cs
@@ -51,6 +51,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
51 { 51 {
52 } 52 }
53 53
54 // disable warning on l1, don't see how we can
55 // code this differently
56 #pragma warning disable 0168
57 /// If arg is another Functor2, then succeed (yield once) if this and arg have the
58 /// same name and all functor args unify, otherwise fail (don't yield).
59 /// If arg is a Variable, then call its unify to unify with this.
60 /// Otherwise fail (don't yield).
54 public IEnumerable<bool> unify(object arg) 61 public IEnumerable<bool> unify(object arg)
55 { 62 {
56 arg = YP.getValue(arg); 63 arg = YP.getValue(arg);
@@ -59,27 +66,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
59 Functor2 argFunctor = (Functor2)arg; 66 Functor2 argFunctor = (Functor2)arg;
60 if (_name.Equals(argFunctor._name)) 67 if (_name.Equals(argFunctor._name))
61 { 68 {
62// disable warning: don't see how we can code this differently short
63// of rewriting the whole thing
64#pragma warning disable 0168
65 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) 69 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
66 { 70 {
67 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) 71 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2))
68 yield return false; 72 yield return false;
69 } 73 }
70#pragma warning restore 0168
71 } 74 }
72 } 75 }
73 else if (arg is Variable) 76 else if (arg is Variable)
74 { 77 {
75// disable warning: don't see how we can code this differently short
76// of rewriting the whole thing
77#pragma warning disable 0168
78 foreach (bool l1 in ((Variable)arg).unify(this)) 78 foreach (bool l1 in ((Variable)arg).unify(this))
79 yield return false; 79 yield return false;
80#pragma warning restore 0168
81 } 80 }
82 } 81 }
82 #pragma warning restore 0168
83
83 84
84 public override string ToString() 85 public override string ToString()
85 { 86 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs
index 907bfca..b237a82 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Functor3.cs
@@ -53,6 +53,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
53 { 53 {
54 } 54 }
55 55
56 // disable warning on l1, don't see how we can
57 // code this differently
58 #pragma warning disable 0168
59 /// If arg is another Functor3, then succeed (yield once) if this and arg have the
60 /// same name and all functor args unify, otherwise fail (don't yield).
61 /// If arg is a Variable, then call its unify to unify with this.
62 /// Otherwise fail (don't yield).
56 public IEnumerable<bool> unify(object arg) 63 public IEnumerable<bool> unify(object arg)
57 { 64 {
58 arg = YP.getValue(arg); 65 arg = YP.getValue(arg);
@@ -61,9 +68,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
61 Functor3 argFunctor = (Functor3)arg; 68 Functor3 argFunctor = (Functor3)arg;
62 if (_name.Equals(argFunctor._name)) 69 if (_name.Equals(argFunctor._name))
63 { 70 {
64// disable warning: don't see how we can code this differently short
65// of rewriting the whole thing
66#pragma warning disable 0168
67 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) 71 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
68 { 72 {
69 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) 73 foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2))
@@ -72,19 +76,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
72 yield return false; 76 yield return false;
73 } 77 }
74 } 78 }
75#pragma warning restore 0168
76 } 79 }
77 } 80 }
78 else if (arg is Variable) 81 else if (arg is Variable)
79 { 82 {
80// disable warning: don't see how we can code this differently short
81// of rewriting the whole thing
82#pragma warning disable 0168
83 foreach (bool l1 in ((Variable)arg).unify(this)) 83 foreach (bool l1 in ((Variable)arg).unify(this))
84 yield return false; 84 yield return false;
85#pragma warning restore 0168
86 } 85 }
87 } 86 }
87 #pragma warning restore 0168
88 88
89 public override string ToString() 89 public override string ToString()
90 { 90 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
index 7d41945..681b2f2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs
@@ -270,8 +270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
270 throw new PrologException("instantiation_error", "Head is an unbound variable"); 270 throw new PrologException("instantiation_error", "Head is an unbound variable");
271 object[] arguments = YP.getFunctorArgs(Head); 271 object[] arguments = YP.getFunctorArgs(Head);
272 272
273 // We always match Head from _allAnswers, and the Body is 273 // We always match Head from _allAnswers, and the Body is Atom.a("true").
274 // Atom.a("true").
275 #pragma warning disable 0168 274 #pragma warning disable 0168
276 foreach (bool l1 in YP.unify(Body, Atom.a("true"))) 275 foreach (bool l1 in YP.unify(Body, Atom.a("true")))
277 { 276 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
index 83ace2d..daac0ba 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
@@ -132,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
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 /// If the list or one of the tails of the list is Variable, raise an instantiation_error.
135 /// This does not call YP.getValue on each element. 136 /// This does not call YP.getValue on each element.
136 /// </summary> 137 /// </summary>
137 /// <param name="list"></param> 138 /// <param name="list"></param>
@@ -143,10 +144,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
143 return new object[0]; 144 return new object[0];
144 145
145 List<object> result = new List<object>(); 146 List<object> result = new List<object>();
146 for (object element = list; 147 object element = list;
147 element is Functor2 && ((Functor2)element)._name == Atom.DOT; 148 while (true) {
148 element = YP.getValue(((Functor2)element)._arg2)) 149 if (element == Atom.NIL)
150 break;
151 if (element is Variable)
152 throw new PrologException(Atom.a("instantiation_error"),
153 "List tail is an unbound variable");
154 if (!(element is Functor2 && ((Functor2)element)._name == Atom.DOT))
155 // Not a proper list.
156 return null;
149 result.Add(((Functor2)element)._arg1); 157 result.Add(((Functor2)element)._arg1);
158 element = YP.getValue(((Functor2)element)._arg2);
159 }
150 160
151 if (result.Count <= 0) 161 if (result.Count <= 0)
152 return null; 162 return null;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
index 3a15449..34010e7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Parser.cs
@@ -31,10 +31,86 @@
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33 33
34 // disable warning on l1, don't see how we can
35 // code this differently
36 #pragma warning disable 0168, 0219, 0162
37
34namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog 38namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
35{ 39{
36 public class Parser 40 public class Parser
37 { 41 {
42 public static IEnumerable<bool> read_term2(object Term, object Options)
43 {
44 Variable Answer = new Variable();
45 Variable Variables = new Variable();
46 foreach (bool l1 in read_termOptions(Options, Variables))
47 {
48 foreach (bool l2 in portable_read3(Answer, Variables, new Variable()))
49 {
50 foreach (bool l3 in remove_pos(Answer, Term))
51 yield return false;
52 }
53 }
54 }
55
56 public static IEnumerable<bool> read_term3(object Input, object Term, object Options)
57 {
58 Variable SaveInput = new Variable();
59 Variable Answer = new Variable();
60 Variable Variables = new Variable();
61 foreach (bool l1 in read_termOptions(Options, Variables))
62 {
63 foreach (bool l2 in YP.current_input(SaveInput))
64 {
65 try
66 {
67 YP.see(Input);
68 foreach (bool l3 in portable_read3(Answer, Variables, new Variable()))
69 {
70 foreach (bool l4 in remove_pos(Answer, Term))
71 yield return false;
72 }
73 }
74 finally
75 {
76 YP.see(SaveInput);
77 }
78 }
79 }
80 }
81
82 /// <summary>
83 /// For read_term, check if Options has variable_names(Variables).
84 /// Otherwise, ignore Options.
85 /// </summary>
86 /// <param name="Options"></param>
87 /// <param name="Variables"></param>
88 /// <returns></returns>
89 private static IEnumerable<bool> read_termOptions(object Options, object Variables)
90 {
91 Options = YP.getValue(Options);
92 if (Options is Variable)
93 throw new PrologException(Atom.a("instantiation_error"), "Options is an unbound variable");
94 // First try to match Options = [variable_names(Variables)]
95 foreach (bool l1 in YP.unify(Options, ListPair.make(new Functor1("variable_names", Variables))))
96 {
97 yield return false;
98 yield break;
99 }
100 // Default: Ignore Options.
101 yield return false;
102 }
103
104 public static IEnumerable<bool> read1(object Term)
105 {
106 return read_term2(Term, Atom.NIL);
107 }
108
109 public static IEnumerable<bool> read2(object Input, object Term)
110 {
111 return read_term3(Input, Term, Atom.NIL);
112 }
113
38 public static IEnumerable<bool> formatError(object Output, object Format, object Arguments) 114 public static IEnumerable<bool> formatError(object Output, object Format, object Arguments)
39 { 115 {
40 // Debug: Simple implementation for now. 116 // Debug: Simple implementation for now.
@@ -44,9 +120,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
44 yield return false; 120 yield return false;
45 } 121 }
46 122
47 // disable warning on l1, don't see how we can
48 // code this differently
49 #pragma warning disable 0168, 0219
50 123
51 // Debug: Hand-modify this central predicate to do tail recursion. 124 // Debug: Hand-modify this central predicate to do tail recursion.
52 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3) 125 public static IEnumerable<bool> read_tokens(object arg1, object arg2, object arg3)
@@ -217,7 +290,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
217 Variable Variables = new Variable(); 290 Variable Variables = new Variable();
218 Variable Answer = new Variable(); 291 Variable Answer = new Variable();
219 Variable x4 = new Variable(); 292 Variable x4 = new Variable();
220 foreach (bool l2 in YP.unify(arg1, new Functor2(@"f", Term, Variables))) 293 foreach (bool l2 in YP.unify(arg1, new Functor2("f", Term, Variables)))
221 { 294 {
222 foreach (bool l3 in YP.repeat()) 295 foreach (bool l3 in YP.repeat())
223 { 296 {
@@ -225,14 +298,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
225 { 298 {
226 foreach (bool l5 in remove_pos(Answer, Term)) 299 foreach (bool l5 in remove_pos(Answer, Term))
227 { 300 {
228 if (YP.termEqual(Term, Atom.a(@"end_of_file"))) 301 if (YP.termEqual(Term, Atom.a("end_of_file")))
229 { 302 {
230 yield break; 303 yield break;
231 // goto cutIf1; 304 goto cutIf1;
232 } 305 }
233 yield return false; 306 yield return false;
234 // cutIf1: 307 cutIf1:
235 // { } 308 { }
236 } 309 }
237 } 310 }
238 } 311 }
@@ -267,7 +340,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
267 object X = arg2; 340 object X = arg2;
268 Variable _Pos = new Variable(); 341 Variable _Pos = new Variable();
269 Variable _Name = new Variable(); 342 Variable _Name = new Variable();
270 foreach (bool l2 in YP.unify(arg1, new Functor3(@"$VAR", _Pos, _Name, X))) 343 foreach (bool l2 in YP.unify(arg1, new Functor3("$VAR", _Pos, _Name, X)))
271 { 344 {
272 if (YP.var(X)) 345 if (YP.var(X))
273 { 346 {
@@ -311,9 +384,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
311 Variable B = new Variable(); 384 Variable B = new Variable();
312 Variable NA = new Variable(); 385 Variable NA = new Variable();
313 Variable NB = new Variable(); 386 Variable NB = new Variable();
314 foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B))) 387 foreach (bool l2 in YP.unify(arg1, new Functor2(",", A, B)))
315 { 388 {
316 foreach (bool l3 in YP.unify(arg2, new Functor2(@",", NA, NB))) 389 foreach (bool l3 in YP.unify(arg2, new Functor2(",", NA, NB)))
317 { 390 {
318 foreach (bool l4 in remove_pos(A, NA)) 391 foreach (bool l4 in remove_pos(A, NA))
319 { 392 {
@@ -432,9 +505,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
432 Variable E = new Variable(); 505 Variable E = new Variable();
433 Variable Xs = new Variable(); 506 Variable Xs = new Variable();
434 Variable Zs = new Variable(); 507 Variable Zs = new Variable();
435 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"comment", S, E), Xs))) 508 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("comment", S, E), Xs)))
436 { 509 {
437 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", S, E), Zs))) 510 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("comment", S, E), Zs)))
438 { 511 {
439 foreach (bool l4 in remove_comments(Xs, Ys, Zs)) 512 foreach (bool l4 in remove_comments(Xs, Ys, Zs))
440 { 513 {
@@ -450,11 +523,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
450 Variable Ys = new Variable(); 523 Variable Ys = new Variable();
451 Variable Pos2 = new Variable(); 524 Variable Pos2 = new Variable();
452 Variable Zs = new Variable(); 525 Variable Zs = new Variable();
453 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Xs))) 526 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("["), Pos), Xs)))
454 { 527 {
455 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"["), Ys))) 528 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("["), Ys)))
456 { 529 {
457 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) 530 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
458 { 531 {
459 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) 532 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
460 { 533 {
@@ -474,11 +547,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
474 Variable Ys = new Variable(); 547 Variable Ys = new Variable();
475 Variable Pos2 = new Variable(); 548 Variable Pos2 = new Variable();
476 Variable Zs = new Variable(); 549 Variable Zs = new Variable();
477 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Xs))) 550 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("/", Atom.a("]"), Pos), Xs)))
478 { 551 {
479 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), Ys))) 552 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), Ys)))
480 { 553 {
481 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2(@"list", Pos, Pos2), Zs))) 554 foreach (bool l4 in YP.unify(arg3, new ListPair(new Functor2("list", Pos, Pos2), Zs)))
482 { 555 {
483 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1))) 556 foreach (bool l5 in YP.unify(Pos2, YP.add(Pos, 1)))
484 { 557 {
@@ -523,7 +596,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
523 { 596 {
524 object S0 = arg2; 597 object S0 = arg2;
525 object x3 = arg3; 598 object x3 = arg3;
526 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)) 599 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("or"), Atom.a("operator"), Atom.a("expected") }), S0))
527 { 600 {
528 yield return false; 601 yield return false;
529 } 602 }
@@ -569,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
569 Variable S = new Variable(); 642 Variable S = new Variable();
570 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S))) 643 foreach (bool l2 in YP.unify(arg1, new ListPair(Token, S)))
571 { 644 {
572 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))) 645 foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a("operator"), Atom.a("expected"), Atom.a("after"), Atom.a("expression") }), new ListPair(Token, S)))
573 { 646 {
574 yield return false; 647 yield return false;
575 } 648 }
@@ -585,7 +658,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
585 object x3 = arg4; 658 object x3 = arg4;
586 foreach (bool l2 in YP.unify(arg1, Atom.NIL)) 659 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
587 { 660 {
588 foreach (bool l3 in syntax_error(new ListPair(Atom.a(@"expression"), new ListPair(Atom.a(@"expected"), Atom.NIL)), Atom.NIL)) 661 foreach (bool l3 in syntax_error(new ListPair(Atom.a("expression"), new ListPair(Atom.a("expected"), Atom.NIL)), Atom.NIL))
589 { 662 {
590 yield return false; 663 yield return false;
591 } 664 }
@@ -614,9 +687,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
614 object x2 = arg3; 687 object x2 = arg3;
615 object x3 = arg4; 688 object x3 = arg4;
616 object x4 = arg5; 689 object x4 = arg5;
617 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 690 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
618 { 691 {
619 foreach (bool l3 in cannot_start(Atom.a(@"}"), S0)) 692 foreach (bool l3 in cannot_start(Atom.a("}"), S0))
620 { 693 {
621 yield return false; 694 yield return false;
622 } 695 }
@@ -627,9 +700,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
627 object x2 = arg3; 700 object x2 = arg3;
628 object x3 = arg4; 701 object x3 = arg4;
629 object x4 = arg5; 702 object x4 = arg5;
630 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 703 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
631 { 704 {
632 foreach (bool l3 in cannot_start(Atom.a(@"]"), S0)) 705 foreach (bool l3 in cannot_start(Atom.a("]"), S0))
633 { 706 {
634 yield return false; 707 yield return false;
635 } 708 }
@@ -640,9 +713,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
640 object x2 = arg3; 713 object x2 = arg3;
641 object x3 = arg4; 714 object x3 = arg4;
642 object x4 = arg5; 715 object x4 = arg5;
643 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 716 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
644 { 717 {
645 foreach (bool l3 in cannot_start(Atom.a(@")"), S0)) 718 foreach (bool l3 in cannot_start(Atom.a(")"), S0))
646 { 719 {
647 yield return false; 720 yield return false;
648 } 721 }
@@ -653,9 +726,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
653 object x2 = arg3; 726 object x2 = arg3;
654 object x3 = arg4; 727 object x3 = arg4;
655 object x4 = arg5; 728 object x4 = arg5;
656 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 729 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
657 { 730 {
658 foreach (bool l3 in cannot_start(Atom.a(@","), S0)) 731 foreach (bool l3 in cannot_start(Atom.a(","), S0))
659 { 732 {
660 yield return false; 733 yield return false;
661 } 734 }
@@ -666,9 +739,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
666 object x2 = arg3; 739 object x2 = arg3;
667 object x3 = arg4; 740 object x3 = arg4;
668 object x4 = arg5; 741 object x4 = arg5;
669 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 742 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
670 { 743 {
671 foreach (bool l3 in cannot_start(Atom.a(@"|"), S0)) 744 foreach (bool l3 in cannot_start(Atom.a("|"), S0))
672 { 745 {
673 yield return false; 746 yield return false;
674 } 747 }
@@ -679,22 +752,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
679 object Precedence = arg3; 752 object Precedence = arg3;
680 object Answer = arg4; 753 object Answer = arg4;
681 object S = arg5; 754 object S = arg5;
682 Variable Chars = new Variable(); 755 Variable Codes = new Variable();
683 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", Chars))) 756 Variable Term = new Variable();
757 Variable A = new Variable();
758 foreach (bool l2 in YP.unify(arg1, new Functor1("string", Codes)))
759 {
760 foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("atom")))
761 {
762 foreach (bool l4 in YP.atom_codes(Term, Codes))
763 {
764 foreach (bool l5 in exprtl0(S0, Term, Precedence, Answer, S))
765 {
766 yield return false;
767 }
768 }
769 goto cutIf1;
770 }
771 foreach (bool l3 in YP.current_prolog_flag(Atom.a("double_quotes"), Atom.a("chars")))
772 {
773 foreach (bool l4 in YP.atom_codes(A, Codes))
774 {
775 foreach (bool l5 in YP.atom_chars(A, Term))
684 { 776 {
685 foreach (bool l3 in exprtl0(S0, Chars, Precedence, Answer, S)) 777 foreach (bool l6 in exprtl0(S0, Term, Precedence, Answer, S))
686 { 778 {
687 yield return false; 779 yield return false;
688 } 780 }
689 } 781 }
690 } 782 }
783 goto cutIf2;
784 }
785 foreach (bool l3 in YP.unify(Term, Codes))
786 {
787 foreach (bool l4 in exprtl0(S0, Term, Precedence, Answer, S))
788 {
789 yield return false;
790 }
791 }
792 cutIf2:
793 cutIf1:
794 { }
795 }
796 }
691 { 797 {
692 object S0 = arg2; 798 object S0 = arg2;
693 object Precedence = arg3; 799 object Precedence = arg3;
694 object Answer = arg4; 800 object Answer = arg4;
695 object S = arg5; 801 object S = arg5;
696 Variable Number = new Variable(); 802 Variable Number = new Variable();
697 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", Number))) 803 foreach (bool l2 in YP.unify(arg1, new Functor1("number", Number)))
698 { 804 {
699 foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S)) 805 foreach (bool l3 in exprtl0(S0, Number, Precedence, Answer, S))
700 { 806 {
@@ -707,11 +813,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
707 object Answer = arg4; 813 object Answer = arg4;
708 object S = arg5; 814 object S = arg5;
709 Variable S1 = new Variable(); 815 Variable S1 = new Variable();
710 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 816 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
711 { 817 {
712 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"]"), S1))) 818 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("]"), S1)))
713 { 819 {
714 foreach (bool l4 in read_atom(new Functor2(@"/", Atom.NIL, 0), S1, Precedence, Answer, S)) 820 foreach (bool l4 in read_atom(new Functor2("/", Atom.NIL, 0), S1, Precedence, Answer, S))
715 { 821 {
716 yield return false; 822 yield return false;
717 } 823 }
@@ -728,7 +834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
728 Variable S2 = new Variable(); 834 Variable S2 = new Variable();
729 Variable RestArgs = new Variable(); 835 Variable RestArgs = new Variable();
730 Variable S3 = new Variable(); 836 Variable S3 = new Variable();
731 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 837 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
732 { 838 {
733 foreach (bool l3 in parse(S1, 999, Arg1, S2)) 839 foreach (bool l3 in parse(S1, 999, Arg1, S2))
734 { 840 {
@@ -751,11 +857,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
751 Variable Term = new Variable(); 857 Variable Term = new Variable();
752 Variable S2 = new Variable(); 858 Variable S2 = new Variable();
753 Variable S3 = new Variable(); 859 Variable S3 = new Variable();
754 foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) 860 foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
755 { 861 {
756 foreach (bool l3 in parse(S1, 1200, Term, S2)) 862 foreach (bool l3 in parse(S1, 1200, Term, S2))
757 { 863 {
758 foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) 864 foreach (bool l4 in expect(Atom.a(")"), S2, S3))
759 { 865 {
760 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) 866 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
761 { 867 {
@@ -774,11 +880,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
774 Variable Term = new Variable(); 880 Variable Term = new Variable();
775 Variable S2 = new Variable(); 881 Variable S2 = new Variable();
776 Variable S3 = new Variable(); 882 Variable S3 = new Variable();
777 foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) 883 foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
778 { 884 {
779 foreach (bool l3 in parse(S1, 1200, Term, S2)) 885 foreach (bool l3 in parse(S1, 1200, Term, S2))
780 { 886 {
781 foreach (bool l4 in expect(Atom.a(@")"), S2, S3)) 887 foreach (bool l4 in expect(Atom.a(")"), S2, S3))
782 { 888 {
783 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S)) 889 foreach (bool l5 in exprtl0(S3, Term, Precedence, Answer, S))
784 { 890 {
@@ -795,11 +901,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
795 object S = arg5; 901 object S = arg5;
796 Variable _Pos = new Variable(); 902 Variable _Pos = new Variable();
797 Variable S1 = new Variable(); 903 Variable S1 = new Variable();
798 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), _Pos))) 904 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), _Pos)))
799 { 905 {
800 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"}"), S1))) 906 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("}"), S1)))
801 { 907 {
802 foreach (bool l4 in read_atom(Atom.a(@"{}"), S1, Precedence, Answer, S)) 908 foreach (bool l4 in read_atom(Atom.a("{}"), S1, Precedence, Answer, S))
803 { 909 {
804 yield return false; 910 yield return false;
805 } 911 }
@@ -816,13 +922,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
816 Variable Term = new Variable(); 922 Variable Term = new Variable();
817 Variable S2 = new Variable(); 923 Variable S2 = new Variable();
818 Variable S3 = new Variable(); 924 Variable S3 = new Variable();
819 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"{"), Pos))) 925 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("{"), Pos)))
820 { 926 {
821 foreach (bool l3 in parse(S1, 1200, Term, S2)) 927 foreach (bool l3 in parse(S1, 1200, Term, S2))
822 { 928 {
823 foreach (bool l4 in expect(Atom.a(@"}"), S2, S3)) 929 foreach (bool l4 in expect(Atom.a("}"), S2, S3))
824 { 930 {
825 foreach (bool l5 in exprtl0(S3, new Functor2(@"{}", Pos, Term), Precedence, Answer, S)) 931 foreach (bool l5 in exprtl0(S3, new Functor2("{}", Pos, Term), Precedence, Answer, S))
826 { 932 {
827 yield return false; 933 yield return false;
828 } 934 }
@@ -844,15 +950,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
844 Variable RestArgs = new Variable(); 950 Variable RestArgs = new Variable();
845 Variable S3 = new Variable(); 951 Variable S3 = new Variable();
846 Variable Term = new Variable(); 952 Variable Term = new Variable();
847 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) 953 foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
848 { 954 {
849 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) 955 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
850 { 956 {
851 foreach (bool l4 in parse(S1, 999, Arg1, S2)) 957 foreach (bool l4 in parse(S1, 999, Arg1, S2))
852 { 958 {
853 foreach (bool l5 in read_args(S2, RestArgs, S3)) 959 foreach (bool l5 in read_args(S2, RestArgs, S3))
854 { 960 {
855 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))))) 961 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)))))
856 { 962 {
857 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S)) 963 foreach (bool l7 in exprtl0(S3, Term, Precedence, Answer, S))
858 { 964 {
@@ -874,9 +980,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
874 Variable Variable_1 = new Variable(); 980 Variable Variable_1 = new Variable();
875 Variable Name = new Variable(); 981 Variable Name = new Variable();
876 Variable Pos = new Variable(); 982 Variable Pos = new Variable();
877 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", Variable_1, Name, Pos))) 983 foreach (bool l2 in YP.unify(arg1, new Functor3("var", Variable_1, Name, Pos)))
878 { 984 {
879 foreach (bool l3 in exprtl0(S0, new Functor3(@"$VAR", Pos, Name, Variable_1), Precedence, Answer, S)) 985 foreach (bool l3 in exprtl0(S0, new Functor3("$VAR", Pos, Name, Variable_1), Precedence, Answer, S))
880 { 986 {
881 yield return false; 987 yield return false;
882 } 988 }
@@ -889,9 +995,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
889 object S = arg5; 995 object S = arg5;
890 Variable Atom_1 = new Variable(); 996 Variable Atom_1 = new Variable();
891 Variable P = new Variable(); 997 Variable P = new Variable();
892 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", Atom_1, P))) 998 foreach (bool l2 in YP.unify(arg1, new Functor2("atom", Atom_1, P)))
893 { 999 {
894 foreach (bool l3 in read_atom(new Functor2(@"/", Atom_1, P), S0, Precedence, Answer, S)) 1000 foreach (bool l3 in read_atom(new Functor2("/", Atom_1, P), S0, Precedence, Answer, S))
895 { 1001 {
896 yield return false; 1002 yield return false;
897 } 1003 }
@@ -906,9 +1012,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
906 Variable Number = new Variable(); 1012 Variable Number = new Variable();
907 Variable S1 = new Variable(); 1013 Variable S1 = new Variable();
908 Variable Negative = new Variable(); 1014 Variable Negative = new Variable();
909 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom.a(@"-"), _Pos))) 1015 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom.a("-"), _Pos)))
910 { 1016 {
911 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"number", Number), S1))) 1017 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1("number", Number), S1)))
912 { 1018 {
913 foreach (bool l4 in YP.unify(Negative, YP.negate(Number))) 1019 foreach (bool l4 in YP.unify(Negative, YP.negate(Number)))
914 { 1020 {
@@ -930,9 +1036,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
930 Variable RestArgs = new Variable(); 1036 Variable RestArgs = new Variable();
931 Variable S3 = new Variable(); 1037 Variable S3 = new Variable();
932 Variable Term = new Variable(); 1038 Variable Term = new Variable();
933 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Functor_1, Pos))) 1039 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Functor_1, Pos)))
934 { 1040 {
935 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a(@"("), S1))) 1041 foreach (bool l3 in YP.unify(arg2, new ListPair(Atom.a("("), S1)))
936 { 1042 {
937 foreach (bool l4 in parse(S1, 999, Arg1, S2)) 1043 foreach (bool l4 in parse(S1, 999, Arg1, S2))
938 { 1044 {
@@ -962,7 +1068,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
962 Variable Term = new Variable(); 1068 Variable Term = new Variable();
963 Variable Arg = new Variable(); 1069 Variable Arg = new Variable();
964 Variable S1 = new Variable(); 1070 Variable S1 = new Variable();
965 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Op, Pos))) 1071 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Op, Pos)))
966 { 1072 {
967 foreach (bool l3 in prefixop(Op, Oprec, Aprec)) 1073 foreach (bool l3 in prefixop(Op, Oprec, Aprec))
968 { 1074 {
@@ -981,7 +1087,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
981 } 1087 }
982 if (YP.greaterThan(Oprec, Precedence)) 1088 if (YP.greaterThan(Oprec, Precedence))
983 { 1089 {
984 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)) 1090 foreach (bool l6 in syntax_error(ListPair.make(new object[] { Atom.a("prefix"), Atom.a("operator"), Op, Atom.a("in"), Atom.a("context"), Atom.a("with"), Atom.a("precedence"), Precedence }), S0))
985 { 1091 {
986 yield return false; 1092 yield return false;
987 } 1093 }
@@ -991,7 +1097,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
991 { 1097 {
992 foreach (bool l6 in parse(S0, Aprec, Arg, S1)) 1098 foreach (bool l6 in parse(S0, Aprec, Arg, S1))
993 { 1099 {
994 foreach (bool l7 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) 1100 foreach (bool l7 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
995 { 1101 {
996 foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) 1102 foreach (bool l8 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
997 { 1103 {
@@ -1006,7 +1112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1006 { 1112 {
1007 foreach (bool l6 in prefix_is_atom(S1, Oprec)) 1113 foreach (bool l6 in prefix_is_atom(S1, Oprec))
1008 { 1114 {
1009 foreach (bool l7 in exprtl(S1, Oprec, new Functor2(@"/", Op, Pos), Precedence, Answer, S)) 1115 foreach (bool l7 in exprtl(S1, Oprec, new Functor2("/", Op, Pos), Precedence, Answer, S))
1010 { 1116 {
1011 yield return false; 1117 yield return false;
1012 } 1118 }
@@ -1014,7 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1014 } 1120 }
1015 foreach (bool l5 in parse(S0, Aprec, Arg, S1)) 1121 foreach (bool l5 in parse(S0, Aprec, Arg, S1))
1016 { 1122 {
1017 foreach (bool l6 in YP.univ(Term, new ListPair(Op, new ListPair(Pos, new ListPair(Arg, Atom.NIL))))) 1123 foreach (bool l6 in YP.univ(Term, ListPair.make(new object[] { Op, Pos, Arg })))
1018 { 1124 {
1019 foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S)) 1125 foreach (bool l7 in exprtl(S1, Oprec, Term, Precedence, Answer, S))
1020 { 1126 {
@@ -1037,7 +1143,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1037 Variable Atom_1 = new Variable(); 1143 Variable Atom_1 = new Variable();
1038 Variable Pos = new Variable(); 1144 Variable Pos = new Variable();
1039 Variable Term = new Variable(); 1145 Variable Term = new Variable();
1040 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", Atom_1, Pos))) 1146 foreach (bool l2 in YP.unify(arg1, new Functor2("/", Atom_1, Pos)))
1041 { 1147 {
1042 foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL)))) 1148 foreach (bool l3 in YP.univ(Term, new ListPair(Atom_1, new ListPair(Pos, Atom.NIL))))
1043 { 1149 {
@@ -1053,7 +1159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1053 public static IEnumerable<bool> cannot_start(object Token, object S0) 1159 public static IEnumerable<bool> cannot_start(object Token, object S0)
1054 { 1160 {
1055 { 1161 {
1056 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)) 1162 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Token, Atom.a("cannot"), Atom.a("start"), Atom.a("an"), Atom.a("expression") }), S0))
1057 { 1163 {
1058 yield return false; 1164 yield return false;
1059 } 1165 }
@@ -1068,7 +1174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1068 Variable Term = new Variable(); 1174 Variable Term = new Variable();
1069 Variable Rest = new Variable(); 1175 Variable Rest = new Variable();
1070 Variable S2 = new Variable(); 1176 Variable S2 = new Variable();
1071 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@","), S1))) 1177 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(","), S1)))
1072 { 1178 {
1073 foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest))) 1179 foreach (bool l3 in YP.unify(arg2, new ListPair(Term, Rest)))
1074 { 1180 {
@@ -1086,7 +1192,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1086 } 1192 }
1087 { 1193 {
1088 object S = arg3; 1194 object S = arg3;
1089 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@")"), S))) 1195 foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(")"), S)))
1090 { 1196 {
1091 foreach (bool l3 in YP.unify(arg2, Atom.NIL)) 1197 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
1092 { 1198 {
@@ -1099,7 +1205,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1099 object S = arg1; 1205 object S = arg1;
1100 object x2 = arg2; 1206 object x2 = arg2;
1101 object x3 = arg3; 1207 object x3 = arg3;
1102 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)) 1208 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Atom.a(", or )"), Atom.a("expected"), Atom.a("in"), Atom.a("arguments") }), S))
1103 { 1209 {
1104 yield return false; 1210 yield return false;
1105 } 1211 }
@@ -1113,7 +1219,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1113 object x2 = arg3; 1219 object x2 = arg3;
1114 foreach (bool l2 in YP.unify(arg1, Atom.NIL)) 1220 foreach (bool l2 in YP.unify(arg1, Atom.NIL))
1115 { 1221 {
1116 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)) 1222 foreach (bool l3 in syntax_error(ListPair.make(new object[] { Atom.a(", | or ]"), Atom.a("expected"), Atom.a("in"), Atom.a("list") }), Atom.NIL))
1117 { 1223 {
1118 yield return false; 1224 yield return false;
1119 } 1225 }
@@ -1142,7 +1248,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1142 Variable Term = new Variable(); 1248 Variable Term = new Variable();
1143 Variable Rest = new Variable(); 1249 Variable Rest = new Variable();
1144 Variable S2 = new Variable(); 1250 Variable S2 = new Variable();
1145 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1251 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1146 { 1252 {
1147 foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest))) 1253 foreach (bool l3 in YP.unify(arg3, new ListPair(Term, Rest)))
1148 { 1254 {
@@ -1163,11 +1269,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1163 object Rest = arg3; 1269 object Rest = arg3;
1164 object S = arg4; 1270 object S = arg4;
1165 Variable S2 = new Variable(); 1271 Variable S2 = new Variable();
1166 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1272 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1167 { 1273 {
1168 foreach (bool l3 in parse(S1, 999, Rest, S2)) 1274 foreach (bool l3 in parse(S1, 999, Rest, S2))
1169 { 1275 {
1170 foreach (bool l4 in expect(Atom.a(@"]"), S2, S)) 1276 foreach (bool l4 in expect(Atom.a("]"), S2, S))
1171 { 1277 {
1172 yield return false; 1278 yield return false;
1173 } 1279 }
@@ -1178,7 +1284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1178 } 1284 }
1179 { 1285 {
1180 Variable S1 = new Variable(); 1286 Variable S1 = new Variable();
1181 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1287 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1182 { 1288 {
1183 foreach (bool l3 in YP.unify(arg2, S1)) 1289 foreach (bool l3 in YP.unify(arg2, S1))
1184 { 1290 {
@@ -1198,7 +1304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1198 object S1 = arg2; 1304 object S1 = arg2;
1199 object x3 = arg3; 1305 object x3 = arg3;
1200 object x4 = arg4; 1306 object x4 = arg4;
1201 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))) 1307 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Atom.a(", | or ]"), Atom.a("expected"), Atom.a("in"), Atom.a("list") }), new ListPair(Token, S1)))
1202 { 1308 {
1203 yield return false; 1309 yield return false;
1204 } 1310 }
@@ -1237,7 +1343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1237 Variable x1 = new Variable(); 1343 Variable x1 = new Variable();
1238 Variable x2 = new Variable(); 1344 Variable x2 = new Variable();
1239 Variable x3 = new Variable(); 1345 Variable x3 = new Variable();
1240 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", x1, x2, x3))) 1346 foreach (bool l2 in YP.unify(arg1, new Functor3("var", x1, x2, x3)))
1241 { 1347 {
1242 foreach (bool l3 in YP.unify(arg2, 1)) 1348 foreach (bool l3 in YP.unify(arg2, 1))
1243 { 1349 {
@@ -1248,7 +1354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1248 { 1354 {
1249 object x2 = arg3; 1355 object x2 = arg3;
1250 Variable x1 = new Variable(); 1356 Variable x1 = new Variable();
1251 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", x1))) 1357 foreach (bool l2 in YP.unify(arg1, new Functor1("number", x1)))
1252 { 1358 {
1253 foreach (bool l3 in YP.unify(arg2, 1)) 1359 foreach (bool l3 in YP.unify(arg2, 1))
1254 { 1360 {
@@ -1259,7 +1365,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1259 { 1365 {
1260 object x2 = arg3; 1366 object x2 = arg3;
1261 Variable x1 = new Variable(); 1367 Variable x1 = new Variable();
1262 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", x1))) 1368 foreach (bool l2 in YP.unify(arg1, new Functor1("string", x1)))
1263 { 1369 {
1264 foreach (bool l3 in YP.unify(arg2, 1)) 1370 foreach (bool l3 in YP.unify(arg2, 1))
1265 { 1371 {
@@ -1269,7 +1375,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1269 } 1375 }
1270 { 1376 {
1271 object x1 = arg3; 1377 object x1 = arg3;
1272 foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) 1378 foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
1273 { 1379 {
1274 foreach (bool l3 in YP.unify(arg2, 1)) 1380 foreach (bool l3 in YP.unify(arg2, 1))
1275 { 1381 {
@@ -1279,7 +1385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1279 } 1385 }
1280 { 1386 {
1281 object x1 = arg3; 1387 object x1 = arg3;
1282 foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) 1388 foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
1283 { 1389 {
1284 foreach (bool l3 in YP.unify(arg2, 0)) 1390 foreach (bool l3 in YP.unify(arg2, 0))
1285 { 1391 {
@@ -1289,7 +1395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1289 } 1395 }
1290 { 1396 {
1291 object x1 = arg3; 1397 object x1 = arg3;
1292 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 1398 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
1293 { 1399 {
1294 foreach (bool l3 in YP.unify(arg2, -1)) 1400 foreach (bool l3 in YP.unify(arg2, -1))
1295 { 1401 {
@@ -1299,11 +1405,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1299 } 1405 }
1300 { 1406 {
1301 Variable x1 = new Variable(); 1407 Variable x1 = new Variable();
1302 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1408 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1303 { 1409 {
1304 foreach (bool l3 in YP.unify(arg2, 0)) 1410 foreach (bool l3 in YP.unify(arg2, 0))
1305 { 1411 {
1306 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"]"), x1))) 1412 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a("]"), x1)))
1307 { 1413 {
1308 yield return true; 1414 yield return true;
1309 yield break; 1415 yield break;
@@ -1313,7 +1419,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1313 } 1419 }
1314 { 1420 {
1315 object x1 = arg3; 1421 object x1 = arg3;
1316 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1422 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1317 { 1423 {
1318 foreach (bool l3 in YP.unify(arg2, 1)) 1424 foreach (bool l3 in YP.unify(arg2, 1))
1319 { 1425 {
@@ -1323,7 +1429,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1323 } 1429 }
1324 { 1430 {
1325 object x1 = arg3; 1431 object x1 = arg3;
1326 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1432 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1327 { 1433 {
1328 foreach (bool l3 in YP.unify(arg2, -1)) 1434 foreach (bool l3 in YP.unify(arg2, -1))
1329 { 1435 {
@@ -1333,11 +1439,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1333 } 1439 }
1334 { 1440 {
1335 Variable x1 = new Variable(); 1441 Variable x1 = new Variable();
1336 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1442 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1337 { 1443 {
1338 foreach (bool l3 in YP.unify(arg2, 0)) 1444 foreach (bool l3 in YP.unify(arg2, 0))
1339 { 1445 {
1340 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a(@"}"), x1))) 1446 foreach (bool l4 in YP.unify(arg3, new ListPair(Atom.a("}"), x1)))
1341 { 1447 {
1342 yield return true; 1448 yield return true;
1343 yield break; 1449 yield break;
@@ -1347,7 +1453,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1347 } 1453 }
1348 { 1454 {
1349 object x1 = arg3; 1455 object x1 = arg3;
1350 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1456 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1351 { 1457 {
1352 foreach (bool l3 in YP.unify(arg2, 1)) 1458 foreach (bool l3 in YP.unify(arg2, 1))
1353 { 1459 {
@@ -1357,7 +1463,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1357 } 1463 }
1358 { 1464 {
1359 object x1 = arg3; 1465 object x1 = arg3;
1360 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 1466 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
1361 { 1467 {
1362 foreach (bool l3 in YP.unify(arg2, -1)) 1468 foreach (bool l3 in YP.unify(arg2, -1))
1363 { 1469 {
@@ -1367,7 +1473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1367 } 1473 }
1368 { 1474 {
1369 object x1 = arg3; 1475 object x1 = arg3;
1370 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1476 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1371 { 1477 {
1372 foreach (bool l3 in YP.unify(arg2, -1)) 1478 foreach (bool l3 in YP.unify(arg2, -1))
1373 { 1479 {
@@ -1377,7 +1483,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1377 } 1483 }
1378 { 1484 {
1379 object x1 = arg3; 1485 object x1 = arg3;
1380 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1486 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1381 { 1487 {
1382 foreach (bool l3 in YP.unify(arg2, -1)) 1488 foreach (bool l3 in YP.unify(arg2, -1))
1383 { 1489 {
@@ -1389,7 +1495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1389 object x3 = arg3; 1495 object x3 = arg3;
1390 Variable x1 = new Variable(); 1496 Variable x1 = new Variable();
1391 Variable x2 = new Variable(); 1497 Variable x2 = new Variable();
1392 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", x1, x2))) 1498 foreach (bool l2 in YP.unify(arg1, new Functor2("atom", x1, x2)))
1393 { 1499 {
1394 foreach (bool l3 in YP.unify(arg2, 0)) 1500 foreach (bool l3 in YP.unify(arg2, 0))
1395 { 1501 {
@@ -1405,9 +1511,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1405 Variable F = new Variable(); 1511 Variable F = new Variable();
1406 Variable Pos = new Variable(); 1512 Variable Pos = new Variable();
1407 Variable S1 = new Variable(); 1513 Variable S1 = new Variable();
1408 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) 1514 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", F, Pos), new ListPair(Atom.a("("), S1))))
1409 { 1515 {
1410 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2(@"atom", F, Pos), new ListPair(Atom.a(@"("), S1)))) 1516 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor2("atom", F, Pos), new ListPair(Atom.a("("), S1))))
1411 { 1517 {
1412 yield return true; 1518 yield return true;
1413 yield break; 1519 yield break;
@@ -1421,9 +1527,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1421 Variable L = new Variable(); 1527 Variable L = new Variable();
1422 Variable P = new Variable(); 1528 Variable P = new Variable();
1423 Variable R = new Variable(); 1529 Variable R = new Variable();
1424 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) 1530 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", F, Pos), S1)))
1425 { 1531 {
1426 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))) 1532 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)))
1427 { 1533 {
1428 foreach (bool l4 in infixop(F, L, P, R)) 1534 foreach (bool l4 in infixop(F, L, P, R))
1429 { 1535 {
@@ -1438,9 +1544,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1438 Variable S1 = new Variable(); 1544 Variable S1 = new Variable();
1439 Variable L = new Variable(); 1545 Variable L = new Variable();
1440 Variable P = new Variable(); 1546 Variable P = new Variable();
1441 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", F, Pos), S1))) 1547 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", F, Pos), S1)))
1442 { 1548 {
1443 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, P), S1))) 1549 foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor3(Atom.a("postfixop", Atom.a("")), new Functor2("/", F, Pos), L, P), S1)))
1444 { 1550 {
1445 foreach (bool l4 in postfixop(F, L, P)) 1551 foreach (bool l4 in postfixop(F, L, P))
1446 { 1552 {
@@ -1481,7 +1587,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1481 Variable L = new Variable(); 1587 Variable L = new Variable();
1482 Variable x3 = new Variable(); 1588 Variable x3 = new Variable();
1483 Variable x4 = new Variable(); 1589 Variable x4 = new Variable();
1484 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { x1, L, x3, x4 }))) 1590 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a("infixop", Atom.a("")), new object[] { x1, L, x3, x4 })))
1485 { 1591 {
1486 if (YP.greaterThanOrEqual(L, P)) 1592 if (YP.greaterThanOrEqual(L, P))
1487 { 1593 {
@@ -1494,7 +1600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1494 Variable x1 = new Variable(); 1600 Variable x1 = new Variable();
1495 Variable L = new Variable(); 1601 Variable L = new Variable();
1496 Variable x3 = new Variable(); 1602 Variable x3 = new Variable();
1497 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), x1, L, x3))) 1603 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a("postfixop", Atom.a("")), x1, L, x3)))
1498 { 1604 {
1499 if (YP.greaterThanOrEqual(L, P)) 1605 if (YP.greaterThanOrEqual(L, P))
1500 { 1606 {
@@ -1504,28 +1610,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1504 } 1610 }
1505 { 1611 {
1506 object x1 = arg2; 1612 object x1 = arg2;
1507 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 1613 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
1508 { 1614 {
1509 yield return false; 1615 yield return false;
1510 } 1616 }
1511 } 1617 }
1512 { 1618 {
1513 object x1 = arg2; 1619 object x1 = arg2;
1514 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1620 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1515 { 1621 {
1516 yield return false; 1622 yield return false;
1517 } 1623 }
1518 } 1624 }
1519 { 1625 {
1520 object x1 = arg2; 1626 object x1 = arg2;
1521 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 1627 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
1522 { 1628 {
1523 yield return false; 1629 yield return false;
1524 } 1630 }
1525 } 1631 }
1526 { 1632 {
1527 object P = arg2; 1633 object P = arg2;
1528 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1634 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1529 { 1635 {
1530 if (YP.greaterThanOrEqual(1100, P)) 1636 if (YP.greaterThanOrEqual(1100, P))
1531 { 1637 {
@@ -1535,7 +1641,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1535 } 1641 }
1536 { 1642 {
1537 object P = arg2; 1643 object P = arg2;
1538 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1644 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1539 { 1645 {
1540 if (YP.greaterThanOrEqual(1000, P)) 1646 if (YP.greaterThanOrEqual(1000, P))
1541 { 1647 {
@@ -1594,13 +1700,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1594 object x2 = arg3; 1700 object x2 = arg3;
1595 object S1 = arg6; 1701 object S1 = arg6;
1596 Variable Term = new Variable(); 1702 Variable Term = new Variable();
1597 foreach (bool l2 in YP.unify(arg1, Atom.a(@"}"))) 1703 foreach (bool l2 in YP.unify(arg1, Atom.a("}")))
1598 { 1704 {
1599 foreach (bool l3 in YP.unify(arg2, Term)) 1705 foreach (bool l3 in YP.unify(arg2, Term))
1600 { 1706 {
1601 foreach (bool l4 in YP.unify(arg4, Term)) 1707 foreach (bool l4 in YP.unify(arg4, Term))
1602 { 1708 {
1603 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"}"), S1))) 1709 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a("}"), S1)))
1604 { 1710 {
1605 yield return false; 1711 yield return false;
1606 } 1712 }
@@ -1612,13 +1718,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1612 object x2 = arg3; 1718 object x2 = arg3;
1613 object S1 = arg6; 1719 object S1 = arg6;
1614 Variable Term = new Variable(); 1720 Variable Term = new Variable();
1615 foreach (bool l2 in YP.unify(arg1, Atom.a(@"]"))) 1721 foreach (bool l2 in YP.unify(arg1, Atom.a("]")))
1616 { 1722 {
1617 foreach (bool l3 in YP.unify(arg2, Term)) 1723 foreach (bool l3 in YP.unify(arg2, Term))
1618 { 1724 {
1619 foreach (bool l4 in YP.unify(arg4, Term)) 1725 foreach (bool l4 in YP.unify(arg4, Term))
1620 { 1726 {
1621 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@"]"), S1))) 1727 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a("]"), S1)))
1622 { 1728 {
1623 yield return false; 1729 yield return false;
1624 } 1730 }
@@ -1630,13 +1736,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1630 object x2 = arg3; 1736 object x2 = arg3;
1631 object S1 = arg6; 1737 object S1 = arg6;
1632 Variable Term = new Variable(); 1738 Variable Term = new Variable();
1633 foreach (bool l2 in YP.unify(arg1, Atom.a(@")"))) 1739 foreach (bool l2 in YP.unify(arg1, Atom.a(")")))
1634 { 1740 {
1635 foreach (bool l3 in YP.unify(arg2, Term)) 1741 foreach (bool l3 in YP.unify(arg2, Term))
1636 { 1742 {
1637 foreach (bool l4 in YP.unify(arg4, Term)) 1743 foreach (bool l4 in YP.unify(arg4, Term))
1638 { 1744 {
1639 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(@")"), S1))) 1745 foreach (bool l5 in YP.unify(arg5, new ListPair(Atom.a(")"), S1)))
1640 { 1746 {
1641 yield return false; 1747 yield return false;
1642 } 1748 }
@@ -1652,13 +1758,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1652 object S1 = arg6; 1758 object S1 = arg6;
1653 Variable Next = new Variable(); 1759 Variable Next = new Variable();
1654 Variable S2 = new Variable(); 1760 Variable S2 = new Variable();
1655 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 1761 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
1656 { 1762 {
1657 if (YP.greaterThanOrEqual(Precedence, 1000)) 1763 if (YP.greaterThanOrEqual(Precedence, 1000))
1658 { 1764 {
1659 foreach (bool l4 in parse(S1, 1000, Next, S2)) 1765 foreach (bool l4 in parse(S1, 1000, Next, S2))
1660 { 1766 {
1661 foreach (bool l5 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) 1767 foreach (bool l5 in exprtl(S2, 1000, new Functor2(",", Term, Next), Precedence, Answer, S))
1662 { 1768 {
1663 yield return false; 1769 yield return false;
1664 } 1770 }
@@ -1668,7 +1774,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1668 } 1774 }
1669 foreach (bool l3 in YP.unify(Answer, Term)) 1775 foreach (bool l3 in YP.unify(Answer, Term))
1670 { 1776 {
1671 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@","), S1))) 1777 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(","), S1)))
1672 { 1778 {
1673 yield return false; 1779 yield return false;
1674 } 1780 }
@@ -1685,13 +1791,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1685 object S1 = arg6; 1791 object S1 = arg6;
1686 Variable Next = new Variable(); 1792 Variable Next = new Variable();
1687 Variable S2 = new Variable(); 1793 Variable S2 = new Variable();
1688 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 1794 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
1689 { 1795 {
1690 if (YP.greaterThanOrEqual(Precedence, 1100)) 1796 if (YP.greaterThanOrEqual(Precedence, 1100))
1691 { 1797 {
1692 foreach (bool l4 in parse(S1, 1100, Next, S2)) 1798 foreach (bool l4 in parse(S1, 1100, Next, S2))
1693 { 1799 {
1694 foreach (bool l5 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) 1800 foreach (bool l5 in exprtl(S2, 1100, new Functor2(";", Term, Next), Precedence, Answer, S))
1695 { 1801 {
1696 yield return false; 1802 yield return false;
1697 } 1803 }
@@ -1701,7 +1807,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1701 } 1807 }
1702 foreach (bool l3 in YP.unify(Answer, Term)) 1808 foreach (bool l3 in YP.unify(Answer, Term))
1703 { 1809 {
1704 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a(@"|"), S1))) 1810 foreach (bool l4 in YP.unify(S, new ListPair(Atom.a("|"), S1)))
1705 { 1811 {
1706 yield return false; 1812 yield return false;
1707 } 1813 }
@@ -1717,9 +1823,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1717 object x5 = arg5; 1823 object x5 = arg5;
1718 object S1 = arg6; 1824 object S1 = arg6;
1719 Variable S = new Variable(); 1825 Variable S = new Variable();
1720 foreach (bool l2 in YP.unify(arg1, new Functor1(@"string", S))) 1826 foreach (bool l2 in YP.unify(arg1, new Functor1("string", S)))
1721 { 1827 {
1722 foreach (bool l3 in cannot_follow(Atom.a(@"chars"), new Functor1(@"string", S), S1)) 1828 foreach (bool l3 in cannot_follow(Atom.a("chars"), new Functor1("string", S), S1))
1723 { 1829 {
1724 yield return false; 1830 yield return false;
1725 } 1831 }
@@ -1732,9 +1838,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1732 object x5 = arg5; 1838 object x5 = arg5;
1733 object S1 = arg6; 1839 object S1 = arg6;
1734 Variable N = new Variable(); 1840 Variable N = new Variable();
1735 foreach (bool l2 in YP.unify(arg1, new Functor1(@"number", N))) 1841 foreach (bool l2 in YP.unify(arg1, new Functor1("number", N)))
1736 { 1842 {
1737 foreach (bool l3 in cannot_follow(Atom.a(@"number"), new Functor1(@"number", N), S1)) 1843 foreach (bool l3 in cannot_follow(Atom.a("number"), new Functor1("number", N), S1))
1738 { 1844 {
1739 yield return false; 1845 yield return false;
1740 } 1846 }
@@ -1746,11 +1852,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1746 object Answer = arg4; 1852 object Answer = arg4;
1747 object S = arg5; 1853 object S = arg5;
1748 Variable S1 = new Variable(); 1854 Variable S1 = new Variable();
1749 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1855 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1750 { 1856 {
1751 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"}"), S1))) 1857 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a("}"), S1)))
1752 { 1858 {
1753 foreach (bool l4 in exprtl0_atom(Atom.a(@"{}"), Term, Precedence, Answer, S, S1)) 1859 foreach (bool l4 in exprtl0_atom(Atom.a("{}"), Term, Precedence, Answer, S, S1))
1754 { 1860 {
1755 yield return false; 1861 yield return false;
1756 } 1862 }
@@ -1764,9 +1870,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1764 object x3 = arg4; 1870 object x3 = arg4;
1765 object x4 = arg5; 1871 object x4 = arg5;
1766 object S1 = arg6; 1872 object S1 = arg6;
1767 foreach (bool l2 in YP.unify(arg1, Atom.a(@"{"))) 1873 foreach (bool l2 in YP.unify(arg1, Atom.a("{")))
1768 { 1874 {
1769 foreach (bool l3 in cannot_follow(Atom.a(@"brace"), Atom.a(@"{"), S1)) 1875 foreach (bool l3 in cannot_follow(Atom.a("brace"), Atom.a("{"), S1))
1770 { 1876 {
1771 yield return false; 1877 yield return false;
1772 } 1878 }
@@ -1778,9 +1884,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1778 object Answer = arg4; 1884 object Answer = arg4;
1779 object S = arg5; 1885 object S = arg5;
1780 Variable S1 = new Variable(); 1886 Variable S1 = new Variable();
1781 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1887 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1782 { 1888 {
1783 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a(@"]"), S1))) 1889 foreach (bool l3 in YP.unify(arg6, new ListPair(Atom.a("]"), S1)))
1784 { 1890 {
1785 foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1)) 1891 foreach (bool l4 in exprtl0_atom(Atom.NIL, Term, Precedence, Answer, S, S1))
1786 { 1892 {
@@ -1796,9 +1902,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1796 object x3 = arg4; 1902 object x3 = arg4;
1797 object x4 = arg5; 1903 object x4 = arg5;
1798 object S1 = arg6; 1904 object S1 = arg6;
1799 foreach (bool l2 in YP.unify(arg1, Atom.a(@"["))) 1905 foreach (bool l2 in YP.unify(arg1, Atom.a("[")))
1800 { 1906 {
1801 foreach (bool l3 in cannot_follow(Atom.a(@"bracket"), Atom.a(@"["), S1)) 1907 foreach (bool l3 in cannot_follow(Atom.a("bracket"), Atom.a("["), S1))
1802 { 1908 {
1803 yield return false; 1909 yield return false;
1804 } 1910 }
@@ -1810,9 +1916,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1810 object x3 = arg4; 1916 object x3 = arg4;
1811 object x4 = arg5; 1917 object x4 = arg5;
1812 object S1 = arg6; 1918 object S1 = arg6;
1813 foreach (bool l2 in YP.unify(arg1, Atom.a(@"("))) 1919 foreach (bool l2 in YP.unify(arg1, Atom.a("(")))
1814 { 1920 {
1815 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) 1921 foreach (bool l3 in cannot_follow(Atom.a("parenthesis"), Atom.a("("), S1))
1816 { 1922 {
1817 yield return false; 1923 yield return false;
1818 } 1924 }
@@ -1824,9 +1930,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1824 object x3 = arg4; 1930 object x3 = arg4;
1825 object x4 = arg5; 1931 object x4 = arg5;
1826 object S1 = arg6; 1932 object S1 = arg6;
1827 foreach (bool l2 in YP.unify(arg1, Atom.a(@" ("))) 1933 foreach (bool l2 in YP.unify(arg1, Atom.a(" (")))
1828 { 1934 {
1829 foreach (bool l3 in cannot_follow(Atom.a(@"parenthesis"), Atom.a(@"("), S1)) 1935 foreach (bool l3 in cannot_follow(Atom.a("parenthesis"), Atom.a("("), S1))
1830 { 1936 {
1831 yield return false; 1937 yield return false;
1832 } 1938 }
@@ -1841,9 +1947,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1841 Variable A = new Variable(); 1947 Variable A = new Variable();
1842 Variable B = new Variable(); 1948 Variable B = new Variable();
1843 Variable P = new Variable(); 1949 Variable P = new Variable();
1844 foreach (bool l2 in YP.unify(arg1, new Functor3(@"var", A, B, P))) 1950 foreach (bool l2 in YP.unify(arg1, new Functor3("var", A, B, P)))
1845 { 1951 {
1846 foreach (bool l3 in cannot_follow(Atom.a(@"variable"), new Functor3(@"var", A, B, P), S1)) 1952 foreach (bool l3 in cannot_follow(Atom.a("variable"), new Functor3("var", A, B, P), S1))
1847 { 1953 {
1848 yield return false; 1954 yield return false;
1849 } 1955 }
@@ -1857,9 +1963,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1857 object S1 = arg6; 1963 object S1 = arg6;
1858 Variable F = new Variable(); 1964 Variable F = new Variable();
1859 Variable P = new Variable(); 1965 Variable P = new Variable();
1860 foreach (bool l2 in YP.unify(arg1, new Functor2(@"atom", F, P))) 1966 foreach (bool l2 in YP.unify(arg1, new Functor2("atom", F, P)))
1861 { 1967 {
1862 foreach (bool l3 in exprtl0_atom(new Functor2(@"/", F, P), Term, Precedence, Answer, S, S1)) 1968 foreach (bool l3 in exprtl0_atom(new Functor2("/", F, P), Term, Precedence, Answer, S, S1))
1863 { 1969 {
1864 yield return false; 1970 yield return false;
1865 } 1971 }
@@ -1881,23 +1987,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1881 Variable R1 = new Variable(); 1987 Variable R1 = new Variable();
1882 Variable L2 = new Variable(); 1988 Variable L2 = new Variable();
1883 Variable O2 = new Variable(); 1989 Variable O2 = new Variable();
1884 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) 1990 foreach (bool l2 in YP.unify(arg1, new Functor2("/", F, Pos)))
1885 { 1991 {
1886 foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2)) 1992 foreach (bool l3 in ambigop(F, Precedence, L1, O1, R1, L2, O2))
1887 { 1993 {
1888 foreach (bool l4 in prefix_is_atom(S1, Precedence)) 1994 foreach (bool l4 in prefix_is_atom(S1, Precedence))
1889 { 1995 {
1890 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)) 1996 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))
1891 { 1997 {
1892 yield return false; 1998 yield return false;
1893 } 1999 }
1894 yield break; 2000 yield break;
1895 } 2001 }
1896 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)) 2002 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))
1897 { 2003 {
1898 yield return false; 2004 yield return false;
1899 } 2005 }
1900 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)) 2006 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))
1901 { 2007 {
1902 yield return false; 2008 yield return false;
1903 } 2009 }
@@ -1915,11 +2021,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1915 Variable L1 = new Variable(); 2021 Variable L1 = new Variable();
1916 Variable O1 = new Variable(); 2022 Variable O1 = new Variable();
1917 Variable R1 = new Variable(); 2023 Variable R1 = new Variable();
1918 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) 2024 foreach (bool l2 in YP.unify(arg1, new Functor2("/", F, Pos)))
1919 { 2025 {
1920 foreach (bool l3 in infixop(F, L1, O1, R1)) 2026 foreach (bool l3 in infixop(F, L1, O1, R1))
1921 { 2027 {
1922 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)) 2028 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))
1923 { 2029 {
1924 yield return false; 2030 yield return false;
1925 } 2031 }
@@ -1936,11 +2042,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1936 Variable Pos = new Variable(); 2042 Variable Pos = new Variable();
1937 Variable L2 = new Variable(); 2043 Variable L2 = new Variable();
1938 Variable O2 = new Variable(); 2044 Variable O2 = new Variable();
1939 foreach (bool l2 in YP.unify(arg1, new Functor2(@"/", F, Pos))) 2045 foreach (bool l2 in YP.unify(arg1, new Functor2("/", F, Pos)))
1940 { 2046 {
1941 foreach (bool l3 in postfixop(F, L2, O2)) 2047 foreach (bool l3 in postfixop(F, L2, O2))
1942 { 2048 {
1943 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)) 2049 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))
1944 { 2050 {
1945 yield return false; 2051 yield return false;
1946 } 2052 }
@@ -1955,7 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1955 object x4 = arg4; 2061 object x4 = arg4;
1956 object x5 = arg5; 2062 object x5 = arg5;
1957 Variable x7 = new Variable(); 2063 Variable x7 = new Variable();
1958 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))) 2064 foreach (bool l2 in syntax_error(ListPair.make(new object[] { new Functor2("-", Atom.a("non"), Atom.a("operator")), X, Atom.a("follows"), Atom.a("expression") }), new ListPair(new Functor2("atom", X, x7), S1)))
1959 { 2065 {
1960 yield return false; 2066 yield return false;
1961 } 2067 }
@@ -1966,7 +2072,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1966 public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens) 2072 public static IEnumerable<bool> cannot_follow(object Type, object Token, object Tokens)
1967 { 2073 {
1968 { 2074 {
1969 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))) 2075 foreach (bool l2 in syntax_error(ListPair.make(new object[] { Type, Atom.a("follows"), Atom.a("expression") }), new ListPair(Token, Tokens)))
1970 { 2076 {
1971 yield return false; 2077 yield return false;
1972 } 2078 }
@@ -2028,7 +2134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2028 Variable Other = new Variable(); 2134 Variable Other = new Variable();
2029 Variable S2 = new Variable(); 2135 Variable S2 = new Variable();
2030 Variable Expr = new Variable(); 2136 Variable Expr = new Variable();
2031 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a(@"infixop", Atom.a(@"")), new object[] { new Functor2(@"/", F, Pos), L, O, R }))) 2137 foreach (bool l2 in YP.unify(arg1, new Functor(Atom.a("infixop", Atom.a("")), new object[] { new Functor2("/", F, Pos), L, O, R })))
2032 { 2138 {
2033 if (YP.greaterThanOrEqual(Precedence, O)) 2139 if (YP.greaterThanOrEqual(Precedence, O))
2034 { 2140 {
@@ -2036,7 +2142,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2036 { 2142 {
2037 foreach (bool l5 in parse(S1, R, Other, S2)) 2143 foreach (bool l5 in parse(S1, R, Other, S2))
2038 { 2144 {
2039 foreach (bool l6 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, new ListPair(Other, Atom.NIL)))))) 2145 foreach (bool l6 in YP.univ(Expr, ListPair.make(new object[] { F, Pos, Term, Other })))
2040 { 2146 {
2041 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S)) 2147 foreach (bool l7 in exprtl(S2, O, Expr, Precedence, Answer, S))
2042 { 2148 {
@@ -2062,13 +2168,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2062 Variable O = new Variable(); 2168 Variable O = new Variable();
2063 Variable Expr = new Variable(); 2169 Variable Expr = new Variable();
2064 Variable S2 = new Variable(); 2170 Variable S2 = new Variable();
2065 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a(@"postfixop", Atom.a(@"")), new Functor2(@"/", F, Pos), L, O))) 2171 foreach (bool l2 in YP.unify(arg1, new Functor3(Atom.a("postfixop", Atom.a("")), new Functor2("/", F, Pos), L, O)))
2066 { 2172 {
2067 if (YP.greaterThanOrEqual(Precedence, O)) 2173 if (YP.greaterThanOrEqual(Precedence, O))
2068 { 2174 {
2069 if (YP.lessThanOrEqual(C, L)) 2175 if (YP.lessThanOrEqual(C, L))
2070 { 2176 {
2071 foreach (bool l5 in YP.univ(Expr, new ListPair(F, new ListPair(Pos, new ListPair(Term, Atom.NIL))))) 2177 foreach (bool l5 in YP.univ(Expr, ListPair.make(new object[] { F, Pos, Term })))
2072 { 2178 {
2073 foreach (bool l6 in peepop(S1, S2)) 2179 foreach (bool l6 in peepop(S1, S2))
2074 { 2180 {
@@ -2092,7 +2198,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2092 object S1 = arg7; 2198 object S1 = arg7;
2093 Variable Next = new Variable(); 2199 Variable Next = new Variable();
2094 Variable S2 = new Variable(); 2200 Variable S2 = new Variable();
2095 foreach (bool l2 in YP.unify(arg1, Atom.a(@","))) 2201 foreach (bool l2 in YP.unify(arg1, Atom.a(",")))
2096 { 2202 {
2097 if (YP.greaterThanOrEqual(Precedence, 1000)) 2203 if (YP.greaterThanOrEqual(Precedence, 1000))
2098 { 2204 {
@@ -2100,7 +2206,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2100 { 2206 {
2101 foreach (bool l5 in parse(S1, 1000, Next, S2)) 2207 foreach (bool l5 in parse(S1, 1000, Next, S2))
2102 { 2208 {
2103 foreach (bool l6 in exprtl(S2, 1000, new Functor2(@",", Term, Next), Precedence, Answer, S)) 2209 foreach (bool l6 in exprtl(S2, 1000, new Functor2(",", Term, Next), Precedence, Answer, S))
2104 { 2210 {
2105 yield return false; 2211 yield return false;
2106 } 2212 }
@@ -2119,7 +2225,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2119 object S1 = arg7; 2225 object S1 = arg7;
2120 Variable Next = new Variable(); 2226 Variable Next = new Variable();
2121 Variable S2 = new Variable(); 2227 Variable S2 = new Variable();
2122 foreach (bool l2 in YP.unify(arg1, Atom.a(@"|"))) 2228 foreach (bool l2 in YP.unify(arg1, Atom.a("|")))
2123 { 2229 {
2124 if (YP.greaterThanOrEqual(Precedence, 1100)) 2230 if (YP.greaterThanOrEqual(Precedence, 1100))
2125 { 2231 {
@@ -2127,7 +2233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2127 { 2233 {
2128 foreach (bool l5 in parse(S1, 1100, Next, S2)) 2234 foreach (bool l5 in parse(S1, 1100, Next, S2))
2129 { 2235 {
2130 foreach (bool l6 in exprtl(S2, 1100, new Functor2(@";", Term, Next), Precedence, Answer, S)) 2236 foreach (bool l6 in exprtl(S2, 1100, new Functor2(";", Term, Next), Precedence, Answer, S))
2131 { 2237 {
2132 yield return false; 2238 yield return false;
2133 } 2239 }
@@ -2161,6 +2267,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2161 { 2267 {
2162 yield break; 2268 yield break;
2163 } 2269 }
2270 foreach (bool l1 in YP.fail())
2271 {
2272 yield return false;
2273 }
2164 } 2274 }
2165 2275
2166 public static IEnumerable<bool> syntax_error(object _List) 2276 public static IEnumerable<bool> syntax_error(object _List)
@@ -2168,12 +2278,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2168 { 2278 {
2169 yield break; 2279 yield break;
2170 } 2280 }
2281 foreach (bool l1 in YP.fail())
2282 {
2283 yield return false;
2284 }
2171 } 2285 }
2172 2286
2173 public static IEnumerable<bool> prefixop(object F, object O, object Q) 2287 public static IEnumerable<bool> prefixop(object F, object O, object Q)
2174 { 2288 {
2175 { 2289 {
2176 foreach (bool l2 in YP.current_op(O, Atom.a(@"fx"), F)) 2290 foreach (bool l2 in YP.current_op(O, Atom.a("fx"), F))
2177 { 2291 {
2178 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) 2292 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2179 { 2293 {
@@ -2181,7 +2295,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2181 } 2295 }
2182 goto cutIf1; 2296 goto cutIf1;
2183 } 2297 }
2184 foreach (bool l2 in YP.current_op(O, Atom.a(@"fy"), F)) 2298 foreach (bool l2 in YP.current_op(O, Atom.a("fy"), F))
2185 { 2299 {
2186 foreach (bool l3 in YP.unify(Q, O)) 2300 foreach (bool l3 in YP.unify(Q, O))
2187 { 2301 {
@@ -2198,7 +2312,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2198 public static IEnumerable<bool> postfixop(object F, object P, object O) 2312 public static IEnumerable<bool> postfixop(object F, object P, object O)
2199 { 2313 {
2200 { 2314 {
2201 foreach (bool l2 in YP.current_op(O, Atom.a(@"xf"), F)) 2315 foreach (bool l2 in YP.current_op(O, Atom.a("xf"), F))
2202 { 2316 {
2203 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) 2317 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2204 { 2318 {
@@ -2206,7 +2320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2206 } 2320 }
2207 goto cutIf1; 2321 goto cutIf1;
2208 } 2322 }
2209 foreach (bool l2 in YP.current_op(O, Atom.a(@"yf"), F)) 2323 foreach (bool l2 in YP.current_op(O, Atom.a("yf"), F))
2210 { 2324 {
2211 foreach (bool l3 in YP.unify(P, O)) 2325 foreach (bool l3 in YP.unify(P, O))
2212 { 2326 {
@@ -2223,7 +2337,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2223 public static IEnumerable<bool> infixop(object F, object P, object O, object Q) 2337 public static IEnumerable<bool> infixop(object F, object P, object O, object Q)
2224 { 2338 {
2225 { 2339 {
2226 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfy"), F)) 2340 foreach (bool l2 in YP.current_op(O, Atom.a("xfy"), F))
2227 { 2341 {
2228 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) 2342 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2229 { 2343 {
@@ -2234,7 +2348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2234 } 2348 }
2235 goto cutIf1; 2349 goto cutIf1;
2236 } 2350 }
2237 foreach (bool l2 in YP.current_op(O, Atom.a(@"xfx"), F)) 2351 foreach (bool l2 in YP.current_op(O, Atom.a("xfx"), F))
2238 { 2352 {
2239 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1))) 2353 foreach (bool l3 in YP.unify(P, YP.subtract(O, 1)))
2240 { 2354 {
@@ -2245,7 +2359,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2245 } 2359 }
2246 goto cutIf2; 2360 goto cutIf2;
2247 } 2361 }
2248 foreach (bool l2 in YP.current_op(O, Atom.a(@"yfx"), F)) 2362 foreach (bool l2 in YP.current_op(O, Atom.a("yfx"), F))
2249 { 2363 {
2250 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1))) 2364 foreach (bool l3 in YP.unify(Q, YP.subtract(O, 1)))
2251 { 2365 {
@@ -2302,7 +2416,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2302 } 2416 }
2303 } 2417 }
2304 { 2418 {
2305 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) 2419 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", Atom.a("end_of_file"), 0), Atom.NIL)))
2306 { 2420 {
2307 yield return false; 2421 yield return false;
2308 } 2422 }
@@ -2336,7 +2450,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2336 } 2450 }
2337 } 2451 }
2338 { 2452 {
2339 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"atom", Atom.a(@"end_of_file"), 0), Atom.NIL))) 2453 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("atom", Atom.a("end_of_file"), 0), Atom.NIL)))
2340 { 2454 {
2341 foreach (bool l3 in YP.unify(arg2, Atom.NIL)) 2455 foreach (bool l3 in YP.unify(arg2, Atom.NIL))
2342 { 2456 {
@@ -2407,7 +2521,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2407 Variable NextCh = new Variable(); 2521 Variable NextCh = new Variable();
2408 foreach (bool l2 in YP.unify(arg1, 37)) 2522 foreach (bool l2 in YP.unify(arg1, 37))
2409 { 2523 {
2410 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) 2524 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("comment", StartPos, EndPos), Tokens)))
2411 { 2525 {
2412 foreach (bool l4 in get_current_position(StartPos)) 2526 foreach (bool l4 in get_current_position(StartPos))
2413 { 2527 {
@@ -2456,7 +2570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2456 { 2570 {
2457 if (YP.equal(C2, new ListPair(42, Atom.NIL))) 2571 if (YP.equal(C2, new ListPair(42, Atom.NIL)))
2458 { 2572 {
2459 foreach (bool l5 in YP.unify(T, new ListPair(new Functor2(@"comment", StartPos, EndPos), Tokens))) 2573 foreach (bool l5 in YP.unify(T, new ListPair(new Functor2("comment", StartPos, EndPos), Tokens)))
2460 { 2574 {
2461 foreach (bool l6 in get_current_position(StartPos1)) 2575 foreach (bool l6 in get_current_position(StartPos1))
2462 { 2576 {
@@ -2498,7 +2612,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2498 Variable NextCh = new Variable(); 2612 Variable NextCh = new Variable();
2499 foreach (bool l2 in YP.unify(arg1, 33)) 2613 foreach (bool l2 in YP.unify(arg1, 33))
2500 { 2614 {
2501 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@"!"), Pos), Tokens))) 2615 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("atom", Atom.a("!"), Pos), Tokens)))
2502 { 2616 {
2503 foreach (bool l4 in get_current_position(Pos)) 2617 foreach (bool l4 in get_current_position(Pos))
2504 { 2618 {
@@ -2518,7 +2632,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2518 Variable NextCh = new Variable(); 2632 Variable NextCh = new Variable();
2519 foreach (bool l2 in YP.unify(arg1, 40)) 2633 foreach (bool l2 in YP.unify(arg1, 40))
2520 { 2634 {
2521 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@" ("), Tokens))) 2635 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(" ("), Tokens)))
2522 { 2636 {
2523 foreach (bool l4 in YP.get_code(NextCh)) 2637 foreach (bool l4 in YP.get_code(NextCh))
2524 { 2638 {
@@ -2535,7 +2649,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2535 Variable NextCh = new Variable(); 2649 Variable NextCh = new Variable();
2536 foreach (bool l2 in YP.unify(arg1, 41)) 2650 foreach (bool l2 in YP.unify(arg1, 41))
2537 { 2651 {
2538 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)))
2539 { 2653 {
2540 foreach (bool l4 in YP.get_code(NextCh)) 2654 foreach (bool l4 in YP.get_code(NextCh))
2541 { 2655 {
@@ -2552,7 +2666,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2552 Variable NextCh = new Variable(); 2666 Variable NextCh = new Variable();
2553 foreach (bool l2 in YP.unify(arg1, 44)) 2667 foreach (bool l2 in YP.unify(arg1, 44))
2554 { 2668 {
2555 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)))
2556 { 2670 {
2557 foreach (bool l4 in YP.get_code(NextCh)) 2671 foreach (bool l4 in YP.get_code(NextCh))
2558 { 2672 {
@@ -2570,7 +2684,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2570 Variable NextCh = new Variable(); 2684 Variable NextCh = new Variable();
2571 foreach (bool l2 in YP.unify(arg1, 59)) 2685 foreach (bool l2 in YP.unify(arg1, 59))
2572 { 2686 {
2573 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom.a(@";"), Pos), Tokens))) 2687 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("atom", Atom.a(";"), Pos), Tokens)))
2574 { 2688 {
2575 foreach (bool l4 in get_current_position(Pos)) 2689 foreach (bool l4 in get_current_position(Pos))
2576 { 2690 {
@@ -2591,7 +2705,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2591 Variable NextCh = new Variable(); 2705 Variable NextCh = new Variable();
2592 foreach (bool l2 in YP.unify(arg1, 91)) 2706 foreach (bool l2 in YP.unify(arg1, 91))
2593 { 2707 {
2594 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"["), Pos), Tokens))) 2708 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("/", Atom.a("["), Pos), Tokens)))
2595 { 2709 {
2596 foreach (bool l4 in get_current_position(Pos)) 2710 foreach (bool l4 in get_current_position(Pos))
2597 { 2711 {
@@ -2612,7 +2726,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2612 Variable NextCh = new Variable(); 2726 Variable NextCh = new Variable();
2613 foreach (bool l2 in YP.unify(arg1, 93)) 2727 foreach (bool l2 in YP.unify(arg1, 93))
2614 { 2728 {
2615 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"]"), Pos), Tokens))) 2729 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("/", Atom.a("]"), Pos), Tokens)))
2616 { 2730 {
2617 foreach (bool l4 in get_current_position(Pos)) 2731 foreach (bool l4 in get_current_position(Pos))
2618 { 2732 {
@@ -2633,7 +2747,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2633 Variable NextCh = new Variable(); 2747 Variable NextCh = new Variable();
2634 foreach (bool l2 in YP.unify(arg1, 123)) 2748 foreach (bool l2 in YP.unify(arg1, 123))
2635 { 2749 {
2636 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"/", Atom.a(@"{"), Pos), Tokens))) 2750 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("/", Atom.a("{"), Pos), Tokens)))
2637 { 2751 {
2638 foreach (bool l4 in get_current_position(Pos)) 2752 foreach (bool l4 in get_current_position(Pos))
2639 { 2753 {
@@ -2653,7 +2767,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2653 Variable NextCh = new Variable(); 2767 Variable NextCh = new Variable();
2654 foreach (bool l2 in YP.unify(arg1, 124)) 2768 foreach (bool l2 in YP.unify(arg1, 124))
2655 { 2769 {
2656 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"|"), Tokens))) 2770 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("|"), Tokens)))
2657 { 2771 {
2658 foreach (bool l4 in YP.get_code(NextCh)) 2772 foreach (bool l4 in YP.get_code(NextCh))
2659 { 2773 {
@@ -2670,7 +2784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2670 Variable NextCh = new Variable(); 2784 Variable NextCh = new Variable();
2671 foreach (bool l2 in YP.unify(arg1, 125)) 2785 foreach (bool l2 in YP.unify(arg1, 125))
2672 { 2786 {
2673 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"}"), Tokens))) 2787 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("}"), Tokens)))
2674 { 2788 {
2675 foreach (bool l4 in YP.get_code(NextCh)) 2789 foreach (bool l4 in YP.get_code(NextCh))
2676 { 2790 {
@@ -2702,7 +2816,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2702 Variable NextCh = new Variable(); 2816 Variable NextCh = new Variable();
2703 foreach (bool l2 in YP.unify(arg1, 34)) 2817 foreach (bool l2 in YP.unify(arg1, 34))
2704 { 2818 {
2705 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"string", Chars), Tokens))) 2819 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1("string", Chars), Tokens)))
2706 { 2820 {
2707 foreach (bool l4 in read_string(Chars, 34, NextCh)) 2821 foreach (bool l4 in read_string(Chars, 34, NextCh))
2708 { 2822 {
@@ -3098,7 +3212,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3098 Variable Atom_1 = new Variable(); 3212 Variable Atom_1 = new Variable();
3099 Variable Pos = new Variable(); 3213 Variable Pos = new Variable();
3100 Variable Tokens = new Variable(); 3214 Variable Tokens = new Variable();
3101 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"atom", Atom_1, Pos), Tokens))) 3215 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2("atom", Atom_1, Pos), Tokens)))
3102 { 3216 {
3103 foreach (bool l3 in YP.unify(Pos, 0)) 3217 foreach (bool l3 in YP.unify(Pos, 0))
3104 { 3218 {
@@ -3121,7 +3235,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3121 Variable NextCh = new Variable(); 3235 Variable NextCh = new Variable();
3122 foreach (bool l2 in YP.unify(arg1, 40)) 3236 foreach (bool l2 in YP.unify(arg1, 40))
3123 { 3237 {
3124 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"("), Tokens))) 3238 foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a("("), Tokens)))
3125 { 3239 {
3126 foreach (bool l4 in YP.get_code(NextCh)) 3240 foreach (bool l4 in YP.get_code(NextCh))
3127 { 3241 {
@@ -3397,7 +3511,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3397 Variable Tokens = new Variable(); 3511 Variable Tokens = new Variable();
3398 Variable Chars = new Variable(); 3512 Variable Chars = new Variable();
3399 Variable NextCh = new Variable(); 3513 Variable NextCh = new Variable();
3400 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3(@"var", Var, Name, StartPos), Tokens))) 3514 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor3("var", Var, Name, StartPos), Tokens)))
3401 { 3515 {
3402 foreach (bool l3 in get_current_position(StartPos)) 3516 foreach (bool l3 in get_current_position(StartPos))
3403 { 3517 {
@@ -3405,7 +3519,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3405 { 3519 {
3406 foreach (bool l5 in YP.atom_codes(Name, Chars)) 3520 foreach (bool l5 in YP.atom_codes(Name, Chars))
3407 { 3521 {
3408 if (YP.termEqual(Name, Atom.a(@"_"))) 3522 if (YP.termEqual(Name, Atom.a("_")))
3409 { 3523 {
3410 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens)) 3524 foreach (bool l7 in read_after_atom(NextCh, Dict, Tokens))
3411 { 3525 {
@@ -3435,7 +3549,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3435 Variable N = new Variable(); 3549 Variable N = new Variable();
3436 Variable V = new Variable(); 3550 Variable V = new Variable();
3437 Variable L = new Variable(); 3551 Variable L = new Variable();
3438 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", N, V), L))) 3552 foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2("=", N, V), L)))
3439 { 3553 {
3440 foreach (bool l3 in YP.unify(N, Name)) 3554 foreach (bool l3 in YP.unify(N, Name))
3441 { 3555 {
@@ -3493,7 +3607,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3493 } 3607 }
3494 foreach (bool l2 in YP.unify(LastCh, Ch)) 3608 foreach (bool l2 in YP.unify(LastCh, Ch))
3495 { 3609 {
3496 foreach (bool l3 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file in /*comment~n"), Atom.NIL)) 3610 foreach (bool l3 in formatError(Atom.a("user_error"), Atom.a("~N** end of file in /*comment~n"), Atom.NIL))
3497 { 3611 {
3498 yield return false; 3612 yield return false;
3499 } 3613 }
@@ -3633,7 +3747,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3633 { 3747 {
3634 if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL))) 3748 if (YP.greaterThanOrEqual(Ch, new ListPair(48, Atom.NIL)))
3635 { 3749 {
3636 foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1(@"number", Number), Tokens1))) 3750 foreach (bool l4 in YP.unify(Tokens, new ListPair(new Functor1("number", Number), Tokens1)))
3637 { 3751 {
3638 foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch)) 3752 foreach (bool l5 in read_float(Number, Dict, Tokens1, new ListPair(48, Atom.NIL), Ch))
3639 { 3753 {
@@ -3662,7 +3776,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3662 } 3776 }
3663 goto cutIf3; 3777 goto cutIf3;
3664 } 3778 }
3665 foreach (bool l2 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** end of file just after full stop~n"), Atom.NIL)) 3779 foreach (bool l2 in formatError(Atom.a("user_error"), Atom.a("~N** end of file just after full stop~n"), Atom.NIL))
3666 { 3780 {
3667 } 3781 }
3668 cutIf3: 3782 cutIf3:
@@ -3680,7 +3794,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3680 Variable NextCh = new Variable(); 3794 Variable NextCh = new Variable();
3681 foreach (bool l2 in prepend(Digits, Chars, Rest)) 3795 foreach (bool l2 in prepend(Digits, Chars, Rest))
3682 { 3796 {
3683 foreach (bool l3 in read_float(Digit, Rest, NextCh, Chars)) 3797 foreach (bool l3 in read_float4(Digit, Rest, NextCh, Chars))
3684 { 3798 {
3685 foreach (bool l4 in YP.number_codes(Number, Chars)) 3799 foreach (bool l4 in YP.number_codes(Number, Chars))
3686 { 3800 {
@@ -3724,7 +3838,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3724 } 3838 }
3725 } 3839 }
3726 3840
3727 public static IEnumerable<bool> read_float(object C1, object arg2, object NextCh, object Total) 3841 public static IEnumerable<bool> read_float4(object C1, object arg2, object NextCh, object Total)
3728 { 3842 {
3729 { 3843 {
3730 Variable Chars = new Variable(); 3844 Variable Chars = new Variable();
@@ -3740,7 +3854,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3740 { 3854 {
3741 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL))) 3855 if (YP.lessThanOrEqual(C2, new ListPair(57, Atom.NIL)))
3742 { 3856 {
3743 foreach (bool l6 in read_float(C2, Chars, NextCh, Total)) 3857 foreach (bool l6 in read_float4(C2, Chars, NextCh, Total))
3744 { 3858 {
3745 yield return false; 3859 yield return false;
3746 } 3860 }
@@ -3770,7 +3884,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3770 } 3884 }
3771 foreach (bool l9 in YP.unify(More, Atom.NIL)) 3885 foreach (bool l9 in YP.unify(More, Atom.NIL))
3772 { 3886 {
3773 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) 3887 foreach (bool l10 in formatError(Atom.a("user_error"), Atom.a("~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3774 { 3888 {
3775 } 3889 }
3776 } 3890 }
@@ -3806,7 +3920,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3806 } 3920 }
3807 foreach (bool l9 in YP.unify(More, Atom.NIL)) 3921 foreach (bool l9 in YP.unify(More, Atom.NIL))
3808 { 3922 {
3809 foreach (bool l10 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) 3923 foreach (bool l10 in formatError(Atom.a("user_error"), Atom.a("~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3810 { 3924 {
3811 } 3925 }
3812 } 3926 }
@@ -3840,7 +3954,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3840 } 3954 }
3841 foreach (bool l8 in YP.unify(More, Atom.NIL)) 3955 foreach (bool l8 in YP.unify(More, Atom.NIL))
3842 { 3956 {
3843 foreach (bool l9 in formatError(Atom.a(@"user_error"), Atom.a(@"~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL))) 3957 foreach (bool l9 in formatError(Atom.a("user_error"), Atom.a("~N** Missing exponent in ~s~n"), new ListPair(Total, Atom.NIL)))
3844 { 3958 {
3845 } 3959 }
3846 } 3960 }
@@ -3920,7 +4034,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3920 Variable C = new Variable(); 4034 Variable C = new Variable();
3921 Variable C3 = new Variable(); 4035 Variable C3 = new Variable();
3922 Variable Digits = new Variable(); 4036 Variable Digits = new Variable();
3923 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1(@"number", Number), Tokens))) 4037 foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor1("number", Number), Tokens)))
3924 { 4038 {
3925 foreach (bool l3 in read_number4(C1, C2, 0, N)) 4039 foreach (bool l3 in read_number4(C1, C2, 0, N))
3926 { 4040 {
@@ -3954,7 +4068,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
3954 } 4068 }
3955 goto cutIf3; 4069 goto cutIf3;
3956 } 4070 }
3957 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)))) 4071 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))))
3958 { 4072 {
3959 foreach (bool l6 in YP.unify(Number, N)) 4073 foreach (bool l6 in YP.unify(Number, N))
3960 { 4074 {
@@ -4240,7 +4354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
4240 { 4354 {
4241 if (YP.lessThan(C1, 0)) 4355 if (YP.lessThan(C1, 0))
4242 { 4356 {
4243 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)))) 4357 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))))
4244 { 4358 {
4245 foreach (bool l6 in YP.unify(Result, -1)) 4359 foreach (bool l6 in YP.unify(Result, -1))
4246 { 4360 {
@@ -4332,7 +4446,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
4332 { 4446 {
4333 if (YP.lessThan(C2, 0)) 4447 if (YP.lessThan(C2, 0))
4334 { 4448 {
4335 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))))) 4449 foreach (bool l7 in formatError(Atom.a("user_error"), Atom.a("~N** end of file in ~c..~c^..~c~n"), ListPair.make(new object[] { Quote, 92, Quote })))
4336 { 4450 {
4337 foreach (bool l8 in YP.unify(Result, -1)) 4451 foreach (bool l8 in YP.unify(Result, -1))
4338 { 4452 {
@@ -4432,7 +4546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
4432 { 4546 {
4433 foreach (bool l7 in YP.unify(Next, Char)) 4547 foreach (bool l7 in YP.unify(Next, Char))
4434 { 4548 {
4435 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))))) 4549 foreach (bool l8 in formatError(Atom.a("user_error"), Atom.a("~N** Strange character ~d ends ~ctoken~c~n"), ListPair.make(new object[] { Char, Quote, Quote })))
4436 { 4550 {
4437 yield return false; 4551 yield return false;
4438 } 4552 }
@@ -4456,6 +4570,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
4456 { } 4570 { }
4457 } 4571 }
4458 } 4572 }
4459 #pragma warning restore 0168, 0219 4573 #pragma warning restore 0168, 0219, 0162
4460 } 4574 }
4461} 4575}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
index f68a941..a606465 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
@@ -43,6 +43,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
43 bool ground(); 43 bool ground();
44 } 44 }
45 45
46 /// <summary>
47 /// A Variable is passed to a function so that it can be unified with
48 /// value or another Variable. See getValue and unify for details.
49 /// </summary>
46 public class Variable : IUnifiable 50 public class Variable : IUnifiable
47 { 51 {
48 // Use _isBound separate from _value so that it can be bound to any value, 52 // Use _isBound separate from _value so that it can be bound to any value,
@@ -50,6 +54,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
50 private bool _isBound = false; 54 private bool _isBound = false;
51 private object _value; 55 private object _value;
52 56
57 /// <summary>
58 /// If this Variable is unbound, then just return this Variable.
59 /// Otherwise, if this has been bound to a value with unify, return the value.
60 /// If the bound value is another Variable, this follows the "variable chain"
61 /// to the end and returns the final value, or the final Variable if it is unbound.
62 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
63 /// </summary>
64 /// <returns></returns>
53 public object getValue() 65 public object getValue()
54 { 66 {
55 if (!_isBound) 67 if (!_isBound)
@@ -68,6 +80,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
68 return result; 80 return result;
69 } 81 }
70 82
83 /// <summary>
84 /// If this Variable is bound, then just call YP.unify to unify this with arg.
85 /// (Note that if arg is an unbound Variable, then YP.unify will bind it to
86 /// this Variable's value.)
87 /// Otherwise, bind this Variable to YP.getValue(arg) and yield once. After the
88 /// yield, return this Variable to the unbound state.
89 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
90 /// </summary>
91 /// <param name="arg"></param>
92 /// <returns></returns>
71 public IEnumerable<bool> unify(object arg) 93 public IEnumerable<bool> unify(object arg)
72 { 94 {
73 if (!_isBound) 95 if (!_isBound)
@@ -92,12 +114,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
92 } 114 }
93 else 115 else
94 { 116 {
95// disable warning: don't see how we can code this differently short 117 // disable warning on l1, don't see how we can
96// of rewriting the whole thing 118 // code this differently
97#pragma warning disable 0168 119 #pragma warning disable 0168
98 foreach (bool l1 in YP.unify(this, arg)) 120 foreach (bool l1 in YP.unify(this, arg))
99 yield return false; 121 yield return false;
100#pragma warning restore 0168 122 #pragma warning restore 0168
101 } 123 }
102 } 124 }
103 125
@@ -105,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
105 { 127 {
106 object value = getValue(); 128 object value = getValue();
107 if (value == this) 129 if (value == this)
108 return "Variable"; 130 return "_Variable";
109 else 131 else
110 return getValue().ToString(); 132 return getValue().ToString();
111 } 133 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
index 76e307a..97c9087 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs
@@ -52,6 +52,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
52 private static TextWriter _outputStream = System.Console.Out; 52 private static TextWriter _outputStream = System.Console.Out;
53 private static TextReader _inputStream = System.Console.In; 53 private static TextReader _inputStream = System.Console.In;
54 private static IndexedAnswers _operatorTable = null; 54 private static IndexedAnswers _operatorTable = null;
55 private static Dictionary<string, object> _prologFlags = new Dictionary<string, object>();
56 public const int MAX_ARITY = 255;
55 57
56 /// <summary> 58 /// <summary>
57 /// An IClause is used so that dynamic predicates can call match. 59 /// An IClause is used so that dynamic predicates can call match.
@@ -62,6 +64,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
62 IEnumerable<bool> clause(object Head, object Body); 64 IEnumerable<bool> clause(object Head, object Body);
63 } 65 }
64 66
67 /// <summary>
68 /// If value is a Variable, then return its getValue. Otherwise, just
69 /// return value. You should call YP.getValue on any object that
70 /// may be a Variable to get the value to pass to other functions in
71 /// your system that are not part of Yield Prolog, such as math functions
72 /// or file I/O.
73 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
74 /// </summary>
75 /// <param name="value"></param>
76 /// <returns></returns>
65 public static object getValue(object value) 77 public static object getValue(object value)
66 { 78 {
67 if (value is Variable) 79 if (value is Variable)
@@ -70,6 +82,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
70 return value; 82 return value;
71 } 83 }
72 84
85 /// <summary>
86 /// If arg1 or arg2 is an object with a unify method (such as Variable or
87 /// Functor) then just call its unify with the other argument. The object's
88 /// unify method will bind the values or check for equals as needed.
89 /// Otherwise, both arguments are "normal" (atomic) values so if they
90 /// are equal then succeed (yield once), else fail (don't yield).
91 /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
92 /// </summary>
93 /// <param name="arg1"></param>
94 /// <param name="arg2"></param>
95 /// <returns></returns>
73 public static IEnumerable<bool> unify(object arg1, object arg2) 96 public static IEnumerable<bool> unify(object arg1, object arg2)
74 { 97 {
75 arg1 = getValue(arg1); 98 arg1 = getValue(arg1);
@@ -622,6 +645,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
622 if (args.Length == 0) 645 if (args.Length == 0)
623 // Return the Name, even if it is not an Atom. 646 // Return the Name, even if it is not an Atom.
624 return YP.unify(Term, Name); 647 return YP.unify(Term, Name);
648 if (args.Length > MAX_ARITY)
649 throw new PrologException
650 (new Functor1("representation_error", Atom.a("max_arity")),
651 "Functor arity " + args.Length + " may not be greater than " + MAX_ARITY);
625 if (!atom(Name)) 652 if (!atom(Name))
626 throw new PrologException 653 throw new PrologException
627 (new Functor2("type_error", Atom.a("atom"), Name), 654 (new Functor2("type_error", Atom.a("atom"), Name),
@@ -666,6 +693,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
666 } 693 }
667 else 694 else
668 { 695 {
696 if ((int)Arity > MAX_ARITY)
697 throw new PrologException
698 (new Functor1("representation_error", Atom.a("max_arity")),
699 "Functor arity " + Arity + " may not be greater than " + MAX_ARITY);
669 if (!(FunctorName is Atom)) 700 if (!(FunctorName is Atom))
670 throw new PrologException 701 throw new PrologException
671 (new Functor2("type_error", Atom.a("atom"), FunctorName), "FunctorName is not an atom"); 702 (new Functor2("type_error", Atom.a("atom"), FunctorName), "FunctorName is not an atom");
@@ -903,8 +934,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
903 _operatorTable.addAnswer(new object[] { 20, Atom.a("xfx"), Atom.a("<--") }); 934 _operatorTable.addAnswer(new object[] { 20, Atom.a("xfx"), Atom.a("<--") });
904 } 935 }
905 936
906 foreach (bool l1 in _operatorTable.match(new object[] { Priority, Specifier, Operator })) 937 return _operatorTable.match(new object[] { Priority, Specifier, Operator });
907 yield return false;
908 } 938 }
909 939
910 public static IEnumerable<bool> atom_length(object atom, object Length) 940 public static IEnumerable<bool> atom_length(object atom, object Length)
@@ -1491,9 +1521,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1491 return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor; 1521 return Term is Functor1 || Term is Functor2 || Term is Functor3 || Term is Functor;
1492 } 1522 }
1493 1523
1524 /// <summary>
1525 /// If input is a TextReader, use it. If input is an Atom or String, create a StreamReader with the
1526 /// input as the filename. If input is a Prolog list, then read character codes from it.
1527 /// </summary>
1528 /// <param name="input"></param>
1494 public static void see(object input) 1529 public static void see(object input)
1495 { 1530 {
1496 input = YP.getValue(input); 1531 input = YP.getValue(input);
1532 if (input is Variable)
1533 throw new PrologException(Atom.a("instantiation_error"), "Arg is an unbound variable");
1534
1535 if (input == null)
1536 {
1537 _inputStream = null;
1538 return;
1539 }
1497 if (input is TextReader) 1540 if (input is TextReader)
1498 { 1541 {
1499 _inputStream = (TextReader)input; 1542 _inputStream = (TextReader)input;
@@ -1509,21 +1552,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1509 _inputStream = new StreamReader((String)input); 1552 _inputStream = new StreamReader((String)input);
1510 return; 1553 return;
1511 } 1554 }
1555 else if (input is Functor2 && ((Functor2)input)._name == Atom.DOT)
1556 {
1557 _inputStream = new CodeListReader(input);
1558 return;
1559 }
1512 else 1560 else
1513 throw new InvalidOperationException("Can't open stream for " + input); 1561 throw new PrologException
1562 (new Functor2("domain_error", Atom.a("stream_or_alias"), input),
1563 "Input stream specifier not recognized");
1514 } 1564 }
1515 1565
1516 public static void seen() 1566 public static void seen()
1517 { 1567 {
1568 if (_inputStream == null)
1569 return;
1518 if (_inputStream == Console.In) 1570 if (_inputStream == Console.In)
1519 return; 1571 return;
1520 _inputStream.Close(); 1572 _inputStream.Close();
1521 _inputStream = Console.In; 1573 _inputStream = Console.In;
1522 } 1574 }
1523 1575
1576 public static IEnumerable<bool> current_input(object Stream)
1577 {
1578 return YP.unify(Stream, _inputStream);
1579 }
1580
1581 /// <summary>
1582 /// If output is a TextWriter, use it. If output is an Atom or a String, create a StreamWriter
1583 /// with the input as the filename.
1584 /// </summary>
1585 /// <param name="output"></param>
1524 public static void tell(object output) 1586 public static void tell(object output)
1525 { 1587 {
1526 output = YP.getValue(output); 1588 output = YP.getValue(output);
1589 if (output is Variable)
1590 throw new PrologException(Atom.a("instantiation_error"), "Arg is an unbound variable");
1591
1592 if (output == null)
1593 {
1594 _outputStream = null;
1595 return;
1596 }
1527 if (output is TextWriter) 1597 if (output is TextWriter)
1528 { 1598 {
1529 _outputStream = (TextWriter)output; 1599 _outputStream = (TextWriter)output;
@@ -1540,11 +1610,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1540 return; 1610 return;
1541 } 1611 }
1542 else 1612 else
1543 throw new InvalidOperationException("Can't open stream for " + output); 1613 throw new PrologException
1614 (new Functor2("domain_error", Atom.a("stream_or_alias"), output),
1615 "Can't open stream for " + output);
1544 } 1616 }
1545 1617
1546 public static void told() 1618 public static void told()
1547 { 1619 {
1620 if (_outputStream == null)
1621 return;
1548 if (_outputStream == Console.Out) 1622 if (_outputStream == Console.Out)
1549 return; 1623 return;
1550 _outputStream.Close(); 1624 _outputStream.Close();
@@ -1558,6 +1632,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1558 1632
1559 public static void write(object x) 1633 public static void write(object x)
1560 { 1634 {
1635 if (_outputStream == null)
1636 return;
1561 x = YP.getValue(x); 1637 x = YP.getValue(x);
1562 if (x is double) 1638 if (x is double)
1563 _outputStream.Write(doubleToString((double)x)); 1639 _outputStream.Write(doubleToString((double)x));
@@ -1591,6 +1667,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1591 1667
1592 public static void put_code(object x) 1668 public static void put_code(object x)
1593 { 1669 {
1670 if (_outputStream == null)
1671 return;
1594 if (var(x)) 1672 if (var(x))
1595 throw new PrologException(Atom.a("instantiation_error"), "Arg 1 is an unbound variable"); 1673 throw new PrologException(Atom.a("instantiation_error"), "Arg 1 is an unbound variable");
1596 int xInt; 1674 int xInt;
@@ -1602,11 +1680,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1602 1680
1603 public static void nl() 1681 public static void nl()
1604 { 1682 {
1683 if (_outputStream == null)
1684 return;
1605 _outputStream.WriteLine(); 1685 _outputStream.WriteLine();
1606 } 1686 }
1607 1687
1608 public static IEnumerable<bool> get_code(object code) 1688 public static IEnumerable<bool> get_code(object code)
1609 { 1689 {
1690 if (_inputStream == null)
1691 return YP.unify(code, -1);
1692 else
1610 return YP.unify(code, _inputStream.Read()); 1693 return YP.unify(code, _inputStream.Read());
1611 } 1694 }
1612 1695
@@ -1763,7 +1846,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1763 /// <summary> 1846 /// <summary>
1764 /// Match all clauses of the dynamic predicate with the name and with arity 1847 /// Match all clauses of the dynamic predicate with the name and with arity
1765 /// arguments.Length. 1848 /// arguments.Length.
1766 /// It is an error if the predicate is not defined. 1849 /// If the predicate is not defined, return the result of YP.unknownPredicate.
1767 /// </summary> 1850 /// </summary>
1768 /// <param name="name">must be an Atom</param> 1851 /// <param name="name">must be an Atom</param>
1769 /// <param name="arguments">an array of arity number of arguments</param> 1852 /// <param name="arguments">an array of arity number of arguments</param>
@@ -1772,11 +1855,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1772 { 1855 {
1773 List<IClause> clauses; 1856 List<IClause> clauses;
1774 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses)) 1857 if (!_predicatesStore.TryGetValue(new NameArity(name, arguments.Length), out clauses))
1775 throw new PrologException 1858 return unknownPredicate(name, arguments.Length,
1776 (new Functor2 1859 "Undefined dynamic predicate: " + name + "/" + arguments.Length);
1777 (Atom.a("existence_error"), Atom.a("procedure"),
1778 new Functor2(Atom.SLASH, name, arguments.Length)),
1779 "Undefined predicate: " + name + "/" + arguments.Length);
1780 1860
1781 if (clauses.Count == 1) 1861 if (clauses.Count == 1)
1782 // Usually there is only one clause, so return it without needing to wrap it in an iterator. 1862 // Usually there is only one clause, so return it without needing to wrap it in an iterator.
@@ -1809,6 +1889,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1809 } 1889 }
1810 1890
1811 /// <summary> 1891 /// <summary>
1892 /// If _prologFlags["unknown"] is fail then return fail(), else if
1893 /// _prologFlags["unknown"] is warning then write the message to YP.write and
1894 /// return fail(), else throw a PrologException for existence_error. .
1895 /// </summary>
1896 /// <param name="name"></param>
1897 /// <param name="arity"></param>
1898 /// <param name="message"></param>
1899 /// <returns></returns>
1900 public static IEnumerable<bool> unknownPredicate(Atom name, int arity, string message)
1901 {
1902 establishPrologFlags();
1903
1904 if (_prologFlags["unknown"] == Atom.a("fail"))
1905 return fail();
1906 else if (_prologFlags["unknown"] == Atom.a("warning"))
1907 {
1908 write(message);
1909 nl();
1910 return fail();
1911 }
1912 else
1913 throw new PrologException
1914 (new Functor2
1915 (Atom.a("existence_error"), Atom.a("procedure"),
1916 new Functor2(Atom.SLASH, name, arity)), message);
1917 }
1918
1919 /// <summary>
1812 /// This is deprecated and just calls matchDynamic. This matches all clauses, 1920 /// This is deprecated and just calls matchDynamic. This matches all clauses,
1813 /// not just the ones defined with assertFact. 1921 /// not just the ones defined with assertFact.
1814 /// </summary> 1922 /// </summary>
@@ -1951,7 +2059,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1951 _predicatesStore[nameArity] = new List<IClause>(); 2059 _predicatesStore[nameArity] = new List<IClause>();
1952 } 2060 }
1953 2061
1954 public static IEnumerable<bool> current_predicate(object NameSlashArity) 2062 /// <summary>
2063 /// If NameSlashArity is var, match with all the dynamic predicates using the
2064 /// Name/Artity form.
2065 /// If NameSlashArity is not var, check if the Name/Arity exists as a static or
2066 /// dynamic predicate.
2067 /// </summary>
2068 /// <param name="NameSlashArity"></param>
2069 /// <param name="declaringClass">if not null, used to resolve references to the default
2070 /// module Atom.a("")</param>
2071 /// <returns></returns>
2072 public static IEnumerable<bool> current_predicate(object NameSlashArity, Type declaringClass)
1955 { 2073 {
1956 NameSlashArity = YP.getValue(NameSlashArity); 2074 NameSlashArity = YP.getValue(NameSlashArity);
1957 // First check if Name and Arity are nonvar so we can do a direct lookup. 2075 // First check if Name and Arity are nonvar so we can do a direct lookup.
@@ -1976,7 +2094,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1976 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity), 2094 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity),
1977 "Arity may not be less than zero"); 2095 "Arity may not be less than zero");
1978 2096
1979 if (_predicatesStore.ContainsKey(new NameArity((Atom)name, (int)arity))) 2097 if (YPCompiler.isCurrentPredicate((Atom)name, (int)arity, declaringClass))
1980 // The predicate is defined. 2098 // The predicate is defined.
1981 yield return false; 2099 yield return false;
1982 } 2100 }
@@ -1991,6 +2109,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
1991 } 2109 }
1992 } 2110 }
1993 2111
2112 /// <summary>
2113 /// Return true if the dynamic predicate store has an entry for the predicate
2114 /// with name and arity.
2115 /// </summary>
2116 /// <param name="name"></param>
2117 /// <param name="arity"></param>
2118 /// <returns></returns>
2119 public static bool isDynamicCurrentPredicate(Atom name, int arity)
2120 {
2121 return _predicatesStore.ContainsKey(new NameArity(name, arity));
2122 }
2123
1994 public static void abolish(object NameSlashArity) 2124 public static void abolish(object NameSlashArity)
1995 { 2125 {
1996 NameSlashArity = YP.getValue(NameSlashArity); 2126 NameSlashArity = YP.getValue(NameSlashArity);
@@ -2019,6 +2149,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2019 throw new PrologException 2149 throw new PrologException
2020 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity), 2150 (new Functor2("domain_error", Atom.a("not_less_than_zero"), arity),
2021 "Arity may not be less than zero"); 2151 "Arity may not be less than zero");
2152 if ((int)arity > MAX_ARITY)
2153 throw new PrologException
2154 (new Functor1("representation_error", Atom.a("max_arity")),
2155 "Arity may not be greater than " + MAX_ARITY);
2022 2156
2023 if (isSystemPredicate((Atom)name, (int)arity)) 2157 if (isSystemPredicate((Atom)name, (int)arity))
2024 throw new PrologException 2158 throw new PrologException
@@ -2077,7 +2211,108 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2077 { 2211 {
2078 throw new PrologException(Term); 2212 throw new PrologException(Term);
2079 } 2213 }
2214 /// <summary>
2215 /// This must be called by any function that uses YP._prologFlags to make sure
2216 /// the initial defaults are loaded.
2217 /// </summary>
2218 private static void establishPrologFlags()
2219 {
2220 if (_prologFlags.Count > 0)
2221 // Already established.
2222 return;
2223
2224 // List these in the order they appear in the ISO standard.
2225 _prologFlags["bounded"] = Atom.a("true");
2226 _prologFlags["max_integer"] = Int32.MaxValue;
2227 _prologFlags["min_integer"] = Int32.MinValue;
2228 _prologFlags["integer_rounding_function"] = Atom.a("toward_zero");
2229 _prologFlags["char_conversion"] = Atom.a("off");
2230 _prologFlags["debug"] = Atom.a("off");
2231 _prologFlags["max_arity"] = MAX_ARITY;
2232 _prologFlags["unknown"] = Atom.a("error");
2233 _prologFlags["double_quotes"] = Atom.a("codes");
2234 }
2235
2236 public static IEnumerable<bool> current_prolog_flag(object Key, object Value)
2237 {
2238 establishPrologFlags();
2239
2240 Key = YP.getValue(Key);
2241 Value = YP.getValue(Value);
2242
2243 if (Key is Variable)
2244 {
2245 // Bind all key values.
2246 foreach (string key in _prologFlags.Keys)
2247 {
2248 foreach (bool l1 in YP.unify(Key, Atom.a(key)))
2249 {
2250 foreach (bool l2 in YP.unify(Value, _prologFlags[key]))
2251 yield return false;
2252 }
2253 }
2254 }
2255 else
2256 {
2257 if (!(Key is Atom))
2258 throw new PrologException
2259 (new Functor2("type_error", Atom.a("atom"), Key), "Arg 1 Key is not an atom");
2260 if (!_prologFlags.ContainsKey(((Atom)Key)._name))
2261 throw new PrologException
2262 (new Functor2("domain_error", Atom.a("prolog_flag"), Key),
2263 "Arg 1 Key is not a recognized flag");
2264
2265 foreach (bool l1 in YP.unify(Value, _prologFlags[((Atom)Key)._name]))
2266 yield return false;
2267 }
2268 }
2269
2270 public static void set_prolog_flag(object Key, object Value)
2271 {
2272 establishPrologFlags();
2273
2274 Key = YP.getValue(Key);
2275 Value = YP.getValue(Value);
2276
2277 if (Key is Variable)
2278 throw new PrologException(Atom.a("instantiation_error"),
2279 "Arg 1 Key is an unbound variable");
2280 if (Value is Variable)
2281 throw new PrologException(Atom.a("instantiation_error"),
2282 "Arg 1 Key is an unbound variable");
2283 if (!(Key is Atom))
2284 throw new PrologException
2285 (new Functor2("type_error", Atom.a("atom"), Key), "Arg 1 Key is not an atom");
2286
2287 string keyName = ((Atom)Key)._name;
2288 if (!_prologFlags.ContainsKey(keyName))
2289 throw new PrologException
2290 (new Functor2("domain_error", Atom.a("prolog_flag"), Key),
2291 "Arg 1 Key " + Key + " is not a recognized flag");
2292
2293 bool valueIsOK = false;
2294 if (keyName == "char_conversion")
2295 valueIsOK = (Value == _prologFlags[keyName]);
2296 else if (keyName == "debug")
2297 valueIsOK = (Value == _prologFlags[keyName]);
2298 else if (keyName == "unknown")
2299 valueIsOK = (Value == Atom.a("fail") || Value == Atom.a("warning") ||
2300 Value == Atom.a("error"));
2301 else if (keyName == "double_quotes")
2302 valueIsOK = (Value == Atom.a("codes") || Value == Atom.a("chars") ||
2303 Value == Atom.a("atom"));
2304 else
2305 throw new PrologException
2306 (new Functor3("permission_error", Atom.a("modify"), Atom.a("flag"), Key),
2307 "May not modify Prolog flag " + Key);
2080 2308
2309 if (!valueIsOK)
2310 throw new PrologException
2311 (new Functor2("domain_error", Atom.a("flag_value"), new Functor2("+", Key, Value)),
2312 "May not set arg 1 Key " + Key + " to arg 2 Value " + Value);
2313
2314 _prologFlags[keyName] = Value;
2315 }
2081 /// <summary> 2316 /// <summary>
2082 /// script_event calls hosting script with events as a callback method. 2317 /// script_event calls hosting script with events as a callback method.
2083 /// </summary> 2318 /// </summary>
@@ -2303,19 +2538,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2303 private IEnumerator<bool> _enumerator; 2538 private IEnumerator<bool> _enumerator;
2304 private PrologException _exception = null; 2539 private PrologException _exception = null;
2305 2540
2306 public Catch(IEnumerable<bool> iterator) 2541 /// <summary>
2542 /// Call YP.getIterator(Goal, declaringClass) and save the returned iterator.
2543 /// If getIterator throws an exception, save it the same as MoveNext().
2544 /// </summary>
2545 /// <param name="Goal"></param>
2546 /// <param name="declaringClass"></param>
2547 public Catch(object Goal, Type declaringClass)
2548 {
2549 try
2307 { 2550 {
2308 _enumerator = iterator.GetEnumerator(); 2551 _enumerator = getIterator(Goal, declaringClass).GetEnumerator();
2552 }
2553 catch (PrologException exception)
2554 {
2555 // MoveNext() will check this.
2556 _exception = exception;
2557 }
2309 } 2558 }
2310 2559
2311 /// <summary> 2560 /// <summary>
2312 /// Call _enumerator.MoveNext(). If it throws a PrologException, set _exception 2561 /// Call _enumerator.MoveNext(). If it throws a PrologException, set _exception
2313 /// and return false. After this returns false, call unifyExceptionOrThrow. 2562 /// and return false. After this returns false, call unifyExceptionOrThrow.
2314 /// Assume that, after this returns false, it will not be called again.
2315 /// </summary> 2563 /// </summary>
2316 /// <returns></returns> 2564 /// <returns></returns>
2317 public bool MoveNext() 2565 public bool MoveNext()
2318 { 2566 {
2567 if (_exception != null)
2568 return false;
2569
2319 try 2570 try
2320 { 2571 {
2321 return _enumerator.MoveNext(); 2572 return _enumerator.MoveNext();
@@ -2372,6 +2623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2372 2623
2373 public void Dispose() 2624 public void Dispose()
2374 { 2625 {
2626 if (_enumerator != null)
2375 _enumerator.Dispose(); 2627 _enumerator.Dispose();
2376 } 2628 }
2377 2629
@@ -2407,7 +2659,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
2407 foreach (bool l2 in YP.unify(Body, _Body)) 2659 foreach (bool l2 in YP.unify(Body, _Body))
2408 yield return false; 2660 yield return false;
2409 } 2661 }
2410 #pragma warning disable 0168 2662 #pragma warning restore 0168
2663 }
2664 }
2665
2666 /// <summary>
2667 /// CodeListReader extends TextReader and overrides Read to read the next code from
2668 /// the CodeList which is a Prolog list of integer character codes.
2669 /// </summary>
2670 public class CodeListReader : TextReader
2671 {
2672 private object _CodeList;
2673
2674 public CodeListReader(object CodeList)
2675 {
2676 _CodeList = YP.getValue(CodeList);
2677 }
2678
2679 /// <summary>
2680 /// If the head of _CodeList is an integer, return it and advance the list. Otherwise,
2681 /// return -1 for end of file.
2682 /// </summary>
2683 /// <returns></returns>
2684 public override int Read()
2685 {
2686 Functor2 CodeListPair = _CodeList as Functor2;
2687 int code;
2688 if (!(CodeListPair != null && CodeListPair._name == Atom.DOT &&
2689 getInt(CodeListPair._arg1, out code)))
2690 {
2691 _CodeList = Atom.NIL;
2692 return -1;
2693 }
2694
2695 // Advance.
2696 _CodeList = YP.getValue(CodeListPair._arg2);
2697 return code;
2411 } 2698 }
2412 } 2699 }
2413 } 2700 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
index 1f1b41d..de7f168 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs
@@ -203,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
203 203
204 // disable warning on l1, don't see how we can 204 // disable warning on l1, don't see how we can
205 // code this differently 205 // code this differently
206 #pragma warning disable 0168, 0164, 0162 206 #pragma warning disable 0168,0164,0162
207 public static bool isDetNoneOut(object State, object Term) 207 public static bool isDetNoneOut(object State, object Term)
208 { 208 {
209 State = YP.getValue(State); 209 State = YP.getValue(State);
@@ -241,7 +241,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
241 241
242 return false; 242 return false;
243 } 243 }
244 #pragma warning restore 0168, 0164, 0162 244 #pragma warning restore 0168,0164,0162
245 245
246 /// <summary> 246 /// <summary>
247 /// Return false if any of args is out, otherwise true. 247 /// Return false if any of args is out, otherwise true.
@@ -280,7 +280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
280 280
281 // disable warning on l1, don't see how we can 281 // disable warning on l1, don't see how we can
282 // code this differently 282 // code this differently
283 #pragma warning disable 0168, 0219, 0164, 0162 283 #pragma warning disable 0168, 0219,0164,0162
284 284
285 /// <summary> 285 /// <summary>
286 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction 286 /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction
@@ -405,8 +405,8 @@ namespace Temporary {
405 /// <summary> 405 /// <summary>
406 /// If the functor with name and args can be called directly as determined by 406 /// If the functor with name and args can be called directly as determined by
407 /// functorCallFunctionName, then call it and return its iterator. If the predicate is 407 /// functorCallFunctionName, then call it and return its iterator. If the predicate is
408 /// dynamic and undefined, or if static and the method cannot be found, throw 408 /// dynamic and undefined, or if static and the method cannot be found, return
409 /// a PrologException for existence_error. 409 /// the result of YP.unknownPredicate.
410 /// This returns null if the functor has a special form than needs to be compiled 410 /// This returns null if the functor has a special form than needs to be compiled
411 /// (including ,/2 and ;/2). 411 /// (including ,/2 and ;/2).
412 /// </summary> 412 /// </summary>
@@ -424,13 +424,11 @@ namespace Temporary {
424 { 424 {
425 Atom functionNameAtom = ((Atom)FunctionName.getValue()); 425 Atom functionNameAtom = ((Atom)FunctionName.getValue());
426 if (functionNameAtom == Atom.NIL) 426 if (functionNameAtom == Atom.NIL)
427 {
428 // name is for a dynamic predicate. 427 // name is for a dynamic predicate.
429 return YP.matchDynamic(name, args); 428 return YP.matchDynamic(name, args);
430 }
431 429
432 // Set the default for the method to call.
433 string methodName = functionNameAtom._name; 430 string methodName = functionNameAtom._name;
431 // Set the default for the method to call.
434 Type methodClass = declaringClass; 432 Type methodClass = declaringClass;
435 433
436 bool checkMode = false; 434 bool checkMode = false;
@@ -448,10 +446,8 @@ namespace Temporary {
448 return null; 446 return null;
449 447
450 if (methodClass == null) 448 if (methodClass == null)
451 throw new PrologException 449 return YP.unknownPredicate
452 (new Functor2 450 (name, args.Length,
453 (Atom.a("existence_error"), Atom.a("procedure"),
454 new Functor2(Atom.a("/"), name, args.Length)),
455 "Cannot find predicate function for: " + name + "/" + args.Length + 451 "Cannot find predicate function for: " + name + "/" + args.Length +
456 " because declaringClass is null. Set declaringClass to the class containing " + 452 " because declaringClass is null. Set declaringClass to the class containing " +
457 methodName); 453 methodName);
@@ -486,10 +482,8 @@ namespace Temporary {
486 } 482 }
487 catch (MissingMethodException) 483 catch (MissingMethodException)
488 { 484 {
489 throw new PrologException 485 return YP.unknownPredicate
490 (new Functor2 486 (name, args.Length,
491 (Atom.a("existence_error"), Atom.a("procedure"),
492 new Functor2(Atom.a("/"), name, args.Length)),
493 "Cannot find predicate function " + methodName + " for " + name + "/" + args.Length + 487 "Cannot find predicate function " + methodName + " for " + name + "/" + args.Length +
494 " in " + methodClass.FullName); 488 " in " + methodClass.FullName);
495 } 489 }
@@ -498,6 +492,54 @@ namespace Temporary {
498 return null; 492 return null;
499 } 493 }
500 494
495 /// <summary>
496 /// Return true if there is a dynamic or static predicate with name and arity.
497 /// This returns false for built-in predicates.
498 /// </summary>
499 /// <param name="name"></param>
500 /// <param name="arity"></param>
501 /// <param name="declaringClass">used to resolve references to the default
502 /// module Atom.a(""). If a declaringClass is needed to resolve the reference but it is
503 /// null, return false</param>
504 /// <returns></returns>
505 public static bool isCurrentPredicate(Atom name, int arity, Type declaringClass)
506 {
507 CompilerState state = new CompilerState();
508 Variable FunctionName = new Variable();
509 foreach (bool l1 in functorCallFunctionName(state, name, arity, FunctionName))
510 {
511 Atom functionNameAtom = ((Atom)FunctionName.getValue());
512 if (functionNameAtom == Atom.NIL)
513 // name is for a dynamic predicate.
514 return YP.isDynamicCurrentPredicate(name, arity);
515
516 string methodName = functionNameAtom._name;
517
518 if (methodName.StartsWith("YP."))
519 // current_predicate/1 should fail for built-ins.
520 return false;
521 if (methodName.Contains("."))
522 // We don't support calling inner classes, etc.
523 return false;
524 if (declaringClass == null)
525 return false;
526
527 foreach (MemberInfo member in declaringClass.GetMember(methodName))
528 {
529 MethodInfo method = member as MethodInfo;
530 if (method == null)
531 continue;
532 if ((method.Attributes | MethodAttributes.Static) == 0)
533 // Not a static method.
534 continue;
535 if (method.GetParameters().Length == arity)
536 return true;
537 }
538 }
539
540 return false;
541 }
542
501 // Compiler output follows. 543 // Compiler output follows.
502 544
503 public class YPInnerClass { } 545 public class YPInnerClass { }
@@ -567,9 +609,14 @@ namespace Temporary {
567 CompilerState.assertPred(State, Atom.a("nl"), Atom.a("det")); 609 CompilerState.assertPred(State, Atom.a("nl"), Atom.a("det"));
568 CompilerState.assertPred(State, new Functor1("write", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 610 CompilerState.assertPred(State, new Functor1("write", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
569 CompilerState.assertPred(State, new Functor1("put_code", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 611 CompilerState.assertPred(State, new Functor1("put_code", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
612 CompilerState.assertPred(State, new Functor1("see", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
613 CompilerState.assertPred(State, Atom.a("seen"), Atom.a("det"));
614 CompilerState.assertPred(State, new Functor1("tell", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
615 CompilerState.assertPred(State, Atom.a("told"), Atom.a("det"));
570 CompilerState.assertPred(State, new Functor1("throw", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 616 CompilerState.assertPred(State, new Functor1("throw", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
571 CompilerState.assertPred(State, new Functor1("abolish", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 617 CompilerState.assertPred(State, new Functor1("abolish", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
572 CompilerState.assertPred(State, new Functor1("retractall", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det")); 618 CompilerState.assertPred(State, new Functor1("retractall", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
619 CompilerState.assertPred(State, new Functor2("set_prolog_flag", new Functor2("::", Atom.a("univ"), Atom.a("in")), new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("det"));
573 CompilerState.assertPred(State, new Functor1("var", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet")); 620 CompilerState.assertPred(State, new Functor1("var", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
574 CompilerState.assertPred(State, new Functor1("nonvar", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet")); 621 CompilerState.assertPred(State, new Functor1("nonvar", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
575 CompilerState.assertPred(State, new Functor1("atom", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet")); 622 CompilerState.assertPred(State, new Functor1("atom", new Functor2("::", Atom.a("univ"), Atom.a("in"))), Atom.a("semidet"));
@@ -2121,7 +2168,7 @@ namespace Temporary {
2121 { 2168 {
2122 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))) 2169 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)))
2123 { 2170 {
2124 foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL))))) 2171 foreach (bool l4 in YP.univ(A, ListPair.make(new object[] { Name, X1, X2 })))
2125 { 2172 {
2126 foreach (bool l5 in binaryExpressionConditional(Name, FunctionName)) 2173 foreach (bool l5 in binaryExpressionConditional(Name, FunctionName))
2127 { 2174 {
@@ -2236,6 +2283,27 @@ namespace Temporary {
2236 Variable B = new Variable(); 2283 Variable B = new Variable();
2237 Variable ATermCode = new Variable(); 2284 Variable ATermCode = new Variable();
2238 Variable BCode = new Variable(); 2285 Variable BCode = new Variable();
2286 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("current_predicate", A), B)))
2287 {
2288 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.current_predicate"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode), Atom.NIL)))
2289 {
2290 foreach (bool l4 in compileTerm(A, State, ATermCode))
2291 {
2292 foreach (bool l5 in compileRuleBody(B, State, BCode))
2293 {
2294 yield return true;
2295 yield break;
2296 }
2297 }
2298 }
2299 }
2300 }
2301 {
2302 object State = arg2;
2303 Variable A = new Variable();
2304 Variable B = new Variable();
2305 Variable ATermCode = new Variable();
2306 Variable BCode = new Variable();
2239 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("asserta", A), B))) 2307 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor1("asserta", A), B)))
2240 { 2308 {
2241 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("call", Atom.a("YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode))) 2309 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2("call", Atom.a("YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
@@ -2299,7 +2367,7 @@ namespace Temporary {
2299 Variable HandlerAndBCode = new Variable(); 2367 Variable HandlerAndBCode = new Variable();
2300 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("catch", Goal, Catcher, Handler), B))) 2368 foreach (bool l2 in YP.unify(arg1, new Functor2(",", new Functor3("catch", Goal, Catcher, Handler), B)))
2301 { 2369 {
2302 foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3("declare", Atom.a("YP.Catch"), CatchGoal, new Functor2("new", Atom.a("YP.Catch"), new ListPair(new Functor2("call", Atom.a("YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2("foreach", new Functor1("var", CatchGoal), BCode), new ListPair(new Functor2("foreach", new Functor3("callMember", new Functor1("var", CatchGoal), Atom.a("unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL))))) 2370 foreach (bool l3 in YP.unify(arg3, ListPair.make(new object[] { new Functor3("declare", Atom.a("YP.Catch"), CatchGoal, new Functor2("new", Atom.a("YP.Catch"), new ListPair(GoalTermCode, new ListPair(new Functor2("call", Atom.a("getDeclaringClass"), Atom.NIL), Atom.NIL)))), new Functor2("foreach", new Functor1("var", CatchGoal), BCode), new Functor2("foreach", new Functor3("callMember", new Functor1("var", CatchGoal), Atom.a("unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode) })))
2303 { 2371 {
2304 foreach (bool l4 in CompilerState.gensym(State, Atom.a("catchGoal"), CatchGoal)) 2372 foreach (bool l4 in CompilerState.gensym(State, Atom.a("catchGoal"), CatchGoal))
2305 { 2373 {
@@ -2833,6 +2901,10 @@ namespace Temporary {
2833 { 2901 {
2834 return true; 2902 return true;
2835 } 2903 }
2904 if (YP.termEqual(Name, Atom.a("current_predicate")))
2905 {
2906 return true;
2907 }
2836 if (YP.termEqual(Name, Atom.a("asserta"))) 2908 if (YP.termEqual(Name, Atom.a("asserta")))
2837 { 2909 {
2838 return true; 2910 return true;
@@ -3016,19 +3088,6 @@ namespace Temporary {
3016 } 3088 }
3017 } 3089 }
3018 { 3090 {
3019 foreach (bool l2 in YP.unify(arg1, Atom.a("current_predicate")))
3020 {
3021 foreach (bool l3 in YP.unify(arg2, 1))
3022 {
3023 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_predicate")))
3024 {
3025 yield return true;
3026 yield break;
3027 }
3028 }
3029 }
3030 }
3031 {
3032 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_length"))) 3091 foreach (bool l2 in YP.unify(arg1, Atom.a("atom_length")))
3033 { 3092 {
3034 foreach (bool l3 in YP.unify(arg2, 2)) 3093 foreach (bool l3 in YP.unify(arg2, 2))
@@ -3214,6 +3273,58 @@ namespace Temporary {
3214 } 3273 }
3215 } 3274 }
3216 { 3275 {
3276 foreach (bool l2 in YP.unify(arg1, Atom.a("see")))
3277 {
3278 foreach (bool l3 in YP.unify(arg2, 1))
3279 {
3280 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.see")))
3281 {
3282 yield return true;
3283 yield break;
3284 }
3285 }
3286 }
3287 }
3288 {
3289 foreach (bool l2 in YP.unify(arg1, Atom.a("seen")))
3290 {
3291 foreach (bool l3 in YP.unify(arg2, 0))
3292 {
3293 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.seen")))
3294 {
3295 yield return true;
3296 yield break;
3297 }
3298 }
3299 }
3300 }
3301 {
3302 foreach (bool l2 in YP.unify(arg1, Atom.a("tell")))
3303 {
3304 foreach (bool l3 in YP.unify(arg2, 1))
3305 {
3306 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.tell")))
3307 {
3308 yield return true;
3309 yield break;
3310 }
3311 }
3312 }
3313 }
3314 {
3315 foreach (bool l2 in YP.unify(arg1, Atom.a("told")))
3316 {
3317 foreach (bool l3 in YP.unify(arg2, 0))
3318 {
3319 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.told")))
3320 {
3321 yield return true;
3322 yield break;
3323 }
3324 }
3325 }
3326 }
3327 {
3217 foreach (bool l2 in YP.unify(arg1, Atom.a("clause"))) 3328 foreach (bool l2 in YP.unify(arg1, Atom.a("clause")))
3218 { 3329 {
3219 foreach (bool l3 in YP.unify(arg2, 2)) 3330 foreach (bool l3 in YP.unify(arg2, 2))
@@ -3434,6 +3545,110 @@ namespace Temporary {
3434 } 3545 }
3435 } 3546 }
3436 } 3547 }
3548 {
3549 foreach (bool l2 in YP.unify(arg1, Atom.a("current_prolog_flag")))
3550 {
3551 foreach (bool l3 in YP.unify(arg2, 2))
3552 {
3553 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_prolog_flag")))
3554 {
3555 yield return true;
3556 yield break;
3557 }
3558 }
3559 }
3560 }
3561 {
3562 foreach (bool l2 in YP.unify(arg1, Atom.a("set_prolog_flag")))
3563 {
3564 foreach (bool l3 in YP.unify(arg2, 2))
3565 {
3566 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.set_prolog_flag")))
3567 {
3568 yield return true;
3569 yield break;
3570 }
3571 }
3572 }
3573 }
3574 {
3575 foreach (bool l2 in YP.unify(arg1, Atom.a("current_input")))
3576 {
3577 foreach (bool l3 in YP.unify(arg2, 1))
3578 {
3579 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_input")))
3580 {
3581 yield return true;
3582 yield break;
3583 }
3584 }
3585 }
3586 }
3587 {
3588 foreach (bool l2 in YP.unify(arg1, Atom.a("current_output")))
3589 {
3590 foreach (bool l3 in YP.unify(arg2, 1))
3591 {
3592 foreach (bool l4 in YP.unify(arg3, Atom.a("YP.current_output")))
3593 {
3594 yield return true;
3595 yield break;
3596 }
3597 }
3598 }
3599 }
3600 {
3601 foreach (bool l2 in YP.unify(arg1, Atom.a("read_term")))
3602 {
3603 foreach (bool l3 in YP.unify(arg2, 2))
3604 {
3605 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read_term2")))
3606 {
3607 yield return true;
3608 yield break;
3609 }
3610 }
3611 }
3612 }
3613 {
3614 foreach (bool l2 in YP.unify(arg1, Atom.a("read_term")))
3615 {
3616 foreach (bool l3 in YP.unify(arg2, 3))
3617 {
3618 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read_term3")))
3619 {
3620 yield return true;
3621 yield break;
3622 }
3623 }
3624 }
3625 }
3626 {
3627 foreach (bool l2 in YP.unify(arg1, Atom.a("read")))
3628 {
3629 foreach (bool l3 in YP.unify(arg2, 1))
3630 {
3631 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read1")))
3632 {
3633 yield return true;
3634 yield break;
3635 }
3636 }
3637 }
3638 }
3639 {
3640 foreach (bool l2 in YP.unify(arg1, Atom.a("read")))
3641 {
3642 foreach (bool l3 in YP.unify(arg2, 2))
3643 {
3644 foreach (bool l4 in YP.unify(arg3, Atom.a("Parser.read2")))
3645 {
3646 yield return true;
3647 yield break;
3648 }
3649 }
3650 }
3651 }
3437 } 3652 }
3438 3653
3439 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3) 3654 public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
@@ -3494,6 +3709,34 @@ namespace Temporary {
3494 object State = arg2; 3709 object State = arg2;
3495 Variable First = new Variable(); 3710 Variable First = new Variable();
3496 Variable Rest = new Variable(); 3711 Variable Rest = new Variable();
3712 Variable CompiledList = new Variable();
3713 Variable x5 = new Variable();
3714 Variable Rest2 = new Variable();
3715 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
3716 {
3717 foreach (bool l3 in YP.unify(arg3, new Functor2("call", Atom.a("ListPair.make"), new ListPair(new Functor1("objectArray", CompiledList), Atom.NIL))))
3718 {
3719 if (YP.nonvar(Rest))
3720 {
3721 foreach (bool l5 in YP.unify(Rest, new ListPair(x5, Rest2)))
3722 {
3723 if (YP.termNotEqual(Rest2, Atom.NIL))
3724 {
3725 foreach (bool l7 in maplist_compileTerm(new ListPair(First, Rest), State, CompiledList))
3726 {
3727 yield return true;
3728 yield break;
3729 }
3730 }
3731 }
3732 }
3733 }
3734 }
3735 }
3736 {
3737 object State = arg2;
3738 Variable First = new Variable();
3739 Variable Rest = new Variable();
3497 Variable Arg1 = new Variable(); 3740 Variable Arg1 = new Variable();
3498 Variable Arg2 = new Variable(); 3741 Variable Arg2 = new Variable();
3499 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest))) 3742 foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
@@ -3563,7 +3806,7 @@ namespace Temporary {
3563 { 3806 {
3564 foreach (bool l8 in compileTerm(X2, State, Arg2)) 3807 foreach (bool l8 in compileTerm(X2, State, Arg2))
3565 { 3808 {
3566 foreach (bool l9 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) 3809 foreach (bool l9 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), ListPair.make(new object[] { NameCode, Arg1, Arg2 }))))
3567 { 3810 {
3568 yield return true; 3811 yield return true;
3569 yield break; 3812 yield break;
@@ -3572,7 +3815,7 @@ namespace Temporary {
3572 } 3815 }
3573 goto cutIf5; 3816 goto cutIf5;
3574 } 3817 }
3575 foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) 3818 foreach (bool l6 in YP.unify(TermArgs, ListPair.make(new object[] { X1, X2, X3 })))
3576 { 3819 {
3577 foreach (bool l7 in compileTerm(X1, State, Arg1)) 3820 foreach (bool l7 in compileTerm(X1, State, Arg1))
3578 { 3821 {
@@ -3580,7 +3823,7 @@ namespace Temporary {
3580 { 3823 {
3581 foreach (bool l9 in compileTerm(X3, State, Arg3)) 3824 foreach (bool l9 in compileTerm(X3, State, Arg3))
3582 { 3825 {
3583 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))))))) 3826 foreach (bool l10 in YP.unify(Result, new Functor2("new", Atom.a("Functor3"), ListPair.make(new object[] { NameCode, Arg1, Arg2, Arg3 }))))
3584 { 3827 {
3585 yield return true; 3828 yield return true;
3586 yield break; 3829 yield break;
@@ -3623,7 +3866,7 @@ namespace Temporary {
3623 { 3866 {
3624 foreach (bool l7 in compileTerm(X2, State, Arg2)) 3867 foreach (bool l7 in compileTerm(X2, State, Arg2))
3625 { 3868 {
3626 foreach (bool l8 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))) 3869 foreach (bool l8 in YP.unify(Result, new Functor2("new", Atom.a("Functor2"), ListPair.make(new object[] { NameCode, Arg1, Arg2 }))))
3627 { 3870 {
3628 yield return true; 3871 yield return true;
3629 yield break; 3872 yield break;
@@ -3632,7 +3875,7 @@ namespace Temporary {
3632 } 3875 }
3633 goto cutIf7; 3876 goto cutIf7;
3634 } 3877 }
3635 foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL))))) 3878 foreach (bool l5 in YP.unify(TermArgs, ListPair.make(new object[] { X1, X2, X3 })))
3636 { 3879 {
3637 foreach (bool l6 in compileTerm(X1, State, Arg1)) 3880 foreach (bool l6 in compileTerm(X1, State, Arg1))
3638 { 3881 {
@@ -3640,7 +3883,7 @@ namespace Temporary {
3640 { 3883 {
3641 foreach (bool l8 in compileTerm(X3, State, Arg3)) 3884 foreach (bool l8 in compileTerm(X3, State, Arg3))
3642 { 3885 {
3643 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))))))) 3886 foreach (bool l9 in YP.unify(Result, new Functor2("new", Atom.a("Functor3"), ListPair.make(new object[] { NameCode, Arg1, Arg2, Arg3 }))))
3644 { 3887 {
3645 yield return true; 3888 yield return true;
3646 yield break; 3889 yield break;
@@ -3725,9 +3968,11 @@ namespace Temporary {
3725 { 3968 {
3726 foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults))) 3969 foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
3727 { 3970 {
3728 foreach (bool l4 in compileTerm(First, State, FirstResult)) 3971 if (YP.nonvar(Rest))
3972 {
3973 foreach (bool l5 in compileTerm(First, State, FirstResult))
3729 { 3974 {
3730 foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults)) 3975 foreach (bool l6 in maplist_compileTerm(Rest, State, RestResults))
3731 { 3976 {
3732 yield return true; 3977 yield return true;
3733 yield break; 3978 yield break;
@@ -3737,6 +3982,7 @@ namespace Temporary {
3737 } 3982 }
3738 } 3983 }
3739 } 3984 }
3985 }
3740 3986
3741 public static IEnumerable<bool> compileExpression(object Term, object State, object Result) 3987 public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
3742 { 3988 {
@@ -6131,6 +6377,6 @@ namespace Temporary {
6131 } 6377 }
6132 } 6378 }
6133 } 6379 }
6134 #pragma warning restore 0168, 0219, 0164, 0162 6380 #pragma warning restore 0168, 0219, 0164,0162
6135 } 6381 }
6136} 6382}