diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT | 109 |
1 files changed, 109 insertions, 0 deletions
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 | ||
33 | TODO | 34 | TODO |
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 ---------- | ||
122 | Using 'import' to call a static function | ||
123 | |||
124 | Taken mostly from http://yieldprolog.sourceforge.net/tutorial4.html | ||
125 | |||
126 | If 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]). | ||
130 | uncle(Person, Uncle):- parent(Person, Parent), brother(Parent, Uncle). | ||
131 | |||
132 | The import directive has two arguments. | ||
133 | The first argument is the module where the imported function is found, which is always ''. | ||
134 | For C#, this means the imported function is in the same class as the calling function. | ||
135 | For Javascript and Python, this means the imported function is in the global scope. | ||
136 | The 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. | ||
137 | In this example, parent has two arguments, so we use parent/2. | ||
138 | |||
139 | Note: you can use an imported function in a dynamically defined goal, or a function in another class. | ||
140 | |||
141 | :- import('', [parent/2]). | ||
142 | uncle(Person, Uncle) :- Goal = parent(Person, Parent), Goal, brother(Parent, Uncle). | ||
143 | |||
144 | :- import('', ['OtherClass.parent'/2]). | ||
145 | uncle(Person, Uncle) :- 'OtherClass.parent'(Person, Parent), brother(Parent, Uncle). | ||
146 | |||
147 | --------- Round-about Hello Wonderful world ---------- | ||
148 | //yp | ||
149 | :-import('',[sayit/1]). | ||
150 | sayhello(X):-sayit(X). | ||
151 | |||
152 | //cs | ||
153 | public void default_event_state_entry() | ||
154 | { | ||
155 | llSay(0,"prolog hello."); | ||
156 | foreach( bool ans in sayhello(Atom.a(@"wonderful world") )){}; | ||
157 | } | ||
158 | |||
159 | PrologCallback 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 ----------------- | ||
168 | Yield Prolog 1.0 Released : It passes all but 15 of the 421 tests in the ISO Prolog test suite. | ||
169 | |||
170 | New Features: | ||
171 | * Added support for Prolog predicates read and read_term. | ||
172 | * In see, Added support for a char code list as the input. | ||
173 | Using this as the input for "fred" makes | ||
174 | set_prolog_flag(double_quotes, atom) and | ||
175 | set_prolog_flag(double_quotes, chars) pass the ISO test suite. | ||
176 | |||
177 | Fixed Bugs: | ||
178 | * In atom_chars, check for unbound tail in the char list. | ||
179 | This makes atom_chars pass the ISO test suite. | ||
180 | * In current_predicate, also check for static functions. | ||
181 | This makes current_predicate pass the ISO test suite. | ||
182 | |||
183 | Known Issues: | ||
184 | |||
185 | Here are the 9 errors of the 421 tests in the ISO test suite in | ||
186 | YieldProlog\source\prolog\isoTestSuite.P . | ||
187 | Some of these have a good excuse for why Yield Prolog produces the error. The rest will be addressed in a future maintenance release. | ||
188 | |||
189 | Goal: call((fail, 1)) | ||
190 | Expected: type_error(callable, (fail, 1)) | ||
191 | Extra Solutions found: failure | ||
192 | |||
193 | Goal: call((write(3), 1)) | ||
194 | Expected: type_error(callable, (write(3), 1)) | ||
195 | Extra Solutions found: type_error(callable, 1) | ||
196 | |||
197 | Goal: call((1; true)) | ||
198 | Expected: type_error(callable, (1 ; true)) | ||
199 | Extra Solutions found: type_error(callable, 1) | ||
200 | |||
201 | Goal: (catch(true, C, write('something')), throw(blabla)) | ||
202 | Expected: system_error | ||
203 | Extra Solutions found: unexpected_ball(blabla) | ||
204 | |||
205 | Goal: catch(number_chars(A,L), error(instantiation_error, _), fail) | ||
206 | Expected: failure | ||
207 | Extra Solutions found: instantiation_error | ||
208 | |||
209 | Goal: Goal: (X = 1 + 2, 'is'(Y, X * 3)) | ||
210 | Expected: [[X <-- (1 + 2), Y <-- 9]] | ||
211 | Extra Solutions found: type_error(evaluable, /(+, 2)) | ||
212 | |||
213 | Goal: 'is'(77, N) | ||
214 | Expected: instantiation_error | ||
215 | Extra Solutions found: N <-- 77) | ||
216 | |||
217 | Goal: \+(!, fail) | ||
218 | Expected: success | ||
219 | Extra Solutions found: failure | ||
220 | |||
221 | ((X=1;X=2), \+((!,fail))) | ||
222 | Expected: [[X <-- 1],[X <-- 2]] | ||
223 | Extra 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 | |||