This commit is contained in:
Vitor Santos Costa 2016-08-01 21:45:42 -05:00
commit 4628adc63e
72 changed files with 8053 additions and 54 deletions

View File

@ -1527,7 +1527,7 @@ void Yap_fail_all(choiceptr bb USES_REGS) {
P = saved_p;
}
bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
bool Yap_execute_pred( PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
yamop *saved_p, *saved_cp;
yamop *CodeAdr;
bool out;

2
DisabledFeatures.txt Normal file
View File

@ -0,0 +1,2 @@
* Threads Support <http://www.gnu.org/software/threads>
GNU Threads Library (or similar)

2
EnabledFeatures.txt Normal file
View File

@ -0,0 +1,2 @@
* GNU libgmp (in some cases MPIR - GNU big integers and rationals
* libreadline - Readline line editing library

View File

@ -176,6 +176,7 @@ extern "C" {
or other mallocs available that do this.
*/
#define DEBUG_DLMALLOC 1
#if DEBUG_DLMALLOC
#include <assert.h>
#else

337
Untitled Normal file
View File

@ -0,0 +1,337 @@
Process: Python [88916]
Path: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.10 (2.7.10)
Code Type: X86-64 (Native)
Parent Process: Atom Helper [88821]
Responsible: Atom [88817]
User ID: 501
Date/Time: 2016-06-12 12:40:34.078 +0100
OS Version: Mac OS X 10.11.5 (15F34)
Report Version: 11
Anonymous UUID: B8085CAA-5C3C-7B89-D7A4-E30E7D5EAC9C
Sleep/Wake UUID: ABD12798-599D-4E2A-8BAF-24F5ACC919E7
Time Awake Since Boot: 220000 seconds
Time Since Wake: 4000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
VM Regions Near 0x8:
-->
__TEXT 0000000105287000-0000000105288000 [ 4K] r-x/rwx SM=COW /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 org.python.python 0x000000010532ffce 0x10528f000 + 659406
1 org.python.python 0x0000000105330481 PyGILState_Ensure + 55
2 com.apple.LLDB.framework 0x0000000108b1e37a lldb_private::ScriptInterpreterPython::Locker::DoAcquireLock() + 28
3 com.apple.LLDB.framework 0x0000000108b23a6b lldb_private::ScriptInterpreterPython::Clear() + 37
4 com.apple.LLDB.framework 0x000000010885e510 lldb_private::Debugger::Clear() + 266
5 com.apple.LLDB.framework 0x000000010885f8ec lldb_private::Debugger::~Debugger() + 28
6 com.apple.LLDB.framework 0x000000010885fc0e lldb_private::Debugger::~Debugger() + 14
7 libc++.1.dylib 0x00007fff91f31cb8 std::__1::__shared_weak_count::__release_shared() + 44
8 com.apple.LLDB.framework 0x00000001068a06cf std::__1::__vector_base<std::__1::shared_ptr<lldb_private::TypeImpl>, std::__1::allocator<std::__1::shared_ptr<lldb_private::TypeImpl> > >::~__vector_base() + 49
9 libsystem_c.dylib 0x00007fff9321246b __cxa_finalize_ranges + 345
10 libsystem_c.dylib 0x00007fff9321276f exit + 55
11 org.python.python 0x000000010533200c 0x10528f000 + 667660
12 org.python.python 0x0000000105331c45 PyErr_PrintEx + 41
13 org.python.python 0x0000000105331668 PyRun_SimpleFileExFlags + 750
14 org.python.python 0x0000000105343011 Py_Main + 3137
15 libdyld.dylib 0x00007fff8d16d5ad start + 1
Thread 1:
0 libsystem_kernel.dylib 0x00007fff9af6bf72 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff9af6b3b3 mach_msg + 55
2 com.apple.CoreFoundation 0x00007fff95f861c4 __CFRunLoopServiceMachPort + 212
3 com.apple.CoreFoundation 0x00007fff95f8568c __CFRunLoopRun + 1356
4 com.apple.CoreFoundation 0x00007fff95f84ed8 CFRunLoopRunSpecific + 296
5 com.apple.CoreFoundation 0x00007fff95fc69b1 CFRunLoopRun + 97
6 com.apple.DebugSymbols 0x00007fff87a2c69a SpotlightQueryThread(void*) + 346
7 libsystem_pthread.dylib 0x00007fff9490e99d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff9490e91a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff9490c351 thread_start + 13
Thread 2:
0 libsystem_kernel.dylib 0x00007fff9af725e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff9490e578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff9490c341 start_wqthread + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff9af725e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff9490e578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff9490c341 start_wqthread + 13
Thread 4:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff9af72efa kevent_qos + 10
1 libdispatch.dylib 0x00007fff87927165 _dispatch_mgr_invoke + 216
2 libdispatch.dylib 0x00007fff87926dcd _dispatch_mgr_thread + 52
Thread 5:
0 libsystem_kernel.dylib 0x00007fff9af725e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff9490e578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff9490c341 start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff9af725e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff9490e578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff9490c341 start_wqthread + 13
Thread 7:
0 libsystem_kernel.dylib 0x00007fff9af725e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff9490e578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff9490c341 start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000001 rbx: 0x00007fb1e266bdb0 rcx: 0x00000b0000000000 rdx: 0x00007fb1e2403388
rdi: 0x00007fb1e2403368 rsi: 0x00000b0000000b00 rbp: 0x00007fff5a9785a0 rsp: 0x00007fff5a978580
r8: 0x00000000fffffffc r9: 0x00007fb1e2403380 r10: 0x00000000ffffffff r11: 0xffffffff00000000
r12: 0x0000000000000001 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000000000001
rip: 0x000000010532ffce rfl: 0x0000000000010206 cr2: 0x0000000000000008
Logical CPU: 6
Error Code: 0x00000004
Trap Number: 14
Binary Images:
0x105287000 - 0x105287fff org.python.python (2.7.10 - 2.7.10) <307E6E15-ECF7-3BB2-AF06-3E8D23DFDECA> /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
0x10528f000 - 0x105380ff7 org.python.python (2.7.10 - 2.7.10) <83AFAAA7-BDFA-354D-8A7A-8F40A30ACB91> /System/Library/Frameworks/Python.framework/Versions/2.7/Python
0x105746000 - 0x105747fff _locale.so (94) <4394AC91-22AE-3D7D-85C4-792A4F35F3F2> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_locale.so
0x10580c000 - 0x10580dff7 time.so (94) <94E8BF2A-7841-32AD-8722-6B2526999CA1> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/time.so
0x105814000 - 0x105816fff select.so (94) <22170D1C-40EF-303A-8BB7-A48E783F9350> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so
0x10581d000 - 0x10581efff fcntl.so (94) <419069D5-A61F-3925-B320-EA7B9E38F44B> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/fcntl.so
0x105823000 - 0x105826fff _struct.so (94) <0DCC6B47-A763-3AA6-82C5-B6A58073286B> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_struct.so
0x10582d000 - 0x10582ffff binascii.so (94) <9044E1C3-221F-3B79-847A-C9C3D8FEA9FD> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/binascii.so
0x105834000 - 0x105835fff cStringIO.so (94) <EC2054BE-E4CD-38B3-BBFB-4FEFB76CF1EF> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/cStringIO.so
0x10596c000 - 0x10596dfff libpanel.5.4.dylib (46) <AF43720C-CE1D-3F76-9E99-4CDCB6FAE3C1> /usr/lib/libpanel.5.4.dylib
0x1059a2000 - 0x1059b0fff _ctypes.so (94) <57C51BC5-542B-3E78-94AC-0AC3DDEAFE8F> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so
0x1059bd000 - 0x1059c1fff itertools.so (94) <889782F7-5414-3881-BAAB-83CACDFDF0C5> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/itertools.so
0x1059cb000 - 0x1059cefff operator.so (94) <D60F7C86-DED4-34F8-BA1B-106E044B6F83> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/operator.so
0x1059d5000 - 0x1059d6ff7 readline.so (94) <9761BEFB-EF61-3542-B6D7-D4EE20F4FCF2> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
0x1059dd000 - 0x1059dffff _collections.so (94) <5FEB3871-0B8F-3233-876C-0E81CF581963> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_collections.so
0x1059e6000 - 0x1059e7fff _heapq.so (94) <9200023E-75BA-3F20-843C-398C3709CA88> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_heapq.so
0x1059ed000 - 0x1059f4ff7 _socket.so (94) <0995C171-1F75-3087-89BE-EC0F68FB1231> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_socket.so
0x1059ff000 - 0x105a00fff _functools.so (94) <49B479ED-A07D-322D-9A29-AFF4CA084219> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_functools.so
0x105a05000 - 0x105a0efff _ssl.so (94) <027A0AA6-E941-32D2-A091-47C3A43DD846> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ssl.so
0x105a1a000 - 0x105a25fff cPickle.so (94) <C34DAE95-E5D5-3B06-9CE1-1FAACAE18EE4> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/cPickle.so
0x105a2c000 - 0x105a3bfff _io.so (94) <39FEF2EC-8D20-33A6-B91F-EF7B2FAE9009> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
0x105a4c000 - 0x105a4fff7 math.so (94) <216DBA90-4498-361D-8321-B41F9A3B121C> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/math.so
0x105a56000 - 0x105a57fff _hashlib.so (94) <D6322B35-8141-3A7B-84CF-07BD4E35C938> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_hashlib.so
0x105a5d000 - 0x105a5eff7 _random.so (94) <5A3C615E-01F8-37C2-A3F2-B1EDEB31C954> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_random.so
0x105a63000 - 0x105a66ff7 strop.so (94) <44D8B4D6-D536-31EE-94EA-4F3C0FC773FA> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/strop.so
0x105a6c000 - 0x105a6cfff _scproxy.so (94) <07D4037C-CB1A-3850-9C0A-A29446A772CE> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_scproxy.so
0x105ab1000 - 0x105ab5fff _json.so (94) <8DF51919-72DB-335D-B4F5-D8B3B7A96A89> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_json.so
0x105ac0000 - 0x105ac9ff7 datetime.so (94) <94EF278A-0BE1-3990-A13B-2A5F36F64263> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/datetime.so
0x10687c000 - 0x10941cff7 com.apple.LLDB.framework (1.350.0.21.9 - 350.0.21.9) <7862FFB0-5204-36DE-A5FA-9BE017CC7E45> /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB
0x7fff6497b000 - 0x7fff649b225f dyld (360.22) <A468D85E-D8D6-3461-8C99-49D3B9ACFC63> /usr/lib/dyld
0x7fff87008000 - 0x7fff872a2ff3 com.apple.security (7.0 - 57337.50.23) <8B6CF71D-A63E-34C9-9227-0AACAB643584> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x7fff875a4000 - 0x7fff875a6ff7 com.apple.xpc.ServiceManagement (1.0 - 1) <D96D7A6D-EDEB-35EE-B5D9-E33A3BF011B5> /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
0x7fff875d7000 - 0x7fff875dbfff libGIF.dylib (1450) <DDEA46A2-85B7-32D7-8CC2-8F4C10AA12D5> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
0x7fff8767e000 - 0x7fff87686fff com.apple.CoreServices.FSEvents (1223.10.1 - 1223.10.1) <7F5B7A23-BC1D-3FA9-A9B8-D534F1E1979A> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents
0x7fff87765000 - 0x7fff877a7ff7 com.apple.Metal (56.6 - 56.6) <2B2C0F78-20B8-3878-B9B1-DE18BB92919D> /System/Library/Frameworks/Metal.framework/Versions/A/Metal
0x7fff877a8000 - 0x7fff8780eff7 libsystem_network.dylib (583.50.1) <B52DAB73-92DC-3DA7-B9F4-B899D66445C1> /usr/lib/system/libsystem_network.dylib
0x7fff8780f000 - 0x7fff8791efe7 libvDSP.dylib (563.5) <9AB6CA3C-4F0E-35E6-9184-9DF86E7C3DAD> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
0x7fff8791f000 - 0x7fff8794cfff libdispatch.dylib (501.40.12) <C7499857-61A5-3D7D-A5EA-65DCC8C3DF92> /usr/lib/system/libdispatch.dylib
0x7fff87961000 - 0x7fff87964fff libCoreVMClient.dylib (119.5) <560D70FB-709F-3030-96C9-F249FCB7DA6D> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
0x7fff87a2b000 - 0x7fff87a65ff7 com.apple.DebugSymbols (132 - 132) <23A42C53-B941-3871-9EE2-4C87A46005B5> /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
0x7fff87a66000 - 0x7fff87a6fff7 com.apple.CommonAuth (4.0 - 2.0) <4B8673E1-3697-3FE2-8D30-AC7AC5D4F8BF> /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
0x7fff87a9f000 - 0x7fff87abbff3 libresolv.9.dylib (60) <A650B5C8-1950-36A0-86D1-0B2465318BFA> /usr/lib/libresolv.9.dylib
0x7fff87b6d000 - 0x7fff87c5fff7 libiconv.2.dylib (44) <F05A0A5A-92A9-3668-8F20-F27CBDA26BE9> /usr/lib/libiconv.2.dylib
0x7fff87c60000 - 0x7fff87c60fff com.apple.Accelerate.vecLib (3.10 - vecLib 3.10) <054DFE32-737D-3211-9A14-0FC5E1A880E3> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
0x7fff87dcf000 - 0x7fff87e76fff com.apple.LanguageModeling (1.0 - 1) <58C18A47-BDE7-3CBE-81C0-797029D170A1> /System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling
0x7fff87e77000 - 0x7fff87f27fe7 libvMisc.dylib (563.5) <6D73C20D-D1C4-3BA5-809B-4B597C15AA86> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
0x7fff87f5a000 - 0x7fff882aefff com.apple.Foundation (6.9 - 1259) <71A9D3A0-0B1F-3E3A-86F3-1486365A6EF2> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x7fff88488000 - 0x7fff88488fff com.apple.CoreServices (728.12 - 728.12) <A4FFF004-53B0-3EAC-A13F-5416BFFD8886> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x7fff884b9000 - 0x7fff8850afff com.apple.audio.CoreAudio (4.3.0 - 4.3.0) <EA7D4F3B-062B-3C81-A98C-C89264D00D48> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x7fff8874d000 - 0x7fff88755ffb libsystem_dnssd.dylib (625.50.5) <4D10E12B-59B5-386F-82DA-326F18028F0A> /usr/lib/system/libsystem_dnssd.dylib
0x7fff88756000 - 0x7fff8876cff7 libLinearAlgebra.dylib (1162.2) <FFE54EDF-F06F-3C0A-864A-4CA7BBFD4B2D> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLinearAlgebra.dylib
0x7fff8876d000 - 0x7fff8879efff com.apple.GSS (4.0 - 2.0) <B490333A-3B3E-397A-AD75-68846E9A9140> /System/Library/Frameworks/GSS.framework/Versions/A/GSS
0x7fff88c4f000 - 0x7fff88d3efff libxml2.2.dylib (29.7) <32BBF51E-B084-3FC2-AE9C-C008BE84102B> /usr/lib/libxml2.2.dylib
0x7fff88ef9000 - 0x7fff88f01fff libcopyfile.dylib (127) <A48637BC-F3F2-34F2-BB68-4C65FD012832> /usr/lib/system/libcopyfile.dylib
0x7fff88f71000 - 0x7fff88fa7fff libssl.0.9.8.dylib (59.40.2) <523FEBFA-4BF7-3A69-83B7-164265BE7F4D> /usr/lib/libssl.0.9.8.dylib
0x7fff88fa8000 - 0x7fff88faaff7 libRadiance.dylib (1450) <BE9E0EBE-C589-3684-B4AE-04F95C8D410A> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
0x7fff893ee000 - 0x7fff89417ff7 libxslt.1.dylib (14.2) <6E8D0F06-9086-32D3-9D87-3870A1CE9E99> /usr/lib/libxslt.1.dylib
0x7fff8949d000 - 0x7fff894b7ff3 liblzma.5.dylib (10) <CC03591B-FA57-3CA5-AC81-0D76033AC0CE> /usr/lib/liblzma.5.dylib
0x7fff894b8000 - 0x7fff894dcfff libJPEG.dylib (1450) <1775E59E-D82C-3F7A-8E4F-B0C13F88F691> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
0x7fff894dd000 - 0x7fff894e0fff com.apple.IOSurface (108.2.1 - 108.2.1) <A0037B0A-277A-393E-9BF6-688595BD564D> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
0x7fff89742000 - 0x7fff89747fff com.apple.TCC (1.0 - 1) <F5EEB2D3-9517-3975-97BE-22CB8E11B8A3> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
0x7fff89b44000 - 0x7fff89b46fff libsystem_coreservices.dylib (19.2) <1B3F5AFC-FFCD-3ECB-8B9A-5538366FB20D> /usr/lib/system/libsystem_coreservices.dylib
0x7fff89bdd000 - 0x7fff89bddff7 libunc.dylib (29) <DDB1E947-C775-33B8-B461-63E5EB698F0E> /usr/lib/system/libunc.dylib
0x7fff89bde000 - 0x7fff89c09ffb libarchive.2.dylib (33.20.2) <6C370A21-63FD-3A68-B4B3-5333F24B770B> /usr/lib/libarchive.2.dylib
0x7fff8a0fc000 - 0x7fff8a16bfff com.apple.SearchKit (1.4.0 - 1.4.0) <F159A888-34CA-36F1-AC8E-EB1B38C9DFB3> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x7fff8a170000 - 0x7fff8a174fff libcache.dylib (75) <9548AAE9-2AB7-3525-9ECE-A2A7C4688447> /usr/lib/system/libcache.dylib
0x7fff8a1e1000 - 0x7fff8a1fdff7 libsystem_malloc.dylib (67.40.1) <5748E8B2-F81C-34C6-8B13-456213127678> /usr/lib/system/libsystem_malloc.dylib
0x7fff8a245000 - 0x7fff8a245fff libmetal_timestamp.dylib (600.0.44.1) <6576F284-BACA-332A-A6E7-FA1C347636E3> /System/Library/PrivateFrameworks/GPUCompiler.framework/libmetal_timestamp.dylib
0x7fff8a2d9000 - 0x7fff8a2dafff liblangid.dylib (122) <9CC4F0D1-5C51-3B69-BC8F-EE3A51FD0822> /usr/lib/liblangid.dylib
0x7fff8a2db000 - 0x7fff8a2e9fff com.apple.opengl (12.1.0 - 12.1.0) <BBC4458E-12FC-3C9B-BF7E-6985D61C7A67> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x7fff8ae82000 - 0x7fff8aeabff7 libxpc.dylib (765.50.8) <54D1328E-054E-3DAA-89E2-375722F9D18F> /usr/lib/system/libxpc.dylib
0x7fff8aeac000 - 0x7fff8b2a8fff libLAPACK.dylib (1162.2) <987E42B0-5108-3065-87F0-9DF7616A8A06> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
0x7fff8b3a2000 - 0x7fff8b648ff7 com.apple.CoreData (120 - 641.3) <A29A5491-6169-372B-828F-84EE0CFD4BC4> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x7fff8b649000 - 0x7fff8b678ffb libsystem_m.dylib (3105) <08E1A4B2-6448-3DFE-A58C-ACC7335BE7E4> /usr/lib/system/libsystem_m.dylib
0x7fff8be57000 - 0x7fff8be6efff libmarisa.dylib (4) <E4919B03-D9BD-3AF8-B436-C415C98E3F0A> /usr/lib/libmarisa.dylib
0x7fff8c64b000 - 0x7fff8c778ff3 com.apple.CoreText (352.0 - 494.11) <08E8640E-6602-3A00-BC28-94235FD311B4> /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
0x7fff8c794000 - 0x7fff8c7e9fff com.apple.AE (701 - 701) <AD492742-F884-386B-A450-FAC281B9FFA4> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x7fff8c83b000 - 0x7fff8c83dfff com.apple.loginsupport (1.0 - 1) <9B2F5F9B-ED38-313F-B798-D2B667BCD6B5> /System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport
0x7fff8cb98000 - 0x7fff8cb9bfff libsystem_sandbox.dylib (460.50.4) <150A9D3D-F69E-32F7-8C7B-8E72CAAFF7E4> /usr/lib/system/libsystem_sandbox.dylib
0x7fff8cb9c000 - 0x7fff8cb9cff7 libkeymgr.dylib (28) <8371CE54-5FDD-3CE9-B3DF-E98C761B6FE0> /usr/lib/system/libkeymgr.dylib
0x7fff8cbff000 - 0x7fff8cc00fff com.apple.TrustEvaluationAgent (2.0 - 25) <0239494E-FEFE-39BC-9FC7-E251BA5128F1> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
0x7fff8cc01000 - 0x7fff8cc01fff libOpenScriptingUtil.dylib (169.1) <AD0DAC8A-9849-3077-999F-9AEC6112BDAB> /usr/lib/libOpenScriptingUtil.dylib
0x7fff8d16a000 - 0x7fff8d16dffb libdyld.dylib (360.22) <CC088C2A-D407-33E7-A6B6-B06E0D4AD999> /usr/lib/system/libdyld.dylib
0x7fff8d245000 - 0x7fff8d246fff libffi.dylib (18.1) <5BA9612C-747E-33CE-9DB1-3C01ECF3041D> /usr/lib/libffi.dylib
0x7fff8d2e2000 - 0x7fff8d378fff com.apple.ColorSync (4.9.0 - 4.9.0) <8FC37E20-6579-3CB2-9D49-BC39FC38DF87> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x7fff8d6fd000 - 0x7fff8d771ff7 com.apple.Heimdal (4.0 - 2.0) <5D365381-8B5E-3259-8867-FC4A7D307BDE> /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
0x7fff8d772000 - 0x7fff8d773fff libDiagnosticMessagesClient.dylib (100) <4243B6B4-21E9-355B-9C5A-95A216233B96> /usr/lib/libDiagnosticMessagesClient.dylib
0x7fff8d7e3000 - 0x7fff8d808ff7 libPng.dylib (1450) <F7944170-4854-3CA5-B66F-7A6CA2292DF2> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
0x7fff8ebb0000 - 0x7fff8ed56ff7 com.apple.audio.toolbox.AudioToolbox (1.13 - 1.13) <082319FC-59F2-3D36-AC9B-94759724E302> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x7fff8f074000 - 0x7fff8f090ff7 libextension.dylib (78) <FD952DA6-BBEC-3CB6-98B3-E1D111C5C54E> /usr/lib/libextension.dylib
0x7fff8f127000 - 0x7fff8f137fff libbsm.0.dylib (34) <7E14504C-A8B0-3574-B6EB-5D5FABC72926> /usr/lib/libbsm.0.dylib
0x7fff8f177000 - 0x7fff903c5fe7 com.apple.CoreGraphics (1.600.0 - 957) <B5D82A82-EDF9-34D5-A8C5-7F25B80985EE> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x7fff903c6000 - 0x7fff904eafff libsqlite3.dylib (216.4) <280D67B8-F93D-3587-A146-19F36C817548> /usr/lib/libsqlite3.dylib
0x7fff90521000 - 0x7fff9055fff7 libGLImage.dylib (12.1) <BB1F1A93-5101-3906-AB17-8D83FCB200F9> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
0x7fff90622000 - 0x7fff90667ff7 com.apple.coreservices.SharedFileList (24.4 - 24.5) <1D2AD77B-778F-3253-A295-3D0A32A8121C> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList
0x7fff90709000 - 0x7fff90717fff libxar.1.dylib (302) <03207F66-2C4A-3DBD-8D81-70F4C85903C4> /usr/lib/libxar.1.dylib
0x7fff90e64000 - 0x7fff90e73ffb com.apple.LangAnalysis (1.7.0 - 1.7.0) <18D21123-A3E7-3851-974A-08E5D4540475> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
0x7fff90f0b000 - 0x7fff90f57fff com.apple.print.framework.PrintCore (11.2 - 472.2) <5AE8AA6B-CE09-397D-B0D4-0F9CCBF1F77D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
0x7fff90f96000 - 0x7fff90fbafff com.apple.MultitouchSupport.framework (304.12 - 304.12) <65CB7653-EACD-3ADB-ABB6-2E0671708301> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
0x7fff91154000 - 0x7fff91165ff7 libsystem_trace.dylib (201.10.3) <F00E92E4-DBDA-3749-B5B3-0C3FBBABA1CB> /usr/lib/system/libsystem_trace.dylib
0x7fff911f6000 - 0x7fff91254fff com.apple.SystemConfiguration (1.14 - 1.14) <D801FAD7-5A2D-3E5E-9F44-B6C9B8BEA747> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x7fff919db000 - 0x7fff919f2ff7 libsystem_coretls.dylib (83.40.5) <C90DAE38-4082-381C-A185-2A6A8B677628> /usr/lib/system/libsystem_coretls.dylib
0x7fff919f3000 - 0x7fff919f3fff com.apple.ApplicationServices (48 - 48) <ADD57D3A-142F-3EF5-BFD8-EACD82164884> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0x7fff91b86000 - 0x7fff91bd2ffb com.apple.HIServices (1.22 - 550) <6B76B41C-CF5A-34C4-89F4-EFD7CA3D1C9D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x7fff91c23000 - 0x7fff91c64ff7 libGLU.dylib (12.1) <CD7A5916-3E3C-3EF3-A275-B281016B99CB> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x7fff91c65000 - 0x7fff91c96ff7 libncurses.5.4.dylib (46) <D4C10699-3E8F-3F42-A695-7490EA4B6B32> /usr/lib/libncurses.5.4.dylib
0x7fff91ef6000 - 0x7fff91f49ff7 libc++.1.dylib (120.1) <8FC3D139-8055-3498-9AC5-6467CB7F4D14> /usr/lib/libc++.1.dylib
0x7fff91f8c000 - 0x7fff91f8eff7 libquarantine.dylib (80) <0F4169F0-0C84-3A25-B3AE-E47B3586D908> /usr/lib/system/libquarantine.dylib
0x7fff91fc3000 - 0x7fff91fddfff com.apple.Kerberos (3.0 - 1) <1B4744BF-E5AE-38E2-AA56-E22D3270F2E8> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
0x7fff9233c000 - 0x7fff9269ef3f libobjc.A.dylib (680) <7489D2D6-1EFD-3414-B18D-2AECCCC90286> /usr/lib/libobjc.A.dylib
0x7fff926df000 - 0x7fff926f0fff libcmph.dylib (6) <BA4BF2C6-7F4E-33B8-9DD7-619C9EB83ECF> /usr/lib/libcmph.dylib
0x7fff92756000 - 0x7fff9279bff3 libFontRegistry.dylib (155.2) <A70DD497-35F3-34DA-9C19-F4B90080E961> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
0x7fff927b9000 - 0x7fff927c4ff7 libcommonCrypto.dylib (60075.50.1) <93732261-34B4-3914-B7A2-90A81A182DBA> /usr/lib/system/libcommonCrypto.dylib
0x7fff927c5000 - 0x7fff927c6ffb libremovefile.dylib (41) <552EF39E-14D7-363E-9059-4565AC2F894E> /usr/lib/system/libremovefile.dylib
0x7fff93126000 - 0x7fff93131ff7 libChineseTokenizer.dylib (16) <79B8C67A-3061-3C78-92CD-4650719E68D4> /usr/lib/libChineseTokenizer.dylib
0x7fff93132000 - 0x7fff9313cfff com.apple.NetAuth (6.0 - 6.0) <D692B1EF-534F-3892-8E2F-2BBA7C8AFD74> /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
0x7fff931b3000 - 0x7fff93240fff libsystem_c.dylib (1082.50.1) <B552D565-B798-3B9B-AE63-F623B42A5F01> /usr/lib/system/libsystem_c.dylib
0x7fff93250000 - 0x7fff935e5fdb com.apple.vImage (8.0 - 8.0) <4BAC9B6F-7482-3580-8787-AB0A5B4D331B> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
0x7fff9394a000 - 0x7fff939bffff com.apple.framework.IOKit (2.0.2 - 1179.50.2) <A509D3AE-9D48-31B7-89C7-326A7A2007B2> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x7fff939e9000 - 0x7fff93a02fff com.apple.CFOpenDirectory (10.11 - 194) <11F95672-55E0-3F9D-9171-5E8C56AEE948> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
0x7fff93ad9000 - 0x7fff93ae1fff libGFXShared.dylib (12.1) <5A0C2493-200C-30BE-97D5-8E8C0B8E604D> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
0x7fff93ae2000 - 0x7fff93aeafff libsystem_networkextension.dylib (385.40.36) <66095DC7-6539-38F2-95EE-458F15F6D014> /usr/lib/system/libsystem_networkextension.dylib
0x7fff93d66000 - 0x7fff93d83ff7 com.apple.AppleVPAFramework (2.1.2 - 2.1.2) <41378C0B-B56A-3A73-9BD0-E06FA1F87B8C> /System/Library/PrivateFrameworks/AppleVPA.framework/Versions/A/AppleVPA
0x7fff94496000 - 0x7fff9449efff com.apple.NetFS (6.0 - 4.0) <842A5346-24C3-3F22-9ECF-E586A10EA1F2> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
0x7fff9449f000 - 0x7fff944a4ff7 libmacho.dylib (875.1) <318264FA-58F1-39D8-8285-1F6254EE410E> /usr/lib/system/libmacho.dylib
0x7fff944a5000 - 0x7fff944cefff libsystem_info.dylib (477.50.4) <FAA9226D-64DE-3769-A6D8-6CABA4B7FF4D> /usr/lib/system/libsystem_info.dylib
0x7fff945f8000 - 0x7fff9466ffeb libcorecrypto.dylib (335.50.1) <B5C05FD7-A540-345A-87BF-8E41848A3C17> /usr/lib/system/libcorecrypto.dylib
0x7fff94672000 - 0x7fff9467afef libsystem_platform.dylib (74.40.2) <29A905EF-6777-3C33-82B0-6C3A88C4BA15> /usr/lib/system/libsystem_platform.dylib
0x7fff947a8000 - 0x7fff94835dd7 com.apple.AppleJPEG (1.0 - 1) <558ACADA-C41F-3EEF-82A0-C2D7B13C5428> /System/Library/PrivateFrameworks/AppleJPEG.framework/Versions/A/AppleJPEG
0x7fff9490b000 - 0x7fff94914ff7 libsystem_pthread.dylib (138.10.4) <3DD1EF4C-1D1B-3ABF-8CC6-B3B1CEEE9559> /usr/lib/system/libsystem_pthread.dylib
0x7fff94915000 - 0x7fff94923ff7 libbz2.1.0.dylib (38) <28E54258-C0FE-38D4-AB76-1734CACCB344> /usr/lib/libbz2.1.0.dylib
0x7fff949d8000 - 0x7fff949e4fff com.apple.speech.synthesis.framework (5.4.12 - 5.4.12) <71DA00B8-5EA2-326B-8814-59DB25512F65> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x7fff949e5000 - 0x7fff94a43fff com.apple.CoreServices.OSServices (728.12 - 728.12) <776EBD4F-7052-377F-A70D-E2FDBD465A5E> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x7fff94c55000 - 0x7fff94c6dfef libcompression.dylib (28) <E7601B62-1053-369D-8A9E-91CF86239220> /usr/lib/libcompression.dylib
0x7fff94d75000 - 0x7fff94d81ff7 com.apple.OpenDirectory (10.11 - 194) <31A67AD5-5CC2-350A-96D7-821DF4BC4196> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
0x7fff94dd2000 - 0x7fff94de9ff7 libsystem_asl.dylib (323.50.1) <41F8E11F-1BD0-3F1D-BA3A-AA1577ED98A9> /usr/lib/system/libsystem_asl.dylib
0x7fff95efc000 - 0x7fff96372fff com.apple.CoreFoundation (6.9 - 1258.1) <943A1383-DA6A-3DC0-ABCD-D9AEB3D0D34D> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff96a8b000 - 0x7fff96a8cffb libSystem.B.dylib (1226.10.1) <C5D09FE1-CC70-383E-AC27-18602F2EDEC4> /usr/lib/libSystem.B.dylib
0x7fff96b0b000 - 0x7fff96b67fff libTIFF.dylib (1450) <14EB7C03-7DDA-3276-BAC5-D597913AC9C4> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
0x7fff9788c000 - 0x7fff97900ff3 com.apple.securityfoundation (6.0 - 55126) <130656AE-2711-3914-8736-D8B021C93FE0> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
0x7fff97901000 - 0x7fff9796fff7 com.apple.ApplicationServices.ATS (377 - 394.4) <9779E916-0788-3CAC-B1EC-F68BCB12A2B6> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x7fff97970000 - 0x7fff979c1ff7 libcups.2.dylib (435.2) <91584A40-214D-33E8-A613-CE22289037C8> /usr/lib/libcups.2.dylib
0x7fff97acb000 - 0x7fff97ad4ff3 libsystem_notify.dylib (150.40.1) <D48BDE34-0F7E-34CA-A0FF-C578E39987CC> /usr/lib/system/libsystem_notify.dylib
0x7fff97c56000 - 0x7fff97c58fff libCVMSPluginSupport.dylib (12.1) <D81B3D8D-B83F-3918-BD4B-6C794A30AF9F> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
0x7fff97c59000 - 0x7fff97c5cff7 libCoreFSCache.dylib (119.5) <2389D7DA-B8EF-3EB4-AAAF-FBEDE01CDECA> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreFSCache.dylib
0x7fff97d7b000 - 0x7fff97d80ff7 libheimdal-asn1.dylib (453.40.10) <981DE40B-FA16-36F7-BE92-8C8A115D6CD9> /usr/lib/libheimdal-asn1.dylib
0x7fff97d81000 - 0x7fff97d9fffb libedit.3.dylib (43) <1D3E3152-4001-3C19-B56A-7543F1BBA47C> /usr/lib/libedit.3.dylib
0x7fff987b2000 - 0x7fff989bffff libicucore.A.dylib (551.51.3) <5BC80F94-C90D-3175-BD96-FF1DC222EC9C> /usr/lib/libicucore.A.dylib
0x7fff989c0000 - 0x7fff989c0ff7 liblaunch.dylib (765.50.8) <834ED605-5114-3641-AA4D-ECF31B801C50> /usr/lib/system/liblaunch.dylib
0x7fff98b55000 - 0x7fff98b8ffff com.apple.QD (3.12 - 302) <0FE53180-2895-3D14-A1E7-F82DE1D106E1> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
0x7fff98be1000 - 0x7fff98be1fff libenergytrace.dylib (10.40.1) <0A491CA7-3451-3FD5-999A-58AB4362682B> /usr/lib/libenergytrace.dylib
0x7fff98c36000 - 0x7fff98c41fff libGL.dylib (12.1) <70D51643-04AC-3400-8F11-A6FC25985289> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x7fff98c77000 - 0x7fff98ca0fff libc++abi.dylib (125) <DCCC8177-3D09-35BC-9784-2A04FEC4C71B> /usr/lib/libc++abi.dylib
0x7fff98cb0000 - 0x7fff98cdfff7 com.apple.DictionaryServices (1.2 - 250.3) <30250542-CBAA-39C1-91AA-B57A5DE17594> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
0x7fff98ce0000 - 0x7fff98ce7ff7 libcompiler_rt.dylib (62) <A13ECF69-F59F-38AE-8609-7B731450FBCD> /usr/lib/system/libcompiler_rt.dylib
0x7fff98d10000 - 0x7fff98fa6fff libmecabra.dylib (696.5) <EF6C0BD4-5FE8-34FB-8ADF-69A53CEC97A9> /usr/lib/libmecabra.dylib
0x7fff99bdb000 - 0x7fff99bdbfff com.apple.Accelerate (1.10 - Accelerate 1.10) <185EC96A-5AF0-3620-A4ED-4D3654D25B39> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
0x7fff99bdc000 - 0x7fff99bddfff libsystem_blocks.dylib (65) <1244D9D5-F6AA-35BB-B307-86851C24B8E5> /usr/lib/system/libsystem_blocks.dylib
0x7fff99d2d000 - 0x7fff99e94fff libBLAS.dylib (1162.2) <A1398FE0-39D2-33EA-9A0F-B2644EEA29A0> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x7fff99f74000 - 0x7fff9a259ffb com.apple.CoreServices.CarbonCore (1136.2 - 1136.2) <2DBAFC9A-6CD6-351D-B1F4-87D81AA6D640> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x7fff9a2cc000 - 0x7fff9a312ff7 libauto.dylib (186) <999E610F-41FC-32A3-ADCA-5EC049B65DFB> /usr/lib/libauto.dylib
0x7fff9a359000 - 0x7fff9a35ffff com.apple.IOAccelerator (205.10 - 205.10) <E46ED853-C2CC-3F29-A7DD-5E9351A2E754> /System/Library/PrivateFrameworks/IOAccelerator.framework/Versions/A/IOAccelerator
0x7fff9a40b000 - 0x7fff9a410ff3 libunwind.dylib (35.3) <F6EB48E5-4D12-359A-AB54-C937FBBE9043> /usr/lib/system/libunwind.dylib
0x7fff9a833000 - 0x7fff9a923fff libJP2.dylib (1450) <FAFF00CD-1CF6-34DE-A06F-31D4BB9C8BA9> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
0x7fff9ab94000 - 0x7fff9aba5fff libSparseBLAS.dylib (1162.2) <EBEB3848-3468-342A-91A6-5C47F2369CD9> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparseBLAS.dylib
0x7fff9abea000 - 0x7fff9ac8afff com.apple.Metadata (10.7.0 - 972.34) <A93B485D-094C-3024-8CBB-D9E035FB83C4> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
0x7fff9af5b000 - 0x7fff9af79ff7 libsystem_kernel.dylib (3248.50.21) <78E54D59-D2B0-3F54-9A4A-0A68D671F253> /usr/lib/system/libsystem_kernel.dylib
0x7fff9b073000 - 0x7fff9b159ff7 libcrypto.0.9.8.dylib (59.40.2) <2486D801-C756-3488-B519-1AA6807E8948> /usr/lib/libcrypto.0.9.8.dylib
0x7fff9b3c1000 - 0x7fff9b4bdff7 libFontParser.dylib (158.6) <267A9AE4-4138-3112-8D73-BDFDC96568FF> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
0x7fff9b4c2000 - 0x7fff9b4ddff7 libCRFSuite.dylib (34) <078B4CD8-6A8C-3067-B2BA-0C2A0BAB8AC3> /usr/lib/libCRFSuite.dylib
0x7fff9b625000 - 0x7fff9b8acff3 com.apple.CFNetwork (760.5.1 - 760.5.1) <EE9426D1-F11C-3DD4-AE08-EA29AEB27177> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x7fff9b928000 - 0x7fff9baeefe7 com.apple.ImageIO.framework (3.3.0 - 1450) <18ABA1F4-43EC-3990-9777-C91FD3D6AF71> /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
0x7fff9bdf0000 - 0x7fff9be24ff7 com.apple.CoreVideo (1.8 - 191.3) <1AA24A1B-CB84-3F6B-B6DE-11494542649C> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
0x7fff9bf5b000 - 0x7fff9bf60fff com.apple.DiskArbitration (2.7 - 2.7) <F55902AA-5316-3255-A701-FDED5B553065> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x7fff9bf61000 - 0x7fff9c086fff com.apple.LaunchServices (728.12 - 728.12) <F5AB56CD-CF33-33F0-A48D-372551714E77> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x7fff9c0e4000 - 0x7fff9c0effff libkxld.dylib (3248.50.21) <99195052-038E-3490-ACF8-76F9AC43897E> /usr/lib/system/libkxld.dylib
0x7fff9d382000 - 0x7fff9d386fff libpam.2.dylib (20) <CFCD19BD-87BC-3F2B-BB1C-4C23E8E55F1A> /usr/lib/libpam.2.dylib
0x7fff9d4b7000 - 0x7fff9d4c8ff7 libz.1.dylib (61.20.1) <B3EBB42F-48E3-3287-9F0D-308E04D407AC> /usr/lib/libz.1.dylib
0x7fff9d4ca000 - 0x7fff9d4f8ff7 com.apple.CoreServicesInternal (248.2 - 248.2) <6E111F0A-D7F1-3738-ADE7-CF983BD4EC8B> /System/Library/PrivateFrameworks/CoreServicesInternal.framework/Versions/A/CoreServicesInternal
0x7fff9d4f9000 - 0x7fff9d4fbff7 libsystem_configuration.dylib (802.40.13) <3DEB7DF9-6804-37E1-BC83-0166882FF0FF> /usr/lib/system/libsystem_configuration.dylib
0x7fff9d5ab000 - 0x7fff9d5acfff libsystem_secinit.dylib (20) <32B1A8C6-DC84-3F4F-B8CE-9A52B47C3E6B> /usr/lib/system/libsystem_secinit.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 11
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 199747
thread_create: 0
thread_set_state: 9181
VM Region Summary:
ReadOnly portion of Libraries: Total=231.3M resident=0K(0%) swapped_out_or_unallocated=231.3M(100%)
Writable regions: Total=112.3M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=112.3M(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Activity Tracing 2048K 2
Dispatch continuations 16.0M 2
Kernel Alloc Once 4K 2
MALLOC 75.5M 22
MALLOC guard page 32K 7
STACK GUARD 56.0M 9
Stack 11.1M 16
VM_ALLOCATE 7448K 21
__DATA 11.8M 183
__LINKEDIT 101.5M 32
__TEXT 129.8M 182
__UNICODE 552K 2
mapped file 47.0M 49
shared memory 324K 9
=========== ======= =======
TOTAL 458.9M 524
Model: MacBookPro11,5, BootROM MBP114.0172.B09, 4 processors, Intel Core i7, 2,5 GHz, 16 GB, SMC 2.30f2
Graphics: AMD Radeon R9 M370X, AMD Radeon R9 M370X, PCIe, 2048 MB
Graphics: Intel Iris Pro, Intel Iris Pro, Built-In
Memory Module: BANK 0/DIMM0, 8 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343147533642465238412D50422020
Memory Module: BANK 1/DIMM0, 8 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343147533642465238412D50422020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x152), Broadcom BCM43xx 1.0 (7.21.95.175.1a6)
Bluetooth: Version 4.4.5f3 17904, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD SM0512G, 500,28 GB
USB Device: USB 3.0 Bus
USB Device: Card Reader
USB Device: Apple Internal Keyboard / Trackpad
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 27.1

72
YAPDroid/YAPDroid.md Normal file
View File

@ -0,0 +1,72 @@
## YAPDroid
This file documents the YAPDroid application. This app was developed in order to
test the YAP-Android interface. It provides a simple REPL with a query window and a text
viewer.
### Design
The YAP interface to Android is based on the SWIG interface generator. SWIG exports the YAP
C++ classes as Java classes. In practice there exist two worlds, the native application
and the Java application:
- YAP runs in Android as a native application in a Linux
environment. Android does not support glibc. Instead, Android libraries are provided by the Android NDK, and
are somewhat limited, i.e., the NDK misses in-memory streams and a `glob`
predicate. Moreover, read-only data is kept in a zipped archive that is made to appear as
a directory, `~/assets`
- SWIG generates the glue code: JNI classes that act as Java classes. Callbacks are possible.
- Java code operates as usual.
### Compiling YAPDroid
The current version was compiled using the recent Android Studio `cmake` support. Android Studio uses
`gradle` as the build system. `gradle` orchestrates compilation of all Java code. External code is delegated
to `cmake` or the Android NDK own builder. The idea fits nicely with YAP; unfortunately, the process currently
crashes in middle.
To install, navigate through these steps:
1. Obtain `gmp` for Android. YAP has used the [Rupan repo](https://github.com/Rupan/gmp); place the repo next to
the yap-6.3 top directory.
2. Install [swig](www/swig.org)
2. Obtain Android Studio. This work used Android Studio 2.2 Beta 3. The IDE includes most everything else you need: the ADK, the NDK, `cmake`, the `ninja` build system, and the debugger.
3. Set YAPDroid as your directory.
4. Adapt the `build.gradle` files to your configuration.
+ It may be a good idea to first generate an empty configuration and compare.
+ In the `lib` directory, please verify wich targets you are generating for.
4. Build the system, either from the GUI or from a terminal, say as:
~~~~~
./gradlew assembleDebug
~~~~~
or
~~~~~
./gradlew :lib:assembleDebug
~~~~~
You should see `cmake` being executed, and after some time `gradle` crash.
5. To actually install the binaries, use:
~~~~~
cd lib/build/intermediates/cmake/debug/json/armeabi-v7a
ninja install
~~~~~
6. Comment the four lines in `lib/build.gradle` to avoid crashing in the `cmake` task.
7. use the GUI commands to compile the app or set your directory bak to
the YAPDroid top-directory and call `gradle`.
Enjoy!
### Limitations and TODO
- improve error handling.
- support `/assets`: the code is written but not tested yet.
- network access
- sqlite testing and support

37
YAPDroid/app/build.gradle Normal file
View File

@ -0,0 +1,37 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "pt.up.yap.app"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
project.gradle.taskGraph.whenReady {
connectedDebugAndroidTest {
ignoreFailures = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pt.up.yap.app"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme"
>
<activity android:name=".YAPDroid"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>

View File

@ -0,0 +1,86 @@
package pt.up.yap.app;
import android.content.Context;
import android.content.res.AssetManager;
import android.support.v4.content.res.ResourcesCompat;
import android.util.Log;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by vsc on 30/05/16.
*/
public class CreateFiles {
public static void setupfiles(Context context, AssetManager assets){
try {
context.getExternalFilesDir("Yap").mkdirs();
context.getExternalFilesDir("Yap/pl").mkdirs();
context.getExternalFilesDir("Yap/os").mkdirs();
String list[] = {};
list= assets.list("Yap");
for (int i = 0; i < list.length; i++) {
copy(context, "Yap/"+ list[i]);
}
list = null;
list= assets.list("Yap/pl");
for (int i = 0; i < list.length; i++) {
copy(context, "Yap/pl/"+ list[i]);
}
list =null;
list= assets.list("Yap/os");
for (int i = 0; i < list.length; i++) {
copy(context, "Yap/os/"+ list[i]);
}
Log.d("CreateFiles", context.getFilesDir().getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
}
private static void copy(Context context, String originalName) {
try {
if (originalName.contains(".")) {
File outFile;
outFile = new File(context.getExternalFilesDir(null), originalName );
InputStream in = context.getAssets().open(originalName);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
byte data[] = new byte[1024];
int count;
while ((count = in.read(data)) != -1) {
out.write(data, 0, count);
}
out.flush();
out.close();
in.close();
in = null;
out = null;
//Log.d("Copied: ", originalName + " to " + destinationName);
//System.out.println("Copied: "+ originalName + " to " + destinationName);
//System.out.println();
}
}catch(IOException e){
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,330 @@
package pt.up.yap.app;
/****
* using sqlite
* For example,the following:
* <p/>
* import android.database.sqlite.SQLiteDatabase;
* <p/>
* should be replaced with:
* <p/>
* import org.sqlite.database.sqlite.SQLiteDatabase;
* <p/>
* As well as replacing all uses of the classes in the android.database.sqlite.* namespace, the application must also be sure to use the following two:
* <p/>
* org.sqlite.database.SQLException
* org.sqlite.database.DatabaseErrorHandler
* <p/>
* instead of:
* <p/>
* android.database.SQLException
* android.database.DatabaseErrorHandler
* <p/>
* Aside from namespace changes, there are other differences from the stock Android interface that applications need to be aware of:
* <p/>
* The SQLiteStatement.simpleQueryForBlobFileDescriptor() API is not available. The collation sequence "UNICODE" is not available. The collation sequence "LOCALIZED", which normally changes with the system's current locale, is always equivalent to SQLite's built in collation BINARY.
****/
import android.content.Context;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Bundle;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.appindexing.Thing;
import com.google.android.gms.common.api.GoogleApiClient;
import org.sqlite.database.DatabaseErrorHandler;
import org.sqlite.database.sqlite.SQLiteDatabase;
import pt.up.yap.lib.*;
class DoNotDeleteErrorHandler implements DatabaseErrorHandler {
private static final String TAG = "DoNotDeleteErrorHandler";
public void onCorruption(SQLiteDatabase dbObj) {
Log.e(TAG, "Corruption reported by sqlite on database: " + dbObj.getPath());
}
}
public class YAPDroid extends Activity {
private static final String TAG = "YAPDroid";
TextView outputText = null;
ScrollView scroller = null;
YAPEngine eng = null;
EditText text;
String str;
String buf;
YAPQuery q;
Boolean running = false, compute = true;
int i = 1;
YAPListTerm vs0;
private AssetManager mgr;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
// private static native void load(AssetManager mgr);
void runQuery(String str, Boolean more) {
try {
// check if at initial query
if (running) {
if (q != null) q.close();
}
if (BuildConfig.DEBUG) {
Log.i(TAG, "query " + str);
}
q = eng.query(str);
// get the uninstantiated query variables.
vs0 = q.namedVars();
running = true;
// start computing
compute = true;
if (BuildConfig.DEBUG) {
Log.i(TAG, "onQueryButtonClick called");
}
Boolean rc = true;
text.setText("?- ");
if (vs0.nil()) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "q0=\n");
}
if (compute && (rc = q.next())) {
outputText.append("yes\n");
running = compute = more;
} else {
outputText.append("no\n");
running = false;
compute = false;
}
} else {
// if (BuildConfig.DEBUG) {
// Log.i(TAG, "q1= " + vs0.text() + "\n");
// }
while (compute && (rc = q.next())) {
YAPListTerm vs = q.namedVars();
while (!vs.nil()) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "q= " + vs.text() + "\n");
}
YAPTerm eq = vs.car();
//outputText.append(Integr.toString(i) + ": " + eq.text() );
outputText.append(Integer.toString(i));
outputText.append(":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() + "\n");
vs = vs.cdr();
}
compute = more;
}
}
if (!rc) {
outputText.append("no\n");
if (q != null)
q.close();
q = null;
compute = false;
running = false;
}
} catch (Exception e) {
outputText.append("Exception thrown :" + e);
if (q != null)
q.close();
compute = true;
running = false;
}
}
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
String s = null;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
PackageManager
m = getPackageManager();
s = getPackageName();
PackageInfo p = m.getPackageInfo(s, 0);
//s = p.applicationInfo.dataDir;
mgr = this.getAssets();
/** static constructor */
// follow this order carefully.
System.loadLibrary("gmp");
System.loadLibrary("Yap");
System.loadLibrary("Yapsqlite3");
System.loadLibrary("Yap++");
System.loadLibrary("YAPDroid");
CreateFiles.setupfiles(this, mgr);
} catch (NameNotFoundException e) {
Log.e(TAG, "Couldn't find package information in PackageManager", e);
}
Log.i(TAG, "mgr=" + mgr);
text = (EditText) findViewById(R.id.EditText01);
outputText = (TextView) findViewById(R.id.OutputText);
outputText.setText("Application " + s + "\nPress 'First' or 'All' to query...\n");
outputText.setMovementMethod(new ScrollingMovementMethod());
scroller = (ScrollView) findViewById(R.id.Scroller);
if (BuildConfig.DEBUG) {
Log.i(TAG, "window making done");
}
eng = new YAPEngine(null, this.getExternalFilesDir("/Yap/pl/boot.yap").getAbsolutePath());
if (BuildConfig.DEBUG) {
Log.i(TAG, "engine done");
}
if (BuildConfig.DEBUG) {
Log.i(TAG, "onClearButtonClick called");
}
JavaCallback callback = new JavaCallback(outputText);
// set the Java Callback
if (BuildConfig.DEBUG) {
Log.i(TAG, "before setting callback");
}
eng.setYAPCallback(callback);
if (BuildConfig.DEBUG) {
Log.i(TAG, "callback done");
}
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
public void onClearButtonClick(View view) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "onClearButtonClick called");
}
// Ensure scroll to end of text
scroller.post(new Runnable() {
public void run() {
scroller.fullScroll(ScrollView.FOCUS_DOWN);
if (running) {
if (q != null)
q.close();
q = null;
}
running = false;
text.setText("");
}
});
}
public void onFirstButtonClick(View view) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "onQueryButtonClick called");
}
// Ensure scroll to end of text
scroller.post(new Runnable() {
public void run() {
scroller.fullScroll(ScrollView.FOCUS_DOWN);
str = text.getText().toString();
//outputText.append("?- " + str+"\n\n");
Log.i(TAG, "onQueryAnyButtonClick " + str + "\n");
runQuery(str, false);
scroller.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
public void onAllButtonClick(View view) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "onQueryButtonClick called");
}
// Ensure scroll to end of text
scroller.post(new Runnable() {
public void run() {
str = text.getText().toString();
scroller.fullScroll(ScrollView.FOCUS_DOWN);
outputText.append("?- " + str + "\n\n");
Log.i(TAG, "onAllButtonClick " + str + "\n");
runQuery(str, true);
scroller.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
public Action getIndexApiAction() {
Thing object = new Thing.Builder()
.setName("YAPDroid Page") // TODO: Define a title for the content shown.
// TODO: Make sure this auto-generated URL is correct.
.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
.build();
return new Action.Builder(Action.TYPE_VIEW)
.setObject(object)
.setActionStatus(Action.STATUS_TYPE_COMPLETED)
.build();
}
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client.connect();
AppIndex.AppIndexApi.start(client, getIndexApiAction());
}
@Override
public void onStop() {
super.onStop();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
AppIndex.AppIndexApi.end(client, getIndexApiAction());
client.disconnect();
}
}
class JavaCallback extends YAPCallback {
private static final String TAG = "JavaCallback";
TextView output;
public JavaCallback(TextView outputText) {
super();
output = outputText;
Log.i(TAG, "java callback init");
}
public void run(String s) {
Log.i(TAG, "java callback ");
output.append(s);
}
}

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".YAPDroid">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:lines="6" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:id="@+id/FirstButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onFirstButtonClick"
android:text="First..." />
<Button
android:id="@+id/AllButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onAllButtonClick"
android:text="All..." />
<Button
android:id="@+id/ClearButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onClearButtonClick"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/Scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/OutputText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false" />
<!-- Set MaxLegth EditText -->
</ScrollView>
</LinearLayout>

23
YAPDroid/build.gradle Normal file
View File

@ -0,0 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

42
YAPDroid/lib/build.gradle Normal file
View File

@ -0,0 +1,42 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "pt.up.yap.app"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
cmake {
// cFlags "-DTEST_C_FLAG1" "-DTEST_C_FLAG2"
// cppFlags "-DTEST_CPP_FLAG2" "-DTEST_CPP_FLAG2"
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// externalNativeBuild {
// cmake {
// path '../../CMakeLists.txt'
// }
// }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
}

1
YAPDroid/settings.gradle Normal file
View File

@ -0,0 +1 @@
include ':app', ':lib'

73
cmake/FindHCC.cmake Normal file
View File

@ -0,0 +1,73 @@
# findHCC does not currently address versioning, i.e.
# a rich directory structure where version number is a subdirectory under root
# Also, supported only on UNIX 64 bit systems.
if(UNIX)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(HSA_LIBRARY
NAMES hsa-runtime64
PATHS
ENV HSA_PATH
/opt/rocm/hsa
PATH_SUFFIXES
lib)
if( NOT DEFINED ENV{HSA_PATH} )
set( ENV{HSA_PATH} /opt/rocm/hsa)
endif()
find_program(HCC
NAMES hcc
PATHS
ENV HCC_PATH
/opt/rocm/hcc
PATH_SUFFIXES
/bin)
if( NOT DEFINED ENV{HCC_PATH} )
set( ENV{HCC_PATH} /opt/rocm/hcc)
endif()
# this is now dynamic
# find_library(AMP_LIBRARY
# NAMES mcwamp
# PATHS
# ENV NCC_PATH
# /opt/rocm/hcc
# PATH_SUFFIXES
# /lib)
find_path(HCC_INCLUDE_DIR
NAMES
hc.hpp
PATHS
ENV NCC_PATH
/opt/rocm/hcc
PATH_SUFFIXES
/include)
set(HSA_LIBRARIES ${HSA_LIBRARY})
#set(HCC_LIBRARIES ${AMP_LIBRARY})
set(HCC_INCLUDE_DIRS ${HCC_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
HCC
FOUND_VAR HCC_FOUND
REQUIRED_VARS HSA_LIBRARIES HCC_INCLUDE_DIRS HCC)
mark_as_advanced(
HSA_LIBRARIES
HCC_INCLUDE_DIRS
)
else()
message(SEND_ERROR "HCC is currently supported only on 64 bit UNIX platforms")
endif()
else()
message(SEND_ERROR "HCC is currently supported on unix platforms")
endif()

56
cmake/FindHIP.cmake Normal file
View File

@ -0,0 +1,56 @@
find_package(CUDA)
if( CUDA_INCLUDE_DIRS AND CUDA_VERSION AND CUDA_NVCC_EXECUTABLE)
message(STATUS "CUDA_VERSION = ${CUDA_VERSION}")
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
message(STATUS "CUDA_NVCC_EXECUTABLE = ${CUDA_NVCC_EXECUTABLE}")
set( HIP_PLATFORM "nvcc" )
#export the environment variable, so that HIPCC can find it.
set(ENV{HIP_PLATFORM} nvcc)
else()
find_package(HCC)
message(STATUS "HCC_FOUND = ${HCC_FOUND}")
message(STATUS "HCC = ${HCC}")
message(STATUS "HCC_INCLUDE_DIRS = ${HCC_INCLUDE_DIRS}")
message(STATUS "HSA_LIBRARIES = ${HSA_LIBRARIES}")
if( ${HCC_FOUND} STREQUAL "TRUE" )
# This directory is hip/cmake! HIP_PATH should be one directory up!
set (HIP_PATH $ENV{HIP_PATH})
if (NOT DEFINED HIP_PATH)
set (HIP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/..)
set( ENV{HIP_PATH} ${HIP_PATH})
endif()
message(STATUS "ENV HIP_PATH = $ENV{HIP_PATH}")
find_program(HIPCC
NAMES hipcc
PATHS
ENV HIP_PATH
PATH_SUFFIXES
/bin)
message(STATUS "HIPCC = ${HIPCC}")
if( DEFINED HIPCC)
set( HIP_PLATFORM "hcc" )
#export the environment variable, so that HIPCC can find it.
set(ENV{HIP_PLATFORM} "hcc")
set (CMAKE_CXX_COMPILER ${HIPCC})
else()
message(SEND_ERROR "Did not find HIPCC")
endif()
else()
message(SEND_ERROR "hcc not found")
endif()
endif()

0
heap_top_ Normal file
View File

0
hh Normal file
View File

285
include/YapStreams.h Normal file
View File

@ -0,0 +1,285 @@
/**************************************************************************
* *
* File: iopreds.h *
* Last rev: 5/2/88 *
* mods: *
* comments: Input/Output C implemented predicates *
* *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
#endif
#ifndef YAPSTREAMS_H
#define YAPSTREAMS_H 1
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#define YAP_ERROR NIL
#define MaxStreams 64
#define EXPAND_FILENAME 0x000080
#define StdInStream 0
#define StdOutStream 1
#define StdErrStream 2
#define ALIASES_BLOCK_SIZE 8
#if _WIN32
#define USE_SOCKET 1
#define HAVE_SOCKET 1
#endif
//#include "Atoms.h"
//#include "Yap.h"
#include <stdlib.h>
/*
* This file defines main data-structure for stream management,
*
*/
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <windows.h>
#endif
#include <wchar.h>
/************ SWI compatible support for unicode representations ************/
typedef struct yap_io_position {
int64_t byteno; /* byte-position in file */
int64_t charno; /* character position in file */
long int lineno; /* lineno in file */
long int linepos; /* position in line */
intptr_t reserved[2]; /* future extensions */
} yapIOPOS;
#ifndef _PL_STREAM_H
typedef struct {
YAP_Atom file; /* current source file */
yapIOPOS position; /* Line, line pos, char and byte */
} yapSourceLocation;
#endif
#define RD_MAGIC 0xefebe128
typedef struct vlist_struct_t {
struct VARSTRUCT *ve;
struct vlist_struct_t *next;
} vlist_t;
typedef struct qq_struct_t {
unsigned char *text;
yapIOPOS start, mid, end;
vlist_t *vlist;
struct qq_struct_t *next;
} qq_t;
typedef struct read_data_t {
unsigned char *here; /* current character */
unsigned char *base; /* base of clause */
unsigned char *end; /* end of the clause */
unsigned char *token_start; /* start of most recent read token */
int magic; /* RD_MAGIC */
struct stream_desc *stream;
FILE *f; /* file. of known */
YAP_Term position; /* Line, line pos, char and byte */
void *posp; /* position pointer */
size_t posi; /* position number */
YAP_Term subtpos; /* Report Subterm positions */
bool cycles; /* Re-establish cycles */
yapSourceLocation start_of_term; /* Position of start of term */
struct mod_entry *module; /* Current source module */
unsigned int flags; /* Module syntax flags */
int styleCheck; /* style-checking mask */
bool backquoted_string; /* Read `hello` as string */
int *char_conversion_table; /* active conversion table */
YAP_Atom on_error; /* Handling of syntax errors */
int has_exception; /* exception is raised */
YAP_Term exception; /* raised exception */
YAP_Term variables; /* report variables */
YAP_Term singles; /* Report singleton variables */
YAP_Term varnames; /* Report variables+names */
int strictness; /* Strictness level */
#ifdef O_QUASIQUOTATIONS
YAP_Term quasi_quotations; /* User option quasi_quotations(QQ) */
YAP_Term qq; /* Quasi quoted list */
YAP_Term qq_tail; /* Tail of the quoted stuff */
#endif
YAP_Term comments; /* Report comments */
} read_data, *ReadData;
#if __APPLE__
#include "fmemopen.h"
#define HAVE_FMEMOPEN 1
#define HAVE_OPEN_MEMSTREAM 1
FILE *open_memstream(char **buf, size_t *len);
#endif
#if __ANDROID__
#undef HAVE_FMEMOPEN
#undef HAVE_OPEN_MEMSTREAM
#endif
#if HAVE_FMEMOPEN
#define MAY_READ 1
#endif
#if HAVE_OPEN_MEMSTREAM
#define MAY_READ 1
#define MAY_WRITE 1
#endif
#if _WIN32
#undef MAY_WRITE
#undef MAY_READ
#endif
typedef struct mem_desc {
char *buf; /* where the file is being read from/written to */
int src; /* where the space comes from, 0 code space, 1 malloc */
YAP_Int max_size; /* maximum buffer size (may be changed dynamically) */
YAP_UInt pos; /* cursor */
volatile void *error_handler;
} memHandle;
#if HAVE_SOCKET
typedef enum { /* in YAP, sockets may be in one of 4 possible status */
new_socket,
server_socket,
client_socket,
server_session_socket,
closed_socket
} socket_info;
typedef enum { /* we accept two domains for the moment, IPV6 may follow */
af_inet, /* IPV4 */
af_unix /* or AF_FILE */
} socket_domain;
#endif
#define Quote_illegal_f 0x01
#define Ignore_ops_f 0x02
#define Handle_vars_f 0x04
#define Use_portray_f 0x08
#define To_heap_f 0x10
#define Unfold_cyclics_f 0x20
#define Use_SWI_Stream_f 0x40
#define BackQuote_String_f 0x80
#define AttVar_None_f 0x100
#define AttVar_Dots_f 0x200
#define AttVar_Portray_f 0x400
#define Blob_Portray_f 0x800
#define No_Escapes_f 0x1000
#define No_Brace_Terms_f 0x2000
#define Fullstop_f 0x4000
#define New_Line_f 0x8000
typedef struct stream_desc {
YAP_Atom name;
YAP_Term user_name;
FILE *file;
// useful in memory streams
char *nbuf;
size_t nsize;
union {
struct {
#define PLGETC_BUF_SIZE 4096
unsigned char *buf, *ptr;
int left;
} file;
memHandle mem_string;
struct {
int fd;
} pipe;
#if HAVE_SOCKET
struct {
socket_domain domain;
socket_info flags;
int fd;
} socket;
#endif
struct {
const unsigned char *buf, *ptr;
} irl;
} u;
YAP_Int charcount, linecount, linepos;
stream_flags_t status;
#if defined(YAPOR) || defined(THREADS)
lockvar streamlock; /* protect stream access */
#endif
int (*stream_putc)(
int, int); /** function the stream uses for writing a single octet */
int (*stream_wputc)(
int, wchar_t); /** function the stream uses for writing a character */
int (*stream_getc)(int); /** function the stream uses for reading an octet. */
int (*stream_wgetc)(
int); /** function the stream uses for reading a character. */
struct vfs *vfs; /** stream belongs to a space */
void *vfs_handle; /** direct handle to stream in that space. */
int (*stream_wgetc_for_read)(
int); /* function the stream uses for parser. It may be different
from above if the ISO character conversion is on */
encoding_t encoding; /** current encoding for stream */
} StreamDesc;
#endif

37
lib/build.gradle Normal file
View File

@ -0,0 +1,37 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "pt.up.yap.app"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
cmake {
// cFlags "-DTEST_C_FLAG1" "-DTEST_C_FLAG2"
// cppFlags "-DTEST_CPP_FLAG2" "-DTEST_CPP_FLAG2"
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
}

113
lib/lib.iml Normal file
View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":lib" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":lib" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.2.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/exposed-instrumentation-api-publish/0.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/rules/0.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/runner/0.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.2.2" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.4.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-integration-1.3" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.4.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.4.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.4.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.4.0" level="project" />
</component>
</module>

60
libYap.cmakr Normal file
View File

@ -0,0 +1,60 @@
include (Sources)
#
include_directories (H H/generated include os OPTYap utf8proc JIT/HPP)
include_directories (BEFORE ${CMAKE_BINARY_DIR})
#utf-8 is not an option
# we use the nice UTF-8 package
#available at the Julia project
include_directories ( utf8proc )
ADD_SUBDIRECTORY ( utf8proc )
find_package (GMP)
macro_log_feature (GMP_FOUND
"GNU libgmp (in some cases MPIR"
"GNU big integers and rationals"
"http://gmplib.org")
set(YAP_SYSTEM_OPTIONS "big_numbers " ${YAP_SYSTEM_OPTIONS})
if (GMP_FOUND)
# GMP_FOUND - true if GMP/MPIR was found
# GMP_INCLUDE_DIRS - include search path
# GMP_LIBRARIES - libraries to link with
# GMP_LIBRARY_DLL - library DLL to install. Only available on WIN32.
# GMP_LIBRARIES_DIR - the directory the library we link with is found in.
include_directories (${GMP_INCLUDE_DIRS})
#add_executable(test ${SOURCES})
add_library(libGMP SHARED IMPORTED GLOBAL)
set_target_properties(libGMP PROPERTIES IMPORTED_LOCATION ${GMP_LIBRARIES})
#config.h needs this (TODO: change in code latter)
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIRS} )
endif (GMP_FOUND)
include( Threads )
#
# include OS and I/o stuff
#
# convenience libraries
# OPTYap exports important flags
#
add_subDIRECTORY (OPTYap)
add_subDIRECTORY (packages/myddas)
add_subDIRECTORY (os)
#bootstrap and saved state
add_subDIRECTORY (pl)
#C++ interface
add_subDIRECTORY (CXX)
ADD_SUBDIRECTORY(swi/library)
ADD_SUBDIRECTORY(library)

View File

@ -0,0 +1,3 @@
## 0.1.0 - First Release
* Every feature added
* Every bug fixed

View File

@ -0,0 +1,3 @@
# language-yap package
A short description of your package.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,14 @@
{
"name": "language-yap",
"version": "0.0.0",
"description": "A short description of your package",
"keywords": [
],
"repository": "https://github.com/atom/language-yap",
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
},
"dependencies": {
}
}

View File

@ -0,0 +1,554 @@
".source.prolog":
editor:
increaseIndentPattern: "(:-|--\\>)\\s*$|^\\s*(->|\\*->|\\;)\\s*$|^\\s*(->|\\*->|\\(|\\{|\\;)\\s*$"
decreaseIndentPattern: "^\\s*(->|\\*->|\\}(\\,)?|\\)(\\,)?|\\;)\\s*$"
decreaseNextIndentPattern: "(\\.)\\s*$"
foldEndPattern: "(\\*/|:-\\s+(endif|end_(object|protocol|category))(?=[.]))"
foldingStartMarker: "^(([a-z]\\w*|\\'\\$\\w\\')\\(|\\s*\\(|\\s*\\/\\*)"
foldingStopMarker: "(\\)|\\.|\\*\\/)\\s*$"
completions: [
"C"
"abolish"
"abolish_all_tables"
"abolish_frozen_choice_points"
"abolish_module"
"abolish_table"
"abort"
"absolute_file_name"
"absolute_file_system_path"
"access"
"access_file"
"acyclic_term"
"add_import_module"
"add_to_array_element"
"add_to_path"
"alarm"
"all"
"always_prompt_user"
"arena_size"
"arg"
"array"
"array_element"
"assert"
"assert_static"
"asserta"
"asserta_static"
"assertz"
"assertz_static"
"at_end_of_line"
"at_end_of_stream"
"at_end_of_stream_0"
"at_halt"
"atom"
"atom_chars"
"atom_codes"
"atom_concat"
"atom_length"
"atom_number"
"atom_string"
"atom_to_term"
"atomic"
"atomic_concat"
"atomic_length"
"atomic_list_concat"
"atomics_to_string"
"attvar"
"b_getval"
"b_setval"
"bagof"
"bb_delete"
"bb_get"
"bb_put"
"bb_update"
"between"
"bootstrap"
"break"
"call"
"call_cleanup"
"call_count"
"call_count_data"
"call_count_reset"
"call_residue"
"call_residue_vars"
"call_shared_object_function"
"call_with_args"
"callable"
"catch"
"catch_ball"
"cd"
"cfile_search_path"
"char_code"
"char_conversion"
"char_type"
"clause"
"clause_property"
"close"
"close_shared_object"
"close_static_array"
"code_type"
"commons_directory"
"commons_library"
"compare"
"compile"
"compile_expressions"
"compile_predicates"
"compound"
"consult"
"consult_depth"
"context_module"
"copy_term"
"copy_term_nat"
"create_mutable"
"create_prolog_flag"
"creep_allowed"
"current_atom"
"current_char_conversion"
"current_host"
"current_input"
"current_key"
"current_line_number"
"current_module"
"current_mutex"
"current_op"
"current_output"
"current_predicate"
"current_prolog_flag"
"current_reference_count"
"current_stream"
"current_thread"
"db_files"
"db_reference"
"debug"
"debugging"
"decrease_reference_count"
"del_attr"
"del_attrs"
"delete_import_module"
"depth_bound_call"
"dif"
"discontiguous"
"display"
"do_c_built_in"
"do_c_built_metacall"
"do_not_compile_expressions"
"dum"
"dump_active_goals"
"duplicate_term"
"dynamic"
"dynamic_predicate"
"dynamic_update_array"
"eamconsult"
"eamtrans"
"end_of_file"
"ensure_loaded"
"erase"
"eraseall"
"erased"
"exists"
"exists_directory"
"exists_file"
"exists_source"
"exo_files"
"expand_expr"
"expand_exprs"
"expand_file_name"
"expand_goal"
"expand_term"
"expects_dialect"
"export"
"export_list"
"export_resource"
"extend"
"fail"
"false"
"file_base_name"
"file_directory_name"
"file_exists"
"file_name_extension"
"file_search_path"
"file_size"
"fileerrors"
"findall"
"float"
"flush_output"
"forall"
"foreign_directory"
"format"
"freeze"
"freeze_choice_point"
"frozen"
"functor"
"garbage_collect"
"garbage_collect_atoms"
"gc"
"get"
"get0"
"get_attr"
"get_attrs"
"get_byte"
"get_char"
"get_code"
"get_depth_limit"
"get_mutable"
"get_string_code"
"get_value"
"getcwd"
"getenv"
"global_trie_statistics"
"ground"
"grow_heap"
"grow_stack"
"halt"
"heap_space_info"
"hide_atom"
"hide_predicate"
"hostname_address"
"hread_get_message"
"hread_signal"
"if"
"ignore"
"import_module"
"incore"
"increase_reference_count"
"init_random_state"
"initialization"
"instance"
"instance_property"
"int_message"
"integer"
"is"
"is_absolute_file_name"
"is_list"
"is_mutable"
"is_tabled"
"isinf"
"isnan"
"key_erased_statistics"
"key_statistics"
"keysort"
"leash"
"length"
"libraries_directories"
"line_count"
"listing"
"load_absolute_foreign_files"
"load_db"
"load_files"
"load_foreign_files"
"log_event"
"logsum"
"ls"
"ls_imports"
"make"
"make_directory"
"make_library_index"
"message_queue_create"
"message_queue_destroy"
"message_queue_property"
"message_to_string"
"mmapped_array"
"module"
"module_property"
"module_state"
"msort"
"multifile"
"must_be_of_type"
"mutex_create"
"mutex_property"
"mutex_unlock_all"
"name"
"nb_create"
"nb_current"
"nb_delete"
"nb_getval"
"nb_linkarg"
"nb_linkval"
"nb_set_bit"
"nb_set_shared_arg"
"nb_set_shared_val"
"nb_setarg"
"nb_setval"
"new_system_module"
"nl"
"no_source"
"no_style_check"
"nodebug"
"nofileeleerrors"
"nogc"
"nonvar"
"nospy"
"nospyall"
"not"
"notrace"
"nth_clause"
"nth_instance"
"number"
"number_atom"
"number_chars"
"number_codes"
"number_string"
"numbervars"
"on_exception"
"on_signal"
"once"
"op"
"opaque"
"open"
"open_pipe_stream"
"open_shared_object"
"opt_statistics"
"or_statistics"
"ortray_clause"
"otherwise"
"parallel"
"parallel_findall"
"parallel_findfirst"
"parallel_once"
"path"
"peek"
"peek_byte"
"peek_char"
"peek_code"
"phrase"
"plus"
"portray_clause"
"predicate_erased_statistics"
"predicate_property"
"predicate_statistics"
"predmerge"
"predsort"
"primitive"
"print"
"print_message"
"print_message_lines"
"private"
"profalt"
"profend"
"profile_data"
"profile_reset"
"profinit"
"profoff"
"profon"
"prolog"
"prolog_current_frame"
"prolog_file_name"
"prolog_file_type"
"prolog_flag"
"prolog_flag_property"
"prolog_initialization"
"prolog_load_context"
"prolog_to_os_filename"
"prompt"
"prompt1"
"put"
"put_attr"
"put_attrs"
"put_byte"
"put_char"
"put_char1"
"put_code"
"putenv"
"pwd"
"qend_program"
"qload_file"
"qload_module"
"qpack_clean_up_to_disjunction"
"qsave_file"
"qsave_module"
"qsave_program"
"raise_exception"
"rational"
"rational_term_to_tree"
"read"
"read_clause"
"read_sig"
"read_term"
"read_term_from_atom"
"read_term_from_atomic"
"read_term_from_string"
"real_path"
"reconsult"
"recorda"
"recorda_at"
"recordaifnot"
"recorded"
"recordz"
"recordz_at"
"recordzifnot"
"release_random_state"
"remove_from_path"
"rename"
"repeat"
"reset_static_array"
"reset_total_choicepoints"
"resize_static_array"
"restore"
"retract"
"retractall"
"rmdir"
"same_file"
"save_program"
"see"
"seeing"
"seen"
"set_base_module"
"set_input"
"set_output"
"set_prolog_flag"
"set_random_state"
"set_stream"
"set_stream_position"
"set_value"
"setarg"
"setenv"
"setof"
"setup_call_catcher_cleanup"
"setup_call_cleanup"
"sformat"
"sh"
"show_all_local_tables"
"show_all_tables"
"show_global_trie"
"show_global_trieshow_tabled_predicates"
"show_low_level_trace"
"show_table"
"show_tabled_predicates"
"showprofres"
"simple"
"skip"
"skip1"
"socket"
"socket_accept"
"socket_bind"
"socket_close"
"socket_connect"
"socket_listen"
"sort"
"sort2"
"source"
"source_file"
"source_file_property"
"source_location"
"source_mode"
"source_module"
"split_path_file"
"spy"
"srandom"
"start_low_level_trace"
"stash_predicate"
"static_array"
"static_array_location"
"static_array_properties"
"static_array_to_term"
"statistics"
"stop_low_level_trace"
"stream_position"
"stream_position_data"
"stream_property"
"stream_select"
"string"
"string_chars"
"string_code"
"string_codes"
"string_concat"
"string_length"
"string_number"
"string_to_atom"
"string_to_atomic"
"string_to_list"
"strip_module"
"style_check"
"sub_atom"
"sub_string"
"subsumes_term"
"succ"
"sys_debug"
"system"
"system_error"
"system_library"
"system_module"
"system_predicate"
"t_body"
"t_head"
"t_hgoal"
"t_hlist"
"t_tidy"
"tab"
"tab1"
"table"
"table_statistics"
"tabling_mode"
"tabling_statistics"
"tell"
"telling"
"term_attvars"
"term_factorized"
"term_to_atom"
"term_to_string"
"term_variables"
"thread_at_exit"
"thread_cancel"
"thread_create"
"thread_default"
"thread_defaults"
"thread_detach"
"thread_exit"
"thread_get_message"
"thread_join"
"thread_local"
"thread_peek_message"
"thread_property"
"thread_self"
"thread_send_message"
"thread_set_default"
"thread_set_defaults"
"thread_signal"
"thread_sleep"
"thread_statistics"
"threads"
"throw"
"time"
"time_file"
"time_file64"
"told"
"tolower"
"total_choicepoints"
"total_erased"
"toupper"
"trace"
"true"
"true_file_name"
"ttyget"
"ttyget0"
"ttynl"
"ttyput"
"ttyskip"
"udi"
"unhide_atom"
"unify_with_occurs_check"
"unix"
"unknown"
"unload_file"
"unload_module"
"unnumbervars"
"update_array"
"update_mutable"
"use_module"
"use_system_module"
"user_defined_directive"
"var"
"version"
"volatile"
"wake_choice_point"
"when"
"with_mutex"
"with_output_to"
"working_directory"
"write"
"write_canonical"
"write_depth"
"write_term"
"writeln"
"writeq"
"yap_flag"
]

View File

@ -0,0 +1,13 @@
".source.prolog":
DCG:
prefix: "dcg"
body: "${1:clause} --> ${0:body}."
Fact:
prefix: "fact"
body: "${1:functor_name}(${2:argument})."
Rule:
prefix: "rule"
body: '''
${1:functor_name}(${2:argument}) :-
${0:%% body}
'''

@ -0,0 +1 @@
Subproject commit d955aca38b7aadce76e6815eb09487a370206742

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.prolog</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START_2</string>
<key>value</key>
<string>/*</string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END_2</string>
<key>value</key>
<string>*/</string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>%% </string>
</dict>
</array>
</dict>
<key>uuid</key>
<string>6994367b-9316-4412-ba64-2c1f741abc8d</string>
</dict>
</plist>

View File

@ -0,0 +1,3 @@
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

373
misc/editors/sublimeyap/MPL Normal file
View File

@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@ -0,0 +1,11 @@
Prolog Syntax Highlighting
==========================
NEW: support for YAP Prolog
Just a quick info for old users: Prolog Syntax Highlighting has
integrated a different dialect, namely ECLiPSe Prolog, thanks to
@pchaigno.
You can find the old syntax highlighting under:
Prolog->SWI-Prolog

View File

@ -0,0 +1,46 @@
# Prolog syntax highlighting for YAP 2 & 3 #
This package adapts the Sublime prolog package to also support YAP.
# Prolog syntax highlighting for Sublime Text 2 & 3 #
This package provides syntax highlighting and automated build for the logic
programming language Prolog. It is highly work in progress, so use with care.
## Auto Build System ##
To be able to use the `Ctrl+B` automatic build, you need to define `main/0`
where you compute the solution and you also print it. For example:
main :- compute(input, Solution), writef('%t\n', [Solution]).
An indicator that this is not done (correctly) is the following error:
ERROR: call/2: Undefined procedure: main/1
ERROR: However, there are definitions for:
ERROR: main/0
## Installation ##
### Installation via Sublime Package Control ###
I recommend using the [Sublime Package Control] [1] to install this package.
This way is much more convenient. It is named *Prolog syntax highlighting*
there, as well.
[1]: http://wbond.net/sublime_packages/package_control
### Manual installation ###
If you want to manually install this package, please do:
cd /tmp
wget -O sublimeprolog.tar.gz http://github.com/alnkpa/sublimeprolog/tarball/master
tar -xzvf sublimeprolog.tar.gz
cd alnkpa-sublimeprolog-<commit>
mv Prolog.tmLanguage ~/.config/sublime-text-2/Packages/User/
## License ##
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at <http://mozilla.org/MPL/2.0/>.

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Miscellaneous</string>
<key>scope</key>
<string>source.prolog</string>
<key>settings</key>
<dict>
<key>disableIndentCorrections</key>
<true/>
<key>highlightPairs</key>
<array>
<array>
<string>[</string>
<string>]</string>
</array>
<array>
<string>(</string>
<string>)</string>
</array>
</array>
<key>increaseIndentPattern</key>
<string>():-\s*$\( \s$</string>
<key>indentOnPaste</key>
<string>simple</string>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>% </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_START_2</string>
<key>value</key>
<string>/*</string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END_2</string>
<key>value</key>
<string>*/</string>
</dict>
</array>
<key>smartTypingPairs</key>
<array>
<array>
<string>[</string>
<string>]</string>
</array>
<array>
<string>(</string>
<string>)</string>
</array>
</array>
</dict>
<key>uuid</key>
<string>487758CF-13E2-413E-8A12-224771481FE9</string>
</dict>
</plist>

View File

@ -207,7 +207,7 @@
:- module(ad_converter,[term_expansion_intern_ad/4,
op(1149, yfx, <-- ),
op( 550, yfx, :: )
]).
]). ƒcrete
% general yap modules
:- use_module(library(lists),[member/2,append/3]).
@ -302,7 +302,7 @@ term_expansion_intern_ad((Head<--Body), Module, Mode, [user:ad_intern((Head<--Bo
).
term_expansion_intern_ad( (Head<--Body),_,_) :-
format(chars(Error), 'Error at compiling the annotated disjunction ~q<--~qb.',[Head,Body]),
format(chars(Error), 'Error at compiling the annotated disjunction ~q<--~m.',[Head,Body]),
print_message(error,Error),
fail.

View File

@ -240,7 +240,6 @@ timer_stop(Name,Duration) :-
->
statistics(walltime,[StopTime,_]),
Duration is StopTime-StartTime;
throw(timer_not_started(timer_stop(Name,Duration)))
).

30
packages/cuda/old/CC_CSSTree.cu Executable file
View File

@ -0,0 +1,30 @@
#include "CC_CSSTree.h"
//return the start position of searching the key.
int CC_CSSTree::search(int key)
{
int i=0;
int curIndex=0;
int curNode=0;
int j=0;
//search
for(i=0;i<level;i++)
{
for(j=0;j<blockSize;j++)
{
if(ntree[curIndex+j]==-1)
break;
if(key<=ntree[curIndex+j])
break;
}
curNode=(fanout*(curNode)+j+1);
curIndex=curNode*blockSize;
//#ifdef DEBUG
// cout<<curNode<<", "<<j<<", "<<ntree[curIndex]<<"; ";
//#endif
}
curIndex=(curNode-numNode)*blockSize;
if(curIndex>numRecord) curIndex=numRecord-1;
//cout<<"I: "<<curIndex<<", ";//cout<<endl;
return curIndex;
}

146
packages/cuda/old/CC_CSSTree.h Executable file
View File

@ -0,0 +1,146 @@
#ifndef CSSTREE_H
#define CSSTREE_H
#include <iostream>
#include <math.h>
using namespace std;
#define divRoundUp(n,s) (((n) / (s)) + ((((n) % (s)) > 0) ? 1 : 0))
#define CSS_TREE_FANOUT 33
//we use implicit pointer to perform the addressing.
typedef int Record;
class CC_GenericTree
{
public:
int numRecord;
Record *data;
//we use the BFS layout as the default layout.
int numNode;
int level;
int gResult;
CC_GenericTree(){}
//we assume that numR=2^i. Otherwise, we pad the array with -1 from the beginning.
//we also assume that the record are sorted by the key.
CC_GenericTree(Record *d, int numR)
{
data=d;
numRecord=numR;
}
virtual ~CC_GenericTree()
{
}
virtual int search(int key)=0;
};
class CC_CSSTree:public CC_GenericTree
{
public:
int *ntree;
int fanout;
int blockSize;
int *vStart;
int *vG;//vG[0] is used in computing the position for level 1.
int numKey;
CC_CSSTree(Record *d, int numR, int f):CC_GenericTree(d,numR)
{
fanout=f;
blockSize=fanout-1;
int numLeaf=divRoundUp(numR,blockSize);
level=1;
int temp=numLeaf;
while(temp>1)
{
temp=divRoundUp(temp, fanout);
level++;
}
numNode=(int)((pow((double)fanout,(double)level)-1)/(fanout-1));
numKey=numNode*blockSize;
ntree=new int[numKey];
vStart=new int[level];
vG=new int[level];
#ifdef DEBUG
cout<<numLeaf<<","<<level<<", "<<numNode<<endl;
#endif
//layout the tree from bottom up.
int i=0,j=0,k=0;
int startNode=0;
int endNode=0;
int startKey, endKey;
int curIndex;
for(i=0;i<numNode;i++)
ntree[i]=-1;
//for <level-1>, i.e., the leaf level. [start,end]
for(i=0;i<level;i++)//level
{
startNode=(int)((pow((double)fanout,(double)i)-1)/(fanout-1));
endNode=(int)((pow((double)fanout,(double)(i+1))-1)/(fanout-1));
for(j= startNode;j< endNode;j++)//which node
{
startKey=j*blockSize;
endKey=startKey+blockSize;
for(k=startKey;k<endKey;k++)
{
curIndex=(int)(blockSize*pow((double)fanout,(double)(level-i-1))*(k+1-startNode*blockSize+(j-startNode))-1);
if(curIndex<numRecord+blockSize)
{
if(curIndex>=numRecord)
curIndex=numRecord-1;
ntree[k]=data[curIndex];
}
else
break;
}
}
}
}
~CC_CSSTree()
{
delete [] ntree;
delete [] vStart;
delete [] vG;
}
virtual int search(int key);
void print()
{
int i=0, j=0;
int k=0;
int startNode=0;
int endNode=0;
int startKey, endKey;
for(i=0;i<level;i++)//level
{
cout<<"Level, "<<i<<endl;
startNode=(int)((pow((double)fanout,(double)i)-1)/(fanout-1));
endNode=(int)((pow((double)fanout,(double)(i+1))-1)/(fanout-1));
for(j= startNode;j< endNode;j++)//which node
{
cout<<"Level, "<<i<<", Node, "<<j<<": ";
startKey=j*blockSize;
endKey=startKey+blockSize;
for(k=startKey;k<endKey;k++)
{
cout<<ntree[k]<<", ";
}
cout<<endl;
}
}
for(i=0;i<numRecord;i++)
{
cout<<data[i]<<", ";
if(i%(fanout-1)==(fanout-2))
cout<<"*"<<endl;
}
}
};
#endif

460
packages/cuda/old/bpreds.cu Executable file
View File

@ -0,0 +1,460 @@
#include <thrust/device_vector.h>
#include <thrust/scan.h>
#include <cstdarg>
#include "pred.h"
/*Determines the maximum from a set of values*/
int maximo(int count, ...)
{
va_list ap;
int j, temp, mx = 0;
va_start(ap, count);
for(j = 0; j < count; j++)
{
temp = va_arg(ap, int);
if(temp > mx)
mx = temp;
}
va_end(ap);
return mx;
}
__global__ void bpreds(int *dop1, int *dop2, int rows, int of1, int of2, int *cons, int numc, int nx, int *res, int *res2)
{
extern __shared__ int shared[];
int id = blockIdx.x * blockDim.x + threadIdx.x;
int x, rowact, rowact1, op1, op2;
if(threadIdx.x < numc)
shared[threadIdx.x] = cons[threadIdx.x];
__syncthreads();
if(id < rows)
{
rowact1 = id * of1;
rowact = id * of2;
for(x = nx; x < numc; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 = dop1[rowact1 - op1 - 1];
else
op1 = dop2[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 = dop1[rowact1 - op2 - 1];
else
op2 = dop2[rowact + op2];
switch(shared[x] - BPOFFSET)
{
case SBG_EQ: if(op1 != op2)
return;
break;
case SBG_GT: if(op1 <= op2)
return;
break;
case SBG_LT: if(op1 >= op2)
return;
break;
case SBG_GE: if(op1 < op2)
return;
break;
case SBG_LE: if(op1 > op2)
return;
break;
case SBG_DF: if(op1 == op2)
return;
}
}
if(res2 != NULL)
res2[id] = 1;
for(x = 0; x < nx; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 *= -1;
else
op1 = dop2[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 *= -1;
else
op2 = dop2[rowact + op2];
switch(shared[x])
{
case SBG_EQ: if(op1 != op2)
return;
break;
case SBG_GT: if(op1 <= op2)
return;
break;
case SBG_LT: if(op1 >= op2)
return;
break;
case SBG_GE: if(op1 < op2)
return;
break;
case SBG_LE: if(op1 > op2)
return;
break;
case SBG_DF: if(op1 == op2)
return;
}
}
res[id] = 1;
}
}
/*Mark all rows that comply with the comparison predicates*/
__global__ void bpredsnormal2(int *dop1, int rows, int of1, int *cons, int numc, int *res)
{
extern __shared__ int shared[];
int id = blockIdx.x * blockDim.x + threadIdx.x;
int x, rowact, op1, op2;
if(threadIdx.x < numc)
shared[threadIdx.x] = cons[threadIdx.x];
__syncthreads();
if(id < rows)
{
rowact = id * of1;
for(x = 0; x < numc; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 *= -1;
else
op1 = dop1[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 *= -1;
else
op2 = dop1[rowact + op2];
switch(shared[x])
{
case SBG_EQ: if(op1 != op2)
return;
break;
case SBG_GT: if(op1 <= op2)
return;
break;
case SBG_LT: if(op1 >= op2)
return;
break;
case SBG_GE: if(op1 < op2)
return;
break;
case SBG_LE: if(op1 > op2)
return;
break;
case SBG_DF: if(op1 == op2)
return;
}
}
res[id] = 1;
}
}
/*Unmark all rows that do not comply with the comparison predicates*/
__global__ void bpredsnormal(int *dop1, int rows, int of1, int *cons, int numc, int *res)
{
extern __shared__ int shared[];
int id = blockIdx.x * blockDim.x + threadIdx.x;
int x, rowact, op1, op2;
if(threadIdx.x < numc)
shared[threadIdx.x] = cons[threadIdx.x];
__syncthreads();
if(id < rows)
{
if(res[id] == 0)
return;
rowact = id * of1;
for(x = 0; x < numc; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 *= -1;
else
op1 = dop1[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 *= -1;
else
op2 = dop1[rowact + op2];
switch(shared[x])
{
case SBG_EQ: if(op1 != op2)
{
res[id] = 0;
return;
}
break;
case SBG_GT: if(op1 <= op2)
{
res[id] = 0;
return;
}
break;
case SBG_LT: if(op1 >= op2)
{
res[id] = 0;
return;
}
break;
case SBG_GE: if(op1 < op2)
{
res[id] = 0;
return;
}
break;
case SBG_LE: if(op1 > op2)
{
res[id] = 0;
return;
}
break;
case SBG_DF: if(op1 == op2)
{
res[id] = 0;
return;
}
}
}
}
}
__global__ void bpredsOR(int *dop1, int *dop2, int rows, int of1, int of2, int *cons, int numc, int nx, int *res, int *res2)
{
extern __shared__ int shared[];
int id = blockIdx.x * blockDim.x + threadIdx.x;
int x, rowact, rowact1, op1, op2;
if(threadIdx.x < numc)
shared[threadIdx.x] = cons[threadIdx.x];
__syncthreads();
if(id < rows)
{
rowact1 = id * of1;
rowact = id * of2;
for(x = nx; x < numc; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 = dop1[rowact1 - op1 - 1];
else
op1 = dop2[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 = dop1[rowact1 - op2 - 1];
else
op2 = dop2[rowact + op2];
switch(shared[x] - BPOFFSET)
{
case SBG_EQ: if(op1 == op2)
{
res2[id] = 1;
x = numc;
}
break;
case SBG_GT: if(op1 > op2)
{
res2[id] = 1;
x = numc;
}
break;
case SBG_LT: if(op1 < op2)
{
res2[id] = 1;
x = numc;
}
break;
case SBG_GE: if(op1 >= op2)
{
res2[id] = 1;
x = numc;
}
break;
case SBG_LE: if(op1 <= op2)
{
res2[id] = 1;
x = numc;
}
break;
case SBG_DF: if(op1 != op2)
{
res2[id] = 1;
x = numc;
}
}
}
for(x = 0; x < nx; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 *= -1;
else
op1 = dop2[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 *= -1;
else
op2 = dop2[rowact + op2];
switch(shared[x])
{
case SBG_EQ: if(op1 == op2)
{
res[id] = 1;
return;
}
break;
case SBG_GT: if(op1 > op2)
{
res[id] = 1;
return;
}
break;
case SBG_LT: if(op1 < op2)
{
res[id] = 1;
return;
}
break;
case SBG_GE: if(op1 >= op2)
{
res[id] = 1;
return;
}
break;
case SBG_LE: if(op1 <= op2)
{
res[id] = 1;
return;
}
break;
case SBG_DF: if(op1 != op2)
{
res[id] = 1;
return;
}
}
}
}
}
/*Mark all rows that comply with the comparison predicates using disjunctions (i.e. a row is marked if it complies with at least one predicate)*/
__global__ void bpredsorlogic2(int *dop1, int rows, int of1, int *cons, int numc, int *res)
{
extern __shared__ int shared[];
int id = blockIdx.x * blockDim.x + threadIdx.x;
int x, rowact, op1, op2;
if(threadIdx.x < numc)
shared[threadIdx.x] = cons[threadIdx.x];
__syncthreads();
if(id < rows)
{
rowact = id * of1;
for(x = 0; x < numc; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 *= -1;
else
op1 = dop1[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 *= -1;
else
op2 = dop1[rowact + op2];
switch(shared[x])
{
case SBG_EQ: if(op1 == op2)
{
res[id] = 1;
return;
}
break;
case SBG_GT: if(op1 > op2)
{
res[id] = 1;
return;
}
break;
case SBG_LT: if(op1 < op2)
{
res[id] = 1;
return;
}
break;
case SBG_GE: if(op1 >= op2)
{
res[id] = 1;
return;
}
break;
case SBG_LE: if(op1 <= op2)
{
res[id] = 1;
return;
}
break;
case SBG_DF: if(op1 != op2)
{
res[id] = 1;
return;
}
}
}
}
}
/*Unmark all rows that do not comply with the comparison predicates using disjunctions (i.e. a row is unmarked only if it complies with none of the predicates)*/
__global__ void bpredsorlogic(int *dop1, int rows, int of1, int *cons, int numc, int *res)
{
extern __shared__ int shared[];
int id = blockIdx.x * blockDim.x + threadIdx.x;
int x, rowact, op1, op2;
if(threadIdx.x < numc)
shared[threadIdx.x] = cons[threadIdx.x];
__syncthreads();
if(id < rows)
{
if(res[id] == 0)
return;
rowact = id * of1;
for(x = 0; x < numc; x += 3)
{
op1 = shared[x+1];
if(op1 < 0)
op1 *= -1;
else
op1 = dop1[rowact + op1];
op2 = shared[x+2];
if(op2 < 0)
op2 *= -1;
else
op2 = dop1[rowact + op2];
switch(shared[x])
{
case SBG_EQ: if(op1 == op2)
return;
break;
case SBG_GT: if(op1 > op2)
return;
break;
case SBG_LT: if(op1 < op2)
return;
break;
case SBG_GE: if(op1 >= op2)
return;
break;
case SBG_LE: if(op1 <= op2)
return;
break;
case SBG_DF: if(op1 != op2)
return;
}
}
res[id] = 0;
}
}

12
packages/cuda/old/bpreds.h Executable file
View File

@ -0,0 +1,12 @@
#ifndef _BPREDS_H_
#define _BPREDS_H_
int maximo(int, ...);
__global__ void bpreds(int*, int*, int, int, int, int*, int, int, int*, int*);
__global__ void bpredsnormal(int*, int, int, int*, int, int*);
__global__ void bpredsnormal2(int*, int, int, int*, int, int*);
__global__ void bpredsOR(int*, int*, int, int, int, int*, int, int, int*, int*);
__global__ void bpredsorlogic(int*, int, int, int*, int, int*);
__global__ void bpredsorlogic2(int*, int, int, int*, int, int*);
#endif

197
packages/cuda/old/creator2.c Executable file
View File

@ -0,0 +1,197 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
/*Program used to generate union2.cu and union2.h. A new pointer and all its operations are generated for each set (pairs, triplets, etc.).
Arguments are the cardinality of the biggest set and the name of the cuda file. For example, executing "creator2 20 union2" will generate
all pointers and operations for all sets from 1 to 20 in the files union2.cu and union2.h.*/
int main(int argc, char *argv[])
{
int num = atoi(argv[1]);
int x;
char *str = (char *)malloc((strlen(argv[2]) + 4) * sizeof(char));
sprintf(str, "%s.cu", argv[2]);
FILE *cuda = fopen(str, "w");
fprintf(cuda, "/*Computer generated file to remove duplicates. Since Thrust's unique and sort, unlike their std's counterparts, don't have a way to specify the size of each element in\n");
fprintf(cuda, "the array, comparing pairs, triplets and other sets is not possible without defining a new pointer and all related operations for each set. If you have a better idea to do\n");
fprintf(cuda, "this, please don't hesitate to email us.*/\n\n");
fprintf(cuda, "#include <thrust/device_vector.h>\n");
fprintf(cuda, "#include <thrust/unique.h>\n");
fprintf(cuda, "#include <thrust/distance.h>\n");
fprintf(cuda, "#include <thrust/sort.h>\n");
fprintf(cuda, "#include <iostream>\n");
fprintf(cuda, "#include \"memory.h\"\n");
fprintf(cuda, "#include \"%s.h\"\n\n", argv[2]);
fprintf(cuda, "int unir(int *res, int rows, int tipo, int **ret, int final)\n");
fprintf(cuda, "{\n");
fprintf(cuda, "\tthrust::device_ptr<int> pt, re;\n");
for(x = 2; x <= num; x++)
fprintf(cuda, "\tthrust::device_ptr<s%d> pt%d, re%d;\n", x, x ,x);
for(x = 2; x <= num; x++)
fprintf(cuda, "\ts%d *t%d;\n", x, x);
fprintf(cuda, "\tint flag, nrows, *nres, size;\n\n");
fprintf(cuda, "#if TIMER\n");
fprintf(cuda, "\tcuda_stats.unions++;\n");
fprintf(cuda, "#endif\n\n");
fprintf(cuda, "\tswitch(tipo)\n");
fprintf(cuda, "\t{\n");
fprintf(cuda, "\t\tcase 1:\n");
fprintf(cuda, "\t\t{\n");
fprintf(cuda, "\t\t\tpt = thrust::device_pointer_cast(res);\n");
fprintf(cuda, "\t\t\tflag = 0;\n");
fprintf(cuda, "\t\t\twhile(flag != 1)\n");
fprintf(cuda, "\t\t\t{\n");
fprintf(cuda, "\t\t\t\ttry\n");
fprintf(cuda, "\t\t\t\t{\n");
fprintf(cuda, "\t\t\t\t\tthrust::sort(pt, pt + rows);\n");
fprintf(cuda, "\t\t\t\t\tif(final)\n");
fprintf(cuda, "\t\t\t\t\t{\n");
fprintf(cuda, "\t\t\t\t\t\tre = thrust::unique(pt, pt + rows, q1());\n");
fprintf(cuda, "\t\t\t\t\t\tre = thrust::unique(pt, re);\n");
fprintf(cuda, "\t\t\t\t\t}\n");
fprintf(cuda, "\t\t\t\t\telse\n");
fprintf(cuda, "\t\t\t\t\t\tre = thrust::unique(pt, pt + rows);\n");
fprintf(cuda, "\t\t\t\t\tflag = 1;\n");
fprintf(cuda, "\t\t\t\t}\n");
fprintf(cuda, "\t\t\t\tcatch(std::bad_alloc &e)\n");
fprintf(cuda, "\t\t\t\t{\n");
fprintf(cuda, "\t\t\t\t\tlimpiar(\"sort/unique in unir\", 0);\n");
fprintf(cuda, "\t\t\t\t}\n");
fprintf(cuda, "\t\t\t}\n");
fprintf(cuda, "\t\t\tnrows = thrust::distance(pt, re);\n");
fprintf(cuda, "\t\t\tif(nrows < rows / 2)\n");
fprintf(cuda, "\t\t\t{\n");
fprintf(cuda, "\t\t\t\tsize = nrows * tipo * sizeof(int);\n");
fprintf(cuda, "\t\t\t\treservar(&nres, size);\n");
fprintf(cuda, "\t\t\t\tcudaMemcpyAsync(nres, res, size, cudaMemcpyDeviceToDevice);\n");
fprintf(cuda, "\t\t\t\tcudaFree(*ret);\n");
fprintf(cuda, "\t\t\t\t*ret = nres;\n");
fprintf(cuda, "\t\t\t}\n");
fprintf(cuda, "\t\t\treturn nrows;\n");
fprintf(cuda, "\t\t}\n");
for(x = 2; x <= num; x++)
{
fprintf(cuda, "\t\tcase %d:\n", x);
fprintf(cuda, "\t\t{\n");
fprintf(cuda, "\t\t\tt%d = (s%d*)res;\n", x, x);
fprintf(cuda, "\t\t\tpt%d = thrust::device_pointer_cast(t%d);\n", x, x);
fprintf(cuda, "\t\t\tflag = 0;\n");
fprintf(cuda, "\t\t\twhile(flag != 1)\n");
fprintf(cuda, "\t\t\t{\n");
fprintf(cuda, "\t\t\t\ttry\n");
fprintf(cuda, "\t\t\t\t{\n");
fprintf(cuda, "\t\t\t\t\tthrust::sort(pt%d, pt%d + rows, o%d());\n", x, x, x);
fprintf(cuda, "\t\t\t\t\tif(final)\n");
fprintf(cuda, "\t\t\t\t\t{\n");
fprintf(cuda, "\t\t\t\t\t\tre%d = thrust::unique(pt%d, pt%d + rows, q%d());\n", x, x, x, x);
fprintf(cuda, "\t\t\t\t\t\tre%d = thrust::unique(pt%d, re%d, p%d());\n", x, x, x, x);
fprintf(cuda, "\t\t\t\t\t}\n");
fprintf(cuda, "\t\t\t\t\telse\n");
fprintf(cuda, "\t\t\t\t\t\tre%d = thrust::unique(pt%d, pt%d + rows, p%d());\n", x, x, x, x);
fprintf(cuda, "\t\t\t\t\tflag = 1;\n");
fprintf(cuda, "\t\t\t\t}\n");
fprintf(cuda, "\t\t\t\tcatch(std::bad_alloc &e)\n");
fprintf(cuda, "\t\t\t\t{\n");
fprintf(cuda, "\t\t\t\t\tlimpiar(\"sort/unique in unir\", 0);\n");
fprintf(cuda, "\t\t\t\t}\n");
fprintf(cuda, "\t\t\t}\n");
fprintf(cuda, "\t\t\tnrows = thrust::distance(pt%d, re%d);\n", x, x);
fprintf(cuda, "\t\t\tif(nrows < rows / 2)\n");
fprintf(cuda, "\t\t\t{\n");
fprintf(cuda, "\t\t\t\tsize = nrows * tipo * sizeof(int);\n");
fprintf(cuda, "\t\t\t\treservar(&nres, size);\n");
fprintf(cuda, "\t\t\t\tcudaMemcpyAsync(nres, res, size, cudaMemcpyDeviceToDevice);\n");
fprintf(cuda, "\t\t\t\tcudaFree(*ret);\n");
fprintf(cuda, "\t\t\t\t*ret = nres;\n");
fprintf(cuda, "\t\t\t}\n");
fprintf(cuda, "\t\t\treturn nrows;\n");
fprintf(cuda, "\t\t}\n");
}
fprintf(cuda, "\t}\n");
fprintf(cuda, "\treturn 0;\n");
fprintf(cuda, "}\n");
fclose(cuda);
sprintf(str, "%s.h", argv[2]);
cuda = fopen(str, "w"); /*tipo de archivo cambiar*/
fprintf(cuda, "#ifndef _");
for(x = 0; x < strlen(argv[2]); x++)
fprintf(cuda, "%c", toupper(argv[2][x]));
fprintf(cuda, "_H_\n");
fprintf(cuda, "#define _");
for(x = 0; x < strlen(argv[2]); x++)
fprintf(cuda, "%c", toupper(argv[2][x]));
fprintf(cuda, "_H_\n\n");
fprintf(cuda, "int unir(int *res, int rows, int tipo, int **ret, int final);\n\n");
for(x = 2; x <= num; x++)
{
fprintf(cuda, "typedef struct n%d\n", x);
fprintf(cuda, "{\n");
fprintf(cuda, "\tint v[%d];\n", x);
fprintf(cuda, "}s%d;\n\n", x);
}
fprintf(cuda, "struct q1\n");
fprintf(cuda, "{\n");
fprintf(cuda, "\t__host__ __device__\n");
fprintf(cuda, "\tbool operator()(const int &r1, const int &r2)\n");
fprintf(cuda, "\t{\n");
fprintf(cuda, "\t\tif(r1 != r2)\n");
fprintf(cuda, "\t\t\treturn true;\n");
fprintf(cuda, "\t\treturn false;\n");
fprintf(cuda, "\t}\n");
fprintf(cuda, "};\n\n");
for(x = 2; x <= num; x++)
{
fprintf(cuda, "struct p%d\n", x);
fprintf(cuda, "{\n");
fprintf(cuda, "\t__host__ __device__\n");
fprintf(cuda, "\tbool operator()(const s%d &r1, const s%d &r2)\n", x, x);
fprintf(cuda, "\t{\n");
fprintf(cuda, "\t\tint x;\n");
fprintf(cuda, "\t\tfor(x = 0; x < %d; x++)\n", x);
fprintf(cuda, "\t\t{\n");
fprintf(cuda, "\t\t\tif(r1.v[x] != r2.v[x])\n");
fprintf(cuda, "\t\t\t\treturn false;\n");
fprintf(cuda, "\t\t}\n");
fprintf(cuda, "\t\treturn true;\n");
fprintf(cuda, "\t}\n");
fprintf(cuda, "};\n\n");
fprintf(cuda, "struct q%d\n", x);
fprintf(cuda, "{\n");
fprintf(cuda, "\t__host__ __device__\n");
fprintf(cuda, "\tbool operator()(const s%d &r1, const s%d &r2)\n", x, x);
fprintf(cuda, "\t{\n");
fprintf(cuda, "\t\tint x;\n");
fprintf(cuda, "\t\tfor(x = 0; x < %d; x++)\n", x);
fprintf(cuda, "\t\t{\n");
fprintf(cuda, "\t\t\tif(r1.v[x] != r2.v[x])\n");
fprintf(cuda, "\t\t\t\treturn true;\n");
fprintf(cuda, "\t\t}\n");
fprintf(cuda, "\t\treturn false;\n");
fprintf(cuda, "\t}\n");
fprintf(cuda, "};\n\n");
fprintf(cuda, "struct o%d\n", x);
fprintf(cuda, "{\n");
fprintf(cuda, "\t__host__ __device__\n");
fprintf(cuda, "\tbool operator()(const s%d &r1, const s%d &r2)\n", x, x);
fprintf(cuda, "\t{\n");
fprintf(cuda, "\t\tint x;\n");
fprintf(cuda, "\t\tfor(x = 0; x < %d; x++)\n", x);
fprintf(cuda, "\t\t{\n");
fprintf(cuda, "\t\t\tif(r1.v[x] > r2.v[x])\n");
fprintf(cuda, "\t\t\t\treturn true;\n");
fprintf(cuda, "\t\t\tif(r1.v[x] < r2.v[x])\n");
fprintf(cuda, "\t\t\t\treturn false;\n");
fprintf(cuda, "\t\t}\n");
fprintf(cuda, "\t\treturn false;\n");
fprintf(cuda, "\t}\n");
fprintf(cuda, "};\n\n");
}
fprintf(cuda, "#endif\n");
fclose(cuda);
free(str);
}

View File

@ -0,0 +1,26 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "MetaKernel YAP 3",
"language": "prolog",
"name": "yap_kernel"
},
"widgets": {
"state": {},
"version": "1.1.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,86 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"code_folding": [],
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<ipywidgets.widgets.widget_selection.ToggleButtons object at 0x105e24da0>\n",
"No (more) answers\n"
]
}
],
"source": [
":= import(mathplot).\n",
"X := plot([1,2,3])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": " YAP-6.3",
"language": "prolog",
"name": "yap_kernel"
},
"language_info": {
"codemirror_mode": {
"name": "prolog",
"version": 2
},
"file_extension": ".yap",
"help_links": [
{
"text": "MetaKernel Magics",
"url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
}
],
"mimetype": "text/prolog",
"name": "text",
"pygments_lexer": "prolog",
"version": "0.0.1"
},
"latex_envs": {
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 0
},
"nav_menu": {},
"toc": {
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 6,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false
},
"widgets": {
"state": {
"09b21d398da9424d94cf3c8e51054154": {
"views": []
},
"369de2fecba34468a7c9cf64076bac60": {
"views": []
},
"7f758a42f83c469882761606f7f8133e": {
"views": []
},
"c028bb350ed6424eb48a02762907868d": {
"views": []
}
},
"version": "1.1.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

View File

@ -0,0 +1,152 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: callcount.yap *
* Last rev: 8/2/02 *
* mods: *
* comments: Some profiling predicates available in yap *
* *
*************************************************************************/
%% @{
/** @defgroup Profiling Profiling Prolog Programs
@ingroup extensions
YAP includes two profilers. The count profiler keeps information on the
number of times a predicate was called. This information can be used to
detect what are the most commonly called predicates in the program. The
count profiler can be compiled by setting YAP's flag profiling
to `on`. The time-profiler is a `gprof` profiler, and counts
how many ticks are being spent on specific predicates, or on other
system functions such as internal data-base accesses or garbage collects.
The YAP profiling sub-system is currently under
development. Functionality for this sub-system will increase with newer
implementation.
*/
%% @{
/** @defgroup Call_Counting Counting Calls
@ingroup Profiling
Predicates compiled with YAP's flag call_counting set to
`on` update counters on the numbers of calls and of
retries. Counters are actually decreasing counters, so that they can be
used as timers. Three counters are available:
+ `calls`: number of predicate calls since execution started or since
system was reset;
+ `retries`: number of retries for predicates called since
execution started or since counters were reset;
+ `calls_and_retries`: count both on predicate calls and
retries.
These counters can be used to find out how many calls a certain
goal takes to execute. They can also be used as timers.
The code for the call counters piggybacks on the profiling
code. Therefore, activating the call counters also activates the profiling
counters.
These are the predicates that access and manipulate the call counters.
*/
:- system_module( '$_callcount', [call_count/3,
call_count_data/3,
call_count_reset/0], []).
:- use_system_module( '$_errors', ['$do_error'/2]).
/** @pred call_count_data(- _Calls_, - _Retries_, - _CallsAndRetries_)
Give current call count data. The first argument gives the current value
for the _Calls_ counter, next the _Retries_ counter, and last
the _CallsAndRetries_ counter.
*/
call_count_data(Calls, Retries, Both) :-
'$call_count_info'(Calls, Retries, Both).
/** @pred call_count_reset
Reset call count counters. All timers are also reset.
*/
call_count_reset :-
'$call_count_reset'.
/** @pred call_count(? _CallsMax_, ? _RetriesMax_, ? _CallsAndRetriesMax_)
Set call counters as timers. YAP will generate an exception
if one of the instantiated call counters decreases to 0:
+ _CallsMax_
throw the exception `call_counter` when the
counter `calls` reaches 0;
+ _RetriesMax_
throw the exception `retry_counter` when the
counter `retries` reaches 0;
+ _CallsAndRetriesMax_
throw the exception
`call_and_retry_counter` when the counter `calls_and_retries`
reaches 0.
YAP will ignore counters that are called with unbound arguments.
Next, we show a simple example of how to use call counters:
~~~~~{.prolog}
?- yap_flag(call_counting,on), [-user]. l :- l. end_of_file. yap_flag(call_counting,off).
yes
yes
?- catch((call_count(10000,_,_),l),call_counter,format("limit_exceeded.~n",[])).
limit_exceeded.
yes
~~~~~
Notice that we first compile the looping predicate `l/0` with
call_counting `on`. Next, we catch/3 to handle an
exception when `l/0` performs more than 10000 reductions.
*/
call_count(Calls, Retries, Both) :-
'$check_if_call_count_on'(Calls, CallsOn),
'$check_if_call_count_on'(Retries, RetriesOn),
'$check_if_call_count_on'(Both, BothOn),
'$call_count_set'(Calls, CallsOn, Retries, RetriesOn, Both, BothOn).
'$check_if_call_count_on'(Calls, 1) :- integer(Calls), !.
'$check_if_call_count_on'(Calls, 0) :- var(Calls), !.
'$check_if_call_count_on'(Calls, A) :-
'$do_error'(type_error(integer,Calls),call_count(A)).
%% @}
/**
@}
*/

View File

@ -0,0 +1,92 @@
from __future__ import print_function
from metakernel import MetaKernel
from metakernel import register_ipython_magics
register_ipython_magics()
class MetaKernelyap(MetaKernel):
implementation = 'MetaKernel YAP'
implementation_version = '1.0'
language = 'text'
language_version = '0.1'
banner = "MetaKernel YAP"
language_info = {
'mimetype': 'text/plain',
'name': 'text',
# ------ If different from 'language':
'codemirror_mode': {
"version": 2,
"name": "prolog"
}
'pygments_lexer': 'language',
'version' : "0.0.1",
'file_extension': '.yap',
'help_links': MetaKernel.help_links,
}
def __init__(self, **kwargs):
MetaKernel.__init__(self, **kwargs)
self._start_yap()
self.qq = None sq
def _start_yap(self):
# Signal handlers are inherited by forked processes, and we can't easily
# reset it from the subprocess. Since kernelapp ignores SIGINT except in
# message handlers, we need to temporarily reset the SIGINT handler here
# so that yap and its children are interruptible.
sig = signal.signal(signal.SIGINT, signal.SIG_DFL)
try:
engine = yap.YAPEngine()
engine.query("load_files(library(python), [])").command()
banner = "YAP {0} Kernel".format(self.engine.version())
finally:
signal.signal(signal.SIGINT, sig)
# Register Yap function to write image data to temporary file
#self.yapwrapper.run_command(image_setup_cmd)
def get_usage(self):
return "This is the YAP kernel."
def do_execute_direct(self, code):
if not code.strip():
return {'status': 'ok', 'execution_count': self.execution_count,
'payload': [], 'user_expressions': {}}
interrupted = False
try:
print self.q
if self.q is None:
self.q = self.engine.query(code.rstrip())
if self.q.next():
vs = self.q.namedVars()
if vs.length() > 0:
l = []
while vs.length() > 0:
eq = vs.car()
l.append(' '.join([getArg(1).text(), '=', eq.getArg(2).text())
vs = vs.cdr()
l.append(';')
o = '\n'.join(l)
else:
return 'yes'
self.q = None
else:
return 'no'
self.q = None
def repr(self, data):
return repr(data)
if __name__ == '__main__':
try:
from ipykernel.kernelapp import IPKernelApp
except ImportError:
from IPython.kernel.zmq.kernelapp import IPKernelApp
IPKernelApp.launch_instance(kernel_class=MetaKernelyap)

View File

@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: yapex
Version: 0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN

View File

@ -0,0 +1,11 @@
setup.py
/Users/vsc/Yap/yap-6.3/packages/python/yapex.py
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/PKG-INFO
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/SOURCES.txt
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/dependency_links.txt
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/top_level.txt
/Users/vsc/github/yap-6.3/packages/python/yapex.py
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/PKG-INFO
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/SOURCES.txt
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/dependency_links.txt
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/top_level.txt

View File

@ -0,0 +1 @@
yapex

View File

@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: yap
Version: 0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN

View File

@ -0,0 +1,14 @@
setup.py
yapPYTHON_wrap.cxx
/Users/vsc/github/yap-6.3/packages/python/pl2pl.c
/Users/vsc/github/yap-6.3/packages/python/pl2py.c
/Users/vsc/github/yap-6.3/packages/python/py2pl.c
/Users/vsc/github/yap-6.3/packages/python/pybips.c
/Users/vsc/github/yap-6.3/packages/python/pypreds.c
/Users/vsc/github/yap-6.3/packages/python/python.c
/Users/vsc/github/yap-6.3/packages/swig/yap.i
/Users/vsc/github/yap-6.3/packages/swig/python/yapex.py
/Users/vsc/github/yap-6.3/packages/swig/python/yap.egg-info/PKG-INFO
/Users/vsc/github/yap-6.3/packages/swig/python/yap.egg-info/SOURCES.txt
/Users/vsc/github/yap-6.3/packages/swig/python/yap.egg-info/dependency_links.txt
/Users/vsc/github/yap-6.3/packages/swig/python/yap.egg-info/top_level.txt

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,2 @@
yap
yapex

View File

@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: yapex
Version: 0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN

View File

@ -0,0 +1,12 @@
setup.py
/Users/vsc/github/yap-6.3/packages/python/pl2pl.c
/Users/vsc/github/yap-6.3/packages/python/pl2py.c
/Users/vsc/github/yap-6.3/packages/python/py2pl.c
/Users/vsc/github/yap-6.3/packages/python/pybips.c
/Users/vsc/github/yap-6.3/packages/python/pypreds.c
/Users/vsc/github/yap-6.3/packages/python/python.c
/Users/vsc/github/yap-6.3/packages/swig/python/yapex.py
/Users/vsc/github/yap-6.3/packages/swig/python/yapex.egg-info/PKG-INFO
/Users/vsc/github/yap-6.3/packages/swig/python/yapex.egg-info/SOURCES.txt
/Users/vsc/github/yap-6.3/packages/swig/python/yapex.egg-info/dependency_links.txt
/Users/vsc/github/yap-6.3/packages/swig/python/yapex.egg-info/top_level.txt

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
yapex

View File

@ -1,50 +0,0 @@
# python commands
import sys
import yap
#
# initialize engine
engine = yap.YAPEngine();
# engine = yap.YAPEngine(yap.YAPParams());
def query( s ):
q = engine.query(s)
while q.next():
vs = q.namedVars()
if vs.length() == 0:
print( "yes" )
return
else:
while vs.length() > 0:
eq = vs.car()
print( eq.getArg(1).text() + " = " + eq.getArg(2).text() )
vs = vs.cdr()
if q.deterministic():
return
s = input("next: ?")
if s.find(';') != 0 :
return
print( "no more answers" )
return
def live():
loop = True
while loop:
try:
s = input("?- ")
query( s )
except SyntaxError as err:
print("Syntax Error error: {0}".format(err))
except EOFError:
return
except RuntimeError as err:
print("YAP Execution Error: {0}".format(err))
except ValueError:
print("Could not convert data to an integer.")
except:
print("Unexpected error:", sys.exc_info()[0])
raise
live()

358
regression/dados/csv2pl_v3 Normal file
View File

@ -0,0 +1,358 @@
% ICD: it does not take into account missing values
%
% utility to translate from CSV style files to Prolog facts.
%
% assumes key is first argument.
%
% call as yap csv2pl -- prefix < Inp.csv > Out
%
% ICD: yap -l csv2pl_v3 -- --modes in.csv out
% alternatively you can call yap and invoke: main(['--modes','in.csv',out]).
% this will generate three files: out.facts, out.modes and out.txt
% out.facts contains all prolog facts for the csv table
% out.modes contains all modes to run with aleph (change as appropriate)
% out.txt contains basic data description (counters)
:- source.
:- style_check(all).
:- yap_flag(unknown, error).
:- yap_flag(write_strings, on).
:- use_module(library(readutil),
[read_line_to_codes/2]).
:- use_module(library(lineutils),
[split/3]).
:- use_module(library(system),
[mktime/2]).
:- ensure_loaded(order_by). % order predicate values
:- ensure_loaded(daynumber).
:- initialization(main).
:- dynamic output_modes/0.
main :-
unix(argv(Args)),
% write(Args),
main(Args).
main(['--modes'|R]) :- !,
assert(output_modes),
main(R).
%ICD: changed here to write in two different files
% also added counters
main([F,O]) :-
open(F, read, S),
atom_concat(O,'.modes',W1),
atom_concat(O,'.facts',W2),
open(W1, write, WModes),
open(W2, write, WFacts),
do(S, WModes, WFacts),
close(WModes), close(WFacts),
close(S),
write('WILL START COUNTING'), nl,
count(O).
/*
main([F]) :-
unix(argv([F])), !,
open(F, read, S),
W = user_output,
do(S, W),
close(S).
main([]) :-
S = user_input,
W = user_output,
do(S, W).
*/
do(S, WModes, WFacts) :-
get_titles(S, WModes, Titles),
get_lines(S, WFacts, Titles).
get_titles(S, W, Titles) :-
read_line_to_codes(S,Line),
split(Line, ",", OTitles),
list_of_titles(OTitles, Titles),
% format('~q~n~q~n',[OTitles,Titles]),
output_modes(Titles, W).
%ICD: changed here to use the Key name
%output_modes(_Key.Titles, W) :-
output_modes([Key|Titles], W) :-
format('~q~n',[[Key|Titles]]),
output_modes, !,
send_determinations(Titles, W),
% format(W, ':- modeh(*,upgrade(+key)).~n',[]),
format(W, ':- modeh(*,upgrade(+~q)).~n',[Key]),
% send_modes(Titles, W).
send_modes(Titles, Key, W).
send_determinations([], W) :-
nl(W).
send_determinations([T|Titles], W) :-
format(W, ':- determination(upgrade/1,~q/2).~n',[T]),
send_determinations(Titles, W).
%ICD: changed to use the key name
send_modes([], _, W) :-
nl(W).
send_modes([T|Titles], Key, W) :-
format(W, ':- modeb(*,~q(+~q,-~q)).~n',[T,Key,T]),
format(W, ':- modeb(*,~q(+~q,#~q)).~n',[T,Key,T]),
send_modes(Titles, Key, W).
list_of_titles([],[]).
list_of_titles([S|Ss], [A|As]) :-
% atom(A, S), % ICD: convert first letter to lowercase, remove plics
S = [H|T], char_type(LowH,to_lower(H)), atom_codes(A,[LowH|T]),
list_of_titles(Ss, As).
continue_list(Titles) -->
",", !,
list_of_titles(Titles).
continue_list([]) --> [].
get_lines(S, W, Titles) :-
read_line_to_codes(S, Line),
write(Line), nl, % ICD
add_line(Line, S, W, Titles).
add_line(end_of_file, _, _, _) :- !.
add_line(Line, S, W, Titles) :-
get_data(Titles, W, Line, []), !,
% write('Parsed correctly'), nl,
get_lines(S, W, Titles).
get_data([_|Titles], W, S1, S) :-
get_field(N, S1,S2),
% write(S1), nl, write(N), nl, write(S2), nl,
get_more_data(Titles, W, N, S2, S).
get_more_data([Field|L], W, Key, L, L) :- !,
add_as_empty([Field|L], W, Key).
get_more_data([Field|L], W, Key) -->
% {write([Field|L]), nl},
",", !,
get_field(N),
% { write(N), write('--'), nl },
{ output_field(W, Field, Key, N) },
get_more_data(L, W, Key).
get_more_data([], _, _) --> [].
get_field(N) -->
"\"", time(N), "\"", !.
get_field(N) -->
time(N), !.
get_field(N) -->
timeHours(N), !.
get_field(N) -->
atom(N), !.
get_field(N) -->
number(N), !.
get_field(?) -->
empty, !.
get_field(A) -->
any(S),
{atom_codes(A, S) }.
any([], [0',|L], [0',|L]) :- !.
any([], [], []) :- !.
any([C|Cs]) --> [C], any(Cs).
time(N) -->
natural(Year),
"-",
% "/",
month(Month),
"-",
% "/",
natural(Day),
{ %writeln(Day:Month:Year),
cvt_to_n(Day, Month, Year, N) }.
timeHours(H:M:S) -->
natural(H),
{format('~q~n',[H])},
":",
natural(M),
":",
natural(S).
cvt_to_n(D, M, Y0, N) :-
Y0 =< 10,
!,
Y is 2000+Y0,
days(Y,M,D,N).
cvt_to_n(D, M, Y0, N) :-
Y0 > 10,
Y0 < 100,
!,
Y is 1900+Y0,
days(Y,M,D,N).
cvt_to_n(D, M, Y, N) :-
days(Y,M,D,N).
number(N) -->
"-", !,
pos_number(N1),
{ N is -N1 }.
number(N) -->
"+", !,
pos_number(N1),
{ N is -N1 }.
number(N) -->
pos_number(N).
pos_number(N) -->
natural(L, L0),
do_float(L0),
{ number_codes(N,L) }.
do_float([0'e|L0]) -->
"e", !,
integer(L0, []).
do_float([0'E|L0]) -->
"E", !,
integer(L0, []).
do_float([0'.|L0]) -->
".", !,
natural(L0, []).
do_float([]) -->
[].
natural(N) -->
natural(L, []),
{ number_codes(N, L) }.
natural([C|L], L0) -->
[C],
{ C >= 0'0, C =< 0'9 }, !,
more_naturals(L, L0).
more_naturals([C|L], L0) -->
[C],
{ C >= 0'0, C =< 0'9 }, !,
more_naturals(L, L0).
more_naturals(L0, L0) --> [].
integer(L,L0) -->
"+", !,
natural(L, L0).
integer([0'-|L],L0) -->
"-", !,
natural(L, L0).
integer(L,L0) -->
natural(L, L0).
atom(T) -->
"\"",
quoted(Name),
{ atom_codes(T, Name) }.
quoted([0'"|Name]) --> "\"\"", !, %"
quoted(Name).
quoted([]) --> "\"", !.
quoted([C|Name]) --> [C],
quoted(Name).
empty([0',|L], [0',|L]).
empty([], []).
month(1) --> "Jan", !.
month(2) --> "Feb", !.
month(3) --> "Mar", !.
month(4) --> "Apr", !.
month(5) --> "May", !.
month(6) --> "Jun", !.
month(7) --> "Jul", !.
month(8) --> "Aug", !.
month(9) --> "Sep", !.
month(10) --> "Oct", !.
month(11) --> "Nov", !.
month(12) --> "Dec", !.
month(I) --> natural(I).
add_as_empty([], _, _).
add_as_empty([Field|L], W, Key) :-
output_field(W, Field, Key, ?),
add_as_empty(L, W, Key).
% ICD: changed
%output_field(_W, _Field, _Key, ?) :- !.
% format(W,'~q(~q,~q).~n',[Field,Key,N]).
%output_field(W, Field, Key, N) :-
% format(W,'~q(~q,~q).~n',[Field,Key,N]).
% ICD: included counters for Field/Value
output_field(W, Field, Key, ?) :- !,
format(W,'~q(~q,~q).~n',[Field,Key,?]),
counting(Field,missing).
/*
output_field(W, Field, Key, N) :-
not atom(N), !,
format(W,'~q(~q,~q).~n',[Field,Key,N]),
counting(Field,N).
output_field(W, Field, Key, N) :-
% convert first letter of predicate value N to lower case if it is uppercase
atom_chars(N,[Char|Chars]),
char_type(Char,upper),
atom_codes(Char,Code),
char_type(LowChar,to_lower(Code)), atom_chars(A,[LowChar|Chars]),
format(W,'~q(~q,~q).~n',[Field,Key,A]),
counting(Field,A), !.
*/
output_field(W, Field, Key, N) :-
format(W,'~q(~q,~q).~n',[Field,Key,N]),
counting(Field,N).
% ICD: include counters
counting(Field,Value) :-
retract(counter(Field,Value,C)),
C1 is C + 1,
assertz(counter(Field,Value,C1)), !.
counting(Field,Value) :-
assertz(counter(Field,Value,1)).
% when it ends
count(FileDescription) :-
write('WILL START COUNTING'), nl,
atom_concat(FileDescription,'.txt',File),
tell(File),
% listing(counter),
counter(Field,_Value,_C),
once(counter(Field,_Value,_C)),
% format('**** WILL WRITE ALL VALUES FOR FIELD: ~q~n',[Field]),
mydisplay(Field),
% format('**** WROTE ALL VALUES FOR FIELD: ~q~n',[Field]),
fail.
count(_) :- told.
/*
mydisplay(Field) :-
write(Field), nl,
counter(Field,Value,C),
tab(4),
format('~q: ~q~n',[Value,C]),
fail.
mydisplay(Field) :-
% format('**** REMOVING ALL FIELD: ~q~n',[Field]),
retractall(counter(Field,_,_)).
*/
% other solution
mydisplay(Field) :-
write(Field), nl,
order_by(counter/3, 2),
forall(counter(Field,Value,C),
(tab(4), format('~q: ~q~n',[Value,C]))
),
retractall(counter(Field,_,_)). %,
% format('REMOVED ALL FIELD: ~q~n',[Field]). %,
% listing(counter).

View File

@ -0,0 +1,32 @@
ID,Date,Time,Value_Carbs,Value_Glucose,Value_Insulin
1,2016-04-23,15:25:47,50,125,5
2,2016-04-23,21:28:10,100,69,10
3,2016-04-23,23:19:04,21,260,21
4,2016-04-24,09:31:40,18,256,6.5
5,2016-04-25,09:32:20,19,72,6.5
6,2016-04-25,16:11:11,20,136,1
7,2016-04-25,20:55:59,50,274,5.5
8,2016-04-26,08:04:07,18,264,7
9,2016-04-26,10:24:41,40,52,9
10,2016-04-26,15:01:50,100,256,10.5
11,2016-04-26,21:33:31,46,168,8
12,2016-04-27,07:32:04,18,99,4
13,2016-04-27,10:02:53,16,103,1.5
14,2016-04-27,15:51:03,115,222,14
15,2016-04-27,20:27:01,50,191,7.5
16,2016-04-28,07:33:27,20,99,5
17,2016-04-28,10:30:33,18,143,2
18,2016-04-28,14:09:37,85,203,10.5
19,2016-04-28,20:45:52,55,134,7.5
20,2016-04-29,07:33:31,20,89,3
21,2016-04-29,10:36:58,16,112,1
22,2016-04-29,15:17:26,111,266,13.5
23,2016-04-29,20:16:38,65,108,10
24,2016-04-30,10:11:31,20,89,2.5
25,2016-04-30,14:31:12,60,258,6
26,2016-04-30,17:44:53,20,57,7
27,2016-04-30,21:26:38,95,227,8
28,2016-05-01,09:51:14,50,129,9.5
29,2016-05-02,09:23:07,20,200,2.5
30,2016-05-02,14:14:50,150,207,17
31,2016-05-02,20:35:16,45,182,6.5
1 ID Date Time Value_Carbs Value_Glucose Value_Insulin
2 1 2016-04-23 15:25:47 50 125 5
3 2 2016-04-23 21:28:10 100 69 10
4 3 2016-04-23 23:19:04 21 260 21
5 4 2016-04-24 09:31:40 18 256 6.5
6 5 2016-04-25 09:32:20 19 72 6.5
7 6 2016-04-25 16:11:11 20 136 1
8 7 2016-04-25 20:55:59 50 274 5.5
9 8 2016-04-26 08:04:07 18 264 7
10 9 2016-04-26 10:24:41 40 52 9
11 10 2016-04-26 15:01:50 100 256 10.5
12 11 2016-04-26 21:33:31 46 168 8
13 12 2016-04-27 07:32:04 18 99 4
14 13 2016-04-27 10:02:53 16 103 1.5
15 14 2016-04-27 15:51:03 115 222 14
16 15 2016-04-27 20:27:01 50 191 7.5
17 16 2016-04-28 07:33:27 20 99 5
18 17 2016-04-28 10:30:33 18 143 2
19 18 2016-04-28 14:09:37 85 203 10.5
20 19 2016-04-28 20:45:52 55 134 7.5
21 20 2016-04-29 07:33:31 20 89 3
22 21 2016-04-29 10:36:58 16 112 1
23 22 2016-04-29 15:17:26 111 266 13.5
24 23 2016-04-29 20:16:38 65 108 10
25 24 2016-04-30 10:11:31 20 89 2.5
26 25 2016-04-30 14:31:12 60 258 6
27 26 2016-04-30 17:44:53 20 57 7
28 27 2016-04-30 21:26:38 95 227 8
29 28 2016-05-01 09:51:14 50 129 9.5
30 29 2016-05-02 09:23:07 20 200 2.5
31 30 2016-05-02 14:14:50 150 207 17
32 31 2016-05-02 20:35:16 45 182 6.5

View File

@ -0,0 +1 @@
?-

View File

@ -0,0 +1,155 @@
date(1,42481).
time(1,15:25:47).
value_Carbs(1,50).
value_Glucose(1,125).
value_Insulin(1,5).
date(2,42481).
time(2,21:28:10).
value_Carbs(2,100).
value_Glucose(2,69).
value_Insulin(2,10).
date(3,42481).
time(3,23:19:4).
value_Carbs(3,21).
value_Glucose(3,260).
value_Insulin(3,21).
date(4,42482).
time(4,9:31:40).
value_Carbs(4,18).
value_Glucose(4,256).
value_Insulin(4, 6.500000).
date(5,42483).
time(5,9:32:20).
value_Carbs(5,19).
value_Glucose(5,72).
value_Insulin(5, 6.500000).
date(6,42483).
time(6,16:11:11).
value_Carbs(6,20).
value_Glucose(6,136).
value_Insulin(6,1).
date(7,42483).
time(7,20:55:59).
value_Carbs(7,50).
value_Glucose(7,274).
value_Insulin(7, 5.500000).
date(8,42484).
time(8,8:4:7).
value_Carbs(8,18).
value_Glucose(8,264).
value_Insulin(8,7).
date(9,42484).
time(9,10:24:41).
value_Carbs(9,40).
value_Glucose(9,52).
value_Insulin(9,9).
date(10,42484).
time(10,15:1:50).
value_Carbs(10,100).
value_Glucose(10,256).
value_Insulin(10, 10.500000).
date(11,42484).
time(11,21:33:31).
value_Carbs(11,46).
value_Glucose(11,168).
value_Insulin(11,8).
date(12,42485).
time(12,7:32:4).
value_Carbs(12,18).
value_Glucose(12,99).
value_Insulin(12,4).
date(13,42485).
time(13,10:2:53).
value_Carbs(13,16).
value_Glucose(13,103).
value_Insulin(13, 1.500000).
date(14,42485).
time(14,15:51:3).
value_Carbs(14,115).
value_Glucose(14,222).
value_Insulin(14,14).
date(15,42485).
time(15,20:27:1).
value_Carbs(15,50).
value_Glucose(15,191).
value_Insulin(15, 7.500000).
date(16,42486).
time(16,7:33:27).
value_Carbs(16,20).
value_Glucose(16,99).
value_Insulin(16,5).
date(17,42486).
time(17,10:30:33).
value_Carbs(17,18).
value_Glucose(17,143).
value_Insulin(17,2).
date(18,42486).
time(18,14:9:37).
value_Carbs(18,85).
value_Glucose(18,203).
value_Insulin(18, 10.500000).
date(19,42486).
time(19,20:45:52).
value_Carbs(19,55).
value_Glucose(19,134).
value_Insulin(19, 7.500000).
date(20,42487).
time(20,7:33:31).
value_Carbs(20,20).
value_Glucose(20,89).
value_Insulin(20,3).
date(21,42487).
time(21,10:36:58).
value_Carbs(21,16).
value_Glucose(21,112).
value_Insulin(21,1).
date(22,42487).
time(22,15:17:26).
value_Carbs(22,111).
value_Glucose(22,266).
value_Insulin(22, 13.500000).
date(23,42487).
time(23,20:16:38).
value_Carbs(23,65).
value_Glucose(23,108).
value_Insulin(23,10).
date(24,42488).
time(24,10:11:31).
value_Carbs(24,20).
value_Glucose(24,89).
value_Insulin(24, 2.500000).
date(25,42488).
time(25,14:31:12).
value_Carbs(25,60).
value_Glucose(25,258).
value_Insulin(25,6).
date(26,42488).
time(26,17:44:53).
value_Carbs(26,20).
value_Glucose(26,57).
value_Insulin(26,7).
date(27,42488).
time(27,21:26:38).
value_Carbs(27,95).
value_Glucose(27,227).
value_Insulin(27,8).
date(28,42489).
time(28,9:51:14).
value_Carbs(28,50).
value_Glucose(28,129).
value_Insulin(28, 9.500000).
date(29,42490).
time(29,9:23:7).
value_Carbs(29,20).
value_Glucose(29,200).
value_Insulin(29, 2.500000).
date(30,42490).
time(30,14:14:50).
value_Carbs(30,150).
value_Glucose(30,207).
value_Insulin(30,17).
date(31,42490).
time(31,20:35:16).
value_Carbs(31,45).
value_Glucose(31,182).
value_Insulin(31, 6.500000).

View File

@ -0,0 +1,18 @@
:- determination(upgrade/1,date/2).
:- determination(upgrade/1,time/2).
:- determination(upgrade/1,value_Carbs/2).
:- determination(upgrade/1,value_Glucose/2).
:- determination(upgrade/1,value_Insulin/2).
:- modeh(*,upgrade(+iD)).
:- modeb(*,date(+iD,-date)).
:- modeb(*,date(+iD,#date)).
:- modeb(*,time(+iD,-time)).
:- modeb(*,time(+iD,#time)).
:- modeb(*,value_Carbs(+iD,-value_Carbs)).
:- modeb(*,value_Carbs(+iD,#value_Carbs)).
:- modeb(*,value_Glucose(+iD,-value_Glucose)).
:- modeb(*,value_Glucose(+iD,#value_Glucose)).
:- modeb(*,value_Insulin(+iD,-value_Insulin)).
:- modeb(*,value_Insulin(+iD,#value_Insulin)).

View File

@ -0,0 +1,113 @@
time
7:32:4: 1
7:33:27: 1
7:33:31: 1
8:4:7: 1
9:23:7: 1
9:31:40: 1
9:32:20: 1
9:51:14: 1
10:2:53: 1
10:11:31: 1
10:24:41: 1
10:30:33: 1
10:36:58: 1
14:9:37: 1
14:14:50: 1
14:31:12: 1
15:1:50: 1
15:17:26: 1
15:25:47: 1
15:51:3: 1
16:11:11: 1
17:44:53: 1
20:16:38: 1
20:27:1: 1
20:35:16: 1
20:45:52: 1
20:55:59: 1
21:26:38: 1
21:28:10: 1
21:33:31: 1
23:19:4: 1
value_Glucose
52: 1
57: 1
69: 1
72: 1
89: 2
99: 2
103: 1
108: 1
112: 1
125: 1
129: 1
134: 1
136: 1
143: 1
168: 1
182: 1
191: 1
200: 1
203: 1
207: 1
222: 1
227: 1
256: 2
258: 1
260: 1
264: 1
266: 1
274: 1
date
42481: 3
42482: 1
42483: 3
42484: 4
42485: 4
42486: 4
42487: 4
42488: 4
42489: 1
42490: 3
value_Carbs
16: 2
18: 4
19: 1
20: 6
21: 1
40: 1
45: 1
46: 1
50: 4
55: 1
60: 1
65: 1
85: 1
95: 1
100: 2
111: 1
115: 1
150: 1
value_Insulin
1.500000: 1
2.500000: 2
5.500000: 1
6.500000: 3
7.500000: 2
9.500000: 1
10.500000: 2
13.500000: 1
1: 2
2: 1
3: 1
4: 1
5: 2
6: 1
7: 2
8: 2
9: 1
10: 2
14: 1
17: 1
21: 1

View File

@ -0,0 +1,197 @@
days(Y,M,D,Total) :-
years_to_days(Y, D1),
months_to_day(M, Y, D2),
Total is D1+D2+D-1.
years_to_days(Y0, DY) :-
Y1 is Y0-1900,
DY is Y1*365+((Y1+3)//4).
months_to_day(1,_,0).
months_to_day(2,_,31).
months_to_day(3,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+ED.
months_to_day(4,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+ED.
months_to_day(5,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+ED.
months_to_day(6,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+31+ED.
months_to_day(7,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+31+30+ED.
months_to_day(8,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+31+30+31+ED.
months_to_day(9,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+31+30+31+31+ED.
months_to_day(10,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+31+30+31+31+30+ED.
months_to_day(11,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+31+30+31+31+30+31+ED.
months_to_day(12,Y,DM) :-
extra_day(Y,ED),
DM is 31+28+31+30+31+30+31+31+30+31+30+ED.
months_to_day(13,Y,DM) :- % should never succeed...
extra_day(Y,ED),
DM is 31+28+31+30+31+30+31+31+30+31+30+31+ED.
extra_day(Y,1) :- Y mod 4 == 0, !.
extra_day(_,0).
date(Total, Y, M, D) :-
get_years(Total, Y, DaysLeft),
get_months(DaysLeft, Y, M, D0),
D is D0+1.
get_years(Total, Y, DaysLeft) :-
daysperyear(Y,D0),
D0 =< Total,
Y1 is Y+1,
daysperyear(Y1,D1),
D1 > Total, !,
DaysLeft is Total-D0.
get_months(Total, Y, Month, Days) :-
months_to_day(Month, Y, DM),
DM =< Total,
Month1 is Month+1,
months_to_day(Month1, Y, DM1),
DM1 > Total, !,
Days is Total-DM.
gendays(120,_) :- !.
gendays(I0,D0) :- !,
J is I0+1900,
format('days(~d,~d).~n',[J,D0]),
( I0 mod 4 =:= 0 -> D is D0+366 ; D is D0+365 ),
I is I0+1,
gendays(I, D).
daysperyear(1900,0).
daysperyear(1901,366).
daysperyear(1902,731).
daysperyear(1903,1096).
daysperyear(1904,1461).
daysperyear(1905,1827).
daysperyear(1906,2192).
daysperyear(1907,2557).
daysperyear(1908,2922).
daysperyear(1909,3288).
daysperyear(1910,3653).
daysperyear(1911,4018).
daysperyear(1912,4383).
daysperyear(1913,4749).
daysperyear(1914,5114).
daysperyear(1915,5479).
daysperyear(1916,5844).
daysperyear(1917,6210).
daysperyear(1918,6575).
daysperyear(1919,6940).
daysperyear(1920,7305).
daysperyear(1921,7671).
daysperyear(1922,8036).
daysperyear(1923,8401).
daysperyear(1924,8766).
daysperyear(1925,9132).
daysperyear(1926,9497).
daysperyear(1927,9862).
daysperyear(1928,10227).
daysperyear(1929,10593).
daysperyear(1930,10958).
daysperyear(1931,11323).
daysperyear(1932,11688).
daysperyear(1933,12054).
daysperyear(1934,12419).
daysperyear(1935,12784).
daysperyear(1936,13149).
daysperyear(1937,13515).
daysperyear(1938,13880).
daysperyear(1939,14245).
daysperyear(1940,14610).
daysperyear(1941,14976).
daysperyear(1942,15341).
daysperyear(1943,15706).
daysperyear(1944,16071).
daysperyear(1945,16437).
daysperyear(1946,16802).
daysperyear(1947,17167).
daysperyear(1948,17532).
daysperyear(1949,17898).
daysperyear(1950,18263).
daysperyear(1951,18628).
daysperyear(1952,18993).
daysperyear(1953,19359).
daysperyear(1954,19724).
daysperyear(1955,20089).
daysperyear(1956,20454).
daysperyear(1957,20820).
daysperyear(1958,21185).
daysperyear(1959,21550).
daysperyear(1960,21915).
daysperyear(1961,22281).
daysperyear(1962,22646).
daysperyear(1963,23011).
daysperyear(1964,23376).
daysperyear(1965,23742).
daysperyear(1966,24107).
daysperyear(1967,24472).
daysperyear(1968,24837).
daysperyear(1969,25203).
daysperyear(1970,25568).
daysperyear(1971,25933).
daysperyear(1972,26298).
daysperyear(1973,26664).
daysperyear(1974,27029).
daysperyear(1975,27394).
daysperyear(1976,27759).
daysperyear(1977,28125).
daysperyear(1978,28490).
daysperyear(1979,28855).
daysperyear(1980,29220).
daysperyear(1981,29586).
daysperyear(1982,29951).
daysperyear(1983,30316).
daysperyear(1984,30681).
daysperyear(1985,31047).
daysperyear(1986,31412).
daysperyear(1987,31777).
daysperyear(1988,32142).
daysperyear(1989,32508).
daysperyear(1990,32873).
daysperyear(1991,33238).
daysperyear(1992,33603).
daysperyear(1993,33969).
daysperyear(1994,34334).
daysperyear(1995,34699).
daysperyear(1996,35064).
daysperyear(1997,35430).
daysperyear(1998,35795).
daysperyear(1999,36160).
daysperyear(2000,36525).
daysperyear(2001,36891).
daysperyear(2002,37256).
daysperyear(2003,37621).
daysperyear(2004,37986).
daysperyear(2005,38352).
daysperyear(2006,38717).
daysperyear(2007,39082).
daysperyear(2008,39447).
daysperyear(2009,39813).
daysperyear(2010,40178).
daysperyear(2011,40543).
daysperyear(2012,40908).
daysperyear(2013,41274).
daysperyear(2014,41639).
daysperyear(2015,42004).
daysperyear(2016,42369).
daysperyear(2017,42735).
daysperyear(2018,43100).
daysperyear(2019,43465).

View File

@ -0,0 +1,32 @@
% taken from http://stackoverflow.com/questions/12272888/default-prolog-predicate-sort
/* File: order_by.pl
Author: Carlo,,,
Created: Sep 5 2012
Purpose: sort fact
*/
:- module(order_by,
[order_by/2
]).
:- use_module(library(apply_macros)).
order_by(PredicateIndicator, Argument) :-
( PredicateIndicator = Module:Functor/Arity
; PredicateIndicator = Functor/Arity, Module = user
),
length(EmptyArgs, Arity),
P =.. [Functor|EmptyArgs],
findall(P, retract(Module:P), L),
predsort(by_arg(Argument), L, S),
maplist(assert_in_module(Module), S).
assert_in_module(Module, P) :-
assertz(Module:P).
by_arg(Argument, Delta, E1, E2) :-
arg(Argument, E1, A1),
arg(Argument, E2, A2),
( A1 @< A2
-> Delta = <
; Delta = >
).

1
regression/dados/run Executable file
View File

@ -0,0 +1 @@
yap -l csv2pl_v3 -- --modes dados.csv > dados.yap

10
regression/plsimple.pl Normal file
View File

@ -0,0 +1,10 @@
:- use_module(library(plunit)).
:- begin_tests(lists).
:- use_module(library(lists)).
test(reverse) :-
reverse([a,b], [b,a]).
:- end_tests(lists).

137
test_answer.pl Normal file
View File

@ -0,0 +1,137 @@
:- module(test_answer,
[ test_answer/0,
test_answer/2
]).
% :- if(absolute_file_name(foreign(unix), _,
% [ file_type(executable),
% file_errors(fail),
% access(read)
% ])).
:- use_module(library(plunit)).
:- use_module(library(unix)).
:- use_module(library(error)).
:- use_module(library(debug)).
:- use_module(library(lists)).
:- use_module(library(maplist)).
%:- use_module(library(dif)).
/** <module> Test unit for toplevel replies
This module tests the way in which the toplevel replies to queries. The
implementation is based on pipes, which are provided by library(unix)
from the clib package. This means that this test can only be executed
after library(unix) has been compiled.
*/
test_answer :-
run_tests([ answer
]).
%% toplevel_answer(+GoalAtom, -Answer:string) is det.
%
% Run GoalAtom in a seperate thread and catch the output that is
% produces by Prolog.
toplevel_answer(Goal, Answer) :-
strip_module( Goal, M, G),
atom_to_term(G, GGoal, Bindings),
call(M:GGoal),
maplist(mkatom, Bindings, Answer).
mkatom(X=T, NT) :-
atom_to_term(NT, X=T, _ ).
%% test_answer(+Query, -OkReplies) is semidet.
%
% True if Query produces one of the outputs in OkReplies.
test_answer(QueryAtom, Replies) :-
toplevel_answer(QueryAtom, Replies).
/* debug(test_answer, 'Got: ~q', [Output]),
member(ReplyAtom, Replies),
term_string(Reply, ReplyAtom,
[ variable_names(ReplyBindings0),
comments(ReplyComments)
]),
maplist(anon_binding, OutBindings, ReplyBindings0, ReplyBindings),
( debug(test_answer, 'Comments: ~p vs ~p',
[OutComments, ReplyComments]),
maplist(compare_comment, OutComments, ReplyComments)
-> true
; debug(test_answer, '~p', [ OutComments \= ReplyComments ]),
fail
),
( Written+OutBindings =@= Reply+ReplyBindings
-> true
; debug(test_answer, '~q',
[ Written+OutBindings \=@= Reply+ReplyBindings ]),
fail
).
*/
anon_binding(Name=_, GName=Var, Name=Var) :-
sub_atom(GName, 0, _, _, '_G'), !.
anon_binding(_, Binding, Binding).
compare_comment(_-C, _-C).
hidden :-
dif(_X, a).
:- begin_tests(answer, [sto(rational_trees)]).
test(simple, true) :-
test_answer('A=1', ['A=1']).
test(simple, true) :-
test_answer('A=1, B=2', ['A=1, B=2']).
test(separated, true) :-
test_answer('X = 2, Y = 1, Z = 2', ['X = Z, Z = 2, Y = 1']).
test(same, true) :-
test_answer('A=1, B=1', ['A=B, B=1']).
test(same, true) :-
test_answer('A=a(B), B=A', ['A=B, B=a(B)']).
test(cycle, true) :-
test_answer('A=a(A)', ['A=a(A)']).
test(cycle, true) :-
test_answer('A=a(A), B=a(a(B))', ['A=B, B=a(a(B))']).
test(double_cycle, true) :-
test_answer('X = s(X,Y), Y = s(X,X)',
[ 'X = Y, Y = s(_S1, _S1), % where
_S1 = s(_S1, s(_S1, _S1))'
]).
test(freeze, true) :-
test_answer('freeze(X, writeln(X))', ['freeze(X, writeln(X))']).
test(hidden, true) :-
test_answer('test_answer:hidden',
[ '% with pending residual goals
dif(_G1,a)'
]).
test(hidden, true) :-
test_answer('test_answer:hidden, A = a',
[ 'A = a,
% with pending residual goals
dif(_G1,a)'
]).
test(hidden, true) :-
test_answer('test_answer:hidden, A = a, dif(B, b)',
[ 'A = a,
dif(B, b),
% with pending residual goals
dif(_G1,a)'
]).
:- end_tests(answer).
/*
:- else. % No foreign(unix) found
test_answer :-
format(user_error, 'Skipped toplevel answer tests; requires clib~n', []).
test_answer(_QueryAtom, _Replies). % satisfy exports
:- endif.
*/