From 323ada012d3bed0c6f7a6d5d0ee14b409b7457c7 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 13 Aug 2008 14:13:49 +0000 Subject: 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 --- .../DotNetEngine/Compiler/YieldProlog/README.TXT | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/README.TXT') 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 * Compiler is generated by compiling the Prolog descrition of itself into C# * Same script entry interface as LSL +* Yield Prolog 1.0.1 Released : it passes all but 9 of the 421 tests in the ISO Prolog test suite (97.8%). TODO * Utilize ability to generate Javascript and Python code @@ -117,6 +118,113 @@ void retractdb2(string predicate, string arg1, string arg2) YP.retractFact(name, new object[] { arg1, arg2 }); } +----------- IMPORT EXTERNAL FUNCTIONS ---------- +Using 'import' to call a static function + +Taken mostly from http://yieldprolog.sourceforge.net/tutorial4.html + +If we want to call a static function but it is not defined in the Prolog code, we can simply add an import directive. +(In Prolog, if you start a line with :- it is a directive to the compiler. Don't forget to end with a period.): + +:- import('', [parent/2]). +uncle(Person, Uncle):- parent(Person, Parent), brother(Parent, Uncle). + +The import directive has two arguments. +The first argument is the module where the imported function is found, which is always ''. +For C#, this means the imported function is in the same class as the calling function. +For Javascript and Python, this means the imported function is in the global scope. +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. +In this example, parent has two arguments, so we use parent/2. + +Note: you can use an imported function in a dynamically defined goal, or a function in another class. + +:- import('', [parent/2]). +uncle(Person, Uncle) :- Goal = parent(Person, Parent), Goal, brother(Parent, Uncle). + +:- import('', ['OtherClass.parent'/2]). +uncle(Person, Uncle) :- 'OtherClass.parent'(Person, Parent), brother(Parent, Uncle). + +--------- Round-about Hello Wonderful world ---------- +//yp +:-import('',[sayit/1]). +sayhello(X):-sayit(X). + +//cs +public void default_event_state_entry() + { + llSay(0,"prolog hello."); + foreach( bool ans in sayhello(Atom.a(@"wonderful world") )){}; + } + +PrologCallback sayit(object ans) + { + llSay(0,"sayit1"); + string msg = "one answer is :"+((Variable)ans).getValue(); + llSay(0,msg); + yield return false; + } + +------------------ UPDATES ----------------- +Yield Prolog 1.0 Released : It passes all but 15 of the 421 tests in the ISO Prolog test suite. + +New Features: +* Added support for Prolog predicates read and read_term. +* In see, Added support for a char code list as the input. +Using this as the input for "fred" makes +set_prolog_flag(double_quotes, atom) and +set_prolog_flag(double_quotes, chars) pass the ISO test suite. + +Fixed Bugs: +* In atom_chars, check for unbound tail in the char list. +This makes atom_chars pass the ISO test suite. +* In current_predicate, also check for static functions. +This makes current_predicate pass the ISO test suite. + +Known Issues: + +Here are the 9 errors of the 421 tests in the ISO test suite in +YieldProlog\source\prolog\isoTestSuite.P . +Some of these have a good excuse for why Yield Prolog produces the error. The rest will be addressed in a future maintenance release. + +Goal: call((fail, 1)) +Expected: type_error(callable, (fail, 1)) +Extra Solutions found: failure + +Goal: call((write(3), 1)) +Expected: type_error(callable, (write(3), 1)) +Extra Solutions found: type_error(callable, 1) + +Goal: call((1; true)) +Expected: type_error(callable, (1 ; true)) +Extra Solutions found: type_error(callable, 1) + +Goal: (catch(true, C, write('something')), throw(blabla)) +Expected: system_error +Extra Solutions found: unexpected_ball(blabla) + +Goal: catch(number_chars(A,L), error(instantiation_error, _), fail) +Expected: failure +Extra Solutions found: instantiation_error + +Goal: Goal: (X = 1 + 2, 'is'(Y, X * 3)) +Expected: [[X <-- (1 + 2), Y <-- 9]] +Extra Solutions found: type_error(evaluable, /(+, 2)) + +Goal: 'is'(77, N) +Expected: instantiation_error +Extra Solutions found: N <-- 77) + +Goal: \+(!, fail) +Expected: success +Extra Solutions found: failure + +((X=1;X=2), \+((!,fail))) +Expected: [[X <-- 1],[X <-- 2]] +Extra Solutions found: failure + + + + ========================= APPENDIX A: touch test ================================ @@ -403,3 +511,4 @@ public IEnumerable prolog_notify(object X) { } } + -- cgit v1.1