Merge branch 'master' of https://github.com/vscosta/yap-6.3
This commit is contained in:
@@ -28,7 +28,7 @@ SOVERSION ${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION}
|
||||
target_link_libraries(Py4YAP YAPPython libYap ${PYTHON_LIBRARIES})
|
||||
|
||||
|
||||
install(TARGETS Py4YAP
|
||||
install(TARGETS Py4YAP
|
||||
RUNTIME DESTINATION ${bindir}
|
||||
LIBRARY DESTINATION ${libdir}
|
||||
ARCHIVE DESTINATION ${libdir}
|
||||
|
@@ -42,7 +42,7 @@ INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/i
|
||||
# LIBRARY DESTINATION ${PYTHON_MODULE_PATH}
|
||||
# )
|
||||
|
||||
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
|
||||
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
|
||||
endif()
|
||||
|
||||
|
93
packages/python/swig/README
Normal file
93
packages/python/swig/README
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
<center>
|
||||

|
||||
</center>
|
||||
|
||||
NOTE: this version of YAP is still experimental, documentation may be out of date.
|
||||
|
||||
## Introduction
|
||||
|
||||
This document provides User information on version 6.3.4 of
|
||||
YAP (<em>Yet Another Prolog</em>). The YAP Prolog System is a
|
||||
high-performance Prolog compiler developed at Universidade do
|
||||
Porto. YAP supports stream Input/Output, sockets, modules,
|
||||
exceptions, Prolog debugger, C-interface, dynamic code, internal
|
||||
database, DCGs, saved states, co-routining, arrays, threads.
|
||||
|
||||
We explicitly allow both commercial and non-commercial use of YAP.
|
||||
|
||||
|
||||
YAP is based on the David H. D. Warren's WAM (Warren Abstract Machine),
|
||||
with several optimizations for better performance. YAP follows the
|
||||
Edinburgh tradition, and was originally designed to be largely
|
||||
compatible with DEC-10 Prolog, Quintus Prolog, and especially with
|
||||
C-Prolog. More recently, we have worked on being compatible with SICStus Prolog and with SWI-Prolog.
|
||||
|
||||
YAP implements most of the ISO-Prolog standard. We are striving at
|
||||
full compatibility, and the manual describes what is still
|
||||
missing.
|
||||
The document is intended neither as an introduction to Prolog nor to the
|
||||
implementation aspects of the compiler. A good introduction to
|
||||
programming in Prolog is the book @cite TheArtOfProlog , by
|
||||
L. Sterling and E. Shapiro, published by "The MIT Press, Cambridge
|
||||
MA". Other references should include the classical @cite ProgrammingInProlog , by W.F. Clocksin and C.S. Mellish, published by
|
||||
Springer-Verlag.
|
||||
|
||||
YAP 6.3.4 has been built with the gcc and clang compilers on Linux and OSX machines. We expect to recover support for WIN32 machines and
|
||||
Android next.
|
||||
|
||||
We are happy to include in YAP several excellent packages developed
|
||||
under separate licenses. Our thanks to the authors for their kind
|
||||
authorization to include these packages.
|
||||
|
||||
The overall copyright and permission notice for YAP4.3 can be found in
|
||||
the Artistic file in this directory. YAP follows the Perl Artistic
|
||||
license, and it is thus non-copylefted freeware. Some components of YAP have been obtained from SWI Prolog and ciao, and have
|
||||
different licenses.
|
||||
|
||||
If you have a question about this software, desire to add code, found a
|
||||
bug, want to request a feature, or wonder how to get further assistance,
|
||||
please send e-mail to <yap-users AT lists.sourceforge.net>. To
|
||||
subscribe to the mailing list, visit the page
|
||||
<https://lists.sourceforge.net/lists/listinfo/yap-users>.
|
||||
|
||||
On-line documentation is available for [YAP](http://www.dcc.fp.pt/~vsc/yap/)
|
||||
|
||||
|
||||
|
||||
The packages are, in alphabetical order:
|
||||
|
||||
+ The CHR package developed by Tom Schrijvers,
|
||||
Christian Holzbaur, and Jan Wielemaker.
|
||||
|
||||
+ The CLP(BN) package and Horus toolkit developed by Tiago Gomes, and Vítor Santos Costa.
|
||||
|
||||
+ The CLP(R) package developed by Leslie De Koninck, Bart Demoen, Tom
|
||||
Schrijvers, and Jan Wielemaker, based on the CLP(Q,R) implementation
|
||||
by Christian Holzbaur.
|
||||
|
||||
+ The CPLint package developed by Fabrizio Riguzzi's research
|
||||
laboratory at the [University of Ferrara](http://www.ing.unife.it/Docenti/FabrizioRiguzzi/)
|
||||
|
||||
+ The CUDA interface package developed by Carlos Martínez, Jorge
|
||||
Buenabad, Inês Dutra and Vítor Santos Costa.
|
||||
|
||||
+ The [GECODE](http://www.gecode.org) interface package developed by Denys Duchier and Vítor Santos Costa.
|
||||
|
||||
+ The [JPL](http://www.swi-prolog.org/packages/jpl/) (Java-Prolog Library) package developed by .
|
||||
|
||||
The minisat SAT solver interface developed by Michael Codish,
|
||||
Vitaly Lagoon, and Peter J. Stuckey.
|
||||
|
||||
+ The MYDDAS relational data-base interface developed at the
|
||||
Universidade do Porto by Tiago Soares, Michel Ferreira, and Ricardo Rocha.
|
||||
|
||||
+ The [PRISM](http://rjida.meijo-u.ac.jp/prism/) logic-based
|
||||
programming system for statistical modeling developed at the Sato
|
||||
Research Laboratory, TITECH, Japan.
|
||||
|
||||
+ The ProbLog 1 system developed by the [ProbLog](https://dtai.cs.kuleuven.be/problog) team in the
|
||||
DTAI group of KULeuven.
|
||||
|
||||
+ The [R](http://stoics.org.uk/~nicos/sware/packs/real/) interface package developed by Nicos Angelopoulos,
|
||||
Vítor Santos Costa, João Azevedo, Jan Wielemaker, and Rui Camacho.
|
@@ -35,7 +35,8 @@ completions(S, Self) :-
|
||||
|
||||
|
||||
strip_final_tokens(['EOT'|Ts], Ts) :- !.
|
||||
strip_final_tokens( Ts, Ts ).|_],
|
||||
strip_final_tokens( Ts, Ts ).
|
||||
|
||||
complete([E,l,C,l,A|More],
|
||||
isconsult(A),
|
||||
%B = l,
|
||||
@@ -80,22 +81,22 @@ isconsult( '[' ).
|
||||
arg([']'|_]).
|
||||
arg([l|_]).
|
||||
|
||||
fileerrors-or_library(F,C) :-
|
||||
file_or_library(F,C) :-
|
||||
libsym(C0),
|
||||
atom_cooncat(F,C,Co).
|
||||
fileerrors-or_library(F,C) :-
|
||||
file_or_library(F,C) :-
|
||||
check_file(F0,C).
|
||||
|
||||
check_file(F0,C) :-
|
||||
atom_concat('\'',F,F0),
|
||||
!,
|
||||
absolute_file_name( F, FF, [access(none)] ),
|
||||
atom_concat( F, '*' , Pat),
|
||||
atom_concat( FF, '*' , Pat),
|
||||
absolute_file_name( Pat, C0, [glob(true)] ),
|
||||
atom_concat(Pat,C00,C0),
|
||||
atom_conct(C00,'\'',C).
|
||||
check_file(F0,C) :-
|
||||
atom_concat( F, '*' , Pat),
|
||||
atom_concat( F0, '*' , Pat),
|
||||
absolute_file_name( Pat, C0, [glob(true)] ),
|
||||
atom_concat(Pat,C,C0).
|
||||
|
||||
@@ -116,7 +117,7 @@ predicate(N,P,A) :-
|
||||
current_predicate(P0/A),
|
||||
atom_concat(N,P,P0).
|
||||
|
||||
cont(0, F, P, P0)- :-
|
||||
atom_concat( F, P, PB ).
|
||||
cont(0, F, P, P0):-
|
||||
atom_concat( F, P, P0 ).
|
||||
cont( _, F, P, PB ):-
|
||||
atom_concat( [F, P, '('], PB ).
|
||||
|
@@ -63,8 +63,12 @@ if platform.system() == 'Windows':
|
||||
local_libs = []
|
||||
win_libs = ['wsock32','ws2_32']
|
||||
my_extra_link_args = ['-Wl,-export-all-symbols']
|
||||
else:
|
||||
my_extra_link_args = ['-Wl,-rpath','-Wl,${libdir}']
|
||||
elif platform.system() == 'Darwin':
|
||||
my_extra_link_args = ['-L','..']
|
||||
win_libs = []
|
||||
local_libs = ['Py4YAP']
|
||||
elif platform.system() == 'Linux':
|
||||
my_extra_link_args = ['-L','..']
|
||||
win_libs = []
|
||||
local_libs = ['Py4YAP']
|
||||
|
||||
|
666
packages/python/swig/yap.i
Normal file
666
packages/python/swig/yap.i
Normal file
@@ -0,0 +1,666 @@
|
||||
// supports Java and Python
|
||||
|
||||
|
||||
/* example.i */
|
||||
%module(directors = "1") yap
|
||||
|
||||
// Language independent exception handler
|
||||
%include exception.i
|
||||
%include stdint.i
|
||||
%include std_string.i
|
||||
%include std_vector.i
|
||||
|
||||
|
||||
%feature("novaluewrapper") std::vector<Term>;
|
||||
|
||||
%ignore *::operator[];
|
||||
|
||||
class YAPAtom;
|
||||
class YAPPredicate;
|
||||
class YAPEngine;
|
||||
|
||||
%{
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <gmpxx.h>
|
||||
|
||||
extern "C"{
|
||||
#include "Yap.h"
|
||||
#ifdef SWIGPYTHON
|
||||
#include <py4yap.h>
|
||||
|
||||
extern inline PyObject *AtomToPy(const char *s) {
|
||||
if (strcmp(s, "true") == 0)
|
||||
return Py_True;
|
||||
if (strcmp(s, "false") == 0)
|
||||
return Py_False;
|
||||
if (strcmp(s, "none") == 0)
|
||||
return Py_None;
|
||||
if (strcmp(s, "[]") == 0)
|
||||
return PyList_New(0);
|
||||
else if (strcmp(s, "{}") == 0)
|
||||
return PyDict_New();
|
||||
/* return __main__,s */
|
||||
else if (PyObject_HasAttrString(py_Main, s)) {
|
||||
return PyObject_GetAttrString(py_Main, s);
|
||||
}
|
||||
// no way to translate
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
%}
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
%typemap(typecheck) Term* {
|
||||
$1 = PySequence_Check($input);
|
||||
}
|
||||
|
||||
// Map a Python sequence into any sized C double array
|
||||
%typemap(in) Term* {
|
||||
int i;
|
||||
if (!PySequence_Check($input)) {
|
||||
PyErr_SetString(PyExc_TypeError,"Expecting a sequence");
|
||||
$1 = nullptr;
|
||||
} else {
|
||||
int sz = PyObject_Length($input);
|
||||
std::vector<Term> v(sz);
|
||||
for (i =0; i < sz; i++) {
|
||||
PyObject *o = PySequence_GetItem($input,i);
|
||||
v[i] = Term(pythonToYAP(o));
|
||||
//Py_DECREF(o);
|
||||
}
|
||||
$1 = &v[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//%typemap(check) YAPEngine::fun(Term) { $1 = 1; }
|
||||
//%typemap(check) YAPEngine::fun(YAPTerm) { $1 = 0; }
|
||||
|
||||
|
||||
%typemap(in) Int { if (PyLong_Check($input)) {
|
||||
$1 = PyLong_AsLong($input);}
|
||||
}
|
||||
|
||||
//%typemap(in) double { if (PyFloat_Check($input)) {
|
||||
// $1 = PyFloat_AsDouble($input); } }
|
||||
|
||||
//%typemap(in) char const * { if (PyUnicode_Check($input)) {
|
||||
// $1 = PyUnicode_AsUTF8($input); } }
|
||||
|
||||
//%typemap(in) YAPTerm { $1 = new YAPTerm(pythonToYAP($input)); PyErr_Clear(); }
|
||||
%typemap(in) YAP_Term { $1 = pythonToYAP($input); PyErr_Clear(); }
|
||||
%typemap(in) Term { $1 = pythonToYAP($input); PyErr_Clear(); }
|
||||
%typemap(in) YAPTerm { YAPTerm(($1 = pythonToYAP($input))); PyErr_Clear(); }
|
||||
|
||||
%typecheck(2) Int { $1 = PyLong_Check($input); }
|
||||
%typecheck(3) double { $1 = PyFloat_Check($input); }
|
||||
%typecheck(2) const char * { $1 = PyUnicode_Check($input); }
|
||||
|
||||
%typecheck(1) Term { $1 = !PyUnicode_Check($input); }
|
||||
%typecheck(1) YAP_Term { $1 = PyUnicode_Check($input); }
|
||||
|
||||
%typecheck(0) YAPTerm { $1 = !PyUnicode_Check($input); }
|
||||
|
||||
|
||||
%typemap(out) YAP_Term { return $result = yap_to_python($1, false, 0, true); }
|
||||
|
||||
%typemap(out) Term { return $result = yap_to_python($1, false, 0, true); }
|
||||
|
||||
%typemap(out) std::vector<Term> {
|
||||
size_t len = $1.size();
|
||||
$result = PyList_New(len);
|
||||
for (size_t i = 0; i< len; i++) {
|
||||
PyObject *o = yap_to_python($1[i],false,0,true);
|
||||
PyList_SetItem($result,i,o);
|
||||
|
||||
}
|
||||
return $result; }
|
||||
|
||||
|
||||
|
||||
// Language independent exception handler
|
||||
|
||||
%exception next {
|
||||
try {
|
||||
$action
|
||||
} catch (YAPError &e) {
|
||||
yap_error_number en = e.getID();
|
||||
PyObject *pyerr = PyExc_RuntimeError;
|
||||
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
switch (e.getErrorClass()) {
|
||||
case YAPC_NO_ERROR:
|
||||
break;
|
||||
/// bad domain, "first argument often is the predicate.
|
||||
case DOMAIN_ERROR: {
|
||||
switch (en) {
|
||||
case DOMAIN_ERROR_OUT_OF_RANGE:
|
||||
pyerr = PyExc_GeneratorExit;
|
||||
break;
|
||||
case DOMAIN_ERROR_NOT_LESS_THAN_ZERO:
|
||||
pyerr = PyExc_IndexError;
|
||||
break;
|
||||
case DOMAIN_ERROR_CLOSE_OPTION:
|
||||
case DOMAIN_ERROR_ENCODING:
|
||||
case DOMAIN_ERROR_PROLOG_FLAG:
|
||||
case DOMAIN_ERROR_ABSOLUTE_FILE_NAME_OPTION:
|
||||
case DOMAIN_ERROR_READ_OPTION:
|
||||
case DOMAIN_ERROR_SET_STREAM_OPTION:
|
||||
pyerr = PyExc_KeyError;
|
||||
break;
|
||||
case DOMAIN_ERROR_FILE_ERRORS:
|
||||
case DOMAIN_ERROR_FILE_TYPE:
|
||||
case DOMAIN_ERROR_IO_MODE:
|
||||
case DOMAIN_ERROR_SOURCE_SINK:
|
||||
case DOMAIN_ERROR_STREAM_POSITION:
|
||||
pyerr = PyExc_IOError;
|
||||
break;
|
||||
default:
|
||||
pyerr = PyExc_ValueError;
|
||||
}
|
||||
} break;
|
||||
/// bad arithmetic
|
||||
case EVALUATION_ERROR: {
|
||||
switch (en) {
|
||||
case EVALUATION_ERROR_FLOAT_OVERFLOW:
|
||||
case EVALUATION_ERROR_INT_OVERFLOW:
|
||||
pyerr = PyExc_OverflowError;
|
||||
break;
|
||||
case EVALUATION_ERROR_FLOAT_UNDERFLOW:
|
||||
case EVALUATION_ERROR_UNDERFLOW:
|
||||
case EVALUATION_ERROR_ZERO_DIVISOR:
|
||||
pyerr = PyExc_ArithmeticError;
|
||||
break;
|
||||
default:
|
||||
pyerr = PyExc_RuntimeError;
|
||||
}
|
||||
} break;
|
||||
/// missing object (I/O mostly)
|
||||
case EXISTENCE_ERROR:
|
||||
pyerr = PyExc_NotImplementedError;
|
||||
break;
|
||||
/// should be bound
|
||||
case INSTANTIATION_ERROR_CLASS:
|
||||
pyerr = PyExc_RuntimeError;
|
||||
break;
|
||||
/// bad access, I/O
|
||||
case PERMISSION_ERROR: {
|
||||
switch (en) {
|
||||
case PERMISSION_ERROR_INPUT_BINARY_STREAM:
|
||||
case PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM:
|
||||
case PERMISSION_ERROR_INPUT_STREAM:
|
||||
case PERMISSION_ERROR_INPUT_TEXT_STREAM:
|
||||
case PERMISSION_ERROR_OPEN_SOURCE_SINK:
|
||||
case PERMISSION_ERROR_OUTPUT_BINARY_STREAM:
|
||||
case PERMISSION_ERROR_REPOSITION_STREAM:
|
||||
case PERMISSION_ERROR_OUTPUT_STREAM:
|
||||
case PERMISSION_ERROR_OUTPUT_TEXT_STREAM:
|
||||
pyerr = PyExc_OverflowError;
|
||||
break;
|
||||
default:
|
||||
pyerr = PyExc_RuntimeError;
|
||||
}
|
||||
} break;
|
||||
/// something that could not be represented into a type
|
||||
case REPRESENTATION_ERROR:
|
||||
pyerr = PyExc_RuntimeError;
|
||||
break;
|
||||
/// not enough ....
|
||||
case RESOURCE_ERROR:
|
||||
pyerr = PyExc_RuntimeError;
|
||||
break;
|
||||
/// bad text
|
||||
case SYNTAX_ERROR_CLASS:
|
||||
pyerr = PyExc_SyntaxError;
|
||||
break;
|
||||
/// OS or internal
|
||||
case SYSTEM_ERROR_CLASS:
|
||||
pyerr = PyExc_RuntimeError;
|
||||
break;
|
||||
/// bad typing
|
||||
case TYPE_ERROR:
|
||||
pyerr = PyExc_TypeError;
|
||||
break;
|
||||
/// should be unbound
|
||||
case UNINSTANTIATION_ERROR_CLASS:
|
||||
pyerr = PyExc_RuntimeError;
|
||||
break;
|
||||
/// escape hatch
|
||||
default:
|
||||
break;
|
||||
}
|
||||
PyErr_SetString(pyerr, e.text().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
%typemap(in) arity_t { (jlong)($input); }
|
||||
|
||||
%typecheck(2) Int { $1 = PyLong_Check($input); }
|
||||
%typecheck(3) double { $1 = PyFloat_Check($input); }
|
||||
%typecheck(2) const char * { $1 = PyUnicode_Check($input); }
|
||||
|
||||
%typecheck(1) Term { $1 = !PyUnicode_Check($input); }
|
||||
%typecheck(1) YAP_Term { $1 = PyUnicode_Check($input); }
|
||||
|
||||
%typecheck(0) YAPTerm { $1 = !PyUnicode_Check($input); }
|
||||
|
||||
|
||||
%typemap(in) jlong %{
|
||||
$1 = (jlong)$input;
|
||||
%}
|
||||
|
||||
%typemap(out) arity_t { *(jlong *)&$result = $1; }
|
||||
|
||||
// Language independent exception handler
|
||||
// simplified version
|
||||
%include <exception.i>
|
||||
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch (const std::out_of_range& e) {
|
||||
SWIG_exception(SWIG_IndexError, e.what());
|
||||
} catch (const std::exception& e) {
|
||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||
} catch (...) {
|
||||
SWIG_exception(SWIG_RuntimeError, "unknown exception");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
%{
|
||||
/* Put header files here or function declarations like below */
|
||||
#include "yapi.hh"
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
#if THREADS
|
||||
#define Yap_regp regcache
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// we cannot consult YapInterface.h, that conflicts with what we
|
||||
// declare, though
|
||||
// it shouldn't
|
||||
}
|
||||
|
||||
extern void init_sqlite();
|
||||
|
||||
%}
|
||||
|
||||
#define X_API
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
//%feature("director") YAPCallback;
|
||||
|
||||
%include "yapa.hh"
|
||||
|
||||
%include "yapie.hh"
|
||||
|
||||
%include "yapt.hh"
|
||||
|
||||
%include "yapdb.hh"
|
||||
|
||||
%include "yapq.hh"
|
||||
|
||||
|
||||
namespace std {
|
||||
|
||||
%template(TermVector) vector<Term>;
|
||||
%feature("novaluewrapper") vector<Term>;
|
||||
|
||||
//%template(YAPTermVector) vector<YAPTerm>;
|
||||
//%feature("novaluewrapper") vector<YAPTerm>;
|
||||
};
|
||||
|
||||
|
||||
%init %{
|
||||
%}
|
133
packages/python/yap_kernel/setup.py
Normal file
133
packages/python/yap_kernel/setup.py
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# the name of the package
|
||||
name = 'yap_kernel'
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Minimal Python version sanity check
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
import sys
|
||||
import sysconfig
|
||||
import setuptools
|
||||
|
||||
v = sys.version_info
|
||||
if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
|
||||
error = "ERROR: %s requires Python version 3.3 or above." % name
|
||||
print(error, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
PY3 = (sys.version_info[0] >= 3)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# get on with it
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
from glob import glob
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
pjoin = os.path.join
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
# pkg_root = pjoin(here, name)
|
||||
|
||||
packages = setuptools.find_packages('/home/vsc/github/yap-6.3/packages/python/yap_kernel')
|
||||
# for d, _, _ in os.walk(pjoin(here, name)):
|
||||
# if os.path.exists(pjoin(d, '__init__.py')):
|
||||
# packages.append(d[len(here)+1:].replace(os.path.sep, '.'))
|
||||
|
||||
sys.path.insert(0, "/home/vsc/github/yap-6.3/packages/python/yap_kernel")
|
||||
package_data = {
|
||||
'yap_ipython': ['prolog/*.*'],
|
||||
'yap_kernel': ['resources/*.*']
|
||||
}
|
||||
|
||||
|
||||
version_ns = {}
|
||||
with open(pjoin('/home/vsc/github/yap-6.3/packages/python/yap_kernel', name, '_version.py')) as f:
|
||||
exec(f.read(), {}, version_ns)
|
||||
|
||||
|
||||
|
||||
|
||||
setup_args = dict(
|
||||
name = name,
|
||||
version = version_ns['__version__'],
|
||||
scripts = glob(pjoin('scripts', '*')),
|
||||
packages = packages,
|
||||
py_modules = ['yap_kernel_launcher'],
|
||||
package_data = package_data,
|
||||
package_dir = {'':"/home/vsc/github/yap-6.3/packages/python/yap_kernel"},
|
||||
description = "YAP Kernel for Jupyter",
|
||||
author = 'YAP Development Team',
|
||||
author_email = 'YAP-dev@scipy.org',
|
||||
url = 'http://ipython.org',
|
||||
license = 'BSD',
|
||||
platforms = "Linux, Mac OS X, Windows",
|
||||
keywords = ['Interactive', 'Interpreter', 'Shell', 'Web'],
|
||||
classifiers = [
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: System Administrators',
|
||||
'Intended Audience :: Science/Research',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Programming Language :: Prolog',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3',
|
||||
],
|
||||
)
|
||||
|
||||
if 'develop' in sys.argv or any(a.startswith('bdist') for a in sys.argv):
|
||||
import setuptools
|
||||
|
||||
setuptools_args = {}
|
||||
install_requires = setuptools_args['install_requires'] = [
|
||||
]
|
||||
|
||||
if any(a.startswith(('bdist', 'build', 'install')) for a in sys.argv):
|
||||
from yap_kernel.kernelspec import write_kernel_spec, make_yap_kernel_cmd, KERNEL_NAME
|
||||
|
||||
|
||||
argv = make_yap_kernel_cmd(executable='python')
|
||||
dest = os.path.join(here, 'resources')
|
||||
if not os.path.exists(dest):
|
||||
os.makedirs( dest )
|
||||
shutil.copy('/home/vsc/github/yap-6.3/docs/icons/yap_32x32x32.png',os.path.join(dest,'logo-32x32.png'))
|
||||
shutil.copy('/home/vsc/github/yap-6.3/docs/icons/yap_64x64x32.png',os.path.join(dest,'logo-64x64.png'))
|
||||
try:
|
||||
write_kernel_spec(dest, overrides={'argv': argv})
|
||||
except:
|
||||
none
|
||||
# shutil.copy('/home/vsc/github/yap-6.3/packages/python/yap_kernel/kernel.js',dest)
|
||||
# shutil.copy('/home/vsc/github/yap-6.3/misc/editors/prolog.js',dest)
|
||||
setup_args['data_files'] = [
|
||||
(pjoin('share', 'jupyter', 'kernels', KERNEL_NAME), glob(pjoin(dest, '*'))),
|
||||
]
|
||||
mode_loc = pjoin( sysconfig.get_path('platlib'), 'notebook', 'static', 'components', 'codemirror', 'mode', 'prolog')
|
||||
custom_loc = pjoin( sysconfig.get_path('platlib'), 'notebook', 'static', 'custom')
|
||||
try:
|
||||
shutil.copy( pjoin( custom_loc, "custom.js") , pjoin( custom_loc, "custom.js.orig"))
|
||||
shutil.copy( "/home/vsc/github/yap-6.3/packages/python/yap_kernel/custom.js" , pjoin( custom_loc, "custom.js"))
|
||||
if not os.path.exists(mode_loc):
|
||||
os.makedirs(mode_loc)
|
||||
shutil.copy( "/home/vsc/github/yap-6.3/misc/editors/prolog.js" , mode_loc)
|
||||
except:
|
||||
pass
|
||||
|
||||
extras_require = setuptools_args['extras_require'] = {
|
||||
'test:python_version=="2.7"': ['mock'],
|
||||
'test': ['nose_warnings_filters', 'nose-timer'],
|
||||
}
|
||||
|
||||
if 'setuptools' in sys.modules:
|
||||
setup_args.update(setuptools_args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
setup(**setup_args)
|
118
packages/python/yap_kernel/x.js
Normal file
118
packages/python/yap_kernel/x.js
Normal file
@@ -0,0 +1,118 @@
|
||||
// leave at least 2 line with only a star on it below, or doc generation fails
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Placeholder for custom user javascript
|
||||
* mainly to be overridden in profile/static/custom/custom.js
|
||||
* This will always be an empty file in IPython
|
||||
*
|
||||
* User could add any javascript in the `profile/static/custom/custom.js` file.
|
||||
* It will be executed by the ipython notebook at load time.
|
||||
*
|
||||
* Same thing with `profile/static/custom/custom.css` to inject custom css into the notebook.
|
||||
*
|
||||
*
|
||||
* The object available at load time depend on the version of IPython in use.
|
||||
* there is no guaranties of API stability.
|
||||
*
|
||||
* The example below explain the principle, and might not be valid.
|
||||
*
|
||||
* Instances are created after the loading of this file and might need to be accessed using events:
|
||||
* define([
|
||||
* 'base/js/namespace',
|
||||
* 'base/js/events'
|
||||
* ], function(IPython, events) {
|
||||
* events.on("app_initialized.NotebookApp", function () {
|
||||
* IPython.keyboard_manager....
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* __Example 1:__
|
||||
*
|
||||
* Create a custom button in toolbar that execute `%qtconsole` in kernel
|
||||
* and hence open a qtconsole attached to the same kernel as the current notebook
|
||||
*
|
||||
* define([
|
||||
* 'base/js/namespace',
|
||||
* 'base/js/events'
|
||||
* ], function(IPython, events) {
|
||||
* events.on('app_initialized.NotebookApp', function(){
|
||||
* IPython.toolbar.add_buttons_group([
|
||||
* {
|
||||
* 'label' : 'run qtconsole',
|
||||
* 'icon' : 'icon-terminal', // select your icon from http://fortawesome.github.io/Font-Awesome/icons
|
||||
* 'callback': function () {
|
||||
* IPython.notebook.kernel.execute('%qtconsole')
|
||||
* }
|
||||
* }
|
||||
* // add more button here if needed.
|
||||
* ]);
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* __Example 2:__
|
||||
*
|
||||
* At the completion of the dashboard loading, load an unofficial javascript extension
|
||||
* that is installed in profile/static/custom/
|
||||
*
|
||||
* define([
|
||||
* 'base/js/events'
|
||||
* ], function(events) {
|
||||
* events.on('app_initialized.DashboardApp', function(){
|
||||
* require(['custom/unofficial_extension.js'])
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* __Example 3:__
|
||||
*
|
||||
* Use `jQuery.getScript(url [, success(script, textStatus, jqXHR)] );`
|
||||
* to load custom script into the notebook.
|
||||
*
|
||||
* // to load the metadata ui extension example.
|
||||
* $.getScript('/static/notebook/js/celltoolbarpresets/example.js');
|
||||
* // or
|
||||
* // to load the metadata ui extension to control slideshow mode / reveal js for nbconvert
|
||||
* $.getScript('/static/notebook/js/celltoolbarpresets/slideshow.js');
|
||||
*
|
||||
*
|
||||
* @module IPython
|
||||
* @namespace IPython
|
||||
* @class customjs
|
||||
* @static
|
||||
*/
|
||||
|
||||
findYapByFileName = function(filename) {
|
||||
console.log(filename);
|
||||
var dot = filename.lastIndexOf(".");
|
||||
var ext = dot > -1 && filename.substring(dot + 1, filename.length);
|
||||
return (ext && (ext == "yap" || ext == "pl"));
|
||||
};
|
||||
|
||||
require([
|
||||
"jquery",
|
||||
// 'custom/prolog'
|
||||
'codemirror/mode/prolog/prolog'
|
||||
], function($,CodeMirror) {
|
||||
//log.console("so far so good\n");
|
||||
var mode = {
|
||||
mime: "text/x-prolog",
|
||||
name: "Prolog",
|
||||
mode: "prolog",
|
||||
ext: ["pl", "yap", "yss", "P"]
|
||||
};
|
||||
//$.getScript('/static/components/codemirror/mode/meta.js');
|
||||
if (Jupyter.editor && Jupyter.editor.file_path &&
|
||||
findYapByFileName( Jupyter.editor.file_path) ) {
|
||||
Jupyter.editor.set_codemirror_mode(mode);
|
||||
//Jupyter.editor.codemirror.setOption("mode","prolog");
|
||||
//$("#current-mode").text("Prolog")
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//$.getScript('/static/components/codemirror/mode/meta.js', (function() {
|
||||
//var v = $('.modeInfo').push(mode);
|
||||
//}));
|
21
packages/python/yap_kernel/yap_kernel.egg-info/PKG-INFO
Normal file
21
packages/python/yap_kernel/yap_kernel.egg-info/PKG-INFO
Normal file
@@ -0,0 +1,21 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: yap-kernel
|
||||
Version: 6.3.5
|
||||
Summary: YAP Kernel for Jupyter
|
||||
Home-page: http://ipython.org
|
||||
Author: YAP Development Team
|
||||
Author-email: YAP-dev@scipy.org
|
||||
License: BSD
|
||||
Description-Content-Type: UNKNOWN
|
||||
Description: UNKNOWN
|
||||
Keywords: Interactive,Interpreter,Shell,Web
|
||||
Platform: Linux
|
||||
Platform: Mac OS X
|
||||
Platform: Windows
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: Intended Audience :: System Administrators
|
||||
Classifier: Intended Audience :: Science/Research
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Programming Language :: Prolog
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 3
|
82
packages/python/yap_kernel/yap_kernel.egg-info/SOURCES.txt
Normal file
82
packages/python/yap_kernel/yap_kernel.egg-info/SOURCES.txt
Normal file
@@ -0,0 +1,82 @@
|
||||
setup.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel_launcher.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/core/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/core/yap_kernel/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/core/yap_kernel/getipython.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/display.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/shellapp.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/core/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/core/getipython.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/core/interactiveshell.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/core/modulefind.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/core/oinspect.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/core/release.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/core/shellapp.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_ipython/prolog/jupyter.yap
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/__main__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/_version.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/codeutil.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/connect.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/datapub.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/displayhook.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/embed.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/eventloops.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/formatters.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/heartbeat.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inputtransformer.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/interactiveshell.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/iostream.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/jsonutil.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/kernelapp.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/kernelbase.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/kernelspec.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/log.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/parentpoller.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/pickleutil.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/serialize.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/yapkernel.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/zmqshell.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel.egg-info/PKG-INFO
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel.egg-info/SOURCES.txt
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel.egg-info/dependency_links.txt
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel.egg-info/requires.txt
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel.egg-info/top_level.txt
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/comm/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/comm/comm.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/comm/manager.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/gui/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/gui/gtk3embed.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/gui/gtkembed.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/blocking.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/channels.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/client.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/constants.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/ipkernel.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/manager.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/socket.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/tests/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/tests/test_kernel.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/inprocess/tests/test_kernelmanager.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/pylab/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/pylab/backend_inline.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/pylab/config.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/resources/kernel.js
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/resources/logo-32x32.png
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/resources/logo-64x64.png
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/resources/prolog.js
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/__init__.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_connect.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_embed_kernel.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_io.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_jsonutil.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_kernel.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_kernelspec.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_message_spec.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_pickleutil.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_serialize.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_start_kernel.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/test_zmq_shell.py
|
||||
/home/vsc/github/yap-6.3/packages/python/yap_kernel/yap_kernel/tests/utils.py
|
@@ -0,0 +1 @@
|
||||
|
@@ -0,0 +1,7 @@
|
||||
|
||||
[test]
|
||||
nose_warnings_filters
|
||||
nose-timer
|
||||
|
||||
[test:python_version=="2.7"]
|
||||
mock
|
@@ -0,0 +1,4 @@
|
||||
core
|
||||
yap_ipython
|
||||
yap_kernel
|
||||
yap_kernel_launcher
|
204
packages/python/yap_kernel/yap_kernel/resources/kernel.js
Normal file
204
packages/python/yap_kernel/yap_kernel/resources/kernel.js
Normal file
@@ -0,0 +1,204 @@
|
||||
define( function() {
|
||||
return {onload:function() {
|
||||
console.info('Kernel specific javascript loaded');
|
||||
// do more things here, like define a codemirror mode]]
|
||||
require(['codemirror/lib/codemirror', 'codemirror/mode/meta'], function(CodeMirror) {
|
||||
` CodeMirror.mI = [
|
||||
{name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
|
||||
{name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]},
|
||||
{name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
|
||||
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
|
||||
{name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
|
||||
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]},
|
||||
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
|
||||
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
|
||||
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
|
||||
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
|
||||
{name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
|
||||
{name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
|
||||
{name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
|
||||
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
|
||||
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
|
||||
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
|
||||
{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
|
||||
{name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
|
||||
{name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
|
||||
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
|
||||
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
|
||||
{name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
|
||||
{name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
|
||||
{name: "Django", mime: "text/x-django", mode: "django"},
|
||||
{name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/},
|
||||
{name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
|
||||
{name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
|
||||
{name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
|
||||
{name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
|
||||
{name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
|
||||
{name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
|
||||
{name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
|
||||
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
|
||||
{name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
|
||||
{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
|
||||
{name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
|
||||
{name: "FCL", mime: "text/x-fcl", mode: "fcl"},
|
||||
{name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
|
||||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
|
||||
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
|
||||
{name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
|
||||
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
||||
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
|
||||
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
|
||||
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
|
||||
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
||||
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
||||
{name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
|
||||
{name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
|
||||
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
|
||||
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
|
||||
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
|
||||
{name: "HTTP", mime: "message/http", mode: "http"},
|
||||
{name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
|
||||
{name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
|
||||
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
||||
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
|
||||
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
||||
mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
|
||||
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
|
||||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
|
||||
{name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
|
||||
{name: "Jinja2", mime: "null", mode: "jinja2"},
|
||||
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
||||
{name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
|
||||
{name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
|
||||
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
|
||||
{name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
|
||||
{name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
|
||||
{name: "mIRC", mime: "text/mirc", mode: "mirc"},
|
||||
{name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
|
||||
{name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
|
||||
{name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
|
||||
{name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
|
||||
{name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
|
||||
{name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
|
||||
{name: "MySQL", mime: "text/x-mysql", mode: "sql"},
|
||||
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
|
||||
{name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
|
||||
{name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
|
||||
{name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]},
|
||||
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
|
||||
{name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
|
||||
{name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
|
||||
{name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
|
||||
{name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
|
||||
{name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
|
||||
{name: "PHP", mime: "application/x-httpd-php", mode: "php", ext: ["php", "php3", "php4", "php5", "phtml"]},
|
||||
{name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
|
||||
{name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
|
||||
{name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
|
||||
{name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
|
||||
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
|
||||
{ name: "Prolog", mime: "text/x-prolog",
|
||||
mode: "prolog", ext: ["pl", "yap", "yss", "P"] },
|
||||
|
||||
{name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
|
||||
< {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/},
|
||||
{name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
|
||||
{name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
|
||||
{name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]},
|
||||
{name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
|
||||
{name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
|
||||
{name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
|
||||
{name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
|
||||
{name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
|
||||
{name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]},
|
||||
{name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
|
||||
{name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
|
||||
{name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
|
||||
{name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
|
||||
{name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
|
||||
{name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
|
||||
{name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
|
||||
{name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
|
||||
{name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
|
||||
{name: "Solr", mime: "text/x-solr", mode: "solr"},
|
||||
{name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]},
|
||||
{name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
|
||||
{name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
|
||||
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
|
||||
{name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
|
||||
{name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]},
|
||||
{name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
|
||||
{name: "sTeX", mime: "text/x-stex", mode: "stex"},
|
||||
{name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]},
|
||||
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
|
||||
{name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
|
||||
{name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
|
||||
{name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
|
||||
{name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
|
||||
{name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
|
||||
{name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
|
||||
{name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
|
||||
{name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
|
||||
{name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
|
||||
{name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
|
||||
{name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
|
||||
{name: "Twig", mime: "text/x-twig", mode: "twig"},
|
||||
{name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]},
|
||||
{name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
|
||||
{name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
|
||||
{name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
|
||||
{name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
|
||||
{name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
|
||||
{name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]},
|
||||
{name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]},
|
||||
{name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
|
||||
{name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]},
|
||||
{name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
|
||||
{name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
|
||||
{name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
|
||||
{name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
|
||||
{name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
|
||||
];
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
CodeMirror.findModeByMIME = function(mime) {
|
||||
mime = mime.toLowerCase();
|
||||
for (var i = 0; i < CodeMirror.mI.length; i++) {
|
||||
var info = CodeMirror.mI[i];
|
||||
if (info.mime == mime) return info;
|
||||
if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
|
||||
if (info.mimes[j] == mime) return info;
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.findModeByExtension = function(ext) {
|
||||
for (var i = 0; i < CodeMirror.mI.length; i++) {
|
||||
var info = CodeMirror.mI[i];
|
||||
if (info.ext) for (var j = 0; j < info.ext.length; j++)
|
||||
if (info.ext[j] == ext) return info;
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.findModeByFileName = function(filename) {
|
||||
for (var i = 0; i < CodeMirror.mI.length; i++) {
|
||||
var info = CodeMirror.mI[i];
|
||||
if (info.file && info.file.test(filename)) return info;
|
||||
}
|
||||
var dot = filename.lastIndexOf(".");
|
||||
var ext = dot > -1 && filename.substring(dot + 1, filename.length);
|
||||
if (ext) return CodeMirror.findModeByExtension(ext);
|
||||
};
|
||||
|
||||
CodeMirror.findModeByName = function(name) {
|
||||
name = name.toLowerCase();
|
||||
for (var i = 0; i < CodeMirror.mI.length; i++) {
|
||||
var info = CodeMirror.mI[i];
|
||||
if (info.name.toLowerCase() == name) return info;
|
||||
if (info.alias) for (var j = 0; j < info.alias.length; j++)
|
||||
if (info.alias[j].toLowerCase() == name) return info;
|
||||
}
|
||||
};
|
||||
} }; });
|
1234
packages/python/yap_kernel/yap_kernel/resources/prolog.js
Normal file
1234
packages/python/yap_kernel/yap_kernel/resources/prolog.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user