This commit is contained in:
Vitor Santos Costa 2018-05-20 00:47:27 +01:00
parent d7c4ac95e0
commit bdf7088665
35 changed files with 735 additions and 401 deletions

View File

@ -639,6 +639,69 @@ void Yap_ThrowExistingError(void) {
Yap_exit(5); Yap_exit(5);
} }
bool Yap_MkErrorRecord( yap_error_descriptor_t *r,
const char *file, const char *function,
int lineno, yap_error_number type, Term where,
const char *s) {
if (!Yap_pc_add_location(r, CP, B, ENV))
Yap_env_add_location(r, CP, B, ENV, 0);
if (where == 0L || where == TermNil||type==INSTANTIATION_ERROR) {
r->culprit = NULL;
} else {
r->culprit = Yap_TermToBuffer(
where, ENC_ISO_UTF8, Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f);
}
r->errorNo = type;
r->errorAsText = Yap_errorName(type);
r->errorClass = Yap_errorClass(type);
r->classAsText =
Yap_errorClassName(r->errorClass);
r->errorLine = lineno;
r->errorFunction = function;
r->errorFile = file;
Yap_prolog_add_culprit(r PASS_REGS1);
LOCAL_PrologMode |= InErrorMode;
Yap_ClearExs();
// first, obtain current location
// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno,
// function);
// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf));
#if DEBUG_STRICT
if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode))
fprintf(stderr, "***** Processing Error %d (%lx,%x) %s***\n", type,
(unsigned long int)LOCAL_Signals, LOCAL_PrologMode, fmt);
else
fprintf(stderr, "***** Processing Error %d (%x) %s***\n", type,
LOCAL_PrologMode, fmt);
#endif
if (r->errorNo == SYNTAX_ERROR) {
r->errorClass = SYNTAX_ERROR_CLASS;
} else if (r->errorNo == SYNTAX_ERROR_NUMBER) {
r->errorClass = SYNTAX_ERROR_CLASS;
r->errorNo = SYNTAX_ERROR;
}
if (type == INTERRUPT_EVENT) {
fprintf(stderr, "%% YAP exiting: cannot handle signal %d\n",
(int)IntOfTerm(where));
Yap_exit(1);
}
// fprintf(stderr, "warning: ");
if (s[0]) {
r->errorMsgLen = strlen(s) + 1;
r->errorMsg = malloc(r->errorMsgLen);
strcpy(r->errorMsg, s);
} else if (LOCAL_ErrorMessage && LOCAL_ErrorMessage[0]) {
r->errorMsgLen = strlen(LOCAL_ErrorMessage) + 1;
r->errorMsg = malloc(r->errorMsgLen);
strcpy(r->errorMsg, LOCAL_ErrorMessage);
} else {
r->errorMsgLen = 0;
r->errorMsg = 0;
}
return true;
}
/** /**
* @brief Yap_Error * @brief Yap_Error
* This function handles errors in the C code. Check errors.yap for the * This function handles errors in the C code. Check errors.yap for the
@ -666,7 +729,8 @@ yamop *Yap_Error__(bool throw, const char *file, const char *function,
va_list ap; va_list ap;
char *fmt; char *fmt;
char s[MAXPATHLEN]; char s[MAXPATHLEN];
switch (type) {
switch (type) {
case SYSTEM_ERROR_INTERNAL: { case SYSTEM_ERROR_INTERNAL: {
fprintf(stderr, "%% Internal YAP Error: %s exiting....\n", tmpbuf); fprintf(stderr, "%% Internal YAP Error: %s exiting....\n", tmpbuf);
// serious = true; // serious = true;
@ -736,73 +800,8 @@ yamop *Yap_Error__(bool throw, const char *file, const char *function,
P = FAILCODE; P = FAILCODE;
LOCAL_PrologMode &= ~InErrorMode; LOCAL_PrologMode &= ~InErrorMode;
return P; return P;
default: default:
if (!Yap_pc_add_location(LOCAL_ActiveError, CP, B, ENV)) va_start(ap, where);
Yap_env_add_location(LOCAL_ActiveError, CP, B, ENV, 0);
break;
}
yap_error_number err = LOCAL_ActiveError->errorNo;
/* disallow recursive error handling */
if (LOCAL_PrologMode & InErrorMode && err) {
fprintf(stderr, "%% ERROR %s %s WITHIN ERROR %s %s\n",
Yap_errorClassName(Yap_errorClass(type)), Yap_errorName(type),
Yap_errorClassName(Yap_errorClass(err)), Yap_errorName(err));
return P;
}
if (LOCAL_PrologMode & BootMode || type == SYSTEM_ERROR_FATAL) {
/* crash in flames! */
fprintf(stderr,
"%s:%d:0 YAP Fatal Error %d in function %s:\n %s exiting....\n",
file, lineno, type, function, s);
error_exit_yap(1);
}
if (LOCAL_DoingUndefp && type == EVALUATION_ERROR_UNDEFINED) {
P = FAILCODE;
CalculateStackGap(PASS_REGS1);
return P;
}
if (where == 0L || where == TermNil||type==INSTANTIATION_ERROR) {
LOCAL_ActiveError->culprit = NULL;
} else {
LOCAL_ActiveError->culprit = Yap_TermToBuffer(
where, ENC_ISO_UTF8, Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f);
}
LOCAL_ActiveError->errorNo = type;
LOCAL_ActiveError->errorAsText = Yap_errorName(type);
LOCAL_ActiveError->errorClass = Yap_errorClass(type);
LOCAL_ActiveError->classAsText =
Yap_errorClassName(LOCAL_ActiveError->errorClass);
LOCAL_ActiveError->errorLine = lineno;
LOCAL_ActiveError->errorFunction = function;
LOCAL_ActiveError->errorFile = file;
Yap_prolog_add_culprit(LOCAL_ActiveError PASS_REGS1);
LOCAL_PrologMode |= InErrorMode;
Yap_ClearExs();
// first, obtain current location
// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno,
// function);
// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf));
#if DEBUG_STRICT
if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode))
fprintf(stderr, "***** Processing Error %d (%lx,%x) %s***\n", type,
(unsigned long int)LOCAL_Signals, LOCAL_PrologMode, fmt);
else
fprintf(stderr, "***** Processing Error %d (%x) %s***\n", type,
LOCAL_PrologMode, fmt);
#endif
if (LOCAL_ActiveError->errorNo == SYNTAX_ERROR) {
LOCAL_ActiveError->errorClass = SYNTAX_ERROR_CLASS;
} else if (LOCAL_ActiveError->errorNo == SYNTAX_ERROR_NUMBER) {
LOCAL_ActiveError->errorClass = SYNTAX_ERROR_CLASS;
LOCAL_ActiveError->errorNo = SYNTAX_ERROR;
}
if (type == INTERRUPT_EVENT) {
fprintf(stderr, "%% YAP exiting: cannot handle signal %d\n",
(int)IntOfTerm(where));
Yap_exit(1);
}
va_start(ap, where);
fmt = va_arg(ap, char *); fmt = va_arg(ap, char *);
if (fmt != NULL) { if (fmt != NULL) {
#if HAVE_VSNPRINTF #if HAVE_VSNPRINTF
@ -810,22 +809,12 @@ yamop *Yap_Error__(bool throw, const char *file, const char *function,
#else #else
(void)vsprintf(s, fmt, ap); (void)vsprintf(s, fmt, ap);
#endif #endif
// fprintf(stderr, "warning: "); va_end(ap);
if (s[0]) { break;
LOCAL_ActiveError->errorMsgLen = strlen(s) + 1;
LOCAL_ActiveError->errorMsg = malloc(LOCAL_ActiveError->errorMsgLen);
strcpy(LOCAL_ActiveError->errorMsg, s);
} else if (LOCAL_ErrorMessage && LOCAL_ErrorMessage[0]) {
LOCAL_ActiveError->errorMsgLen = strlen(LOCAL_ErrorMessage) + 1;
LOCAL_ActiveError->errorMsg = malloc(LOCAL_ActiveError->errorMsgLen);
strcpy(LOCAL_ActiveError->errorMsg, LOCAL_ErrorMessage);
} else {
LOCAL_ActiveError->errorMsgLen = 0;
LOCAL_ActiveError->errorMsg = 0;
}
} }
va_end(ap); }
if (where == 0 || where == TermNil) { Yap_MkErrorRecord(LOCAL_ActiveError, file, function, lineno, type, where, s);
if (where == 0 || where == TermNil) {
LOCAL_ActiveError->culprit = 0; LOCAL_ActiveError->culprit = 0;
} }
if (P == (yamop *)(FAILCODE)) { if (P == (yamop *)(FAILCODE)) {

View File

@ -54,7 +54,6 @@ static choiceptr cp_from_integer(Term cpt USES_REGS) {
/** /**
* Represents a choice-point as an offset to the top of local stack. This should * Represents a choice-point as an offset to the top of local stack. This should
* *be stable acroos gc or stack shifts. * *be stable acroos gc or stack shifts.
* @procedure Yap_cp_as_integer
* @param cp pointer to choice-point * @param cp pointer to choice-point
* @return Term with offset * @return Term with offset
*/ */

View File

@ -36,7 +36,7 @@ YAPPredicate::YAPPredicate(Term &t, Term &tmod, CELL *&ts, const char *pname) {
ap = nullptr; ap = nullptr;
restart: restart:
if (IsVarTerm(t)) { if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR, t0, pname); throw YAPError( SOURCE(), INSTANTIATION_ERROR, t0, pname);
} else if (IsAtomTerm(t)) { } else if (IsAtomTerm(t)) {
ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod)); ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod));
ts = nullptr; ts = nullptr;
@ -49,15 +49,15 @@ restart:
} else if (IsApplTerm(t)) { } else if (IsApplTerm(t)) {
Functor fun = FunctorOfTerm(t); Functor fun = FunctorOfTerm(t);
if (IsExtensionFunctor(fun)) { if (IsExtensionFunctor(fun)) {
Yap_Error(TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(t, tmod), pname); throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(t, tmod), pname);
} }
if (fun == FunctorModule) { if (fun == FunctorModule) {
tmod = ArgOfTerm(1, t); tmod = ArgOfTerm(1, t);
if (IsVarTerm(tmod)) { if (IsVarTerm(tmod)) {
Yap_Error(INSTANTIATION_ERROR, t0, pname); throw YAPError( SOURCE(), INSTANTIATION_ERROR, t0, pname);
} }
if (!IsAtomTerm(tmod)) { if (!IsAtomTerm(tmod)) {
Yap_Error(TYPE_ERROR_ATOM, t0, pname); throw YAPError( SOURCE(), TYPE_ERROR_ATOM, t0, pname);
} }
t = ArgOfTerm(2, t); t = ArgOfTerm(2, t);
goto restart; goto restart;
@ -65,10 +65,33 @@ restart:
ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod)); ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod));
ts = RepAppl(t) + 1; ts = RepAppl(t) + 1;
} else { } else {
Yap_Error(TYPE_ERROR_CALLABLE, t0, pname); throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, t0, pname);
} }
} }
Term YAPTerm::getArg(arity_t i) {
BACKUP_MACHINE_REGS();
Term tf = 0;
Term t0 = gt();
if (IsApplTerm(t0)) {
if (i > ArityOfFunctor(FunctorOfTerm(t0)))
throw YAPError( SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
tf = (ArgOfTerm(i, t0));
} else if (IsPairTerm(t0)) {
if (i == 1)
tf = (HeadOfTerm(t0));
else if (i == 2)
tf = (TailOfTerm(t0));
else
throw YAPError( SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
} else {
throw YAPError( SOURCE(), TYPE_ERROR_COMPOUND, t0, "t0.getArg()");
}
RECOVER_MACHINE_REGS();
return tf;
}
YAPAtomTerm::YAPAtomTerm(char s[]) { // build string YAPAtomTerm::YAPAtomTerm(char s[]) { // build string
BACKUP_H(); BACKUP_H();
@ -242,7 +265,7 @@ Term &YAPTerm::operator[](arity_t i) {
tf = RepPair(t0) + 1; tf = RepPair(t0) + 1;
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
} else { } else {
Yap_Error(TYPE_ERROR_COMPOUND, t0, ""); throw YAPError( SOURCE(), TYPE_ERROR_COMPOUND, t0, "");
} }
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return *tf; return *tf;
@ -279,6 +302,24 @@ YAPPairTerm::YAPPairTerm() {
RECOVER_H(); RECOVER_H();
} }
std::vector<Term> YAPPairTerm::listToArray() {
Term *tailp;
Term t1 = gt();
Int l = Yap_SkipList(&t1, &tailp);
if (l < 0) {
throw YAPError( SOURCE(), TYPE_ERROR_LIST, (t), nullptr);
}
std::vector<Term> o = std::vector<Term>(l);
int i = 0;
Term t = gt();
while (t != TermNil) {
o[i++] = HeadOfTerm(t);
t = TailOfTerm(t);
}
return o;
}
YAP_tag_t YAPTerm::tag() { YAP_tag_t YAPTerm::tag() {
Term tt = gt(); Term tt = gt();
if (IsVarTerm(tt)) { if (IsVarTerm(tt)) {
@ -333,6 +374,16 @@ Term YAPTerm::deepCopy() {
return (tn); return (tn);
} }
Term YAPListTerm::cdr() {
Term to = gt();
if (IsPairTerm(to))
return (TailOfTerm(to));
else if (to == TermNil)
return TermNil;
/* error */
throw YAPError( SOURCE(), TYPE_ERROR_LIST, to, "");
}
Term YAPListTerm::dup() { Term YAPListTerm::dup() {
yhandle_t tn; yhandle_t tn;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
@ -380,7 +431,7 @@ Term YAPListTerm::car() {
if (IsPairTerm(to)) if (IsPairTerm(to))
return (HeadOfTerm(to)); return (HeadOfTerm(to));
else { else {
Yap_Error(TYPE_ERROR_LIST, to, ""); throw YAPError( SOURCE(), TYPE_ERROR_LIST, to, "");
return TermUnique; return TermUnique;
} }
} }
@ -436,9 +487,9 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) {
if (LOCAL_CommittedError != nullptr) { if (LOCAL_CommittedError != nullptr) {
std::cerr << "Exception received by " << __func__ << "( " std::cerr << "Exception received by " << __func__ << "( "
<< YAPError(LOCAL_CommittedError).text() << ").\n Forwarded...\n\n"; << YAPError( LOCAL_CommittedError).text() << ").\n Forwarded...\n\n";
// Yap_PopTermFromDB(LOCAL_ActiveError->errorTerm); // Yap_PopTermFromDB(info->errorTerm);
// throw YAPError(); // throw throw YAPError( SOURCE(), );
} }
Yap_CloseHandles(q.CurSlot); Yap_CloseHandles(q.CurSlot);
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
@ -454,43 +505,50 @@ bool YAPEngine::mgoal(Term t, Term tmod) {
CACHE_REGS CACHE_REGS
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
Term *ts = nullptr; Term *ts = nullptr;
if (IsStringTerm(tmod)) try {
tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod))); if (IsStringTerm(tmod))
PredEntry *ap = (new YAPPredicate(t, tmod, ts, "C++"))->ap; tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod)));
if (ap == nullptr || ap->OpcodeOfPred == UNDEF_OPCODE) { PredEntry *ap = (new YAPPredicate(t, tmod, ts, "C++"))->ap;
ap = rewriteUndefEngineQuery(ap, t, tmod); if (ap == nullptr || ap->OpcodeOfPred == UNDEF_OPCODE) {
} ap = rewriteUndefEngineQuery(ap, t, tmod);
if (IsApplTerm(t)) }
ts = RepAppl(t) + 1; if (IsApplTerm(t))
else if (IsPairTerm(t)) ts = RepAppl(t) + 1;
ts = RepPair(t); else if (IsPairTerm(t))
/* legal ap */ ts = RepPair(t);
arity_t arity = ap->ArityOfPE; /* legal ap */
arity_t arity = ap->ArityOfPE;
for (arity_t i = 0; i < arity; i++) { for (arity_t i = 0; i < arity; i++) {
XREGS[i + 1] = ts[i]; XREGS[i + 1] = ts[i];
} }
ts = nullptr; ts = nullptr;
bool result; bool result;
q.CurSlot = Yap_StartSlots(); q.CurSlot = Yap_StartSlots();
q.p = P; q.p = P;
q.cp = CP; q.cp = CP;
// allow Prolog style exception handling // allow Prolog style exception handling
// don't forget, on success these guys may create slots // don't forget, on success these guys may create slots
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec "); __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
result = (bool)YAP_EnterGoal(ap, nullptr, &q);
if (LOCAL_CommittedError != nullptr) {
std::cerr << "Exception received by " << __func__ << "( "
<< YAPError(LOCAL_CommittedError).text() << ").\n Forwarded...\n\n";
}
result = (bool)YAP_EnterGoal(ap, nullptr, &q);
if (LOCAL_CommittedError != nullptr &&
LOCAL_CommittedError->errorNo != YAP_NO_ERROR) {
throw YAPError( LOCAL_CommittedError);
}
{ {
YAP_LeaveGoal(result, &q); YAP_LeaveGoal(result, &q);
// PyEval_RestoreThread(_save); // PyEval_RestoreThread(_save);
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return result; return result;
} }
} catch ( ... ) {
if (LOCAL_CommittedError != nullptr &&
LOCAL_CommittedError->errorNo != YAP_NO_ERROR) {
std::cerr << "Exception received by " << __func__ << "( "
<< YAPError( LOCAL_CommittedError).text() << ").\n Forwarded...\n\n";
}
}
} }
void YAPEngine::release() { void YAPEngine::release() {
@ -527,7 +585,7 @@ Term YAPEngine::fun(Term t) {
name = AtomDot; name = AtomDot;
f = FunctorDot; f = FunctorDot;
} else { } else {
Yap_ThrowError(TYPE_ERROR_CALLABLE, t, 0); throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, t, 0);
return 0L; return 0L;
} }
XREGS[arity + 1] = MkVarTerm(); XREGS[arity + 1] = MkVarTerm();
@ -548,9 +606,9 @@ Term YAPEngine::fun(Term t) {
bool result = (bool)YAP_EnterGoal(ap, nullptr, &q); bool result = (bool)YAP_EnterGoal(ap, nullptr, &q);
if (LOCAL_CommittedError != nullptr) { if (LOCAL_CommittedError != nullptr) {
std::cerr << "Exception received by " << __func__ << "( " std::cerr << "Exception received by " << __func__ << "( "
<< YAPError(LOCAL_CommittedError).text() << ").\n Forwarded...\n\n"; << YAPError( LOCAL_CommittedError).text() << ").\n Forwarded...\n\n";
// Yap_PopTermFromDB(LOCAL_ActiveError->errorTerm); // Yap_PopTermFromDB(info->errorTerm);
// throw YAPError(); // throw throw YAPError( SOURCE(), );
} }
{ {
YAP_LeaveGoal(result, &q); YAP_LeaveGoal(result, &q);
@ -668,15 +726,15 @@ bool YAPQuery::next() {
Yap_CloseHandles(q_handles); Yap_CloseHandles(q_handles);
q_open = false; q_open = false;
if (LOCAL_CommittedError != nullptr) { if (LOCAL_CommittedError != nullptr) {
// Yap_PopTermFromDB(LOCAL_ActiveError->errorTerm); // Yap_PopTermFromDB(info->errorTerm);
// throw YAPError(); // throw throw YAPError( );
Term es[2]; Term es[2];
es[0] = TermError; es[0] = TermError;
es[1] = MkErrorTerm(LOCAL_CommittedError); es[1] = MkErrorTerm(LOCAL_CommittedError);
Functor f = Yap_MkFunctor(Yap_LookupAtom("print_message"), 2); Functor f = Yap_MkFunctor(Yap_LookupAtom("print_message"), 2);
YAP_RunGoalOnce(Yap_MkApplTerm(f, 2, es)); YAP_RunGoalOnce(Yap_MkApplTerm(f, 2, es));
// Yap_PopTermFromDB(LOCAL_ActiveError->errorTerm); // Yap_PopTermFromDB(info->errorTerm);
// throw YAPError(); // throw throw YAPError( SOURCE(), );
} }
} else { } else {
q_handles = Yap_StartSlots(); q_handles = Yap_StartSlots();
@ -806,7 +864,7 @@ void YAPEngine::doInit(YAP_file_type_t BootMode, YAPEngineArgs *engineArgs) {
YAP_Init(engineArgs); YAP_Init(engineArgs);
/* Begin preprocessor code */ /* Begin preprocessor code */
/* live */ /* live */
// yerror = YAPError(); // yerror = throw YAPError( SOURCE(), );
#if YAP_PYTHON #if YAP_PYTHON
do_init_python(); do_init_python();
#endif #endif
@ -853,13 +911,15 @@ PredEntry *YAPPredicate::getPred(YAPTerm &tt, CELL *&outp) {
CACHE_REGS CACHE_REGS
Term m = Yap_CurrentModule(), t = tt.term(); Term m = Yap_CurrentModule(), t = tt.term();
t = Yap_StripModule(t, &m); t = Yap_StripModule(t, &m);
std::cerr << "Exception received by " << __func__ << "( "
<< tt.text() << ").\n Forwarded...\n\n";
if (IsVarTerm(t) || IsNumTerm(t)) { if (IsVarTerm(t) || IsNumTerm(t)) {
if (IsVarTerm(t)) if (IsVarTerm(t))
Yap_ThrowError(INSTANTIATION_ERROR, tt.term(), 0); throw YAPError( SOURCE(), INSTANTIATION_ERROR, tt.term(), 0);
else if (IsNumTerm(t)) else if (IsNumTerm(t))
Yap_ThrowError(TYPE_ERROR_CALLABLE, tt.term(), 0); throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, tt.term(), 0);
std::cerr << "Exception received by " << __func__ << "( "
<< YAPTerm(tt).text() << ").\n Forwarded...\n\n";
} }
tt.put(t); tt.put(t);
if (IsAtomTerm(t)) { if (IsAtomTerm(t)) {
@ -878,7 +938,7 @@ PredEntry *YAPPredicate::getPred(YAPTerm &tt, CELL *&outp) {
} }
Functor f = FunctorOfTerm(t); Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) { if (IsExtensionFunctor(f)) {
Yap_ThrowError(TYPE_ERROR_CALLABLE, t, 0); throw YAPError( SOURCE(), TYPE_ERROR_CALLABLE, t, 0);
} else { } else {
ap = RepPredProp(PredPropByFunc(f, m)); ap = RepPredProp(PredPropByFunc(f, m));
outp = RepAppl(t) + 1; outp = RepAppl(t) + 1;
@ -943,34 +1003,41 @@ void *YAPPrologPredicate::retractClause(YAPTerm skeleton, bool all) {
std::string YAPError::text() { std::string YAPError::text() {
char buf[256]; char buf[256];
std::string s = ""; std::string s = "";
if (LOCAL_ActiveError->errorFunction) { if (info->errorNo == YAP_NO_ERROR)
s += LOCAL_ActiveError->errorFile; return 0;
if (info->errorFunction) {
s += info->errorFile;
s += ":"; s += ":";
sprintf(buf, "%ld", (long int)LOCAL_ActiveError->errorLine); sprintf(buf, "%ld", (long int)info->errorLine);
s += buf; s += buf;
s += ":0 in C-code"; s += ":0 in C-code";
} }
if (LOCAL_ActiveError->prologPredLine) { if (info->prologPredLine) {
s += "\n"; s += "\n";
s += LOCAL_ActiveError->prologPredFile; s += info->prologPredFile;
s += ":"; s += ":";
sprintf(buf, "%ld", (long int)LOCAL_ActiveError->prologPredLine); sprintf(buf, "%ld", (long int)info->prologPredLine);
s += buf; // std::to_string(LOCAL_ActiveError->prologPredLine) ; s += buf; // std::to_string(info->prologPredLine) ;
// YAPIntegerTerm(LOCAL_ActiveError->prologPredLine).text(); // YAPIntegerTerm(info->prologPredLine).text();
s += ":0 "; s += ":0 ";
s += LOCAL_ActiveError->prologPredModule; s += info->prologPredModule;
s += ":"; s += ":";
s += (LOCAL_ActiveError->prologPredName); s += (info->prologPredName);
s += "/"; s += "/";
sprintf(buf, "%ld", (long int)LOCAL_ActiveError->prologPredArity); sprintf(buf, "%ld", (long int)info->prologPredArity);
s += // std::to_string(LOCAL_ActiveError->prologPredArity); s += // std::to_string(info->prologPredArity);
buf; buf;
} }
s += " error "; s += " error ";
if (LOCAL_ActiveError->classAsText != nullptr) if (info->classAsText == nullptr)
s += LOCAL_ActiveError->classAsText; info->classAsText = Yap_errorClassName(info->errorClass);
if (info->classAsText != nullptr)
s += info->classAsText;
s += "."; s += ".";
s += LOCAL_ActiveError->errorAsText; if (info->errorAsText == nullptr)
info->errorAsText = Yap_errorName(info->errorNo);
if (info->errorAsText != nullptr)
s += info->errorAsText;
s += ".\n"; s += ".\n";
// printf("%s\n", s.c_str()); // printf("%s\n", s.c_str());
return s.c_str(); return s.c_str();
@ -996,11 +1063,6 @@ void YAPEngine::reSet() {
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
} }
YAPError::YAPError(yap_error_number id, YAPTerm culprit, std::string txt) {
ID = id;
goal = culprit.text();
info = txt;
}
Term YAPEngine::top_level(std::string s) { Term YAPEngine::top_level(std::string s) {
/// parse string s and make term with var names /// parse string s and make term with var names
@ -1010,7 +1072,7 @@ Term YAPEngine::top_level(std::string s) {
ARG2 = tp; ARG2 = tp;
ARG3 = MkVarTerm(); ARG3 = MkVarTerm();
if (ARG1 == 0) if (ARG1 == 0)
Yap_Error(SYNTAX_ERROR, ARG1, "in input query"); throw YAPError( SOURCE(), SYNTAX_ERROR, ARG1, "in input query");
YAPPredicate p = YAPPredicate(YAP_TopGoal()); YAPPredicate p = YAPPredicate(YAP_TopGoal());
YAPQuery *Q = new YAPQuery(p, 0); YAPQuery *Q = new YAPQuery(p, 0);
Term ts[2]; Term ts[2];

View File

@ -121,6 +121,7 @@ class YAPModule;
class YAPError; class YAPError;
class YAPPredicate; class YAPPredicate;
#include "yapa.hh" #include "yapa.hh"
#include "yapie.hh" #include "yapie.hh"

View File

@ -1,12 +1,12 @@
/** /**
* @file yapie.hh * @file yapie.hh
* *
* @defgroup yap-cplus-error-hanadlinge Errir Handling in the YAP interface. * @defgroup yap-cplus-error-hanadlinge Error Handling in the YAP interface.
* *
* @brief this is an attempt at supporting error * @brief error handling in C++ and OO languages
* *
* @ingroup yap-cplus-interface * @ingroup yap-cplus-interface
* @tableofcontents *
* *
* @{ * @{
* *
@ -15,7 +15,7 @@
* YAP itself. One can also define one's own error objects. * YAP itself. One can also define one's own error objects.
* *
* Errors will be thrown from the `C++` code, and may be processed in * Errors will be thrown from the `C++` code, and may be processed in
* very different ways. The error object should provide as much data asa * very different ways. The error object should provide as much data as
* possible. * possible.
*/ */
@ -24,43 +24,65 @@
#define YAPIE_HH #define YAPIE_HH
class X_API YAPPPredicate; class X_API YAPPPredicate;
class X_API YAPTerm;
/// take information on a Prolog error: /// take information on a Prolog error:
class X_API YAPError { class X_API YAPError {
yap_error_number ID;
std::string goal, info;
int swigcode; int swigcode;
yap_error_descriptor_t *info;
public: public:
YAPError(){ /// wraps the default error descriptor
if (LOCAL_ActiveError == nullptr) YAPError() {
return; info = LOCAL_ActiveError;
ID = LOCAL_ActiveError->errorNo; if (!info)
if (ID != YAP_NO_ERROR) {}; LOCAL_ActiveError = info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1);
std::cerr << "Error detected" << ID << "\n"; // if (info->errorNo != YAP_NO_ERROR) {};
//std::cerr << "Error detected" << info->errorNo << "\n";
} }
YAPError(yap_error_descriptor_t *des){ /// if des != nullptr, wrap a preexisting error descriptor;
ID = des->errorNo; /// otherwise, generate a new one
if (ID != YAP_NO_ERROR) {}; YAPError(yap_error_descriptor_t *des) {
std::cerr << "Error detected" << ID << "\n"; if (des)
info= des;
else info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1);
// if (info->errorNo != YAP_NO_ERROR) {};
//std::cerr << "Error detected" << info->errorNo << "\n";
} }
/// error handler object with initial data when receiving the error term /// error handler object with initial data when receiving the error term
YAPError(yap_error_number id, YAPTerm culprit, std::string txt); // YAPError( std::string file, std::string function, int lineno,
// yap_error_number id, YAPTerm culprit, std::string txt) {
// info = new yap_error_descriptor_t;
// Yap_MkErrorRecord(info, file.c_str(), function.c_str(), lineno, id, culprit.term(), txt.c_str());
//}
/// error handler object with initial data when receiving the error term
YAPError( const char * file, const char * function, int lineno,
yap_error_number id, YAP_Term culprit, const char * txt) {
info = (yap_error_descriptor_t *)calloc( sizeof( yap_error_descriptor_t ), 1);
Yap_MkErrorRecord(info, file, function, lineno, id, culprit, txt);
}
/// short version
#define SOURCE() __FILE__, __FUNCTION__, __LINE__
/// we just know the error number /// we just know the error number
/// exact error ID /// exact error ID
yap_error_number getID() { return LOCAL_ActiveError->errorNo; }; yap_error_number getID() { return info->errorNo; };
/// class of error /// class of error
yap_error_class_number getErrorClass() { yap_error_class_number getErrorClass() {
return Yap_errorClass(LOCAL_ActiveError->errorNo); return Yap_errorClass(info->errorNo);
}; };
/// where in the code things happened; /// where in the code things happened;
const char *getFile() { return LOCAL_ActiveError->errorFile; }; const char *getFile() { return info->errorFile; };
/// predicate things happened; /// predicate things happened;
Int getLine() { return LOCAL_ActiveError->errorLine; }; Int getLine() { return info->errorLine; };
/// the term that caused the bug /// the term that caused the bug
// YAPTerm getCulprit(LOCAL_ActiveError->errorFile){}; // YAPTerm getCulprit(info->errorFile){};
/// text describing the Error /// text describing the Error
std::string text(); std::string text();
}; };

View File

@ -195,28 +195,7 @@ public:
virtual bool isList() { return Yap_IsListTerm(gt()); } /// term is a list virtual bool isList() { return Yap_IsListTerm(gt()); } /// term is a list
/// extract the argument i of the term, where i in 1...arityvoid *Yap_RepStreamFromId(int sno) /// extract the argument i of the term, where i in 1...arityvoid *Yap_RepStreamFromId(int sno)
virtual Term getArg(arity_t i) { virtual Term getArg(arity_t i);
BACKUP_MACHINE_REGS();
Term tf = 0;
Term t0 = gt();
if (IsApplTerm(t0)) {
if (i > ArityOfFunctor(FunctorOfTerm(t0)))
YAPError(DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
tf = (ArgOfTerm(i, t0));
} else if (IsPairTerm(t0)) {
if (i == 1)
tf = (HeadOfTerm(t0));
else if (i == 2)
tf = (TailOfTerm(t0));
else
YAPError(DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
} else {
YAPError(TYPE_ERROR_COMPOUND, t0, "t0.getArg()");
}
RECOVER_MACHINE_REGS();
return tf;
}
/// extract the arity of the term /// extract the arity of the term
/// variables have arity 0 /// variables have arity 0
@ -375,22 +354,7 @@ public:
YAPTerm car() { return YAPTerm(HeadOfTerm(gt())); } YAPTerm car() { return YAPTerm(HeadOfTerm(gt())); }
bool nil() { return gt() == TermNil; } bool nil() { return gt() == TermNil; }
YAPPairTerm cdr() { return YAPPairTerm(TailOfTerm(gt())); } YAPPairTerm cdr() { return YAPPairTerm(TailOfTerm(gt())); }
std::vector<Term> listToArray() { std::vector<Term> listToArray();
Term *tailp;
Term t1 = gt();
Int l = Yap_SkipList(&t1, &tailp);
if (l < 0) {
throw YAPError(TYPE_ERROR_LIST, YAPTerm(t), "");
}
std::vector<Term> o = std::vector<Term>(l);
int i = 0;
Term t = gt();
while (t != TermNil) {
o[i++] = HeadOfTerm(t);
t = TailOfTerm(t);
}
return o;
}
}; };
/** /**
@ -455,15 +419,7 @@ public:
/// Extract the tail elements of a list. /// Extract the tail elements of a list.
/// ///
/// @param[in] the list /// @param[in] the list
Term cdr() { Term cdr();
Term to = gt();
if (IsPairTerm(to))
return (TailOfTerm(to));
else if (to == TermNil)
return TermNil;
/* error */
throw YAPError(TYPE_ERROR_LIST, YAPTerm(to), "");
}
/// copy a list. /// copy a list.
/// ///
/// @param[in] the list /// @param[in] the list

View File

@ -239,9 +239,9 @@ Set or read system properties for _Param_:
#define YAP_FLAG(ITEM, NAME, WRITABLE, DEF, INIT, HELPER) ITEM #define YAP_FLAG(ITEM, NAME, WRITABLE, DEF, INIT, HELPER) ITEM
#define START_LOCAL_FLAGS enum { #define START_LOCAL_FLAGS enum THREAD_LOCAL_FLAGS {
#define END_LOCAL_FLAGS }; #define END_LOCAL_FLAGS };
#define START_GLOBAL_FLAGS enum { #define START_GLOBAL_FLAGS enum GLOBAL_FLAGS {
#define END_GLOBAL_FLAGS }; #define END_GLOBAL_FLAGS };
/* */ /* */
@ -250,6 +250,7 @@ Set or read system properties for _Param_:
/* Local flags */ /* Local flags */
#include "YapLFlagInfo.h" #include "YapLFlagInfo.h"
#ifndef DOXYGEN
#undef YAP_FLAG #undef YAP_FLAG
#undef START_LOCAL_FLAGS #undef START_LOCAL_FLAGS
@ -257,6 +258,8 @@ Set or read system properties for _Param_:
#undef START_GLOBAL_FLAGS #undef START_GLOBAL_FLAGS
#undef END_GLOBAL_FLAGS #undef END_GLOBAL_FLAGS
#endif
bool setYapFlag(Term tflag, Term t2); bool setYapFlag(Term tflag, Term t2);
Term getYapFlag(Term tflag); Term getYapFlag(Term tflag);

View File

@ -17,11 +17,10 @@
/** @file YapGFlagInfo.h /** @file YapGFlagInfo.h
@addtogroup YAPGFlags YAPGlobalFlags @addtogroup YAPFlags
@ingroup builtins
@{ @{
@enum global_flags_setup Global Flags supported by YAP @enum GLOBAL_FLAGS Global Flags supported by YAP
@brief global flags and their values. @brief global flags and their values.
*/ */

View File

@ -24,7 +24,8 @@
@{ @{
@enum local_flags_setup thread-local flag: @enum THREAD_LOCAL_FLAGS Local Flags supported by YAP
@brief local flags and their values.
*/ */
START_LOCAL_FLAGS START_LOCAL_FLAGS

View File

@ -354,10 +354,8 @@ typedef enum {
YAP_STRING_INT = 0x40, /// target is an integer term YAP_STRING_INT = 0x40, /// target is an integer term
YAP_STRING_FLOAT = 0x80, /// target is a floar term YAP_STRING_FLOAT = 0x80, /// target is a floar term
YAP_STRING_BIG = 0x100, /// target is an big num term YAP_STRING_BIG = 0x100, /// target is an big num term
YAP_STRING_DATUM = YAP_STRING_DATUM = 0x200, /// associated with previous 3, use actual object if type, not tern
0x200, /// associated with previous 3, use actual object if type, not tern YAP_STRING_LENGTH = 0x400, /// input: length is fixed; output: return integer with length
YAP_STRING_LENGTH =
0x400, /// input: length is fixed; output: return integer with length
YAP_STRING_NTH = 0x800, /// input: ignored; output: nth char YAP_STRING_NTH = 0x800, /// input: ignored; output: nth char
YAP_STRING_TERM = 0x1000, // Generic term, if nothing else given YAP_STRING_TERM = 0x1000, // Generic term, if nothing else given
YAP_STRING_DIFF = 0x2000, // difference list YAP_STRING_DIFF = 0x2000, // difference list

View File

@ -59,13 +59,20 @@ ${CMAKE_SOURCE_DIR}/packages/prosqlite
${CMAKE_SOURCE_DIR}/packages/pyswip ${CMAKE_SOURCE_DIR}/packages/pyswip
${CMAKE_SOURCE_DIR}/packages/yap-lbfgs/liblbfgs-1.10 ${CMAKE_SOURCE_DIR}/packages/yap-lbfgs/liblbfgs-1.10
${CMAKE_SOURCE_DIR}/library/dialect/swi/os ${CMAKE_SOURCE_DIR}/library/dialect/swi/os
${CMAKE_SOURCE_DIR}/packages/gecode/gecode3_yap.cc ${CMAKE_SOURCE_DIR}/packages/python
${CMAKE_SOURCE_DIR}/packages/gecode/gecode4_yap.cc ${CMAKE_SOURCE_DIR}/*/bprolog/*
${CMAKE_SOURCE_DIR}/packages/gecode/gecode3.yap ${CMAKE_SOURCE_DIR}/*/prism/*
${CMAKE_SOURCE_DIR}/packages/gecode/gecode4.yap ${CMAKE_SOURCE_DIR}/*/gecodde/[345]*
${CMAKE_SOURCE_DIR}/packages/gecode/gecode3_yap_hand_written.yap ${CMAKE_SOURCE_DIR}/packages/gecode/gecode3_yap.cc
${CMAKE_SOURCE_DIR}/packages/gecode/gecode4_yap_hand_written.yap ${CMAKE_SOURCE_DIR}/packages/gecode/gecode4_yap.cc
*/CMakeFiles/* *~ */#* ${CMAKE_SOURCE_DIR}/packages/gecode/gecode5_yap.cc
${CMAKE_SOURCE_DIR}/packages/gecode/gecode3.yap
${CMAKE_SOURCE_DIR}/packages/gecode/gecode4.yap
${CMAKE_SOURCE_DIR}/packages/gecode/gecode5.yap
${CMAKE_SOURCE_DIR}/packages/gecode/gecode3_yap_hand_written.yap
${CMAKE_SOURCE_DIR}/packages/gecode/gecode4_yap_hand_written.yap
${CMAKE_SOURCE_DIR}/packages/gecode/gecode5_yap_hand_written.yap
*/CMakeFiles/* *~ */#*
) )
@ -97,6 +104,7 @@ endforeach(i ${DOCS_EXCLUDE_})
${CMAKE_SOURCE_DIR}/os ${CMAKE_SOURCE_DIR}/os
${CMAKE_SOURCE_DIR}/library ${CMAKE_SOURCE_DIR}/library
${CMAKE_SOURCE_DIR}/swi/library ${CMAKE_SOURCE_DIR}/swi/library
${CMAKE_SOURCE_DIR}/packages
) )
foreach(i ${DOC_INPUT_FILES_}) foreach(i ${DOC_INPUT_FILES_})

View File

@ -98,7 +98,7 @@ OUTPUT_LANGUAGE = English
# documentation (similar to Javadoc). Set to NO to disable this. # documentation (similar to Javadoc). Set to NO to disable this.
# The default value is: YES. # The default value is: YES.
BRIEF_MEMBER_DESC = NO BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
# description of a member or function before the detailed description # description of a member or function before the detailed description
@ -107,7 +107,7 @@ BRIEF_MEMBER_DESC = NO
# brief descriptions will be completely suppressed. # brief descriptions will be completely suppressed.
# The default value is: YES. # The default value is: YES.
REPEAT_BRIEF = NO REPEAT_BRIEF = YES
# This tag implements a quasi-intelligent brief description abbreviator that is # This tag implements a quasi-intelligent brief description abbreviator that is
# used to form the text in various listings. Each string in this list, if found # used to form the text in various listings. Each string in this list, if found
@ -900,14 +900,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to # Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/* # exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS = @PROJECT_SOURCE_DIR@/*/bprolog/* \ EXCLUDE_PATTERNS = @DOCS_EXCLUDE@
@PROJECT_SOURCE_DIR@/*/prism/* \
@PROJECT_SOURCE_DIR@/packages/gecode/gecode4_yap.cc \
@PROJECT_SOURCE_DIR@/packages/gecode/gecode3.yap \
@PROJECT_SOURCE_DIR@/packages/gecode/gecode4.yap \
@PROJECT_SOURCE_DIR@/packages/gecode/gecode3_yap_hand_written.yap \
\ \
@PROJECT_SOURCE_DIR@/packages/gecode/gecode4_yap_hand_written.yap
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the # (namespaces, classes, functions, etc.) that should be excluded from the
@ -2071,7 +2064,7 @@ ENABLE_PREPROCESSING = YES
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
MACRO_EXPANSION = NO MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
# the macro expansion is limited to the macros specified with the PREDEFINED and # the macro expansion is limited to the macros specified with the PREDEFINED and
@ -2079,14 +2072,14 @@ MACRO_EXPANSION = NO
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
EXPAND_ONLY_PREDEF = NO EXPAND_ONLY_PREDEF = YES
# If the SEARCH_INCLUDES tag is set to YES, the include files in the # If the SEARCH_INCLUDES tag is set to YES, the include files in the
# INCLUDE_PATH will be searched if a #include is found. # INCLUDE_PATH will be searched if a #include is found.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
SEARCH_INCLUDES = YES SEARCH_INCLUDES = NO
# The INCLUDE_PATH tag can be used to specify one or more directories that # The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by the # contain include files that are not input files but should be processed by the
@ -2116,7 +2109,20 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator. # recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = PREDEFINED =
YAP_FLAG(ITEM,NAME,WRITABLE,DEF,INIT,HELPER)=ITEM \
START_LOCAL_FLAGS="enum THREAD_LOCAL_FLAGS {" \
END_LOCAL_FLAGS=" };"\
START_GLOBAL_FLAGS="enum GLOBAL_FLAGS {" \
END_GLOBAL_FLAGS="};" \
LOCAL(A, B)="A B" \
LOCAL_INIT(A, B, C)="A B;B = C" \
LOCAL_ARRAY(A, B, C)="A B[C]" \
LOCAL_ARRAY_ARRAY(A, B, C,D)="A B[C][D]"\
LOCAL_INIT(A, B, C, D)="A B[C][D]"\
LOCAL_INITF(A, B, C)=" A B; C"\
LOCAL_INIT_RESTORE(A,B,C,D)="A B; C; D;"\
PREG=Yap_REGS.P_
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The # tag can be used to specify a list of macro names that should be expanded. The

View File

@ -60,7 +60,7 @@ $( document ).ready(function() {
$('div.fragment.well div.line:last').css('margin-bottom', '15px'); $('div.fragment.well div.line:last').css('margin-bottom', '15px');
$('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered table-small;').each(function(){ $('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered table-small;').each(function(){
$(this).prepend('<thead></thead>'); $(this).prepend('<thead><th scope="col">first</th><th scope="col">Last</th>s</thead>');
$(this).find('tbody > tr:first').prependTo($(this).find('thead')); $(this).find('tbody > tr:first').prependTo($(this).find('thead'));
$(this).bootstrapTable('remove', {class: 'separator'}); $(this).bootstrapTable('remove', {class: 'separator'});
$(this).find('td > span.success').parent().addClass('success'); $(this).find('td > span.success').parent().addClass('success');

View File

@ -1,12 +1,11 @@
lDownloading and Installing YAP {#INSTALL} Downloading and Installing YAP {#INSTALL}
=========================== ===========================
This text includes instructions to download and install YAP. This text includes instructions to download and install YAP.
[TOC] [TOC]
Downloading YAP {#Download} ## Downloading YAP {#Download}
----------------
The latest development version of Yap-6 is available source-only The latest development version of Yap-6 is available source-only
through GIT repositories. The main reference repository is at through GIT repositories. The main reference repository is at
@ -32,7 +31,10 @@ The first argument is the repository, the last argument is the (optional) target
It may be useful to know: It may be useful to know:
+ If you are have limited bandwith or disk spaceq, consider using + If you are have limited bandwith or disk spaceq, consider using
`git clone --depth XX` to only include the last `XX` commits. ~~~~~
git clone --depth XX
~~~~~
to only include the last `XX` commits.
+ Older versions of YAP were distributed with modules. YAP-6.3.5 is + Older versions of YAP were distributed with modules. YAP-6.3.5 is
a single package, and it does not need `git submodule`. a single package, and it does not need `git submodule`.
@ -42,16 +44,16 @@ It may be useful to know:
version of doxygen adapted to Prolog that was used to generate version of doxygen adapted to Prolog that was used to generate
these documents. these documents.
Compiling YAP {#CompilingYAP} ## CompilingYAP Compiling YAP
----------------
YAP-6.3.4 is a [cmake](www.cmake.org) based YAP-6.3.4 is a [cmake](www.cmake.org) based
system. We use `cmake` because it supports mosts popular software, can system. We use `cmake` because it supports mosts popular software, can
generate Makefiles, Ninja, Apple's XCode, VisualStudio and ANdroid generate Makefiles, Ninja, Apple's XCode, VisualStudio and ANdroid
Studio, and because it includes packaging suppport, The steps required Studio, and because it includes packaging suppport, The steps required
to install core YAP under `cmake`: to install core YAP under `cmake` are presented in detail next.
### The compiler ### Compilation The compiler
*Status as of early 2017* *Status as of early 2017*
@ -104,7 +106,7 @@ available at GitHub.
+ make sure to install Python-3, and not Python-2, + make sure to install Python-3, and not Python-2,
### Compile and Install ### Compiling Compile and Install
1: Create a directory, say `Build` and `cd` to the directory (`cd Build`). 1: Create a directory, say `Build` and `cd` to the directory (`cd Build`).
*YAP should not be compiled at its rootxo directory, some packages do not allow for that. *YAP should not be compiled at its rootxo directory, some packages do not allow for that.

View File

@ -1,7 +1,7 @@
YAP packages {#packages} YAP packages {#packages}
============ ============
+ @subpage realxplxc + @subpage realmd
+ @subpage BDDs + @subpage BDDs

View File

@ -241,7 +241,10 @@ INLINE_ONLY extern inline Term Yap_ensure_atom__(const char *fu, const char *fi,
#define LOCAL_ErrorMessage LOCAL_ActiveError->errorMsg #define LOCAL_ErrorMessage LOCAL_ActiveError->errorMsg
extern void Yap_ThrowExistingError(void); extern void Yap_ThrowExistingError(void);
extern bool Yap_MkErrorRecord( yap_error_descriptor_t *r,
const char *file, const char *function,
int lineno, yap_error_number type, YAP_Term where,
const char *msg);
extern yap_error_descriptor_t * Yap_pc_add_location(yap_error_descriptor_t *t, void *pc0, void *b_ptr0, void *env0); extern yap_error_descriptor_t * Yap_pc_add_location(yap_error_descriptor_t *t, void *pc0, void *b_ptr0, void *env0);
extern yap_error_descriptor_t *Yap_env_add_location(yap_error_descriptor_t *t,void *cp0, void * b_ptr0, void *env0, YAP_Int ignore_first); extern yap_error_descriptor_t *Yap_env_add_location(yap_error_descriptor_t *t,void *cp0, void * b_ptr0, void *env0, YAP_Int ignore_first);

View File

@ -5,7 +5,6 @@
* *
* @brief Stub for maplist and friends * @brief Stub for maplist and friends
* *
*
*/ */
@ -24,10 +23,9 @@
]). ]).
/** /**
@defgroup apply_stub Apply Predicates
@ingroup library
@defgroup ApplyMaplist Appy Stub for maplist Predicates
@ingroup maplist
@{ @{
@ -37,14 +35,14 @@ predicate to all elements of a list.
The apply library is a _stub_, it just forwards definitions to the The apply library is a _stub_, it just forwards definitions to the
@ref maplist library. The predicates forwarded are: @ref maplist library. The predicates forwarded are:
* maplist:maplist/2, * maplist/2,
* maplist:maplist/3, * maplist/3,
* maplist:maplist/4, * maplist/4,
* maplist:maplist/5, * maplist/5,
* maplist:include/3, * include/3,
* maplist:exclude/3, * exclude/3,
* maplist:partition/4, * partition/4,
* maplist:partition/5 * partition/5
*/ */

View File

@ -6,11 +6,12 @@
%% of a list or to all sub-terms of a term. %% of a list or to all sub-terms of a term.
:- module(apply_macros, []). :- module(apply_macros, []).
%% @namespace maplist
/** /**
@defgroup apply_macros Apply Interface to maplist @defgroup apply_macros Apply Interface to maplist
@ingroup library @ingroup maplist
@{ @{
This library provides a SWI-compatible set of utilities for applying a This library provides a SWI-compatible set of utilities for applying a
@ -19,14 +20,15 @@ predicate to all elements of a list.
The apply library just forwards The apply library just forwards
definitions to the @ref maplist library, these include: definitions to the @ref maplist library, these include:
- maplist/2,
- maplist/3, + maplist/2,
- maplist/4, + maplist/3,
- maplist/5, + maplist/4,
- include/3, + maplist/5,
- exclude/3, + include/3,
- partition/4, + exclude/3,
- partition/5 + partition/4,
+ partition/5
*/ */

View File

@ -44,83 +44,6 @@
sumnodes/4 sumnodes/4
]). ]).
/**
* @defgroup maplist Map List and Term Operations
* @ingroup library
* @{
*
* This library provides a set of utilities for applying a predicate to
* all elements of a list. They allow one to easily perform the most common do-loop constructs in Prolog.
* To avoid performance degradation, each call creates an
* equivalent Prolog program, without meta-calls, which is executed by
* the Prolog engine instead. The library was based on code
* by Joachim Schimpf and on code from SWI-Prolog, and it is also inspired by the GHC
* libraries.
*
* The routines are available once included with the
* `use_module(library(apply_macros))` command.
*/
/*
Examples:
~~~~
given the progran:
~~~~
plus(X,Y,Z) :- Z is X + Y.
plus_if_pos(X,Y,Z) :- Y > 0, Z is X + Y.
vars(X, Y, [X|Y]) :- var(X), !.
vars(_, Y, Y).
trans(TermIn, TermOut) :-
nonvar(TermIn),
TermIn =.. [p|Args],
TermOut =..[q|Args], !.
trans(X,X).
~~~~
%success
?- maplist(plus(1), [1,2,3,4], [2,3,4,5]).
?- checklist(var, [X,Y,Z]).
?- selectlist(<(0), [-1,0,1], [1]).
?- convlist(plus_if_pos(1), [-1,0,1], [2]).
?- sumlist(plus, [1,2,3,4], 1, 11).
?- maplist(mapargs(number_atom),[c(1),s(1,2,3)],[c('1'),s('1','2','3')]).
~~~~
*/
/** @pred maplist( 2:Pred, + _List1_,+ _List2_)
Apply _Pred_ on all successive pairs of elements from
_List1_ and
_List2_. Fails if _Pred_ can not be applied to a
pair. See the example above.
*/
/** @pred maplist(3:Pred,+ List1,+ List2,+ List4)
Apply _Pred_ on all successive triples of elements from _List1_,
_List2_ and _List3_. Fails if _Pred_ can not be applied to a
triple. See the example above.
*/
:- meta_predicate :- meta_predicate
selectlist(2,+,-), selectlist(2,+,-),
selectlist(3,+,+,-), selectlist(3,+,+,-),
@ -161,6 +84,73 @@ triple. See the example above.
:- use_module(library(charsio), [format_to_chars/3, read_from_chars/2]). :- use_module(library(charsio), [format_to_chars/3, read_from_chars/2]).
:- use_module(library(occurs), [sub_term/2]). :- use_module(library(occurs), [sub_term/2]).
/**
* @defgroup maplist Map List and Term Operations
* @ingroup library
* @{
*
* This library provides a set of utilities for applying a predicate to
* all elements of a list. They allow one to easily perform the most common do-loop constructs in Prolog.
* To avoid performance degradation, each call creates an
* equivalent Prolog program, without meta-calls, which is executed by
* the Prolog engine instead. The library was based on code
* by Joachim Schimpf and on code from SWI-Prolog, and it is also inspired by the GHC
* libraries.
*
* The routines are available once included with the
* `use_module(library(maplist))` command.
* Examples:
*
* ~~~~
* plus(X,Y,Z) :- Z is X + Y.
*
* plus_if_pos(X,Y,Z) :- Y > 0, Z is X + Y.
*
* vars(X, Y, [X|Y]) :- var(X), !.
* vars(_, Y, Y).
*
* trans(TermIn, TermOut) :-
* nonvar(TermIn),
* TermIn =.. [p|Args],
* TermOut =..[q|Args], !.
* trans(X,X).
* ~~~~
* %success
*
* ?- maplist(plus(1), [1,2,3,4], [2,3,4,5]).
*
* ?- checklist(var, [X,Y,Z]).
*
* ?- selectlist(<(0), [-1,0,1], [1]).
*
* ?- convlist(plus_if_pos(1), [-1,0,1], [2]).
*
* ?- sumlist(plus, [1,2,3,4], 1, 11).
*
* ?- maplist(mapargs(number_atom),[c(1),s(1,2,3)],[c('1'),s('1','2','3')]).
* ~~~~
*
**/
/** @pred maplist( 2:Pred, + _List1_,+ _List2_)
Apply _Pred_ on all successive pairs of elements from
_List1_ and
_List2_. Fails if _Pred_ can not be applied to a
pair. See the example above.
*/
/** @pred maplist(3:Pred,+ List1,+ List2,+ List4)
Apply _Pred_ on all successive triples of elements from _List1_,
_List2_ and _List3_. Fails if _Pred_ can not be applied to a
triple. See the example above.
*/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Definitions for Metacalls % Definitions for Metacalls

View File

@ -1,8 +1,10 @@
site_name: 'YAP' site_name: 'YAP'
theme: 'readthedocs' theme: 'readthedocs'
markdown_extensions:
use_directory_urls: false
plugins: plugins:
- search - search
- awesome-pages: - awesome-pages:
filename: .index filename: .index
disable_auto_arrange_index: false disable_auto_arrange_index: false
collapse_single_pages: true collapse_single_pages: true

View File

@ -287,7 +287,8 @@ Instead of probabilities every fact has a t( ) prefix. The t stands for tunable
~~~~ ~~~~
t(0.5)::heads(_). t(0.5)::heads(_).
~~~~ ~~~~
*
*/
/** @defgroup ProbLogPredicates ProbLog Predicates /** @defgroup ProbLogPredicates ProbLog Predicates
@ingroup ProbLog1 @ingroup ProbLog1
@ -300,7 +301,6 @@ In the description of the arguments of functors the following notation will be u
+ a preceding minus sign will denote an "output argument" + a preceding minus sign will denote an "output argument"
+ an argument with no preceding symbol can be used in both ways + an argument with no preceding symbol can be used in both ways
@{
/** /**
* @pred problog_max(+G, -Prob, -FactsUsed) * @pred problog_max(+G, -Prob, -FactsUsed)
@ -344,7 +344,6 @@ This predicate returns the lower and upper bound of the probability of achieving
This predicate returns the lower bound of the probability of achieving the goal G obtained by cutting the sld tree at the given probability for each branch. This predicate returns the lower bound of the probability of achieving the goal G obtained by cutting the sld tree at the given probability for each branch.
*/ */
%% @}
/** /**
@defgroup ProbLogParameterLearning ProbLog Parameter Learning Predicates @defgroup ProbLogParameterLearning ProbLog Parameter Learning Predicates
@ -4188,3 +4187,4 @@ user:term_expansion(Term,ExpandedTerm) :-
problog:term_expansion_intern(Term,Mod,ExpandedTerm). problog:term_expansion_intern(Term,Mod,ExpandedTerm).
%% @} %% @}

View File

@ -1,6 +1,6 @@
/** /**
@file bdd.yap @file bdd/bdd.yap
@defgroup BDDsPL Binary Decision Diagrams and Friends @defgroup BDDsPL Binary Decision Diagrams and Friends
@ingroup BDDs @ingroup BDDs

View File

@ -68,6 +68,15 @@
%% * Added initialization directives for saved-states %% * Added initialization directives for saved-states
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% @file chr_runtime.pl
%% @brief CHR runtime
%% @namespace locked
%% @brief internal CHR space
%% @namespace error_locked
%% @brief internal CHR space
%% @addtogroup CHR_Rule_Types Rule Types %% @addtogroup CHR_Rule_Types Rule Types
%% @ingroup CHR %% @ingroup CHR
% %

View File

@ -29,6 +29,12 @@
the GNU General Public License. the GNU General Public License.
*/ */
%% @file chr_swi.pl
%% @brief CHR SWI specific
%% @namespace check
%% @brief internal space
%% SWI begin %% SWI begin
%% @addtogroup CHR chr %% @addtogroup CHR chr
%% @ingroup packages %% @ingroup packages

View File

@ -1341,3 +1341,6 @@ keep_list_(_, X) :-
(Space += maximize(X,Y)) :- !, maximize(Space,X,Y). (Space += maximize(X,Y)) :- !, maximize(Space,X,Y).
(Space += keep(X)) :- !, keep_(Space,X). (Space += keep(X)) :- !, keep_(Space,X).
%! @}

View File

@ -1341,3 +1341,5 @@ keep_list_(_, X) :-
(Space += maximize(X,Y)) :- !, maximize(Space,X,Y). (Space += maximize(X,Y)) :- !, maximize(Space,X,Y).
(Space += keep(X)) :- !, keep_(Space,X). (Space += keep(X)) :- !, keep_(Space,X).
%! @}

View File

@ -1,3 +1,19 @@
/**
* @file real.c
* @date Sat May 19 13:44:04 2018
*
* @brief Prolog to R interface
*
*
*/
/**
* @defgroup realI Interface Prolog to R
* @ brief How to call R from YAP
* @ingroup realm
* @{
*/
#define CSTACK_DEFNS #define CSTACK_DEFNS
#include "rconfig.h" #include "rconfig.h"
#if HAVE_R_H || !defined(_YAP_NOT_INSTALLED_) #if HAVE_R_H || !defined(_YAP_NOT_INSTALLED_)
@ -2210,3 +2226,5 @@ install_real(void) { /* FUNCTOR_dot2 = PL_new_functor(PL_new_atom("."), 2); */
} }
#endif /* R_H */ #endif /* R_H */
/// @}

View File

@ -1,5 +1,3 @@
The R Prolog Programming Interface {#realxplxc}
===================================
@file real.md @file real.md
@author Nicos Angelopoulos @author Nicos Angelopoulos
@ -7,6 +5,10 @@ The R Prolog Programming Interface {#realxplxc}
@version 1:0:4, 2013/12/25, sinter_class @version 1:0:4, 2013/12/25, sinter_class
@license Perl Artistic License @license Perl Artistic License
@defgroup realmd The R Prolog Programming Interface
@ingroup packages
@{
+ @ref realpl + @ref realpl
This library enables the communication with an R process started as a shared library. This library enables the communication with an R process started as a shared library.
@ -42,7 +44,10 @@ The main modes for utilising the interface are
Pass Prolog data to R, pass R data to Prolog or assign an R expression to Pass Prolog data to R, pass R data to Prolog or assign an R expression to
an assignable R expression. an assignable R expression.
### Testing Real {#TestingR}
@defgroup TestingR Testing Real
@ingroup realmd
@{
There is a raft of examples packed in a single file that tests the library. There is a raft of examples packed in a single file that tests the library.
@ -53,7 +58,10 @@ There is a raft of examples packed in a single file that tests the library.
?- edit( pack(real/examples/for_real) ). ?- edit( pack(real/examples/for_real) ).
~~~~ ~~~~
### Prolog and R Syntax {#RSyntax} @}
@defgroup RSyntax Prolog and R Syntax
@ingroup realmd
@{
There are syntactic conventions in R that make unparsable prolog code. There are syntactic conventions in R that make unparsable prolog code.
Notably function and variable names are allowed to contain dots, square brackets are used Notably function and variable names are allowed to contain dots, square brackets are used
@ -155,7 +163,11 @@ This is only advisable for short data structures. For instance,
Through this interface it is more convenient to be explicit about R chars by Prolog prepending Through this interface it is more convenient to be explicit about R chars by Prolog prepending
atoms or codes with + as in the above example. atoms or codes with + as in the above example.
### Examples {#RealExamples}
@}
@defgroup RealExamples Examples
@ingroup realmd
@{
~~~~ ~~~~
@ -202,7 +214,12 @@ logical :-
~~~~ ~~~~
#### Info
@}
@defgroup RealInfo Real Information
@ingroup realmd
@{
@see http://stoics.org.uk/~nicos/sware/real @see http://stoics.org.uk/~nicos/sware/real
@see pack(real/examples/for_real) @see pack(real/examples/for_real)
@ -211,10 +228,233 @@ logical :-
@see pack(real/doc/padl2013-real.pdf) @see pack(real/doc/padl2013-real.pdf)
@see http://www.r-project.org/ @see http://www.r-project.org/
Also @subpaage yap-real describes the YAP specfic details in real. Also @ref yap-real describes the YAP specfic details in real.
@file real.md
'
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll@}
@defgroup yap_real Development of real in YAP
@ingroup realmd
@{
*/Development of real in YAP (#yap_real)
---------------------------
YAP includes a development version of real, designed to experiment YAP includes a development version of real, designed to experiment
with the internals of the implementation of R. It includes major with the internals of the implementation of R. It includes major
@ -264,3 +504,6 @@ in~\cite{}. Their major differences:
- Updates: Nicos Angelopoulos, Dec. 2013, March, 2014 - Updates: Nicos Angelopoulos, Dec. 2013, March, 2014
- Updates: Vitor Santos Costa Dec. 2015 - Updates: Vitor Santos Costa Dec. 2015
@}
@}

View File

@ -14,7 +14,7 @@
* @file real.pl * @file real.pl
* @brief Prolog component of r_interface * @brief Prolog component of r_interface
* @defgroup realpl Prolog component of r_interface * @defgroup realpl Prolog component of r_interface
* @ingroup real * @ingroup realmd
* @{ * @{
* Initialization code and key predicares for R-Prolog interface. * Initialization code and key predicares for R-Prolog interface.
* *
@ -950,4 +950,5 @@ prolog:message( r_root ) -->
:- initialization( set_prolog_flag( double_quotes, string) ). :- initialization( set_prolog_flag( double_quotes, string) ).
%%% @} %% @}

View File

@ -278,3 +278,4 @@ print_param(Name,Value,Text,Dom) :-
format(user,'~w~10+~w~19+~w~15+~w~30+~n',[Dom,Name,Value,Text]). format(user,'~w~10+~w~19+~w~15+~w~30+~n',[Dom,Name,Value,Text]).
%% @}

View File

@ -14,7 +14,7 @@
@author L.Damas, V.S.Costa @author L.Damas, V.S.Costa
@defgroup AbsoluteFileName File Name Resolution @defgroup AbsoluteFileName File Name Resolution
@ingroup builtins @ingroup load_files
Support for file name resolution through absolute_file_name/3 and Support for file name resolution through absolute_file_name/3 and
friends. These utility built-ins describe a list of directories that friends. These utility built-ins describe a list of directories that

View File

@ -7,7 +7,9 @@
* @brief support Prolog dialects * @brief support Prolog dialects
* *
* @defgroup Dialects Compatibilty with other Prolog dialects * @defgroup Dialects Compatibilty with other Prolog dialects
* @ingroup builtins * @ingroup extensions
* @{
* @brief Prolog dialects
* *
*/ */
@ -54,7 +56,7 @@ check_dialect(Dialect) :-
check_dialect(Dialect) :- check_dialect(Dialect) :-
'$do_error'(domain_error(dialect,Dialect),(:- expects_dialect(Dialect))). '$do_error'(domain_error(dialect,Dialect),(:- expects_dialect(Dialect))).
%% exists_source(+Source) is semidet. %% @pred exists_source(+Source) is semidet.
% %
% True if Source (a term valid for load_files/2) exists. Fails % True if Source (a term valid for load_files/2) exists. Fails
% without error if this is not the case. The predicate is intended % without error if this is not the case. The predicate is intended
@ -77,8 +79,8 @@ exists_source(Source, Path) :-
file_errors(fail) file_errors(fail)
]). ]).
%% source_exports(+Source, +Export) is semidet. %% @pred source_exports(+Source, +Export) is semidet.
%% source_exports(+Source, -Export) is nondet. %% @pred source_exports(+Source, -Export) is nondet.
% %
% True if Source exports Export. Fails without error if this is % True if Source exports Export. Fails without error if this is
% not the case. See also exists_source/1. % not the case. See also exists_source/1.
@ -93,7 +95,7 @@ source_exports(Source, Export) :-
; lists:member(Export, Exports) ; lists:member(Export, Exports)
). ).
%% open_source(+Source, -In:stream) is semidet. %% @pred open_source(+Source, -In:stream) is semidet.
% %
% Open a source location. % Open a source location.
@ -108,3 +110,5 @@ open_source(File, In) :-
exports(In, Exports) :- exports(In, Exports) :-
read(In, Term), read(In, Term),
Term = (:- module(_Name, Exports)). Term = (:- module(_Name, Exports)).
@}

View File

@ -33,7 +33,7 @@
/** /**
* @defgroup DebSet Debugger Control * @defgroup DebSet Debugger Control
* @ingroup builtins Deb_Interaction * @ingroup Deb_Interaction
@{ @{
The The

View File

@ -16,7 +16,7 @@
*************************************************************************/ *************************************************************************/
/** /**
* @file utils.yap * @file pl/utils.yap
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan> * @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Thu Oct 19 12:21:01 2017 * @date Thu Oct 19 12:21:01 2017
* *

View File

@ -35,6 +35,12 @@
* @defgroup ypp Yap PreProcessing * @defgroup ypp Yap PreProcessing
* @ingroup library * @ingroup library
* *
* This program_continuation can be used as a preprocessor in the
* style of the `C` language. Currently, it must be used through
* ypp_consult and or ypp_reconsult.
*
* Notice that ypp uses `#` commands.
*
*/ */
%==================================================================================== %====================================================================================