doc support
This commit is contained in:
Vitor Santos Costa 2016-11-23 22:35:39 -06:00
parent 8d1cc35a8a
commit d37e198c12
115 changed files with 133 additions and 2855 deletions

View File

@ -399,11 +399,11 @@ X_API Term YAP_MkAtomTerm(Atom n) {
X_API Atom YAP_AtomOfTerm(Term t) { return (AtomOfTerm(t)); }
X_API bool YAP_IsWideAtom(Atom a) {
const unsigned char *s = RepAtom(a)->UStrOfAE;
int32_t v;
const unsigned char *s = RepAtom(a)->UStrOfAE;
int32_t v;
while (*s) {
size_t n = get_utf8(s,1,&v);
if (n>1)
size_t n = get_utf8(s, 1, &v);
if (n > 1)
return true;
}
return false;
@ -419,15 +419,15 @@ X_API const char *YAP_AtomName(Atom a) {
X_API const wchar_t *YAP_WideAtomName(Atom a) {
int32_t v;
const unsigned char *s = RepAtom(a)->UStrOfAE;
size_t n = strlen_utf8( s );
wchar_t *dest = Malloc( (n+1)* sizeof(wchar_t)), *o = dest;
size_t n = strlen_utf8(s);
wchar_t *dest = Malloc((n + 1) * sizeof(wchar_t)), *o = dest;
while (*s) {
size_t n = get_utf8(s,1,&v);
if (n==0)
return NULL;
size_t n = get_utf8(s, 1, &v);
if (n == 0)
return NULL;
*o++ = v;
}
o[0] = '\0';
o[0] = '\0';
return dest;
}
@ -452,10 +452,9 @@ X_API Atom YAP_LookupAtom(const char *c) {
X_API Atom YAP_LookupWideAtom(const wchar_t *c) {
CACHE_REGS
Atom a;
while (TRUE) {
a = Yap_NWCharsToAtom(c, -1 USES_REGS);
a = Yap_NWCharsToAtom(c, -1 USES_REGS);
if (a == NIL || Yap_get_signal(YAP_CDOVF_SIGNAL)) {
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP failed to grow heap: %s",
@ -490,10 +489,9 @@ X_API size_t YAP_AtomNameLength(Atom at) {
if (IsBlob(at)) {
return RepAtom(at)->rep.blob->length;
}
unsigned char *c = RepAtom(at)->UStrOfAE;
return strlen_utf8(c);
unsigned char *c = RepAtom(at)->UStrOfAE;
return strlen_utf8(c);
}
X_API Term YAP_MkVarTerm(void) {
@ -2303,10 +2301,11 @@ YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
Yap_init_yapor_global_local_memory();
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
GLOBAL_PrologShouldHandleInterrupts = yap_init->PrologShouldHandleInterrupts;
GLOBAL_PrologShouldHandleInterrupts =
!yap_init->PrologCannotHandleInterrupts && !Yap_embedded;
Yap_InitSysbits(0); /* init signal handling and time, required by later
functions */
GLOBAL_argv = yap_init->Argv;
GLOBAL_argv = yap_init->Argv;
GLOBAL_argc = yap_init->Argc;
if (0 && ((YAP_QLY && yap_init->SavedState) ||
(YAP_BOOT_PL && (yap_init->YapPrologBootFile)))) {
@ -2367,10 +2366,10 @@ YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
//
CACHE_REGS
if (Yap_embedded)
if (yap_init->QuietMode) {
setVerbosity(TermSilent);
}
if (Yap_embedded)
if (yap_init->QuietMode) {
setVerbosity(TermSilent);
}
{
if (yap_init->YapPrologRCFile != NULL) {
/*
@ -3208,10 +3207,10 @@ size_t YAP_UTF8_TextLength(Term t) {
Term hd = HeadOfTerm(t);
if (IsAtomTerm(hd)) {
Atom at = AtomOfTerm(hd);
unsigned char *s = RepAtom(at)->UStrOfAE;
int32_t ch;
get_utf8(s, 1, &ch);
c = ch;
unsigned char *s = RepAtom(at)->UStrOfAE;
int32_t ch;
get_utf8(s, 1, &ch);
c = ch;
} else if (IsIntegerTerm(hd)) {
c = IntegerOfTerm(hd);
} else {
@ -3222,8 +3221,8 @@ size_t YAP_UTF8_TextLength(Term t) {
}
} else if (IsAtomTerm(t)) {
Atom at = AtomOfTerm(t);
sz = strlen(RepAtom(at)->StrOfAE);
} else if (IsStringTerm(t)) {
sz = strlen(RepAtom(at)->StrOfAE);
} else if (IsStringTerm(t)) {
sz = strlen(StringOfTerm(t));
}
return sz;

View File

@ -315,9 +315,9 @@ inline static bool do_execute(Term t, Term mod USES_REGS) {
/* I cannot use the standard macro here because
otherwise I would dereference the argument and
might skip a svar */
if (pen->PredFlags & MetaPredFlag) {
return CallMetaCall(t, mod PASS_REGS);
}
if (pen->PredFlags & MetaPredFlag) {
return CallMetaCall(t, mod PASS_REGS);
}
pt = RepAppl(t) + 1;
for (i = 1; i <= arity; i++) {
#if YAPOR_SBA
@ -1444,27 +1444,31 @@ static bool exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) {
LOCAL_PrologMode = UserMode;
P = (yamop *)FAILCODE;
} break;
case 2: {
/* arithmetic exception */
/* must be done here, otherwise siglongjmp will clobber all the
* registers
*/
Yap_Error(LOCAL_Error_TYPE, TermNil, NULL);
/* reset the registers so that we don't have trash in abstract
* machine */
Yap_set_fpu_exceptions(
getAtomicGlobalPrologFlag(ARITHMETIC_EXCEPTIONS_FLAG));
P = (yamop *)FAILCODE;
LOCAL_PrologMode = UserMode;
} break;
case 4: {
P = (yamop *)FAILCODE;
LOCAL_PrologMode = UserMode;
} break;
case 2: {
/* arithmetic exception */
/* must be done here, otherwise siglongjmp will clobber all the
* registers
*/
Yap_Error(LOCAL_Error_TYPE, TermNil, NULL);
/* reset the registers so that we don't have trash in abstract
* machine */
Yap_set_fpu_exceptions(
getAtomicGlobalPrologFlag(ARITHMETIC_EXCEPTIONS_FLAG));
P = (yamop *)FAILCODE;
LOCAL_PrologMode = UserMode;
} break;
case 3: { /* saved state */
LOCAL_CBorder = OldBorder;
return false;
}
case 4: {
/* abort */
/* can be called from anywgerre, must reset registers,
*/
Yap_JumpToEnv(TermDAbort);
P = (yamop *)FAILCODE;
LOCAL_PrologMode = UserMode;
} break;
default:
/* do nothing */
LOCAL_PrologMode = UserMode;

View File

@ -25,18 +25,18 @@ static char SccsId[] = "%W% %G%";
#include <unistd.h>
#endif
#if _WIN32
#include <stdio.h>
#include <io.h>
#include <stdio.h>
#endif
#include "Yatom.h"
#include "YapHeap.h"
#include "Yatom.h"
#include "eval.h"
#include "yapio.h"
#ifdef TABLING
#include "tab.macros.h"
#endif /* TABLING */
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#if HAVE_STRING_H
#include <string.h>
#endif
@ -63,7 +63,11 @@ static yap_signals InteractSIGINT(int ch) {
#endif
switch (ch) {
case 'a':
/* abort computation */
/* abort computation */
#if PUSH_REGS
// restore_absmi_regs(&Yap_standard_regs);
#endif
siglongjmp(LOCAL_RestartEnv, 4);
return YAP_ABORT_SIGNAL;
case 'b':
/* continue */
@ -183,35 +187,32 @@ inline static bool get_signal(yap_signals sig USES_REGS) {
#endif
}
bool Yap_DisableInterrupts(int wid)
{
bool Yap_DisableInterrupts(int wid) {
LOCAL_InterruptsDisabled = true;
YAPEnterCriticalSection();
return true;
}
bool Yap_EnableInterrupts(int wid)
{
bool Yap_EnableInterrupts(int wid) {
LOCAL_InterruptsDisabled = false;
YAPLeaveCriticalSection();
return true;
}
/**
Function called to handle delayed interrupts.
*/
int Yap_HandleInterrupts(void) {
bool Yap_HandleSIGINT(void) {
CACHE_REGS
yap_signals sig;
if (get_signal(YAP_INT_SIGNAL PASS_REGS)) {
do {
if ((sig = ProcessSIGINT()) != YAP_NO_SIGNAL)
do_signal(worker_id, sig PASS_REGS);
LOCAL_PrologMode &= ~InterruptMode;
return 1;
}
return 0;
return true;
} while (get_signal(YAP_INT_SIGNAL PASS_REGS));
return false;
}
static Int p_creep(USES_REGS1) {

View File

@ -369,8 +369,7 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
p++;
}
} else {
YAP_SetOutputMessage();
YAP_SetOutputMessage();
}
break;
#endif
@ -446,13 +445,13 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
break;
case 'n':
if (!strcmp("nosignals", p)) {
iap->PrologShouldHandleInterrupts = FALSE;
iap->PrologCannotHandleInterrupts = true;
break;
}
break;
case '-':
if (!strcmp("-nosignals", p)) {
iap->PrologShouldHandleInterrupts = FALSE;
iap->PrologCannotHandleInterrupts = true;
break;
} else if (!strncmp("-home=", p, strlen("-home="))) {
GLOBAL_Home = p + strlen("-home=");

View File

@ -59,12 +59,12 @@ include(Sources NO_POLICY_SCOPE)
include(Model NO_POLICY_SCOPE)
include_directories ( utf8proc packages/myddas packages/myddas/sqlite3)
include_directories ( utf8proc packages/myddas packages/myddas/sqlite3/src)
if (ANDROID)
include_directories (
packages/myddas/sqlite3/Android/jni/sqlite
packages/myddas/sqlite3/Android/jni/sqlite/nativehelper
packages/myddas/sqlite3/src/Android/jni/sqlite
packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper
)
endif (ANDROID)

View File

@ -95,7 +95,7 @@ A Csult F "$csult"
A CurrentModule F "$current_module"
A Cut N "!"
A CutBy F "$cut_by"
A DAbort F "$abort"
A DAbort N "abort"
A DBLoad F "$db_load"
A DBREF N "DBRef"
A DBReference N "db_reference"

View File

@ -90,7 +90,7 @@
AtomCurrentModule = Yap_FullLookupAtom("$current_module"); TermCurrentModule = MkAtomTerm(AtomCurrentModule);
AtomCut = Yap_LookupAtom("!"); TermCut = MkAtomTerm(AtomCut);
AtomCutBy = Yap_FullLookupAtom("$cut_by"); TermCutBy = MkAtomTerm(AtomCutBy);
AtomDAbort = Yap_FullLookupAtom("$abort"); TermDAbort = MkAtomTerm(AtomDAbort);
AtomDAbort = Yap_LookupAtom("abort"); TermDAbort = MkAtomTerm(AtomDAbort);
AtomDBLoad = Yap_FullLookupAtom("$db_load"); TermDBLoad = MkAtomTerm(AtomDBLoad);
AtomDBREF = Yap_LookupAtom("DBRef"); TermDBREF = MkAtomTerm(AtomDBREF);
AtomDBReference = Yap_LookupAtom("db_reference"); TermDBReference = MkAtomTerm(AtomDBReference);

View File

@ -128,15 +128,13 @@ endif(POLICY CMP0043)
if (ANDROID)
set ( prefix ${YAP_APP_DIR}/generated )
set ( datarootdir ${YAP_APP_DIR}/generated/assets )
#set ( includedir "${prefix}/assets/include")
set ( libpl ${YAP_APP_DIR}/generated/assets/Yap)
set ( prefix ${YAP_APP_DIR}/build )
set ( datarootdir ${prefix}/assets )
else()
set ( prefix "${CMAKE_INSTALL_PREFIX}")
set ( datarootdir ${prefix}/share )
set ( libpl "${datarootdir}/Yap")
endif()
set ( libpl ${datarootdir}/Yap)
set ( includedir "${prefix}/include")
set ( exec_prefix "${prefix}")
set ( libdir "${exec_prefix}/lib")
@ -144,7 +142,7 @@ set ( dlls "${exec_prefix}/lib/Yap")
set ( datadir "${datarootdir}")
set ( mandir "${datarootdir}/man")
set ( bindir "${exec_prefix}/bin")
set ( docdir "${exec_prefix}/doc/Yap")
set ( docdir "${datarootdir}/doc/Yap")
set(YAP_ROOTDIR ${prefix})

View File

@ -785,8 +785,8 @@ INPUT = /Users/vsc/git/yap-6.3/pl \
/Users/vsc/git/yap-6.3/library \
/Users/vsc/git/yap-6.3/packages \
/Users/vsc/git/yap-6.3/swi/library \
/Users/vsc/git/yap-6.3/docs/*.md \
/Users/vsc/git/yap-6.3/*.md \
/Users/vsc/git/yap-6.3/docs/md \
/Users/vsc/git/yap-6.3/INSTALL.md \
# This tag can be used to specify the character encoding of the source files

View File

@ -384,7 +384,7 @@ INLINE_GROUPED_CLASSES = NO
# with only public data fields or simple typedef fields will be shown inline in
# the documentation of the scope in which they are defined (i.e. file,
# namespace, or group documentation), provided this scope is documented. If set
v# to NO, structs, classes, and unions are shown on a separate page (for HTML and
# to NO, structs, classes, and unions are shown on a separate page (for HTML and
# Man pages) or section (for LaTeX and RTF).
# The default value is: NO.
@ -785,8 +785,8 @@ INPUT = @PROJECT_SOURCE_DIR@/pl \
@PROJECT_SOURCE_DIR@/library \
@PROJECT_SOURCE_DIR@/packages \
@PROJECT_SOURCE_DIR@/swi/library \
@PROJECT_SOURCE_DIR@/docs/*.md \
@PROJECT_SOURCE_DIR@/*.md
@PROJECT_SOURCE_DIR@/docs/md \
@PROJECT_SOURCE_DIR@/INSTALL.md
# This tag can be used to specify the character encoding of the source files
@ -827,7 +827,11 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = *pltotex.pl
EXCLUDE = *pltotex.pl \
@PROJECT_SOURCE_DIR@/packages/myddas/sqlite3/src \
@PROJECT_SOURCE_DIR@/packages/gecode/4.0.* \
@PROJECT_SOURCE_DIR@/packages/gecode/3,* \
@PROJECT_SOURCE_DIR@/C/traced_absmi_insts.h
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@ -1133,7 +1137,7 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/solarized-light.css
# @CMAKE_SOURCE_DIR@/docs/solarized-light.css

View File

@ -1,31 +0,0 @@
YAP Built-ins {#builtins}
=================
This chapter describes the core predicates that control the execution of
Prolog programs, provide fundamental functionality such as termm manipulation or arithmetic, and support interaction with external
resources, Many of the predicates described here have been standardised by the ISO. The standartised subset of Proloh also known as ISO-Prolog.
In the description of the arguments of functors the following notation
will be used:
+ a preceding plus sign will denote an argument as an "input
argument" - it cannot be a free variable at the time of the call;
+ a preceding minus sign will denote an "output argument";
+ an argument with no preceding symbol can be used in both ways.
+ @ref YAPControl
+ @ref Arithmetic
+ @ref YAPChars
+ @ref YAP_Terms
+ @ref InputOutput
+ @ref AbsoluteFileName
+ @ref YAPOS
+ @ref Internal_Database
+ @ref Sets

View File

@ -1,17 +0,0 @@
Downloading YAP {#download}
==============
The latest development version of Yap-6 is yap-6.3.4 and can be
obtained from the repositories
<http://sourceforge.net/p/yap/yap-6.3>
and
<https://github.com/vscosta/yap-6.3>
YAP-6.3.4 does not use modules. Please just use `git clone` to obtain the distribution.
Most of these repositories are basically copies of the original
repositories at the SWI-Prolog site. YAP-6 will work either with or
without these packages.

View File

@ -1,21 +0,0 @@
Extensions to core Prolog. {#extensions}
=========================
YAP includes a number of extensions over the original Prolog
language. Next, we discuss how to use the most important ones.
+ @ref Rational_Trees
+ @ref AttributedVariables
+ @ref DepthLimited
+ @ref Tabling
+ @ref Threads
+ @ref Profiling
+ @ref YAPArrays
+ @ref Parallelism

View File

@ -1,16 +0,0 @@
The Foreign Code Interface {#fli}
===========================
YAP provides the user with three facilities for writing
predicates in a language other than Prolog. Under Unix systems,
most language implementations were linkable to `C`, and the first interface exported the YAP machinery to the C language. YAP also implements most of the SWI-Prolog foreign language interface.
This gives portability with a number of SWI-Prolog packages and avoids garnage collection by using @ref slotInterface. Last, a new C++ based interface is
being designed to work with the swig (www.swig.orgv) interface compiler.
+ The @ref c-interface exports the YAP engine.
+ The @ref swi-c-interface emulates Jan Wielemaker's SWI foreign language interface.
+ The @ref yap-cplus-interface is desiged to interface with the SWIG package by using Object-Oriented concepts
+ The @ref LoadInterface handles the setup of foreign files

File diff suppressed because one or more lines are too long

View File

@ -1,58 +0,0 @@
The YAP Library (#library)
==============
Library files reside in the library_directory path (set by the
`LIBDIR` variable in the Makefile for YAP). Several files in the
library are originally from the public-domain Edinburgh Prolog library.
- @ref apply
- @ref apply_macros
- @ref arg
- @ref Association_Lists
- @ref avl
- @ref bhash
- @ref block_diagram
- @ref c_alarms
- @ref charsio
- @ref clauses
- @ref cleanup
- @ref dbqueues
- @ref dbusage
- @ref dgraphs
- @ref exo_interval
- @ref flags
- @ref gensym
- @ref yap_hacks
- @ref heaps
- @ref lam_mpi
- @ref line_utils
- @ref swi_listing
- @ref lists
- @ref mapargs
- @ref maplist
- @ref matlab
- @ref matrix
- @ref nb
- @ref Ordered_Sets
- @ref parameters
- @ref queues
- @ref random
- @ref Pseudo_Random
- @ref rbtrees
- @ref regexp
- @ref rltrees
- @ref Splay_Trees
- @ref operating_system_support,
- @ref Terms
- @ref timeout
- @ref trees
- @ref tries
- @ref ugraphs
- @ref undgraphs
- @ref varnumbers
- @ref wdgraphs
- @ref wdgraphs
- @ref wdgraphs
- @ref wgraphs
- @ref wundgraphs
- @ref ypp

View File

@ -1,11 +0,0 @@
Loading and Oganising YAP Programs {#consult}
===================================
Next, we present the main predicates and directives available to load
files and to control the Prolog environment.
+ @ref YAPConsulting
+ @subpage YAPModules
+ @ref YAPSaving

View File

@ -1,9 +1,6 @@
Attributed Variables and Co-Routining {#AttributedVariables}
=======================================
@defgroup AttributedVariables Attributed Variables and Co-Routining
@ingroup extensions
YAP supports attributed variables, originally developed at OFAI by
Christian Holzbaur. Attributes are a means of declaring that an
arbitrary term is a property for a variable. These properties can be
@ -11,7 +8,6 @@ updated during forward execution. Moreover, the unification algorithm is
aware of attributed variables and will call user defined handlers when
trying to unify these variables.
Attributed variables provide an elegant abstraction over which one can
extend Prolog systems. Their main application so far has been in
implementing constraint handlers, such as Holzbaur's CLPQR, Fruewirth

View File

@ -1,7 +1,5 @@
# The YAP Module system
The YAP Module system (#YAPModules)
-
The YAP Module system {#YAPModules}
======================
The YAP module system is based on the Quintus/SISCtus module

View File

@ -1,28 +0,0 @@
YAP packages files {#packages}
===================
+ @subpage real
+ @ref BDDs
+ @subpage ecode
+ @subpage myddas
+ @ref PFL/CLP(BN)
+ @ref ProbLog1
+ @ref Python
+ @subpage YAPRaptor
+ @ref YAP-LBFGS
+ @subpage yap-udi-indexers
Leuven packages ported from SWI-Prolog:
+ @subpage chr
+ @subpage clpqr

View File

@ -1,190 +0,0 @@
Running YAP {#run}
===========
We next describe how to invoke YAP in Unix systems.
@section Running_YAP_Interactively Running YAP Interactively
Most often you will want to use YAP in interactive mode. Assuming that
YAP is in the user's search path, the top-level can be invoked under
Unix with the following command:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yap [-s n] [-h n] [-a n] [-c IP_HOST port ] [filename]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All the arguments and flags are optional and have the following meaning:
+ -?
print a short error message.
+ -s _Size_
allocate _Size_ KBytes for local and global stacks. The user may
specify <tt>M</tt> bytes.
+ -h _Size_
allocate _Size_ KBytes for heap and auxiliary stacks
+ -t _Size_
allocate _Size_ KBytes for the trail stack
+ -L _Size_
SWI-compatible option to allocate _Size_ K bytes for local and global stacks, the local stack
cannot be expanded. To avoid confusion with the load option, _Size_
must immediately follow the letter `L`.
+ -G _Size_
SWI-compatible option to allocate _Size_ K bytes for local and global stacks; the global
stack cannot be expanded
+ -T _Size_
SWI-compatible option to allocate _Size_ K bytes for the trail stack; the trail cannot be expanded.
+ -l _YAP_FILE_
compile the Prolog file _YAP_FILE_ before entering the top-level.
+ -L _YAP_FILE_
compile the Prolog file _YAP_FILE_ and then halt. This option is
useful for implementing scripts.
+ -g _Goal_
run the goal _Goal_ before top-level. The goal is converted from
an atom to a Prolog term.
+ -z _Goal_
run the goal _Goal_ as top-level. The goal is converted from
an atom to a Prolog term.
+ -b _BOOT_FILE_
boot code is in Prolog file _BOOT_FILE_. The filename must define
the predicate `'$live'/0`.
+ -c <tt>IP_HOST</tt> <tt>port</tt>
connect standard streams to host <tt>IP_HOST</tt> at port <tt>port</tt>
+ filename
restore state saved in the given file
+ -f
do not consult initial files
+ -q
do not print informational messages
+ --
separator for arguments to Prolog code. These arguments are visible
through the unix/1 built-in predicate.
Note that YAP will output an error message on the following conditions:
+
a file name was given but the file does not exist or is not a saved
YAP state;
+
the necessary amount of memory could not be allocated;
+
the allocated memory is not enough to restore the state.
When restoring a saved state, YAP will allocate the
same amount of memory as that in use when the state was saved, unless a
different amount is specified by flags in the command line. By default,
YAP restores the file startup.yss from the current directory or from
the YAP library.
+
YAP usually boots from a saved state. The saved state will use the default
installation directory to search for the YAP binary unless you define
the environment variable YAPBINDIR.
+
YAP always tries to find saved states from the current directory
first. If it cannot it will use the environment variable YAPLIBDIR, if
defined, or search the default library directory.
+
YAP will try to find library files from the YAPSHAREDIR/library
directory.
@section Running_Prolog_Files Running Prolog Files
YAP can also be used to run Prolog files as scripts, at least in
Unix-like environments. A simple example is shown next (do not forget
that the shell comments are very important):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/local/bin/yap -L --
#
# Hello World script file using YAP
#
# put a dot because of syntax errors .
:- write('Hello World'), nl.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The `#!` characters specify that the script should call the binary
file YAP. Notice that many systems will require the complete path to the
YAP binary. The `-L` flag indicates that YAP should consult the
current file when booting and then halt. The remaining arguments are
then passed to YAP. Note that YAP will skip the first lines if they
start with `#` (the comment sign for Unix's shell). YAP will
consult the file and execute any commands.
A slightly more sophisticated example is:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/yap -L --
#
# Hello World script file using YAP
# .
:- initialization(main).
main :- write('Hello World'), nl.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The `initialization` directive tells YAP to execute the goal main
after consulting the file. Source code is thus compiled and `main`
executed at the end. The `.` is useful while debugging the script
as a Prolog program: it guarantees that the syntax error will not
propagate to the Prolog code.
Notice that the `--` is required so that the shell passes the extra
arguments to YAP. As an example, consider the following script
`dump_args`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/yap -L --
#.
main( [] ).
main( [H|T] ) :-
write( H ), nl,
main( T ).
:- unix( argv(AllArgs) ), main( AllArgs ).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you this run this script with the arguments:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./dump_args -s 10000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the script will start an YAP process with stack size `10MB`, and
the list of arguments to the process will be empty.
Often one wants to run the script as any other program, and for this it
is convenient to ignore arguments to YAP. This is possible by using
`L --` as in the next version of `dump_args`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/yap -L --
main( [] ).
main( [H|T] ) :-
write( H ), nl,
main( T ).
:- unix( argv(AllArgs) ), main( AllArgs ).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The `--` indicates the next arguments are not for YAP. Instead,
they must be sent directly to the argv built-in. Hence, running
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./dump_args test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
will write `test` on the standard output.

View File

@ -1,182 +0,0 @@
Compatibility with other Prolog systems {#swi}
=======================================
YAP has been designed to be as compatible as possible with other
Prolog systems, originally with C-Prolog\cite x and SICStus
Prolog~\cite x . More recent work on YAP has striven at making YAP
compatible with the ISO-Prolog standard\cite x , and with Jan
Wielemaker's SWI-Prolog\cite x .
SWI-Prolog and YAP have collaborated at improved compatibility \cite x . This
resulted in Prolog extensions such as the `dialect` feature. YAP
currently supports most of the SWI-Prolog foreign interface. The following SWI
libraries have been adapted to YAP:
+ @ref aggregate
+ @ref base64
+ @ref broadcast
+ @ref ctypes
+ @ref date
+ @ref prolog_debug
+ @ref prolog_edit
+ @ref error
+ @ref nb_set
+ @ref prolog_operator
+ @ref swi_option
+ @ref pairs
+ @ref pio
+ @ref predicate_options,
+ @ref predopts
+ @ref prolog_clause
+ @ref prolog_colour
+ @ref prolog_source
+ @ref prolog_xref
+ @ref pure_input
+ @ref quasi_quotations
+ @ref read_util
+ @ref record
+ @ref settings
+ @ref shlib
+ @ref thread_pool
+ @ref url
+ @ref utf8
+ @ref win_menu
+ @ref www_browser
Note that in general SWI code may be from an earlier version than the
one available with SWI-Prolog. SWI-Prolog are obviously not
responsible for any incompatibilities and/or bugs in the YAP port.
Please do refer to the SWI-Prolog home page:
<http://www.swi-prolog.org>
for more information on SWI-Prolog and the SWI packages.
Compatibility with the C-Prolog interpreter {#ChYProlog}
-------------------------------------------
YAP was designed so that most C-Prolog programs should run under YAP
without changes.
The most important difference between YAP and C-Prolog is that, being
YAP a compiler, some changes should be made if predicates such as
assert/1, clause/1 and retract/1 are used. First
predicates which will change during execution should be declared as
`dynamic` by using commands like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:- dynamic f/n.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
where `f` is the predicate name and n is the arity of the
predicate. Note that several such predicates can be declared in a
single command:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:- dynamic f/2, ..., g/1.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Primitive predicates such as `retract` apply only to dynamic
predicates. Finally note that not all the C-Prolog primitive predicates
are implemented in YAP. They can easily be detected using the
`unknown` system predicate provided by YAP.
Last, by default YAP enables character escapes in strings. You can
disable the special interpretation for the escape character by using:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:- yap_flag(character_escapes,off).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
or by using:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:- yap_flag(language,cprolog).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compatibility with the Quintus and SICStus Prolog systems
---------------------------------------------------------
The Quintus Prolog system was the first Prolog compiler to use Warren's
Abstract Machine. This system was very influential in the Prolog
community. Quintus Prolog implemented compilation into an abstract
machine code, which was then emulated. Quintus Prolog also included
several new built-ins, an extensive library, and in later releases a
garbage collector. The SICStus Prolog system, developed at SICS (Swedish
Institute of Computer Science), is an emulator based Prolog system
largely compatible with Quintus Prolog. SICStus Prolog has evolved
through several versions. The current version includes several
extensions, such as an object implementation, co-routining, and
constraints.
Both YAP and SICStus Prolog obey the Edinburgh Syntax and are based on
the WAM. Even so, there are major important differences:
+ Differently from SICStus Prolog, both consulted and dynamic code in YAP
are compiled, not interpreted. All code in YAP is compiled.
+ The following SICStus Prolog v3 built-ins are not (currently)
implemented in YAP (note that this is only a partial list):
stream_interrupt/3, reinitialize/0, help/0, help/1,
trimcore/0, and require/1.
+ The consult/1 predicate in YAP follows C-Prolog
semantics. That is, it adds clauses to the data base, even for
preexisting procedures. This is different from consult/1 in
SICStus Prolog or SWI-Prolog.
+ This list is incomplete.
Compatibility with the ISO Prolog standard
------------------------------------------
The Prolog standard was developed by ISO/IEC JTC1/SC22/WG17, the
international standardization working group for the programming language
Prolog. The book "Prolog: The Standard" by Deransart, Ed-Dbali and
Cervoni gives a complete description of this standard. Development in
YAP from YAP4.1.6 onwards have striven at making YAP
compatible with ISO Prolog. As such:
+ YAP now supports all of the built-ins required by the
ISO-standard, and,
+ Error-handling is as required by the standard.
YAP by default is not fully ISO standard compliant. You can set the
language flag to `iso` to obtain better
compatibility. Setting this flag changes the following:
+ By default, YAP implements the
atom_chars/2 (see Testing Terms), and
number_chars/2, (see Testing Terms),
built-ins as per the original Quintus Prolog definition, and
not as per the ISO definition.
Calling `set_prolog_flag(to_chars_mode,iso)` will switch
YAP to use the ISO definition for
atom_chars/2 and number_chars/2.
+ By default, YAP allows executable goals in directives. In ISO mode
most directives can only be called from top level (the exceptions are
set_prolog_flag/2 and op/3).
+ Error checking for meta-calls under ISO Prolog mode is stricter
than by default.
+ The strict_iso flag automatically enables the ISO Prolog
standard. This feature should disable all features not present in the
standard.
The following incompatibilities between YAP and the ISO standard are
known to still exist (please check Ulrich Neumerkel's page for more details):
<ul>
<li>Currently, YAP does not handle overflow errors in integer
operations, and handles floating-point errors only in some
architectures. Otherwise, YAP follows IEEE arithmetic.
Please inform the authors on other incompatibilities that may still
exist.

View File

@ -1,566 +0,0 @@
YAP Syntax (#YAPSyntax)
============
@defgroup YAPSyntax YAP Syntax
@ingroup mainpage
We will describe the syntax of YAP at two levels. We first will
describe the syntax for Prolog terms. In a second level we describe
the tokens from which Prolog terms are
built.
@defgroup Formal_Syntax Syntax of Terms
@ingroup YAPSyntax
Below, we describe the syntax of YAP terms from the different
classes of tokens defined above. The formalism used will be <em>BNF</em>,
extended where necessary with attributes denoting integer precedence or
operator type.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
term ----> subterm(1200) end_of_term_marker
subterm(N) ----> term(M) [M <= N]
term(N) ----> op(N, fx) subterm(N-1)
| op(N, fy) subterm(N)
| subterm(N-1) op(N, xfx) subterm(N-1)
| subterm(N-1) op(N, xfy) subterm(N)
| subterm(N) op(N, yfx) subterm(N-1)
| subterm(N-1) op(N, xf)
| subterm(N) op(N, yf)
term(0) ----> atom '(' arguments ')'
| '(' subterm(1200) ')'
| '{' subterm(1200) '}'
| list
| string
| number
| atom
| variable
arguments ----> subterm(999)
| subterm(999) ',' arguments
list ----> '[]'
| '[' list_expr ']'
list_expr ----> subterm(999)
| subterm(999) list_tail
list_tail ----> ',' list_expr
| ',..' subterm(999)
| '|' subterm(999)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Notes:
+ \a op(N,T) denotes an atom which has been previously declared with type
\a T and base precedence \a N.
+ Since ',' is itself a pre-declared operator with type \a xfy and
precedence 1000, is \a subterm starts with a '(', \a op must be
followed by a space to avoid ambiguity with the case of a functor
followed by arguments, e.g.:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ (a,b) [the same as '+'(','(a,b)) of arity one]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
versus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+(a,b) [the same as '+'(a,b) of arity two]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
In the first rule for term(0) no blank space should exist between
\a atom and '('.
+
Each term to be read by the YAP parser must end with a single
dot, followed by a blank (in the sense mentioned in the previous
paragraph). When a name consisting of a single dot could be taken for
the end of term marker, the ambiguity should be avoided by surrounding the
dot with single quotes.
# @defgroup Tokens Prolog Tokens
@ingroup YAPSyntax
Prolog tokens are grouped into the following categories:
## @defgroup Numbers Numbers
@ingroup Tokens
Numbers can be further subdivided into integer and floating-point numbers.
### @defgroup Integers Integers
@ingroup Numbers
Integer numbers
are described by the following regular expression:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<integer> := {<digit>+<single-quote>|0{xXo}}<alpha_numeric_char>+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
where {...} stands for optionality, \a + optional repetition (one or
more times), \a \\\<digit\\\> denotes one of the characters 0 ... 9, \a |
denotes or, and \a \\\<single-quote\\\> denotes the character "'". The digits
before the \a \\\<single-quote\\\> character, when present, form the number
basis, that can go from 0, 1 and up to 36. Letters from `A` to
`Z` are used when the basis is larger than 10.
Note that if no basis is specified then base 10 is assumed. Note also
that the last digit of an integer token can not be immediately followed
by one of the characters 'e', 'E', or '.'.
Following the ISO standard, YAP also accepts directives of the
form `0x` to represent numbers in hexadecimal base and of the form
`0o` to represent numbers in octal base. For usefulness,
YAP also accepts directives of the form `0X` to represent
numbers in hexadecimal base.
Example:
the following tokens all denote the same integer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 2'1010 3'101 8'12 16'a 36'a 0xa 0o12
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Numbers of the form `0'a` are used to represent character
constants. So, the following tokens denote the same integer:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0'd 100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
YAP (version 6.3.4) supports integers that can fit
the word size of the machine. This is 32 bits in most current machines,
but 64 in some others, such as the Alpha running Linux or Digital
Unix. The scanner will read larger or smaller integers erroneously.
### @defgroup Floats Floats
@ingroup Numbers
Floating-point numbers are described by:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<float> := <digit>+{<dot><digit>+}
<exponent-marker>{<sign>}<digit>+
|<digit>+<dot><digit>+
{<exponent-marker>{<sign>}<digit>+}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
where \a \\\<dot\\\> denotes the decimal-point character '.',
\a \\\<exponent-marker\\\> denotes one of 'e' or 'E', and \a \\\<sign\\\> denotes
one of '+' or '-'.
Examples:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10.0 10e3 10e-3 3.1415e+3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Floating-point numbers are represented as a double in the target
machine. This is usually a 64-bit number.
## Strings @defgroup Strings Character Strings
Strings are described by the following rules:
~~~~
string --> " string_quoted_characters "
string --> ` string_quoted_characters `
string_quoted_characters --> '"' '"' string_quoted_characters
string_quoted_characters --> '\'
escape_sequence string_quoted_characters
string_quoted_characters -->
string_character string_quoted_characters
escape_sequence --> 'a' | 'b' | 'r' | 'f' | 't' | 'n' | 'v'
escape_sequence --> '\' | '"' | ''' | '`'
escape_sequence --> at_most_3_octal_digit_seq_char '\'
escape_sequence --> 'x' at_most_2_hexa_digit_seq_char '\'
~~~~
where `string_character` is any character except the double quote (back quote)
and escape characters.
YAP supports four different textual elements:
+ Atoms, mentioned above, are textual representations of symbols, that are interned in the
data-base. They are stored either in ISO-LATIN-1 (first 256 code points), or as UTF-32.
+ Strings are atomic representations of text. The back-quote character is used to identify these objects in the program. Strings exist as stack objects, in the same way as other Prolog terms. As Prolog unification cannot be used to manipulate strings, YAP includes built-ins such as string_arg/3, sub_string/5, or string_concat to manipulate them efficiently. Strings are stored as opaque objects containing a
+ Lists of codes represent text as a list of numbers, where each number is a character code. A string of _N_ bytes requires _N_ pairs, that is _2N_ cells, leading to a total of 16 bytes per character on 64 byte machines. Thus, they are a very expensive, but very flexible representation, as one can use unification to construct and access string elements.
+ Lists of atoms represent text as a list of atoms, where each number has a single character code. A string of _N_ bytes also requires _2N_ pairs. They have similar properties to lists of codes.
The flags `double_quotes` and `backquoted_string` change the interpretation of text strings, they can take the
values `atom`, `string`, `codes`, and `chars`.
Examples:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"" "a string" "a double-quote:"""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The first string is an empty string, the last string shows the use of
double-quoting.
Escape sequences can be used to include the non-printable characters
`a` (alert), `b` (backspace), `r` (carriage return),
`f` (form feed), `t` (horizontal tabulation), `n` (new
line), and `v` (vertical tabulation). Escape sequences also be
include the meta-characters `\\`, `"`, `'`, and
```. Last, one can use escape sequences to include the characters
either as an octal or hexadecimal number.
The next examples demonstrates the use of escape sequences in YAP:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"\x0c\" "\01\" "\f" "\\"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The first three examples return a list including only character 12 (form
feed). The last example escapes the escape character.
Escape sequences were not available in C-Prolog and in original
versions of YAP up to 4.2.0. Escape sequences can be disabled by using:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:- yap_flag(character_escapes,false).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## @addgroup Atoms Atoms
@ingroup Tokens
Atoms are defined by one of the following rules:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
atom --> solo-character
atom --> lower-case-letter name-character*
atom --> symbol-character+
atom --> single-quote single-quote
atom --> ''' atom_quoted_characters '''
atom_quoted_characters --> ''' ''' atom_quoted_characters
atom_quoted_characters --> '\' atom_sequence string_quoted_characters
atom_quoted_characters --> character string_quoted_characters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
where:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<solo-character> denotes one of: ! ;
<symbol-character> denotes one of: # & * + - . / : <
= > ? @ \ ^ ~ `
<lower-case-letter> denotes one of: a...z
<name-character> denotes one of: _ a...z A...Z 0....9
<single-quote> denotes: '
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and `string_character` denotes any character except the double quote
and escape characters. Note that escape sequences in strings and atoms
follow the same rules.
Examples:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a a12x '$a' ! => '1 2'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Version `4.2.0` of YAP removed the previous limit of 256
characters on an atom. Size of an atom is now only limited by the space
available in the system.
## @addgroup Variables Variables
@ingroup Tokens
Variables are described by:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<variable-starter><variable-character>+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
where
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<variable-starter> denotes one of: _ A...Z
<variable-character> denotes one of: _ a...z A...Z
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a variable is referred only once in a term, it needs not to be named
and one can use the character `_` to represent the variable. These
variables are known as anonymous variables. Note that different
occurrences of `_` on the same term represent <em>different</em>
anonymous variables.
## @addgroup Punctuation_Tokens Punctuation Tokens
@ingroup Tokens
Punctuation tokens consist of one of the following characters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
( ) , [ ] { } |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These characters are used to group terms.
@subsection Layout Layout
Any characters with ASCII code less than or equal to 32 appearing before
a token are ignored.
All the text appearing in a line after the character \a % is taken to
be a comment and ignored (including \a %). Comments can also be
inserted by using the sequence `/\*` to start the comment and
`\*` followed by `/` to finish it. In the presence of any sequence of comments or
layout characters, the YAP parser behaves as if it had found a
single blank character. The end of a file also counts as a blank
character for this purpose.
## @addgroup WideChars Encoding Wide Character Support
@ingroup YAPSyntax
YAP now implements a SWI-Prolog compatible interface to wide
characters and the Universal Character Set (UCS). The following text
was adapted from the SWI-Prolog manual.
YAP now supports wide characters, characters with character
codes above 255 that cannot be represented in a single byte.
<em>Universal Character Set</em> (UCS) is the ISO/IEC 10646 standard
that specifies a unique 31-bits unsigned integer for any character in
any language. It is a superset of 16-bit Unicode, which in turn is
a superset of ISO 8859-1 (ISO Latin-1), a superset of US-ASCII. UCS
can handle strings holding characters from multiple languages and
character classification (uppercase, lowercase, digit, etc.) and
operations such as case-conversion are unambiguously defined.
For this reason YAP, following SWI-Prolog, has two representations for
atoms. If the text fits in ISO Latin-1, it is represented as an array
of 8-bit characters. Otherwise the text is represented as an array of
wide chars, which may take 16 or 32 bits. This representational issue
is completely transparent to the Prolog user. Users of the foreign
language interface sometimes need to be aware of these issues though. Notice that this will likely
change in the future, we probably will use an UTF-8 based representation.
Character coding comes into view when characters of strings need to be
read from or written to file or when they have to be communicated to
other software components using the foreign language interface. In this
section we only deal with I/O through streams, which includes file I/O
as well as I/O through network sockets.
== @addgroup Stream_Encoding Wide character encodings on streams
@ingroup WideChars
The UCS standard describes all possible characters (or code points, as they include
ideograms, ligatures, and other symbols). The current version, Unicode 8.0, allows
code points up to 0x10FFFF, and thus allows for 1,114,112 code points. See [Unicode Charts](http://unicode.org/charts/) for the supported languages.
Notice that most symbols are rarely used. Encodings represent the Unicode characters in a way
that is more suited for communication. The most popular encoding, especially in the context of the web and in the Unix/Linux/BSD/Mac communities, is
UTF-8. UTF-8 is compact and as it uses bytes, does not have different endianesses.
Bytes 0...127 represent simply the corresponding US-ASCII
character, while bytes 128...255 are used for multi-byte
encoding of characters placed higher in the UCS space.
Especially on
MS-Windows and Java the 16-bit Unicode standard, represented by pairs of bytes is
also popular. Originally, Microsoft supported a UCS-2 with 16 bits that
could represent only up to 64k characters. This was later extended to support the full
Unicode, we will call the latter version UTF-16. The extension uses a hole in the first 64K code points. Characters above 0xFFFF are divided into two 2-byte words, each one in that hole. There are two versions of UTF-16: big and low
endian. By default, UTF-16 is big endian, in practice most often it is used on Intel
hardware that is naturally little endian.
UTF-32, often called UCS-4, provides a natural interface where a code point is coded as
four octets. Unfortunately, it is also more expensive, so it is not as widely used.
Last, other encodings are also commonly used. One such legacy encoding is ISO-LATIN-1, that
supported latin based languages in western europe. YAP currently uses either ISO-LATIN-1 or UTF-32
internally.
Prolog supports the default encoding used by the Operating System,
Namely, YAP checks the variables LANG, LC_ALL and LC_TYPE. Say, if at boot YAP detects that the
environment variable `LANG` ends in "UTF-8", this encoding is
assumed. Otherwise, the default is `text` and the translation is
left to the wide-character functions of the C-library (note that the
Prolog native UTF-8 mode is considerably faster than the generic
`mbrtowc()` one).
Prolog allows the encoding to be specified explicitly in
load_files/2 for loading Prolog source with an alternative
encoding, `open/4` when opening files or using `set_stream/2` on
any open stream (not yet implemented). For Prolog source files we also
provide the `encoding/1` directive that can be used to switch
between encodings that are compatible to US-ASCII (`ascii`,
`iso_latin_1`, `utf8` and many locales).
For
additional information and Unicode resources, please visit the
[unicode](http://www.unicode.org/) organization web page.
YAP currently defines and supports the following encodings:
+ `octet`
Default encoding for <em>binary</em> streams. This causes
the stream to be read and written fully untranslated.
+ `ascii` or `US_ASCII`
7-bit encoding in 8-bit bytes. Equivalent to `iso_latin_1`,
but generates errors and warnings on encountering values above
127.
+ `iso_latin_1` or `ISO-8859-1`
8-bit encoding supporting many western languages. This causes
the stream to be read and written fully untranslated.
+ `text`
C-library default locale encoding for text files. Files are read and
written using the C-library functions `mbrtowc()` and
`wcrtomb()`. This may be the same as one of the other locales,
notably it may be the same as `iso_latin_1` for western
languages and `utf8` in a UTF-8 context.
+ `utf8`, `iso_utf8`, or `UTF-8``
Multi-byte encoding of the full Unicode 8, compatible to `ascii` .
See above.
+ `unicode_be` or `UCS-2BE`
Unicode Big Endian. Reads input in pairs of bytes, most
significant byte first. Can only represent 16-bit characters.
+ `unicode_le` or `UCS-2LE`
Unicode Little Endian. Reads input in pairs of bytes, least
significant byte first. Can only represent 16-bit characters.
+ `utf16_le` or `UTF-16LE` (experimental)
UTF-16 Little Endian. Reads input in pairs of bytes, least
significant byte first. Can represent the full Unicode.
+ `utf16_le` or `UTF-16BE` (experimental)
Unicode Big Endian. Reads input in pairs of bytes, least
significant byte first. Can represent the full Unicode.
+ `utf32_le` or `UTF-32LE` (experimental)
UTF-16 Little Endian. Reads input in pairs of bytes, least
significant byte first. Can represent the full Unicode.
+ `utf32_le` or `UTF-32BE` (experimental)
Unicode Big Endian. Reads input in pairs of bytes, least
significant byte first. Can only represent 16-bit characters.
Note that not all encodings can represent all characters. This implies
that writing text to a stream may cause errors because the stream
cannot represent these characters. The behaviour of a stream on these
errors can be controlled using `open/4` or `set_stream/2` (not
implemented). Initially the terminal stream write the characters using
Prolog escape sequences while other streams generate an I/O exception.
=== @addgroup BOM BOM: Byte Order Mark
@ingroup WideChars
From Stream Encoding, you may have got the impression that
text-files are complicated. This section deals with a related topic,
making live often easier for the user, but providing another worry to
the programmer. *BOM* or <em>Byte Order Marker</em> is a technique
for identifying Unicode text-files as well as the encoding they
use. Please read the [W3C](https://www.w3.org/International/questions/qa-byte-order-mark.en.php]
page for a detailed explanation of byte-order marks.
BOMa are necessary on multi-byte encodings, such as UTF-16 and UTF-32. There is a BOM for UTF-8, but it is rarely used.
The BOM is handled by the open/4 predicate. By default, text-files are
probed for the BOM when opened for reading. If a BOM is found, the
encoding is set accordingly and the property `bom(true)` is
available through stream_property/2. When opening a file for
writing, writing a BOM can be requested using the option
`bom(true)` with `open/4`. YAP will parse an UTF-8 file for a BOM only if explicitly required to do so. Do notice that YAP will write a BOM by default on UTF-16 (including UCS-2) and
UTF-32; otherwise the default is not to write a BOM. BOMs are not avaliable for ASCII and
ISO-LATIN-1.
= @addgroup Operators Summary of YAP Predefined Operators
@ingroup YapSyntax
The Prolog syntax caters for operators of three main kinds:
+ prefix;
+ infix;
+ postfix.
Each operator has precedence in the range 1 to 1200, and this
precedence is used to disambiguate expressions where the structure of the
term denoted is not made explicit using brackets. The operator of higher
precedence is the main functor.
If there are two operators with the highest precedence, the ambiguity
is solved analyzing the types of the operators. The possible infix types are:
_xfx_, _xfy_, and _yfx_.
With an operator of type _xfx_ both sub-expressions must have lower
precedence than the operator itself, unless they are bracketed (which
assigns to them zero precedence). With an operator type _xfy_ only the
left-hand sub-expression must have lower precedence. The opposite happens
for _yfx_ type.
A prefix operator can be of type _fx_ or _fy_.
A postfix operator can be of type _xf_ or _yf_.
The meaning of the notation is analogous to the above.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a + b * c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
means
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a + (b * c)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
as + and \* have the following types and precedences:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:-op(500,yfx,'+').
:-op(400,yfx,'*').
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now defining
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:-op(700,xfy,'++').
:-op(700,xfx,'=:=').
a ++ b =:= c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
means
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a ++ (b =:= c)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following is the list of the declarations of the predefined operators:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:-op(1200,fx,['?-', ':-']).
:-op(1200,xfx,[':-','-->']).
:-op(1150,fx,[block,dynamic,mode,public,multifile,meta_predicate,
sequential,table,initialization]).
:-op(1100,xfy,[';','|']).
:-op(1050,xfy,->).
:-op(1000,xfy,',').
:-op(999,xfy,'.').
:-op(900,fy,['\+', not]).
:-op(900,fx,[nospy, spy]).
:-op(700,xfx,[@>=,@=<,@<,@>,<,=,>,=:=,=\=,\==,>=,=<,==,\=,=..,is]).
:-op(500,yfx,['\/','/\','+','-']).
:-op(500,fx,['+','-']).
:-op(400,yfx,['<<','>>','//','*','/']).
:-op(300,xfx,mod).
:-op(200,xfy,['^','**']).
:-op(50,xfx,same).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@}

View File

@ -1,53 +0,0 @@
YAP 6-3.4 Manual {#mainpage}
====================
This file documents the YAP Prolog System version 6.3.4, a high-performance Prolog compiler developed at LIACC, Universidade do Porto. YAP is based on David H. D. Warren's WAM (Warren Abstract Machine), with several optimizations for better performance. YAP follows the Edinburgh tradition, and is largely compatible with DEC-10 Prolog, Quintus Prolog, and originally with C-Prolog.
The manual is organised as follows:
+ @subpage download
+ @subpage install
+ @subpage run
+ @subpage builtins
+ @subpage extensions
+ @subpage library
+ @subpage swi
+ @subpage packages
+ @subpage YAPProgramming
+ @subpage Fli
\author Vitor Santos Costa,
\author Luís Damas,
\author Rogério Reis
\author Rúben Azevedo
© 1989-201 L. Damas, V. Santos Costa and Universidade
do Porto.
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
This manual was written by Vítor Santos Costa,
Luís Damas, Rogério Reis, and Rúben Azevedo. The
manual is largely based on the DECsystem-10 Prolog User's Manual by
D.L. Bowen, L. Byrd, F. C. N. Pereira, L. M. Pereira, and
D. H. D. Warren. We have used comments from the Edinburgh Prolog
library written by R. O'Keefe. Documentation from many built-ins is
originally from the SWI-Prolog manual, with the gracious authorization
from
Jan Wielemaker. We would also like to gratefully
acknowledge the contributions from Ashwin Srinivasian.

View File

@ -276,8 +276,9 @@ typedef struct yap_boot_params {
/* if NON-0, say how long to keep nodes (default = 3) */
unsigned long int DelayedReleaseLoad;
/* end of YAPOR fields */
/* whether Prolog should handle interrupts */
int PrologShouldHandleInterrupts;
/* whether Prolog should handle interrupts. Note that
interrupts will always be disabled in embedded mode. */
bool PrologCannotHandleInterrupts;
/* flag for JIT mode */
int ExecutionMode;
/* number of arguments that Prolog will see */

File diff suppressed because it is too large Load Diff

View File

@ -74,11 +74,8 @@ MY_add_subdirectory(tries)
MY_add_subdirectory(ytest)
if (ANDROID)
file(INSTALL ${LIBRARY_PL} DESTINATION ${libpl})
if (0)
file(COPY ${LIBRARY_PL} DESTINATION ${libpl})
else()
install(FILES ${LIBRARY_PL}
DESTINATION ${libpl}
)
endif()
install(FILES ${LIBRARY_PL} DESTINATION ${libpl})
endif()

View File

@ -131,7 +131,7 @@ open_log(F) :-
* @pred log_goal( +Tag , :Goal )
*
* @param [in] evaluate goal _Goal_ with output before,
* during and after the goal has been evaluted.
* during and after the goal has been evaluated.
*
*/
A <-* Goal :-
@ -147,9 +147,9 @@ open_log(F) :-
).
/**
* @pred <--( +Tag , :Goal )
* @pred `<--`( +Tag , :Goal )
*
* @param [in] output goal _Goal_ before and after being evaluted.but onlu
* @param [in] output goal _Goal_ before and after being evaluated, but only
* taking the first solution. The _Tag_ must be an atom or a string.
*
*/

View File

@ -317,11 +317,12 @@ static bool set_fpu_exceptions(Term flag) {
static void ReceiveSignal(int s, void *x, void *y) {
CACHE_REGS
LOCAL_PrologMode |= InterruptMode;
printf("11ooo\n");
my_signal(s, ReceiveSignal);
switch (s) {
case SIGINT:
// always direct SIGINT to console
Yap_external_signal(0, YAP_INT_SIGNAL);
Yap_HandleSIGINT();
break;
case SIGALRM:
Yap_external_signal(worker_id, YAP_ALARM_SIGNAL);
@ -816,9 +817,6 @@ yap_error_number Yap_MathException__(USES_REGS1) {
/* SIGINT can cause problems, if caught before full initialization */
void Yap_InitOSSignals(int wid) {
if (Yap_embedded) {
return;
}
if (GLOBAL_PrologShouldHandleInterrupts) {
#if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT)
my_signal(SIGQUIT, ReceiveSignal);

View File

@ -107,7 +107,8 @@ extern char *Yap_MemStreamBuf(int sno);
extern X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp,
int prio, Term *bindings_p);
extern Term Yap_StringToNumberTerm(const char *s, encoding_t *encp, bool error_on);
extern Term Yap_StringToNumberTerm(const char *s, encoding_t *encp,
bool error_on);
extern int Yap_FormatFloat(Float f, char **s, size_t sz);
extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
encoding_t *encp, memBufSource src);
@ -140,7 +141,7 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
unsigned char cs[10];
if (c < 0)
return TermEof;
size_t n = put_utf8( cs, c );
size_t n = put_utf8(cs, c);
cs[n] = '\0';
return MkAtomTerm(Yap_ULookupAtom(cs));
}
@ -148,4 +149,5 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
/// UT when yap started
extern uint64_t Yap_StartOfWTimes;
extern bool Yap_HandleSIGINT(void);
#endif

View File

@ -1,4 +1,4 @@
Boolean Decision Making in YAP (#BDDs)
Boolean Decision Making in YAP {#BDDs}
==============================
This is an experimental interface to BDD libraries. It is not as

View File

@ -1,4 +1,4 @@
USING THE GECODE MODULE (#Gecode)
USING THE GECODE MODULE {#gecode}
=======================
There are two ways to use the gecode interface from YAP. The original approach,

View File

@ -12,7 +12,7 @@ set(MYDDAS_DRIVERS
"myddas_driver.ypp"
)
message("libpl ${libpl}")
if (ANDROID)
if (0)
set (PREFIX ${libpl} )
else()
set (PREFIX ${CMAKE_CURRENT_BINARY_DIR} )
@ -40,7 +40,7 @@ function(cpp_compile output filename)
endfunction()
function(cpp_driver output dbms filename)
if (ANDROID)
if (0)
set(outfile ${libpl}/myddas_${dbms}.yap)
else()
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/myddas_${dbms}.yap)
@ -69,10 +69,8 @@ foreach (driver ${MYDDAS_DBMS})
cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp)
endforeach ()
add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP}
add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
)
MY_install(FILES ${MYDDAS_YAP}
install(FILES ${MYDDAS_YAP}
DESTINATION ${libpl}
)

View File

@ -2,8 +2,9 @@ message( " * Sqlite3 Data-Base (http://www.sqlite3ql.org), distributed with MY
set( YAPSQLITE3_SOURCES
myddas_sqlite3.c
sqlite3.c
sqlite3.h
src/sqlite3.c
src/sqlite3.h
src/sqlite3ext.h
)
#sqlite3 is now in the system
@ -25,22 +26,22 @@ add_definitions(-DSQLITE_ENABLE_FTS5=1 )
if (ANDROID)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. Android/jni/sqlite Android/jni/sqlite/nativehelper )
include_directories( .. src/Android/jni/sqlite src/Android/jni/sqlite/nativehelper )
set(YAPSQLITE3_SOURCES
${YAPSQLITE3_SOURCES}
Android/jni/sqlite/JNIHelp.cpp
Android/jni/sqlite/JniConstants.cpp
Android/jni/sqlite/android_database_SQLiteCommon.cpp
Android/jni/sqlite/android_database_SQLiteCommon.h
Android/jni/sqlite/android_database_SQLiteConnection.cpp
Android/jni/sqlite/android_database_SQLiteDebug.cpp
Android/jni/sqlite/android_database_SQLiteGlobal.cpp
Android/jni/sqlite/nativehelper/jni.h
Android/jni/sqlite/nativehelper/jniConstants.h
Android/jni/sqlite/nativehelper/JNIHelp.h
Android/jni/sqlite/nativehelper/ScopedLocalRef.h
${YAPSQLITE3_SOURCES}
src/Android/jni/sqlite/JNIHelp.cpp
src/Android/jni/sqlite/JniConstants.cpp
src/Android/jni/sqlite/android_database_SQLiteCommon.cpp
src/Android/jni/sqlite/android_database_SQLiteCommon.h
src/Android/jni/sqlite/android_database_SQLiteConnection.cpp
src/Android/jni/sqlite/android_database_SQLiteDebug.cpp
src/Android/jni/sqlite/android_database_SQLiteGlobal.cpp
src/Android/jni/sqlite/nativehelper/jni.h
src/Android/jni/sqlite/nativehelper/jniConstants.h
src/Android/jni/sqlite/nativehelper/JNIHelp.h
src/Android/jni/sqlite/nativehelper/ScopedLocalRef.h
)
endif (ANDROID)

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Some files were not shown because too many files have changed in this diff Show More