Merge branch 'master' of ssh://yap.git.sourceforge.net/gitroot/yap/yap-6.3

This commit is contained in:
Vítor Santos Costa 2011-06-14 09:23:32 +01:00
commit 5614d05a03
67 changed files with 4967 additions and 505 deletions

3
.gitmodules vendored
View File

@ -34,3 +34,6 @@
[submodule "packages/YapR"]
path = packages/YapR
url = git://yap.git.sourceforge.net/gitroot/yap/YapR
[submodule "packages/pldoc"]
path = packages/pldoc
url = git://yap.git.sourceforge.net/gitroot/yap/pldoc

View File

@ -9222,7 +9222,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, plus_vc_unk, plus_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A+B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A+ " Int_FORMAT, PREG->u.xxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -9322,7 +9322,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, plus_y_vc_unk, plus_y_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A+B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A+ " Int_FORMAT, PREG->u.yxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -9408,7 +9408,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, minus_cv_unk, minus_cv_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A-B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is " Int_FORMAT "-A", PREG->u.xxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -9508,7 +9508,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, minus_y_cv_unk, minus_y_cv_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A-B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is " Int_FORMAT "-A", PREG->u.yxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -9594,7 +9594,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, times_vc_unk, times_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A*B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A* " Int_FORMAT, PREG->u.xxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -9694,7 +9694,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, times_y_vc_unk, times_y_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A*B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A* " Int_FORMAT, PREG->u.yxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -9830,7 +9830,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, div_cv_unk, div_cv_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A//B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is " Int_FORMAT "// A", PREG->u.xxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -9988,7 +9988,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, div_y_cv_unk, div_y_cv_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A//B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is " Int_FORMAT "// A", PREG->u.yxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -10075,7 +10075,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, and_vc_unk, and_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A/\\B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A /\\ " Int_FORMAT , PREG->u.xxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -10175,7 +10175,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, and_y_vc_unk, and_y_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A/\\B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A /\\ " Int_FORMAT , PREG->u.yxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -10261,7 +10261,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, or_vc_unk, or_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A\\/B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A \\/ " Int_FORMAT , PREG->u.xxn.c);
setregs();
FAIL();
ENDP(pt0);
@ -10361,7 +10361,7 @@ Yap_absmi(int inp)
BEGP(pt0);
deref_body(d0, pt0, or_y_vc_unk, or_y_vc_nvar);
saveregs();
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A\\/B");
Yap_Error(INSTANTIATION_ERROR, TermNil, "X is A \\/ " Int_FORMAT , PREG->u.yxn.c);
setregs();
FAIL();
ENDP(pt0);

View File

@ -493,41 +493,43 @@ Yap_GetOpProp(Atom a, op_type type USES_REGS)
{ /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a);
PropEntry *pp;
OpEntry *info = NULL;
READ_LOCK(ae->ARWLock);
pp = RepProp(ae->PropsOfAE);
while (!EndOfPAEntr(pp) &&
( pp->KindOfPE != OpProperty ||
((OpEntry *)pp)->OpModule != CurrentModule))
pp = RepProp(pp->NextOfPE);
if ((info = (OpEntry *)pp)) {
if ((type == INFIX_OP && !info->Infix) ||
(type == POSFIX_OP && !info->Posfix) ||
(type == PREFIX_OP && !info->Prefix))
pp = RepProp(NIL);
}
if (EndOfPAEntr(pp)) {
pp = RepProp(ae->PropsOfAE);
while (!EndOfPAEntr(pp) &&
( pp->KindOfPE != OpProperty ||
((OpEntry *)pp)->OpModule != PROLOG_MODULE))
while (!EndOfPAEntr(pp)) {
OpEntry *info = NULL;
if ( pp->KindOfPE != OpProperty) {
pp = RepProp(pp->NextOfPE);
if ((info = (OpEntry *)pp)) {
if ((type == INFIX_OP && !info->Infix) ||
(type == POSFIX_OP && !info->Posfix) ||
(type == PREFIX_OP && !info->Prefix))
pp = RepProp(NIL);
continue;
}
info = (OpEntry *)pp;
if (info->OpModule != CurrentModule &&
info->OpModule != PROLOG_MODULE) {
pp = RepProp(pp->NextOfPE);
continue;
}
if (type == INFIX_OP) {
if (!info->Infix) {
pp = RepProp(pp->NextOfPE);
continue;
}
} else if (type == POSFIX_OP) {
if (!info->Posfix) {
pp = RepProp(pp->NextOfPE);
continue;
}
} else {
if (!info->Prefix) {
pp = RepProp(pp->NextOfPE);
continue;
}
}
}
if (!info) {
READ_UNLOCK(ae->ARWLock);
return NULL;
} else {
READ_LOCK(info->OpRWLock);
READ_UNLOCK(ae->ARWLock);
return info;
}
READ_UNLOCK(ae->ARWLock);
return NULL;
}

View File

@ -2429,13 +2429,13 @@ a_fetch_vv(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
PInstr *p = cip->cpc->nextInst;
Ventry *ve;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}
p = p->nextInst;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}
@ -2458,7 +2458,7 @@ a_fetch_vc(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
PInstr *p = cip->cpc->nextInst;
Ventry *ve;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}
@ -2479,7 +2479,7 @@ a_fetch_cv(cmp_op_info *cmp_info, int pass_no, struct intermediates *cip)
PInstr *p = cip->cpc->nextInst;
Ventry *ve;
ve = (Ventry *) p->rnd1;
if (ve->KindOfVE != PermVar && p->op != nop_op) {
if (ve->KindOfVE != PermVar && p->op != nop_op && p->op != put_var_op) {
p->rnd2 = ve->NoOfVE & MaskVarAdrs;
p->op = nop_op;
}

View File

@ -294,8 +294,8 @@ Yap_MkBlobStringTerm(const char *s, size_t len)
H[1] = BLOB_STRING;
siz = (sizeof(size_t)+len+sizeof(CELL))/sizeof(CELL);
dst->_mp_size = siz;
dst->_mp_alloc = 0L;
dst->_mp_size = 0L;
dst->_mp_alloc = siz;
sp = (blob_string_t *)(dst+1);
H = (CELL *)sp;
sp->len = sz;
@ -314,10 +314,39 @@ Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
size_t sz;
MP_INT *dst = (MP_INT *)(H+2);
blob_string_t *sp;
size_t siz;
size_t siz, i = 0;
sz = wcslen(s);
if (len > 0 && sz > len) sz = len;
while (i < sz) {
if (s[i++] >= 255) break;
}
if (i == sz) {
char *target;
size_t i = 0;
if (len/sizeof(CELL) > (ASP-ret)-1024) {
return TermNil;
}
H[0] = (CELL)FunctorBigInt;
H[1] = BLOB_STRING;
siz = (sizeof(size_t)+len+sizeof(CELL))/sizeof(CELL);
dst->_mp_size = 0L;
dst->_mp_alloc = siz;
sp = (blob_string_t *)(dst+1);
H = (CELL *)sp;
sp->len = sz;
target = (char *)(sp+1);
while (i < sz+1) {
target[i] = s[i];
i++;
}
H += siz;
H[0] = EndSpecials;
H++;
return AbsAppl(ret);
}
if (len/sizeof(CELL) > (ASP-ret)-1024) {
return TermNil;
}
@ -325,12 +354,12 @@ Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
H[1] = BLOB_WIDE_STRING;
siz = (sizeof(size_t)+(len+2)*sizeof(wchar_t))/sizeof(CELL);
dst->_mp_size = siz;
dst->_mp_alloc = 0L;
dst->_mp_size = 0L;
dst->_mp_alloc = siz;
sp = (blob_string_t *)(dst+1);
H = (CELL *)sp;
sp->len = sz;
wcsncpy((wchar_t *)(sp+1), s, sz);
wcsncpy((wchar_t *)(sp+1), s, sz+1);
H += siz;
H[0] = EndSpecials;
H++;

View File

@ -2528,20 +2528,20 @@ YAP_Read(IOSTREAM *inp)
BACKUP_MACHINE_REGS();
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp, &tpos);
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp, FALSE, &tpos);
if (LOCAL_ErrorMessage)
{
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
RECOVER_MACHINE_REGS();
return 0;
}
if (inp->flags & (SIO_FEOF|SIO_FEOF2)) {
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
RECOVER_MACHINE_REGS();
return MkAtomTerm (AtomEof);
}
t = Yap_Parse();
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
RECOVER_MACHINE_REGS();
return t;

View File

@ -1771,6 +1771,21 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
serious = TRUE;
}
break;
case TYPE_ERROR_STRING:
{
int i;
Term ti[2];
i = strlen(tmpbuf);
ti[0] = MkAtomTerm(AtomString);
ti[1] = where;
nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti);
tp = tmpbuf+i;
psize -= i;
fun = FunctorError;
serious = TRUE;
}
break;
case TYPE_ERROR_UBYTE:
{
int i;

View File

@ -402,19 +402,19 @@ Yap_StringToTerm(char *s,Term *tp)
if (sno == NULL)
return FALSE;
TR_before_parse = TR;
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(sno, &tpos);
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(sno, FALSE, &tpos);
if (tokstart == NIL || tokstart->Tok == Ord (eot_tok)) {
if (tp) {
*tp = MkAtomTerm(AtomEOFBeforeEOT);
}
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
Sclose(sno);
return FALSE;
} else if (LOCAL_ErrorMessage) {
if (tp) {
*tp = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
}
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
Sclose(sno);
return FALSE;
}
@ -422,11 +422,11 @@ Yap_StringToTerm(char *s,Term *tp)
TR = TR_before_parse;
if (!t || LOCAL_ErrorMessage) {
GenerateSyntaxError(tp, tokstart, sno PASS_REGS);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
Sclose(sno);
return FALSE;
}
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
Sclose(sno);
return t;
}
@ -512,25 +512,25 @@ Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
if (st == NULL) {
return FALSE;
}
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(st, tpos);
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(st, FALSE, tpos);
if (LOCAL_ErrorMessage)
{
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
if (terror)
*terror = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return FALSE;
}
pt = Yap_Parse();
if (LOCAL_ErrorMessage || pt == (CELL)0) {
GenerateSyntaxError(terror, tokstart, st PASS_REGS);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return FALSE;
}
if (varnames) {
*varnames = Yap_VarNames(LOCAL_VarTable, TermNil);
if (!*varnames) {
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return FALSE;
}
}
@ -548,6 +548,7 @@ Yap_readTerm(void *st0, Term *tp, Term *varnames, Term *terror, Term *tpos)
Vars: ARG4
Pos: ARG5
Err: ARG6
Comments: ARG7
*/
static Int
do_read(IOSTREAM *inp_stream, int nargs USES_REGS)
@ -556,6 +557,8 @@ static Int
TokEntry *tokstart;
Term tmod = Deref(ARG3), OCurrentModule = CurrentModule, tpos;
extern void Yap_setCurrentSourceLocation(IOSTREAM **s);
Term tcomms = Deref(ARG7);
int store_comments = IsVarTerm(tcomms);
Yap_setCurrentSourceLocation(&inp_stream);
if (IsVarTerm(tmod)) {
@ -565,11 +568,6 @@ static Int
return FALSE;
}
LOCAL_Error_TYPE = YAP_NO_ERROR;
tpos = Yap_StreamPosition(inp_stream);
if (!Yap_unify(tpos,ARG5)) {
/* do this early so that we do not have to protect it in case of stack expansion */
return FALSE;
}
while (TRUE) {
CELL *old_H;
int64_t cpos = 0;
@ -583,10 +581,12 @@ static Int
while (TRUE) {
old_H = H;
tpos = Yap_StreamPosition(inp_stream);
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp_stream, &tpos);
LOCAL_Comments = TermNil;
LOCAL_CommentsNextChar = LOCAL_CommentsTail = NULL;
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp_stream, store_comments, &tpos);
if (LOCAL_Error_TYPE != YAP_NO_ERROR && seekable) {
H = old_H;
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
if (seekable) {
Sseek64(inp_stream, cpos, SIO_SEEK_SET);
}
@ -616,6 +616,10 @@ static Int
break;
}
}
if (!Yap_unify(tpos,ARG5)) {
/* do this early so that we do not have to protect it in case of stack expansion */
return FALSE;
}
LOCAL_Error_TYPE = YAP_NO_ERROR;
/* preserve value of H after scanning: otherwise we may lose strings
and floats */
@ -624,10 +628,10 @@ static Int
/* did we get the end of file from an abort? */
if (LOCAL_ErrorMessage &&
!strcmp(LOCAL_ErrorMessage,"Abort")) {
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return FALSE;
} else {
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return Yap_unify_constant(ARG2, MkAtomTerm (AtomEof))
&& Yap_unify_constant(ARG4, TermNil);
@ -670,7 +674,7 @@ static Int
}
if (ParserErrorStyle == QUIET_ON_PARSER_ERROR) {
/* just fail */
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return FALSE;
} else if (ParserErrorStyle == CONTINUE_ON_PARSER_ERROR) {
LOCAL_ErrorMessage = NULL;
@ -682,14 +686,14 @@ static Int
LOCAL_ErrorMessage = "SYNTAX ERROR";
if (ParserErrorStyle == EXCEPTION_ON_PARSER_ERROR) {
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
Yap_Error(SYNTAX_ERROR,terr,LOCAL_ErrorMessage);
return FALSE;
} else /* FAIL ON PARSER ERROR */ {
Term t[2];
t[0] = terr;
t[1] = MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage));
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return Yap_unify(ARG6,Yap_MkApplTerm(Yap_MkFunctor(AtomError,2),2,t));
}
}
@ -701,6 +705,8 @@ static Int
}
if (!Yap_unify(t, ARG2))
return FALSE;
if (store_comments && !Yap_unify(LOCAL_Comments, ARG7))
return FALSE;
if (AtomOfTerm (Deref (ARG1)) == AtomTrue) {
while (TRUE) {
CELL *old_H = H;
@ -721,10 +727,10 @@ static Int
TR = old_TR;
}
}
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return Yap_unify (v, ARG4);
} else {
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
return TRUE;
}
}
@ -732,7 +738,7 @@ static Int
static Int
p_read ( USES_REGS1 )
{ /* '$read'(+Flag,?Term,?Module,?Vars,-Pos,-Err) */
return do_read(NULL, 6 PASS_REGS);
return do_read(NULL, 7 PASS_REGS);
}
extern int Yap_getInputStream(Int, IOSTREAM **);
@ -743,10 +749,10 @@ p_read2 ( USES_REGS1 )
IOSTREAM *inp_stream;
Int out;
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG7) PASS_REGS), &inp_stream)) {
if (!Yap_getInputStream(Yap_InitSlot(Deref(ARG8) PASS_REGS), &inp_stream)) {
return(FALSE);
}
out = do_read(inp_stream, 7 PASS_REGS);
out = do_read(inp_stream, 8 PASS_REGS);
return out;
}
@ -1108,8 +1114,8 @@ Yap_InitIOPreds(void)
/* here the Input/Output predicates */
Yap_InitCPred ("$set_read_error_handler", 1, p_set_read_error_handler, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$get_read_error_handler", 1, p_get_read_error_handler, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$read", 6, p_read, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred ("$read", 7, p_read2, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred ("$read", 7, p_read, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred ("$read", 8, p_read2, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred ("$start_line", 1, p_startline, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$change_type_of_char", 2, p_change_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$type_of_char", 2, p_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag);

View File

@ -267,7 +267,7 @@ IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS)
{
int p;
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS);
OpEntry *opp = Yap_GetOpProp(op, POSFIX_OP PASS_REGS);
if (!opp)
return FALSE;
if (opp->OpModule &&

View File

@ -8,7 +8,7 @@
* *
**************************************************************************
* *
* File: %W% %G% *
* File: %W% %G% *
* Last rev: 22-1-03 *
* mods: *
* comments: Prolog's scanner *
@ -746,7 +746,7 @@ Yap_scan_num(IOSTREAM *inp)
ch = getchr(inp);
}
if (chtype(ch) != NU) {
Yap_clean_tokenizer(NULL, NULL, NULL);
Yap_clean_tokenizer(NULL, NULL, NULL, 0L);
return TermNil;
}
cherr = '\0';
@ -754,13 +754,68 @@ Yap_scan_num(IOSTREAM *inp)
return TermNil;
out = get_num(&ch, &cherr, inp, ptr, 4096, sign); /* */
PopScannerMemory(ptr, 4096);
Yap_clean_tokenizer(NULL, NULL, NULL);
Yap_clean_tokenizer(NULL, NULL, NULL, 0L);
if (LOCAL_ErrorMessage != NULL || ch != -1 || cherr)
return TermNil;
return out;
}
#define CHECK_SPACE() \
if (ASP-H < 1024) { \
LOCAL_ErrorMessage = "Stack Overflow"; \
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; \
LOCAL_Error_Size = 0L; \
if (p) \
p->Tok = Ord(kind = eot_tok); \
/* serious error now */ \
return l; \
}
static void
open_comment(int ch, IOSTREAM *inp_stream) {
CELL *h0 = H;
H += 5;
h0[0] = AbsAppl(h0+2);
h0[1] = TermNil;
if (!LOCAL_CommentsTail) {
/* first comment */
LOCAL_Comments = AbsPair(h0);
} else {
/* extra comment */
*LOCAL_CommentsTail = AbsPair(h0);
}
LOCAL_CommentsTail = h0+1;
h0 += 2;
h0[0] = (CELL)FunctorMinus;
h0[1] = Yap_StreamPosition(inp_stream);
h0[2] = TermNil;
LOCAL_CommentsNextChar = h0+2;
LOCAL_CommentsBuff = (wchar_t *)malloc(1024*sizeof(wchar_t));
LOCAL_CommentsBuffLim = 1024;
LOCAL_CommentsBuff[0] = ch;
LOCAL_CommentsBuffPos = 1;
}
static void
extend_comment(int ch) {
LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = ch;
LOCAL_CommentsBuffPos++;
if (LOCAL_CommentsBuffPos == LOCAL_CommentsBuffLim-1) {
LOCAL_CommentsBuff = (wchar_t *)realloc(LOCAL_CommentsBuff,sizeof(wchar_t)*(LOCAL_CommentsBuffLim+4096));
LOCAL_CommentsBuffLim += 4096;
}
}
static void
close_comment(void) {
LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = '\0';
*LOCAL_CommentsNextChar = Yap_MkBlobWideStringTerm(LOCAL_CommentsBuff, LOCAL_CommentsBuffPos);
free(LOCAL_CommentsBuff);
LOCAL_CommentsBuffLim = 0;
}
static wchar_t *
ch_to_wide(char *base, char *charp)
{
@ -791,7 +846,7 @@ ch_to_wide(char *base, char *charp)
}
TokEntry *
Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
{
CACHE_REGS
TokEntry *t, *l, *p;
@ -846,7 +901,27 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
switch (chtype(ch)) {
case CC:
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF);
if (store_comments) {
CHECK_SPACE();
open_comment(ch, inp_stream);
continue_comment:
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) {
CHECK_SPACE();
extend_comment(ch);
}
CHECK_SPACE();
extend_comment(ch);
if (chtype(ch) != EF) {
ch = getchr(inp_stream);
if (chtype(ch) == CC) {
extend_comment(ch);
goto continue_comment;
}
}
close_comment();
} else {
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF);
}
if (chtype(ch) != EF) {
/* blank space */
if (t == l) {
@ -854,15 +929,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
}
if (ASP-H < 1024) {
LOCAL_ErrorMessage = "Stack Overflow";
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = 0L;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
}
CHECK_SPACE();
*tposp = Yap_StreamPosition(inp_stream);
}
goto restart;
@ -947,15 +1014,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
/* serious error now */
return l;
}
if (ASP-H < 1024) {
LOCAL_ErrorMessage = "Stack Overflow";
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = 0L;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
}
CHECK_SPACE();
if ((t->TokInfo = get_num(&cha,&cherr,inp_stream,ptr,4096,1)) == 0L) {
if (p)
p->Tok = Ord(kind = eot_tok);
@ -1157,29 +1216,39 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
och = ch;
ch = getchr(inp_stream);
if (och == '/' && ch == '*') {
while ((och != '*' || ch != '/') && chtype(ch) != EF) {
och = ch;
ch = getchr(inp_stream);
if (store_comments) {
CHECK_SPACE();
open_comment('/', inp_stream);
while ((och != '*' || ch != '/') && chtype(ch) != EF) {
och = ch;
CHECK_SPACE();
extend_comment(ch);
ch = getchr(inp_stream);
}
if (chtype(ch) != EF) {
CHECK_SPACE();
extend_comment(ch);
}
close_comment();
} else {
while ((och != '*' || ch != '/') && chtype(ch) != EF) {
och = ch;
ch = getchr(inp_stream);
}
}
if (chtype(ch) == EF) {
t->Tok = Ord(kind = eot_tok);
}
ch = getchr(inp_stream);
if (t == l) {
/* we found a comment before reading characters */
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
} else {
/* leave comments */
ch = getchr(inp_stream);
if (t == l) {
/* we found a comment before reading characters */
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
}
CHECK_SPACE();
*tposp = Yap_StreamPosition(inp_stream);
}
if (ASP-H < 1024) {
LOCAL_ErrorMessage = "Stack Overflow";
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
LOCAL_Error_Size = 0L;
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
return l;
}
*tposp = Yap_StreamPosition(inp_stream);
}
goto restart;
}
@ -1189,8 +1258,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
if (chtype(ch) == CC)
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF);
t->Tok = Ord(kind = eot_tok);
}
else {
} else {
TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE;
charp = TokImage;
*charp++ = och;
@ -1293,7 +1361,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
}
void
Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable)
Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable, Term commentable)
{
CACHE_REGS
struct scanner_extra_alloc *ptr = LOCAL_ScannerExtraBlocks;
@ -1302,5 +1370,7 @@ Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartab
free(ptr);
ptr = next;
}
LOCAL_Comments = TermNil;
LOCAL_CommentsNextChar = LOCAL_CommentsTail = NULL;
}

View File

@ -1065,6 +1065,263 @@ p_name( USES_REGS1 )
}
static Int
p_string_to_atom( USES_REGS1 )
{ /* name(?Atomic,?String) */
char *String; /* alloc temp space on trail */
Term t = Deref(ARG1), NewT, AtomNameT = Deref(ARG2);
restart_aux:
if (!IsVarTerm(t)) {
Atom at;
do {
if (Yap_IsWideStringTerm(t)) {
at = Yap_LookupWideAtom(Yap_BlobWideStringOfTerm(t));
} else if (Yap_IsStringTerm(t)) {
at = Yap_LookupAtom(Yap_BlobStringOfTerm(t));
} else if (IsAtomTerm(t)) {
return Yap_unify(t, ARG2);
} else if (IsIntTerm(t)) {
char *String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, IntOfTerm(t));
at = Yap_LookupAtom(String);
} else if (IsFloatTerm(t)) {
char *String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, "%f", FloatOfTerm(t));
at = Yap_LookupAtom(String);
} else if (IsLongIntTerm(t)) {
char *String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, LongIntOfTerm(t));
at = Yap_LookupAtom(String);
#if USE_GMP
} else if (IsBigIntTerm(t)) {
String = Yap_PreAllocCodeSpace();
if (!Yap_gmp_to_string(t, String, ((char *)AuxSp-String)-1024, 10 ))
goto expand_auxsp;
at = Yap_LookupAtom(String);
#endif
} else {
Yap_Error(TYPE_ERROR_ATOMIC,AtomNameT,"name/2");
return FALSE;
}
if (at != NIL)
break;
if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, ARG2, "generating atom from string in string_to_atom/2");
return FALSE;
}
t = Deref(ARG1);
} while(TRUE);
return Yap_unify_constant(ARG2, MkAtomTerm(at));
}
if (IsVarTerm(AtomNameT)) {
Yap_Error(INSTANTIATION_ERROR, ARG1, "string_to_atom/2");
return(FALSE);
}
else if (IsAtomTerm(AtomNameT)) {
Atom at = AtomOfTerm(AtomNameT);
if (IsWideAtom(at)) {
wchar_t *s = RepAtom(at)->WStrOfAE;
NewT = Yap_MkBlobWideStringTerm(s, wcslen(s));
return Yap_unify(NewT, ARG1);
} else
String = RepAtom(at)->StrOfAE;
} else if (IsIntTerm(AtomNameT)) {
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, IntOfTerm(AtomNameT));
} else if (IsFloatTerm(AtomNameT)) {
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, "%f", FloatOfTerm(AtomNameT));
} else if (IsLongIntTerm(AtomNameT)) {
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, LongIntOfTerm(AtomNameT));
#if USE_GMP
} else if (IsBigIntTerm(AtomNameT)) {
String = Yap_PreAllocCodeSpace();
if (!Yap_gmp_to_string(AtomNameT, String, ((char *)AuxSp-String)-1024, 10 ))
goto expand_auxsp;
#endif
} else {
Yap_Error(TYPE_ERROR_ATOMIC,AtomNameT,"name/2");
return FALSE;
}
NewT = Yap_MkBlobStringTerm(String, strlen(String));
return Yap_unify(NewT, ARG1);
/* error handling */
expand_auxsp:
String = Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE);
if (String + 1024 > (char *)AuxSp) {
/* crash in flames */
Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "allocating temp space in string_to_atom/2");
return FALSE;
}
AtomNameT = Deref(ARG1);
t = Deref(ARG2);
goto restart_aux;
}
static Int
p_string_to_list( USES_REGS1 )
{ /* name(?Atomic,?String) */
char *String; /* alloc temp space on trail */
Term t = Deref(ARG1), NewT, NameT = Deref(ARG2);
restart_aux:
if (!IsVarTerm(t)) {
Term StringT;
if (Yap_IsWideStringTerm(t)) {
StringT = Yap_WideStringToList(Yap_BlobWideStringOfTerm(t));
} else if (Yap_IsStringTerm(t)) {
StringT = Yap_StringToList(Yap_BlobStringOfTerm(t));
} else if (IsAtomTerm(t)) {
Atom at = AtomOfTerm(t);
if (IsWideAtom(at))
StringT = Yap_WideStringToList(RepAtom(at)->WStrOfAE);
else
StringT = Yap_StringToList(RepAtom(at)->StrOfAE);
} else if (IsIntTerm(t)) {
char *String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, IntOfTerm(t));
StringT = Yap_StringToList(String);
} else if (IsFloatTerm(t)) {
char *String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, "%f", FloatOfTerm(t));
StringT = Yap_StringToList(String);
} else if (IsLongIntTerm(t)) {
char *String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, LongIntOfTerm(t));
StringT = Yap_StringToList(String);
#if USE_GMP
} else if (IsBigIntTerm(t)) {
String = Yap_PreAllocCodeSpace();
if (!Yap_gmp_to_string(t, String, ((char *)AuxSp-String)-1024, 10 ))
goto expand_auxsp;
StringT = Yap_StringToList(String);
#endif
} else {
Yap_Error(TYPE_ERROR_ATOMIC,NameT,"string_to_list/2");
return FALSE;
}
return Yap_unify_constant(ARG2, StringT);
}
if (!IsVarTerm(NameT)) {
if (IsAtomTerm(NameT)) {
Atom at = AtomOfTerm(NameT);
if (IsWideAtom(at)) {
wchar_t *s = RepAtom(at)->WStrOfAE;
NewT = Yap_MkBlobWideStringTerm(s, wcslen(s));
return Yap_unify(NewT, ARG1);
} else
String = RepAtom(at)->StrOfAE;
} else if (IsIntTerm(NameT)) {
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, IntOfTerm(NameT));
} else if (IsFloatTerm(NameT)) {
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, "%f", FloatOfTerm(NameT));
} else if (IsLongIntTerm(NameT)) {
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
sprintf(String, Int_FORMAT, LongIntOfTerm(NameT));
#if USE_GMP
} else if (IsBigIntTerm(NameT)) {
String = Yap_PreAllocCodeSpace();
if (!Yap_gmp_to_string(NameT, String, ((char *)AuxSp-String)-1024, 10 ))
goto expand_auxsp;
#endif
} else {
wchar_t *WString = (wchar_t *)Yap_PreAllocCodeSpace();
wchar_t *ws = WString;
while (IsPairTerm(NameT)) {
Term Head = HeadOfTerm(NameT);
Int i;
if (IsVarTerm(Head)) {
Yap_Error(INSTANTIATION_ERROR,Head,"string_codes/2");
return FALSE;
}
if (!IsIntegerTerm(Head)) {
Yap_Error(TYPE_ERROR_INTEGER,Head,"string_codes/2");
return FALSE;
}
i = IntegerOfTerm(Head);
if (i < 0) {
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,Head,"string_codes/2");
return FALSE;
}
if (ws > (wchar_t *)AuxSp-1024) {
goto expand_auxsp;
}
*ws++ = i;
NameT = TailOfTerm(NameT);
}
if (IsVarTerm(NameT)) {
Yap_Error(INSTANTIATION_ERROR,ARG2,"string_codes/2");
return FALSE;
}
if (NameT != TermNil) {
Yap_Error(TYPE_ERROR_LIST,ARG2,"string_codes/2");
return FALSE;
}
*ws++ = '\0';
NewT = Yap_MkBlobWideStringTerm(WString, wcslen(WString));
return Yap_unify(NewT, ARG1);
/* **** */
}
NewT = Yap_MkBlobStringTerm(String, sizeof(String));
return Yap_unify(NewT, ARG1);
}
Yap_Error(INSTANTIATION_ERROR, ARG1, "string_to_list/2");
return(FALSE);
/* error handling */
expand_auxsp:
String = Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE);
if (String + 1024 > (char *)AuxSp) {
/* crash in flames */
Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "allocating temp space in string_to_list/2");
return FALSE;
}
NameT = Deref(ARG1);
t = Deref(ARG2);
goto restart_aux;
}
static Int
p_atom_chars( USES_REGS1 )
{
@ -4126,6 +4383,8 @@ Yap_InitCPreds(void)
/* general purpose */
Yap_InitCPred("$opdec", 4, p_opdec, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("name", 2, p_name, 0);
Yap_InitCPred("string_to_atom", 2, p_string_to_atom, 0);
Yap_InitCPred("string_to_list", 2, p_string_to_list, 0);
Yap_InitCPred("char_code", 2, p_char_code, SafePredFlag);
Yap_InitCPred("atom_chars", 2, p_atom_chars, 0);
Yap_InitCPred("atom_codes", 2, p_atom_codes, 0);
@ -4294,5 +4553,3 @@ Yap_InitCPreds(void)
CurrentModule = cm;
}
}

View File

@ -26,3 +26,4 @@ typedef struct VARSTRUCT {
struct VARSTRUCT *VarLeft, *VarRight;
char VarRep[1];
} VarEntry;

View File

@ -547,6 +547,7 @@ typedef enum
TYPE_ERROR_NUMBER,
TYPE_ERROR_PREDICATE_INDICATOR,
TYPE_ERROR_PTR,
TYPE_ERROR_STRING,
TYPE_ERROR_UBYTE,
TYPE_ERROR_UCHAR,
TYPE_ERROR_VARIABLE,

View File

@ -260,6 +260,18 @@
#define REMOTE_VarTable(wid) REMOTE(wid)->VarTable_
#define LOCAL_AnonVarTable LOCAL->AnonVarTable_
#define REMOTE_AnonVarTable(wid) REMOTE(wid)->AnonVarTable_
#define LOCAL_Comments LOCAL->Comments_
#define REMOTE_Comments(wid) REMOTE(wid)->Comments_
#define LOCAL_CommentsTail LOCAL->CommentsTail_
#define REMOTE_CommentsTail(wid) REMOTE(wid)->CommentsTail_
#define LOCAL_CommentsNextChar LOCAL->CommentsNextChar_
#define REMOTE_CommentsNextChar(wid) REMOTE(wid)->CommentsNextChar_
#define LOCAL_CommentsBuff LOCAL->CommentsBuff_
#define REMOTE_CommentsBuff(wid) REMOTE(wid)->CommentsBuff_
#define LOCAL_CommentsBuffPos LOCAL->CommentsBuffPos_
#define REMOTE_CommentsBuffPos(wid) REMOTE(wid)->CommentsBuffPos_
#define LOCAL_CommentsBuffLim LOCAL->CommentsBuffLim_
#define REMOTE_CommentsBuffLim(wid) REMOTE(wid)->CommentsBuffLim_
#define LOCAL_RestartEnv LOCAL->RestartEnv_
#define REMOTE_RestartEnv(wid) REMOTE(wid)->RestartEnv_
#define LOCAL_FileNameBuf LOCAL->FileNameBuf_

View File

@ -147,6 +147,12 @@ typedef struct worker_local {
TokEntry* toktide_;
VarEntry* VarTable_;
VarEntry* AnonVarTable_;
Term Comments_;
CELL* CommentsTail_;
CELL* CommentsNextChar_;
wchar_t* CommentsBuff_;
size_t CommentsBuffPos_;
size_t CommentsBuffLim_;
sigjmp_buf RestartEnv_;
char FileNameBuf_[YAP_FILENAME_MAX];
char FileNameBuf2_[YAP_FILENAME_MAX];

View File

@ -151,6 +151,12 @@ static void InitWorker(int wid) {
REMOTE_PrologMode(wid) = BootMode;
REMOTE_CritLocks(wid) = 0;

View File

@ -154,6 +154,12 @@ static void RestoreWorker(int wid USES_REGS) {
#ifdef ANALYST

View File

@ -271,8 +271,8 @@ VarEntry STD_PROTO(*Yap_LookupVar,(char *));
Term STD_PROTO(Yap_VarNames,(VarEntry *,Term));
/* routines in scanner.c */
TokEntry STD_PROTO(*Yap_tokenizer,(struct io_stream *, Term *));
void STD_PROTO(Yap_clean_tokenizer,(TokEntry *, VarEntry *, VarEntry *));
TokEntry STD_PROTO(*Yap_tokenizer,(struct io_stream *, int, Term *));
void STD_PROTO(Yap_clean_tokenizer,(TokEntry *, VarEntry *, VarEntry *,Term));
Term STD_PROTO(Yap_scan_num,(struct io_stream *));
char STD_PROTO(*Yap_AllocScannerMemory,(unsigned int));

View File

@ -28,6 +28,7 @@ PROGRAMS= $(srcdir)/base64.pl \
$(srcdir)/broadcast.pl \
$(srcdir)/date.pl \
$(srcdir)/debug.pl \
$(srcdir)/main.pl \
$(srcdir)/maplist.pl \
$(srcdir)/nb_set.pl \
$(srcdir)/operators.pl \
@ -41,7 +42,8 @@ PROGRAMS= $(srcdir)/base64.pl \
$(srcdir)/shlib.pl \
$(srcdir)/thread_pool.pl \
$(srcdir)/url.pl \
$(srcdir)/utf8.pl
$(srcdir)/utf8.pl \
$(srcdir)/www_browser.pl
install: $(PROGRAMS)

114
LGPL/main.pl Normal file
View File

@ -0,0 +1,114 @@
/* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@cs.vu.nl
WWW: http://www.swi-prolog.org
Copyright (C): 1985-2011, University of Amsterdam
VU University Amsterdam
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
As a special exception, if you link this library with other files,
compiled with a Free Software compiler, to produce an executable, this
library does not by itself cause the resulting executable to be covered
by the GNU General Public License. This exception does not however
invalidate any other reasons why the executable file might be covered by
the GNU General Public License.
*/
:- module(prolog_main,
[ main/0
]).
:- use_module(library(lists)).
/** <module> Provide entry point for scripts
This library is intended for supporting PrologScript on Unix using the
=|#!|= magic sequence for scripts using commandline options. The entry
point main/0 calls the user-supplied predicate main/1 passing a list of
commandline options. Below is `echo' in Prolog (adjust /usr/bin/pl to
where SWI-Prolog is installed)
==
#!/usr/bin/pl -q -g main -s
main(Argv) :-
echo(Argv).
echo([]) :- nl.
echo([Last]) :- !,
write(Last), nl.
echo([H|T]) :-
write(H), write(' '),
echo(T).
==
@see XPCE users should have a look at library(pce_main), which
starts the GUI and processes events until all windows have gone.
*/
:- module_transparent
main/0.
%% main
%
% Call main/1 using the passed command-line arguments.
main :-
context_module(M),
set_signals,
argv(Av),
run_main(M, Av).
%% run_main(+Module, +Args)
%
% Run the main routine, guarding for exceptions and failure of the
% main/1 routine
run_main(Module, Av) :-
( catch(call(Module:main, Av), E, true)
-> ( var(E)
-> halt(0)
; print_message(error, E),
halt(1)
)
; print_message(error, goal_failed(main(Av))),
halt(1)
).
argv(Av) :-
current_prolog_flag(argv, Argv),
( append(_, [--|Av], Argv)
-> true
; current_prolog_flag(dialect, yap)
-> Argv = Av
; current_prolog_flag(windows, true)
-> Argv = [_Prog|Av]
; Av = []
).
set_signals :-
on_signal(int, _, interrupt).
%% interrupt(+Signal)
%
% We received an interrupt. This handler is installed using
% on_signal/3.
interrupt(_Sig) :-
halt(1).

View File

@ -12,7 +12,7 @@ EROOTDIR = @exec_prefix@
LIBDIR=@libdir@/Yap
#
#
CC=@CC@
CC=@CC@ -municode -DUNICODE -D_UNICODE
CPPFLAGS=@CPPFLAGS@
CFLAGS= @CFLAGS@ $(DEFS) $(CPPFLAGS) -I$(srcdir) -DRLC_VENDOR="\"YAP\""
#

View File

@ -3239,7 +3239,7 @@ rlc_write(rlc_console c, TCHAR *buf, size_t count)
return -1;
for(s=buf, e=&buf[count]; s<e; s++)
{ if ( *s == '\n' )
{ if ( *s == '\n' )
b->promptlen = 0;
else if ( b->promptlen < MAXPROMPT-1 )
b->promptbuf[b->promptlen++] = *s;

0
LGPL/swi_console/edit.c Normal file → Executable file
View File

216
LGPL/www_browser.pl Normal file
View File

@ -0,0 +1,216 @@
/* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@cs.vu.nl
WWW: http://www.swi-prolog.org
Copyright (C): 1985-2011, University of Amsterdam
VU University Amsterdam
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
As a special exception, if you link this library with other files,
compiled with a Free Software compiler, to produce an executable, this
library does not by itself cause the resulting executable to be covered
by the GNU General Public License. This exception does not however
invalidate any other reasons why the executable file might be covered by
the GNU General Public License.
*/
:- module(www_browser,
[ www_open_url/1, % +UrlOrSpec
expand_url_path/2 % +Spec, -URL
]).
:- use_module(library(lists)).
:- use_module(library(readutil)).
:- multifile
known_browser/2.
%% www_open_url(+Url)
%
% Open URL in running version of the users' browser or start a new
% browser. This predicate tries the following steps:
%
% 1. If a prolog flag (see set_prolog_flag/2) =browser= is set
% or the environment =BROWSER= and this is the name of a known
% executable, use this. This uses www_open_url/2.
%
% 2. On Windows, use win_shell(open, URL)
%
% 3. Find a generic `open' comment. Candidates are =open=,
% =|gnome-open|=, =kfmclient=.
%
% 4. Try to find a known browser.
%
% @tbd Figure out the right tool in step 3 as it is not
% uncommon that multiple are installed.
www_open_url(Spec) :- % user configured
( current_prolog_flag(browser, Browser)
; getenv('BROWSER', Browser)
),
has_command(Browser), !,
expand_url_path(Spec, URL),
www_open_url(Browser, URL).
:- if(current_predicate(win_shell/2)).
www_open_url(Spec) :- % Windows shell
expand_url_path(Spec, URL),
win_shell(open, URL).
:- endif.
www_open_url(Spec) :- % Unix `open document'
open_command(Open),
has_command(Open), !,
expand_url_path(Spec, URL),
format(string(Cmd), '~w "~w"', [Open, URL]),
shell(Cmd).
www_open_url(Spec) :- % KDE client
has_command(kfmclient), !,
expand_url_path(Spec, URL),
format(string(Cmd), 'kfmclient openURL "~w"', [URL]),
shell(Cmd).
www_open_url(Spec) :- % something we know
known_browser(Browser, _),
has_command(Browser), !,
expand_url_path(Spec, URL),
www_open_url(Browser, URL).
open_command('gnome-open').
open_command(open).
%% www_open_url(+Browser, +URL) is det.
%
% Open a page using a browser. Preferably we use an existing
% browser to to the job. Currently only supports browsers with a
% netscape compatible remote interface.
%
% @see http://www.mozilla.org/unix/remote.html
www_open_url(Browser, URL) :-
compatible(Browser, netscape),
netscape_remote(Browser, 'ping()', []), !,
netscape_remote(Browser, 'openURL(~w,new-window)', [URL]).
www_open_url(Browser, URL) :-
format(string(Cmd), '"~w" "~w" &', [Browser, URL]),
shell(Cmd).
%% netscape_remote(+Browser, +Format, +Args) is semidet.
%
% Execute netscape remote command using =|-remote|=. Create the
% remote command using format/3 from Format and Args.
%
% @bug At least firefox gives always 0 exit code on -remote,
% so we must check the error message. Grrrr.
netscape_remote(Browser, Fmt, Args) :-
format(string(RCmd), Fmt, Args),
format(string(Cmd), '"~w" -remote "~w" 2>&1', [Browser, RCmd]),
open(pipe(Cmd), read, In),
call_cleanup(read_stream_to_codes(In, Codes),
close(In)),
( append("Error:", _, Codes)
-> !, fail
; true
).
compatible(Browser, With) :-
file_base_name(Browser, Base),
known_browser(Base, With).
%% known_browser(+FileBaseName, -Compatible)
%
% True if browser FileBaseName has a remote protocol compatible to
% Compatible.
known_browser(firefox, netscape).
known_browser(mozilla, netscape).
known_browser(netscape, netscape).
known_browser(konqueror, -).
known_browser(opera, -).
%% has_command(+Command)
%
% Succeeds if Command is in $PATH. Works for Unix systems. For
% Windows we have to test for executable extensions.
:- dynamic
command_cache/2.
:- volatile
command_cache/2.
has_command(Command) :-
command_cache(Command, Path), !,
Path \== (-).
has_command(Command) :-
( getenv('PATH', Path),
( current_prolog_flag(windows, true)
-> Sep = (;)
; Sep = (:)
),
atomic_list_concat(Parts, Sep, Path),
member(Part, Parts),
prolog_to_os_filename(PlPart, Part),
atomic_list_concat([PlPart, Command], /, Exe),
access_file(Exe, execute)
-> assert(command_cache(Command, Exe))
; assert(command_cache(Command, -)),
fail
).
/*******************************
* NET PATHS *
*******************************/
%% url_path(+Alias, -Expansion) is nondet.
%
% Define URL path aliases. This multifile predicate is defined in
% module =user=. Expansion is either a URL, or a term Alias(Sub).
:- multifile
user:url_path/2.
user:url_path(swipl, 'http://www.swi-prolog.org').
user:url_path(swipl_faq, swipl('FAQ')).
user:url_path(swipl_man, swipl('pldoc/index.html')).
user:url_path(swipl_mail, swipl('Mailinglist.html')).
user:url_path(swipl_download, swipl('Download.html')).
user:url_path(swipl_bugs, swipl('bugzilla')).
user:url_path(swipl_quick, swipl('man/quickstart.html')).
%% expand_url_path(+Spec, -URL)
%
% Expand URL specifications similar to absolute_file_name/3. The
% predicate url_path/2 plays the role of file_search_path/2.
expand_url_path(URL, URL) :-
atomic(URL), !. % Allow atom and string
expand_url_path(Spec, URL) :-
Spec =.. [Path, Local],
( user:url_path(Path, Spec2)
-> expand_url_path(Spec2, URL0),
( Local == '.'
-> URL = URL0
; sub_atom(Local, 0, _, _, #)
-> atom_concat(URL0, Local, URL)
; atomic_list_concat([URL0, Local], /, URL)
)
; throw(error(existence_error(url_path, Path), expand_url_path/2))
).

View File

@ -325,6 +325,7 @@ PL_SOURCES= \
$(srcdir)/pl/udi.yap \
$(srcdir)/pl/utils.yap \
$(srcdir)/pl/history.pl \
$(srcdir)/pl/swi.yap \
$(srcdir)/pl/yapor.yap $(srcdir)/pl/yio.yap
YAPDOCS=$(srcdir)/docs/yap.tex $(srcdir)/docs/chr.tex \
@ -565,13 +566,13 @@ pl-nt.o: $(srcdir)/packages/PLStream/pl-nt.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/packages/PLStream @EXTRA_INCLUDES_FOR_WIN32@ $(srcdir)/packages/PLStream/pl-nt.c -o $@
pl-ntcon.o: $(srcdir)/console/LGPL/pl-ntcon.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/console/LGPL/pl-ntcon.c -o $@
$(CC) -municode -DUNICODE -D_UNICODE -c $(CFLAGS) -DPL_CONSOLE=1 -I$(srcdir)/include $(srcdir)/console/LGPL/pl-ntcon.c -o $@
pl-ntconsole.o: $(srcdir)/console/LGPL/pl-ntconsole.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir) -I$(srcdir)/include -I$(srcdir)/packages/PLStream @EXTRA_INCLUDES_FOR_WIN32@ $(srcdir)/console/LGPL/pl-ntconsole.c -o $@
$(CC) -municode -DUNICODE -D_UNICODE -c $(CFLAGS) -DPL_CONSOLE=1 -I$(srcdir) -I$(srcdir)/include -I$(srcdir)/packages/PLStream @EXTRA_INCLUDES_FOR_WIN32@ $(srcdir)/console/LGPL/pl-ntconsole.c -o $@
pl-ntmain.o: $(srcdir)/console/LGPL/pl-ntmain.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream @EXTRA_INCLUDES_FOR_WIN32@ $(srcdir)/console/LGPL/pl-ntmain.c -o $@
$(CC) -municode -DUNICODE -D_UNICODE -c $(CFLAGS) -DPL_CONSOLE=1 -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream @EXTRA_INCLUDES_FOR_WIN32@ $(srcdir)/console/LGPL/pl-ntmain.c -o $@
pl-buffer.o: $(srcdir)/packages/PLStream/pl-buffer.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream @EXTRA_INCLUDES_FOR_WIN32@ $(srcdir)/packages/PLStream/pl-buffer.c -o $@
@ -682,13 +683,14 @@ all: startup.yss
@INSTALL_DLLS@ (cd library/tries; $(MAKE))
@INSTALL_DLLS@ (cd packages/clib; $(MAKE))
@INSTALL_DLLS@ (cd packages/http; $(MAKE))
# @INSTALL_DLLS@ (cd packages/pldoc; $(MAKE))
@INSTALL_DLLS@ (cd packages/plunit; $(MAKE))
@INSTALL_DLLS@ (cd packages/R; $(MAKE))
@INSTALL_DLLS@ (cd packages/RDF; $(MAKE))
@INSTALL_DLLS@ (cd packages/semweb; $(MAKE))
@INSTALL_DLLS@ (cd packages/sgml; $(MAKE))
@INSTALL_YAPR@ (cd packages/YapR; $(MAKE))
@USE_MINISAT@ (cd packages/CLPBN/clpbn/bp ; $(MAKE))
# @USE_MINISAT@ (cd packages/CLPBN/clpbn/bp ; $(MAKE))
@USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE))
@INSTALL_DLLS@ (cd packages/zlib; $(MAKE))
@ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE))
@ -703,9 +705,11 @@ startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES)
yap@EXEC_SUFFIX@: $(HEADERS) yap.o @YAPLIB@
$(MPI_CC) $(EXECUTABLE_CFLAGS) $(LDFLAGS) -o yap yap.o @YAPLIB@ $(LIBS) @MPI_LIBS@
plyap@EXEC_SUFFIX@: $(PLCONS_OBJECTS) $(HEADERS) @YAPLIB@ LGPL/swi_console/plterm.dll
plyap: pl-yap@EXEC_SUFFIX@
pl-yap@EXEC_SUFFIX@: $(PLCONS_OBJECTS) $(HEADERS) @YAPLIB@ LGPL/swi_console/plterm.dll
(cd LGPL/swi_console; $(MAKE))
$(MPI_CC) $(EXECUTABLE_CFLAGS) $(LDFLAGS) -o pl-yap $(PLCONS_OBJECTS) LGPL/swi_console/plterm.dll @YAPLIB@ $(LIBS) @MPI_LIBS@
$(MPI_CC) -municode -DUNICODE -D_UNICODE $(EXECUTABLE_CFLAGS) $(LDFLAGS) -Wl,-subsystem,windows -o pl-yap $(PLCONS_OBJECTS) LGPL/swi_console/plterm.dll @YAPLIB@ $(LIBS) @MPI_LIBS@
libYap.a: $(LIB_OBJECTS)
-rm -f libYap.a
@ -741,13 +745,14 @@ install_unix: startup.yss libYap.a
@INSTALL_DLLS@ (cd library/tries; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/clib; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/http; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/pldoc; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/plunit; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/sgml; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/R; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/RDF; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/semweb; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/zlib; $(MAKE) @ZLIB_INSTALL@)
@INSTALL_DLLS@ (cd packages/CLPBN/clpbn/bp ; $(MAKE) install)
# @INSTALL_DLLS@ (cd packages/CLPBN/clpbn/bp ; $(MAKE) install)
@USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE) install)
@INSTALL_MATLAB@ (cd library/matlab; $(MAKE) install)
@INSTALL_YAPR@ (cd packages/YapR; $(MAKE) install)
@ -794,6 +799,7 @@ install_win32: startup.yss
@INSTALL_YAPR@ (cd packages/YapR; $(MAKE) install)
(cd library/tries; $(MAKE) install)
(cd packages/clib; $(MAKE) install)
(cd packages/pldoc; $(MAKE) install)
(cd packages/plunit; $(MAKE) install)
(cd packages/http; $(MAKE) install)
(cd packages/R; $(MAKE) install)
@ -802,7 +808,7 @@ install_win32: startup.yss
(cd packages/semweb; $(MAKE) install)
(cd packages/zlib; $(MAKE) @ZLIB_INSTALL@)
(cd packages/CLPBN ; $(MAKE) install)
(cd packages/CLPBN/clpbn/bp ; $(MAKE) install)
# (cd packages/CLPBN/clpbn/bp ; $(MAKE) install)
@ENABLE_JPL@ (cd packages/jpl ; $(MAKE) install)
@USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE) install)
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install)
@ -853,6 +859,7 @@ clean: clean_docs
@INSTALL_DLLS@ (cd library/tries; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/clib; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/http; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/pldoc; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/plunit; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/R; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/RDF; $(MAKE) clean)
@ -860,7 +867,7 @@ clean: clean_docs
@INSTALL_DLLS@ (cd packages/sgml; $(MAKE) clean)
@INSTALL_YAPR@ (cd packages/YapR; $(MAKE) clean)
@USE_MINISAT@ (cd packages/swi-minisat2; $(MAKE) clean)
@USE_MINISAT@ (cd packages/CLPBN/clpbn/bp; $(MAKE) clean)
# @USE_MINISAT@ (cd packages/CLPBN/clpbn/bp; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/zlib; $(MAKE) clean)
@ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) clean)
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) clean)

534
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -2042,6 +2042,7 @@ mkdir -p packages/jpl/examples/java
mkdir -p packages/meld
mkdir -p packages/PLStream
mkdir -p packages/PLStream/libtai
mkdir -p packages/pldoc
mkdir -p packages/plunit
mkdir -p packages/ProbLog
mkdir -p packages/ProbLog/simplecudd
@ -2080,6 +2081,7 @@ AC_CONFIG_FILES([packages/cplint/approx/simplecuddLPADs/Makefile])
AC_CONFIG_FILES([packages/http/Makefile])
AC_CONFIG_FILES([packages/meld/Makefile])
AC_CONFIG_FILES([packages/PLStream/libtai/Makefile])
AC_CONFIG_FILES([packages/pldoc/Makefile])
AC_CONFIG_FILES([packages/plunit/Makefile])
AC_CONFIG_FILES([packages/ProbLog/Makefile ])
AC_CONFIG_FILES([packages/R/Makefile])

View File

@ -69,7 +69,7 @@ consoleHandlerRoutine(DWORD id)
*******************************/
int
main(int argc, char **argv)
APP_main(int argc, char **argv)
{
#if O_CTRLC
main_thread_id = GetCurrentThreadId();

View File

@ -1,4 +1,4 @@
/* $Id$
/* $Id$
Part of SWI-Prolog

View File

@ -22,9 +22,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define _UNICODE 1
#define UNICODE 1
#include <windows.h>
#include <tchar.h>
#include <malloc.h>
@ -997,6 +994,9 @@ win32main(rlc_console c, int argc, TCHAR **argv)
set_window_title(c);
rlc_bind_terminal(c);
if ( !PL_initialise(argc, av) )
PL_halt(1);
PL_register_extensions_in_module("system", extensions);
install_readline(c);
PL_action(PL_ACTION_GUIAPP, TRUE);
@ -1032,9 +1032,6 @@ win32main(rlc_console c, int argc, TCHAR **argv)
}
av[i] = NULL;
if ( !PL_initialise(argc, av) )
PL_halt(1);
rlc_bind_terminal(c);
PL_halt(PL_toplevel() ? 0 : 1);
@ -1047,10 +1044,10 @@ And this is the real application's main as Windows sees it. See
console.c for further details.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
int PASCAL
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{ LPTSTR cmdline;
int WINAPI
wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPWSTR lpszCmdLine, int nCmdShow)
{ LPWSTR cmdline;
InitializeCriticalSection(&mutex);

View File

@ -100,3 +100,14 @@ with_stream(Stream, Goal) :-
current_output(Stream),
call(Goal).
%% read_from_chars(+Codes, -Term) is det.
%
% Read Codes into Term.
%
% @compat The SWI-Prolog version does not require Codes to end
% in a full-stop.
read_from_chars("", end_of_file) :- !.
read_from_chars(List, Term) :-
atom_to_term(List, Term, _).

View File

@ -10,7 +10,6 @@
chdir/1,
compile_aux_clauses/1,
convert_time/2,
'$set_source_module'/2,
'$declare_module'/5,
'$set_predicate_attribute'/3,
stamp_date_time/3,
@ -183,25 +182,6 @@ compile_aux_clauses([Cl|Cls]) :-
assert_static(M:Cl),
compile_aux_clauses(Cls).
'$set_source_module'(Source0, SourceF) :-
prolog_load_context(module, Source0), !,
module(SourceF).
'$set_source_module'(Source0, SourceF) :-
current_module(Source0, SourceF).
/** '$declare_module'(+Module, +Super, +File, +Line, +Redefine) is det.
Start a new (source-)module
@param Module is the name of the module to declare
@param File is the canonical name of the file from which the module
is loaded
@param Line is the line-number of the :- module/2 directive.
@param Redefine If =true=, allow associating the module to a new file
*/
'$declare_module'(Name, Context, _, _, _) :-
add_import_module(Name, Context, start).
'$set_predicate_attribute'(_, _, _).
flag(Key, Old, New) :-

View File

@ -1176,7 +1176,7 @@ X_API int PL_unify_int64(term_t t, int64_t n)
iterm = YAP_MkBigNumTerm((void *)&rop);
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS),iterm);
#else
fprintf(stderr,"Error: please install GM\n");
fprintf(stderr,"Error in PL_unify_int64: please install GMP\n");
return FALSE;
#endif

View File

@ -12,7 +12,8 @@
flatten/2,
last/2,
list_concat/2,
max_list/2,
max_list/2,
list_to_set/2,
member/2,
memberchk/2,
min_list/2,
@ -415,3 +416,27 @@ subtract([E|T], D, R) :-
subtract(T, D, R).
subtract([H|T], D, [H|R]) :-
subtract(T, D, R).
%% list_to_set(+List, ?Set) is det.
%
% True when Set has the same element as List in the same order.
% The left-most copy of the duplicate is retained. The complexity
% of this operation is |List|^2.
%
% @see sort/2.
list_to_set(List, Set) :-
list_to_set_(List, Set0),
Set = Set0.
list_to_set_([], R) :-
close_list(R).
list_to_set_([H|T], R) :-
memberchk(H, R), !,
list_to_set_(T, R).
close_list([]) :- !.
close_list([_|T]) :-
close_list(T).

179
man/doc2tex Executable file
View File

@ -0,0 +1,179 @@
#!/usr/bin/env perl
sub printTeX
{ s/`([@\w]+)\s*<->([a-z]\w*)/\\index{\l\1,\\both{\2}}`\\classboth{\1}{\2}/g;
s/`([@\w]+)\s*<-([a-z]\w*)/\\index{\l\1,\\get{\2}}`\\classget{\1}{\2}/g;
s/`([@\w]+)\s*->([a-z]\w*)/\\index{\l\1,\\send{\2}}`\\classsend{\1}{\2}/g;
s/<->([a-z]\w*)/\\both{\1}/g;
s/<-([a-z]\w*)/\\get{\1}/g;
s/->([a-z]\w*)/\\send{\1}/g;
s/(^|\s|\()([a-z]\w+)\/((\d+|\[\d+(-|,)\d+\]))/\1\\index{\2\/\3}\\predref{\2}{\3}/g;
s/(\s+|^)([a-z]\w+)\/\/((\d+|\[\d+(-|,)\d+\]))/\1\\index{\2\/\/\3}\\dcgref{\2}{\3}/g;
s/(\w\.\w)\.(\s+[a-z])/\1.\\\2/g;
s/(^|[^\w}\\])@([a-z]\w*)/\1\\index{@\2}\\objectname{\2}/g;
s/(^|[^'])<(\w[-~\w]*)>/\1\\bnfmeta{\2}/g;
s/\\class{([<\\=>]*)}/\\verb!\1!/g;
s/==>/\$\\longrightarrow\$/g;
s/^((\\index{[^}]+})+) *$/\1%/;
s/(\\index{[^}]*)\\index{[^}]*}([^}]*})/\1\2/g;
s/(\\class(get|send|both){)\\index{[^}]*}/\1/g;
s/(PL_[a-z_]*)\(([^\)]*)\)/\\funcref{\1}{\2}/g;
# Prolog special arguments ...
# TBD: pick these up automatically from pl.sty
s/\\file{([^}]*\\bnfmeta[^}]*)}/\\metafile{\1}/g;
s/\\file{([^}]*\\arg[^}]*)}/\\metafile{\1}/g;
s/\\file{([^}]+)}/\\file@\1@/g;
s/\\htmloutput{([^}]+)}/\\htmloutput@\1@/g;
s/{#!}/{\\Sexe}/g;
s/{#>}/{\\Scgt}/g;
s/{#>=}/{\\Scge}/g;
s/{#<}/{\\Sclt}/g;
s/{#=<}/{\\Scle}/g;
s/{#=}/{\\Sceq}/g;
s/{#\\=}/{\\Scne}/g;
s/{#\\}/{\\Snot}/g;
s/{#\\\/}/{\\Sor}/g;
s/{#\/\\}/{\\Sand}/g;
s/{#<=>}/{\\Sequiv}/g;
s/{#<=}/{\\Slimpl}/g;
s/{#=>}/{\\Srimpl}/g;
s/{#<==}/{\\Slimplies}/g;
s/{#==>}/{\\Srimplies}/g;
s/{#<==>}/{\\Scequal}/g;
s/{#=\\=}/{\\Scine}/g;
s/{#=:=}/{\\Scieq}/g;
s/{!}/{\\Scut}/g;
s/{,}/{\\Scomma}/g;
s/{->}/{\\Sifthen}/g;
s/{\*->}/{\\Ssoftcut}/g;
s/{\.}/{\\Sdot}/g;
s/{;}/{\\Ssemicolon}/g;
s/{<}/{\\Slt}/g;
s/{><}/{\\Sxor}/g;
s/{=}/{\\Seq}/g;
s/{=\.\.}/{\\Suniv}/g;
s/{=:=}/{\\Saeq}/g;
s/{=<}/{\\Sle}/g;
s/{<=}/{\\Sel}/g;
s/{==}/{\\Sequal}/g;
s/{=@=}/{\\Sstructeq}/g;
s/{\\=@=}/{\\Sstructneq}/g;
s/{=\\=}/{\\Sane}/g;
s/{>}/{\\Sgt}/g;
s/{>=}/{\\Sge}/g;
s/{@<}/{\\Stlt}/g;
s/{@=<}/{\\Stle}/g;
s/{@>}/{\\Stgt}/g;
s/{@>=}/{\\Stge}/g;
s/{\\\+}/{\\Snot}/g;
s/{\\=}/{\\Sne}/g;
s/{\\==}/{\\Snequal}/g;
s/{\^}/{\\Shat}/g;
s/{\|}/{\\Sbar}/g;
s/{\*}/{\\Stimes}/g;
s/{\*\*}/{\\Spow}/g;
s/{\+}/{\\Splus}/g;
s/{-}/{\\Sminus}/g;
s/{\/}/{\\Sdiv}/g;
s/{\/\/}/{\\Sidiv}/g;
s/{\/\\}/{\\Sand}/g;
s/{<<}/{\\Slshift}/g;
s/{>>}/{\\Srshift}/g;
s/{\\}/{\\Sneg}/g;
s/{\\\/}/{\\Sor}/g;
s/{\$}/{\\Sdollar}/g;
s/{\?}/{\\Squest}/g;
s/{:}/{\\Smodule}/g;
s/{:-}/{\\Sneck}/g;
s/{\?-}/{\\Sdirective}/g;
s/{-->}/{\\Sdcg}/g;
s/{~}/{\\Stilde}/g;
s/{%}/{\\Spercent}/g;
s/{{}}/{\\Scurl}/g;
s/{xXX..\\}/{\\SxXX}/g;
s/\\file@([^@]+)@/\\file{\1}/g;
s/\\htmloutput@([^@]+)@/\\htmloutput{\1}/g;
print;
}
sub expandTabs
{ while ( ($i = index($_, "\t")) != $[-1 )
{ $nspaces = 8 - $i % 8;
for( $spaces="", $i=0; $i<$nspaces; $i++ )
{ $spaces .= " ";
}
s/\t/$spaces/;
}
}
sub
expandSpecials
{ s/\^/\\verb!^!/g;
s/\|/\\verb!|!/g;
}
sub printCode
{ print;
while (<ARGV> )
{ &expandTabs;
print;
if ( /\\end{(code|verbatim)}/ )
{ return;
}
}
}
sub printPceCode
{ $line = 0;
print;
while (<ARGV> )
{ $line++;
&expandTabs;
if ( /\\end{pcecode}/ )
{ print;
return;
}
chomp;
print "\\lineno{$line}\\verb`$_`\n";
}
}
sub skiptonext
{ while (<ARGV>)
{ if ( ! /^\s*$/ )
{ return;
}
last;
}
while (<ARGV>)
{ if ( ! /^\s*$/ )
{ return;
}
}
}
# MAIN PROGRAM
while (<>)
{ while ( /\\begin{pcecode}/ )
{ &printPceCode;
print "\n\\noindent\n";
&skiptonext;
}
while ( /\\begin{(code|verbatim)}/ )
{ &printCode;
print "\n\\noindent\n";
&skiptonext;
}
&printTeX;
}

43
man/fancychap.sty Normal file
View File

@ -0,0 +1,43 @@
\font\chapnum = cminch
\font\chaptitle = cmssbx10 scaled \magstep5
\def\booktitle{\mbox{}}
\newdimen\titlewidth
\newdimen\titlenumwidth
\titlewidth\textwidth
\titlenumwidth 3cm
\addtolength{\titlewidth}{-\titlenumwidth}
%----------------------------------------------------------------------
% Chapters
%----------------------------------------------------------------------
\def\breakit{\ } % allow linebreak in chapter title
\def\@makechapterhead#1{ % Heading for \chapter command
\vspace*{0pt} % Space at top of text page.
{ \parindent 0pt \raggedright
\ifnum \c@secnumdepth >\m@ne % IF secnumdepth > -1 THEN
\begin{minipage}{\headwidth}
\parbox[b]{\titlewidth}{%
\def\breakit{\par}\raggedright
\baselineskip .33in {\chaptitle #1}}\nobreak
\parbox[b]{\titlenumwidth}{\raggedleft {\chapnum \thechapter}}
\par\vskip 3pt
\rule[0pt]{\headwidth}{4pt}
\end{minipage}
\fi
\vskip 20pt
\nobreak % TeX penalty to prevent pagebreak.
} }
\def\@makeschapterhead#1{ % Heading for \chapter* command
\vspace*{0pt} % Space at top of page.
\markboth{\booktitle}{#1}
{ \parindent 0pt \raggedright
\begin{minipage}{\headwidth}
\parbox[b]{\titlewidth}{\raggedright {\chaptitle #1}}
\par\vskip 5pt
\rule[0pt]{\headwidth}{4pt}
\end{minipage}
\nobreak % TeX penalty to prevent page break.
\vskip 30pt % Space between title and text.
}}

174
man/html.sty Normal file
View File

@ -0,0 +1,174 @@
% HTML.sty
%
% Provide LaTeX definitions for the latex2html translator.
% Requires LaTeX2e or later
%
% Author: Jan Wielemaker, SWI, University of Amsterdam
% \onefile
%
% Do not section the output (i.e. put all output in the same HTML file).
\newcommand{\onefile}{}
% \bodycolor{Color}
%
% Define colour for running text body (<BODY BGCOLOR=Color>).
\newcommand{\bodycolor}[1]{}
% \linkimage{Id}{ImagePath}
%
% Define image to use for specified link id
\newcommand{\linkimage}[2]{}
% \htmlmainfile{File}
% \htmloutput{Directory}
%
% Define the main output file and directory
\newcommand{\htmlmainfile}[1]{}
\newcommand{\htmloutput}[1]{}
% htmlfiledepth{Depth}
%
% Defines the depth at which sections are split into separate files
% Default is 2 (each subsection produces a file). See also \onefile
\newcommand{\htmlfiledepth}[1]{}
% \email[TextToShow]{URL}
% \url[TextToShow]{URL}
%
% References to E-mail addresses and general URL's. If the optional
% argument is provided, this is the text printed for the label. Otherwise
% the address itself is printed.
\def\url{\@ifnextchar[{\@url}{\@plainurl}}
\def\@url[#1]#2{#1}
\def\@plainurl#1{{\tt #1}}
\let\email=\url
% \begin{shortlist} ... \end{shortlist}
%
% As itemize environment, but do not include extra space between the
% items.
\newenvironment{shortlist}{%
\begin{itemize}\setlength{\itemsep}{0pt}}{%
\end{itemize}}
% \begin{dlist} ... \end{dlist}
%
% As description environment, but start a newline after the item
\let\latexitem=\item
\newenvironment{dlist}{%
\begin{description}%
\def\item[##1]{\latexitem[##1]\hfill\\}}{%
\end{description}}
\newenvironment{itemlist}
{\itemize
\renewcommand\makelabel[1]{%
\hspace\labelwidth
\llap{\@itemlabel}%
\hspace\labelsep
\makebox[\linewidth][l]{\it ##1}%
\hspace{-\labelsep}}%
}%
{\enditemize}
% \var{Var}
%
% Indicate Var is a variable or argument.
\def\var#1{{\it #1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Comment.sty version 2.0, 19 June 1992
% selectively in/exclude pieces of text: the user can define new
% comment versions, and each is controlled separately.
% This style can be used with plain TeX or LaTeX, and probably
% most other packages too.
%
% Examples of use in LaTeX and TeX follow \endinput
%
% Author
% Victor Eijkhout
% Department of Computer Science
% University Tennessee at Knoxville
% 104 Ayres Hall
% Knoxville, TN 37996
% USA
%
% eijkhout@cs.utk.edu
%
% Usage: all text included in between
% \comment ... \endcomment
% or \begin{comment} ... \end{comment}
% is discarded. The closing command should appear on a line
% of its own. No starting spaces, nothing after it.
% This environment should work with arbitrary amounts
% of comment.
%
% Other 'comment' environments are defined by
% and are selected/deselected with
% \includecomment{versiona}
% \excludecoment{versionb}
%
% These environments are used as
% \versiona ... \endversiona
% or \begin{versiona} ... \end{versiona}
% with the closing command again on a line of its own.
%
% Basic approach:
% to comment something out, scoop up every line in verbatim mode
% as macro argument, then throw it away.
% For inclusions, both the opening and closing comands
% are defined as noop
%
% Changed \next to \html@next to prevent clashes with other sty files
% (mike@emn.fr)
% Changed \html@next to \htmlnext so the \makeatletter and
% \makeatother commands could be removed (they were causing other
% style files - changebar.sty - to crash) (nikos@cbl.leeds.ac.uk)
% Changed \htmlnext back to \html@next...
\makeatletter
\def\makeinnocent#1{\catcode`#1=12 }
\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
\def\ThrowAwayComment#1{\begingroup
\def\CurrentComment{#1}%
\let\do\makeinnocent \dospecials
\makeinnocent\^^L% and whatever other special cases
\endlinechar`\^^M \catcode`\^^M=12 \xComment}
{\catcode`\^^M=12 \endlinechar=-1 %
\gdef\xComment#1^^M{\def\test{#1}
\csarg\ifx{PlainEnd\CurrentComment Test}\test
\let\html@next\endgroup
\else \csarg\ifx{LaLaEnd\CurrentComment Test}\test
\edef\html@next{\endgroup\noexpand\end{\CurrentComment}}
\else \let\html@next\xComment
\fi \fi \html@next}
}
\makeatother
\def\includecomment
#1{\expandafter\def\csname#1\endcsname{}%
\expandafter\def\csname end#1\endcsname{}}
\def\excludecomment
#1{\expandafter\def\csname#1\endcsname{\ThrowAwayComment{#1}}%
{\escapechar=-1\relax
\csarg\xdef{PlainEnd#1Test}{\string\\end#1}%
\csarg\xdef{LaLaEnd#1Test}{\string\\end\string\{#1\string\}}%
}}
\excludecomment{comment}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\excludecomment{htmlonly}
\newenvironment{latexonly}{}{}

1254
man/name.bst Normal file

File diff suppressed because it is too large Load Diff

1102
man/pl.bib Normal file

File diff suppressed because it is too large Load Diff

508
man/pl.sty Normal file
View File

@ -0,0 +1,508 @@
% SWI-Prolog document-style
% Test for PDF generation using pdflatex
\usepackage{ifpdf}
%Old tex versions
%\newif\ifpdf
%\ifx\pdfoutput\undefined
% \pdffalse
%\else
% \pdfoutput=1
% \pdftrue
%\fi
% Get hyperrefs to work
\usepackage{makeidx}
\usepackage{url}
\ifpdf
\usepackage[pdftex,colorlinks=true,urlcolor=blue]{hyperref}
\pdfcompresslevel=9
% \pdfcatalog{
% /PageMode /UseOutLines
% }
\usepackage[pdftex]{graphicx}
\DeclareGraphicsExtensions{.pdf,.jpg,.png}
\else
\usepackage[dvips]{graphicx}
\DeclareGraphicsExtensions{.eps,.ps}
\fi
\graphicspath{{figs/}{./}}
% Other styles
\usepackage{a4wide}
\usepackage{longtable}
\usepackage{ifthen}
\usepackage{dcolumn}
\usepackage{calc}
\setlongtables
\catcode`\^^A=8% downarrow are for subscripts
\catcode`\_=\active
\def_{\ifmmode\else\_\fi}
\def\vobeyspaces{\@vobeyspaces}
\newcommand{\onlinebreak}{}
% References
\newcommand{\secref}[1]{section~\ref{sec:#1}}
\newcommand{\appref}[1]{appendix~\ref{sec:#1}}
\newcommand{\chapref}[1]{chapter~\ref{sec:#1}}
\newcommand{\figref}[1]{figure~\ref{fig:#1}}
\newcommand{\tabref}[1]{table~\ref{tab:#1}}
\newcommand{\Secref}[1]{Section~\ref{sec:#1}}
\newcommand{\Appref}[1]{Appendix~\ref{sec:#1}}
\newcommand{\Chapref}[1]{Chapter~\ref{sec:#1}}
\newcommand{\Figref}[1]{Figure~\ref{fig:#1}}
\newcommand{\Tabref}[1]{Table~\ref{tab:#1}}
\newcommand{\tm}{$^{tm}$}
\newcommand{\reffont}{\tt}
\newcommand{\predref}[2]{% % functor/arity
\mbox{\reffont #1/#2}}
\newcommand{\dcgref}[2]{% % functor//arity
\mbox{\reffont #1//#2}}
\newcommand{\qpredref}[3]{% % module:functor/arity
\mbox{\reffont #1:#2/#3}}
\newcommand{\qdcgref}[3]{% % module:functor//arity
\mbox{\reffont #1:#2//#3}}
\newcommand{\nopredref}[2]{% % functor/arity (external)
\mbox{\reffont #1/#2}}
\newcommand{\functor}[2]{% % functor/arity (no predicate)
\mbox{\reffont #1/#2}}
\newcommand{\manref}[2]{% % page(n)
\mbox{{\reffont #1(}{\rm #2}{\tt )}}}
\newcommand{\funcref}[2]{% % function(Args...)
\mbox{{\reffont #1(}{\it #2}{\tt )}}}
\newcommand{\prologflag}[1]{%
\mbox{\reffont #1}}
% Descriptions (definitions) of various things
% Note: I do not know where the 1ex comes from. This should fit
% exactly, but appearently some dimension is missing. I suspect
% a space creaping in somewhere.
\def\@nodescription{false}
\newcommand{\defentry}[1]{\definition{#1}}
\newcommand{\definition}[1]{%
\onlinebreak%
\ifthenelse{\equal{\@nodescription}{true}}{%
\def\@nodescription{false}%
\makebox[-\leftmargin]{\mbox{}}\makebox[\linewidth+\leftmargin-1ex][l]{\bf #1}\\}{%
\item[{\makebox[\linewidth+\leftmargin-1ex][l]{#1}}]}}
\newcommand{\nodescription}{\def\@nodescription{true}}
\makeatletter
\def\cmdlineoptionitem{\@ifstar{\@gluedcmdoptitem}{\@cmdoptitem}}
\def\@gluedcmdoptitem#1#2{\definition{\texttt{#1}\var{#2}}}
\def\@cmdoptitem#1#2{\definition{\texttt{#1} \var{#2}}}
\makeatother
\newcommand{\longoptionitem}[2]{%
\ifthenelse{\equal{}{#2}}{%
\definition{-{}-#1}}{%
\definition{-{}-#1={\it #2}}}\ignorespaces}
\newcommand{\longoption}[2]{%
\ifthenelse{\equal{}{#2}}{%
\mbox{\reffont -{}-#1}}{%
\mbox{\reffont -{}-#1={\it #2}}}}
\newcommand{\traceoption}[3]{%
\definition{{\tt #1} (#2)}#3%
\ignorespaces}
\newcommand{\pleaseoption}[3]{%
\definition{#1 {\it #2} {\rm(default: \it #3)}}%
\ignorespaces}
%\prologflagitem{Name}{Type}{Access}
\newcommand{\prologflagitem}[3]{%
\definition{#1 {\it (#2%
\ifthenelse{\equal{rw}{#3}}{, changeable}{})}}%
\index{flag:#1}\ignorespaces}
\newcommand{\escapeitem}[1]{%
\definition{\Sesc{\tt #1}}
\ignorespaces}
\newcommand{\fmtchar}[1]{%
\item[\tt #1]%
\ignorespaces}
% \directive{Name}{Arity}{Args}
% \predicate[Attibutes]{Name}{Arity}{Args}
% \infixop{Name}{Left}{Right}
% \prefixop{Name}{Right}
% \dcg[Attibutes]{Name}{Arity}{Args}
%
% Predicate descriptions. Must appear in a description
% environment.
\newcommand{\resitem}[1]{%
\defentry{#1}%
\index{#1}\ignorespaces}
\makeatletter
\def\predatt#1{\hfill{\it\footnotesize[#1]}}
\def\predicate{\@ifnextchar[{\@attpredicate}{\@predicate}}
\def\qpredicate{\@ifnextchar[{\@attqpredicate}{\@qpredicate}}
\def\@predicate#1#2#3{%
\ifthenelse{\equal{#2}{0}}{%
\defentry{#1}}{%
\defentry{#1({\it #3})}}%
\index{#1/#2}\ignorespaces}
\def\@attpredicate[#1]#2#3#4{%
\ifthenelse{\equal{#3}{0}}{%
\defentry{#2\predatt{#1}}}{%
\defentry{#2({\it #4})\predatt{#1}}}%
\index{#2/#3}\ignorespaces}
\def\@qpredicate#1#2#3#4{%
\ifthenelse{\equal{#3}{0}}{%
\defentry{#1:#2}}{%
\defentry{#1:#2({\it #4})}}%
\index{#1/#2}\ignorespaces}
\def\@attqpredicate[#1]#2#3#4#5{%
\ifthenelse{\equal{#4}{0}}{%
\defentry{#2:#3\predatt{#1}}}{%
\defentry{#2:#3({\it #5})\predatt{#1}}}%
\index{#2/#3}\ignorespaces}
\def\directive{\@ifnextchar[{\@attdirective}{\@directive}}
\def\@directive#1#2#3{%
\ifthenelse{\equal{#2}{0}}{%
\defentry{:- #1}}{%
\defentry{:- #1({\it #3})}}%
\index{#1/#2}\ignorespaces}
\def\@attdirective[#1]#2#3#4{%
\ifthenelse{\equal{#3}{0}}{%
\defentry{:- #2\predatt{#1}}}{%
\defentry{:- #2({\it #4})\predatt{#1}}}%
\index{#2/#3}\ignorespaces}
\def\dcg{\@ifnextchar[{\@attdcg}{\@dcg}}
\def\@dcg#1#2#3{%
\ifthenelse{\equal{#2}{0}}{%
\defentry{#1}}{%
\defentry{#1({\it #3}) \texttt{//}}}%
\index{#1/#2}\ignorespaces}
\def\@attdcg[#1]#2#3#4{%
\ifthenelse{\equal{#3}{0}}{%
\defentry{#2 \texttt{//}\predatt{#1}}}{%
\defentry{#2({\it #4}) \texttt{//}\predatt{#1}}}%
\index{#2//#3}\ignorespaces}
\def\infixop{\@ifnextchar[{\@attinfixop}{\@infixop}}
\def\@infixop#1#2#3{%
\defentry{{\it #2} #1 {\it #3}}%
\index{#1/2}\ignorespaces}
\def\@attinfixop[#1]#2#3#4{%
\defentry{{\it #3} #2 {\it #4}\predatt{#1}}%
\index{#2/2}\ignorespaces}
\def\prefixop{\@ifnextchar[{\@attprefixop}{\@prefixop}}
\def\@prefixop#1#2{%
\defentry{#1 {\it #2}}%
\index{#1/1}\ignorespaces}
\def\@attprefixop[#1]#2#3{%
\defentry{#2 {\it #3}\predatt{#1}}%
\index{#2/1}\ignorespaces}
\makeatother
% \termitem{functor}{Args}
% \infixtermitem{functor}{Left}{Right}
% \prefixtermitem{functor}{Right}
% \postfixtermitem{functor}{Left}
%
% Terms in description lists. Typically used to describe various
% possible values or types for a term.
\newcommand{\termitem}[2]{%
\ifthenelse{\equal{}{#2}}{%
\definition{#1}}{%
\definition{#1({\it #2})}}\ignorespaces}
\newcommand{\infixtermitem}[3]{%
\definition{{\it #2} #1 {\it #3}}\ignorespaces}
\newcommand{\prefixtermitem}[2]{%
\definition{#1 {\it #2}}\ignorespaces}
\newcommand{\postfixtermitem}[2]{%
\definition{{\it #2} #1}\ignorespaces}
% \term{functor}{Args}
% \infixterm{functor}{Left}{Right}
% \prefixterm{functor}{Right}
% \postfixterm{functor}{Left}
%
% Terms used in running text.
\def\term{}
\renewcommand{\term}[2]{%
\ifthenelse{\equal{\protect}{\protect#2}}{%
{\reffont #1}}{%
{\reffont #1}({\it #2})}}
\newcommand{\infixterm}[3]{{\it #2} #1 {\it #3}}
\newcommand{\prefixterm}[2]{#1 {\it #2}}
\newcommand{\postfixterm}[2]{{\it #2} #1}
\newcommand{\errorterm}[2]{\mbox{\tt%
\ifthenelse{\equal{}{#2}}{%
#1}{%
#1(#2)}}}
\newcommand{\cfunction}[3]{%
\defentry{{\tt #1} #2{\rm (}{\it #3}{\rm )}}%
\index{#2()}\ignorespaces}
\newcommand{\constructor}[2]{%
\defentry{#1::#1{\rm (}{\it #2}{\rm )}}%
\index{#1::#1()}\ignorespaces}
\newcommand{\destructor}[1]{%
\defentry{#1::\Stilde{}#1{\rm ()}}%
\index{#1::\Stilde{}#1()}\ignorespaces}
\newcommand{\cppcast}[2]{%
\defentry{#1::operator #2{\rm ({\it void})}}%
\index{#1::operator #2()}\ignorespaces}
\newcommand{\cdecl}[2]{{\tt #1} {\em #2}}
\newcommand{\cmacro}[3]{%
\defentry{{\it #1} #2({\it #3})}%
\index{#2()}\ignorespaces}
\newcommand{\constitem}[1]{%
\definition{#1}%
\index{#1}\ignorespaces}
\newcommand{\cglobalvar}[1]{{\tt #1}}
\newcommand{\classitem}[1]{%
\definition{Class #1}%
\index{#1 \string\idxtype{class}}\ignorespaces}
\newcommand{\menuitem}[2]{%
\ifthenelse{\equal{\protect}{\protect#2}}{%
\definition{\textsf #1}}{%
\definition{\textsf #1 ({\it #2})}}%
\index{#1 \string\idxtype{menu}}%
\ignorespaces}
% \tag{Keyword}
%
% PlDoc @keyword expansion. \mtag{Keyword} is a multi-valued tag
\newcommand{\tag}[1]{%
\item[#1]}
\newcommand{\mtag}[1]{%
\item[#1]\mbox{}\\}
\newcommand{\bnfmeta}[1]{\ifmmode{\langle\mbox{\it #1}\rangle}\else$\langle\mbox{\it #1}\rangle$\fi}
\newcommand{\bnfor}{\ifmmode\mid\else$\mid$\fi}
\newcommand{\isa}{& ::= &}
\newcommand{\ora}{& $\mid$ &}
\renewcommand{\arg}[1]{\ifmmode\mbox{\em #1}\else{\it #1}\fi}
\newcommand{\class}[1]{{\em #1}\index{#1 \string\idxtype{class}}}
\newcommand{\classs}[1]{{\em #1s}\index{#1 \string\idxtype{class}}}
\newcommand{\demo}[1]{{\sf #1}\index{#1 \string\idxtype{demo}}}
\newcommand{\pllib}[1]{{\texttt{#1}}\index{#1 \string\idxtype{library}}}
\newcommand{\clib}[1]{{\tt #1}\index{#1 \string\idxtype{library}}}
\newcommand{\tool}[1]{{\em #1}\index{#1 \string\idxtype{tool}}}
\newcommand{\menuref}[1]{\textsf{#1}\index{#1 \string\idxtype{menu}}}
\newcommand{\constf}[1]{{\reffont #1}}
\newcommand{\const}[1]{{\tt #1}}
\newcommand{\plflag}[1]{{\tt #1}}
\newcommand{\type}[1]{{\reffont #1}}
\newcommand{\idx}[1]{#1\index{#1}}
\newcommand{\foreseen}[1]{\footnote{#1}}
\newcommand{\metafile}[1]{\mbox{\tt #1}}
\newcommand\file{\begingroup \urlstyle{tt}\Url}
\newcommand\email{\begingroup \urlstyle{tt}\Url}
\newcommand{\env}[1]{\mbox{\tt #1}}
\newcommand{\except}[1]{\mbox{\tt #1}}
\newcommand{\exam}[1]{\mbox{\tt #1}}
\newcommand{\module}[1]{\mbox{\reffont #1}}
\newcommand{\fileext}[1]{\mbox{\texttt{.#1}}}
\newcommand{\option}[1]{\mbox{\tt #1}}
\newcommand{\resource}[1]{\mbox{\reffont #1}}
\newcommand{\cmdlineoption}[1]{\mbox{\tt #1}}
\newcommand{\argoption}[2]{\mbox{\tt #1 \em #2}}
\newcommand{\ctype}[1]{{\texttt{#1}}}
\newcommand{\op}[1]{{\tt #1}}
\newcommand{\program}[1]{\texttt{#1}}
\newcommand{\manpage}[2]{{\bf #1}(#2)}
\newcommand{\chr}[1]{{\tt #1}}
\newcommand{\jargon}[1]{{\em #1}}
\newcommand{\strong}[1]{{\bf #1}}
\newcommand{\texcmd}[1]{{\Sesc}{\tt #1}}
\newcommand{\texenv}[1]{{\tt #1}}
\newcommand{\texmode}[1]{{\tt #1}}
\newcommand{\HTML}[1]{{\bf #1}}
\newcommand{\libdoc}[2]{\section{\pllib{#1}: #2}}
\newcommand{\key}[1]{{\sf #1}}
\newcommand{\menu}[2]{%
{\sf #1}%
\ifthenelse{\equal{#2}{}}{%
}{%
~(\texttt{#2})}}
\newcommand\satom{\begingroup \urlstyle{tt}\Url}
\newcommand\fmtseq{\begingroup \urlstyle{tt}\Url}
\urldef{\Sexe}\satom{#!} % #!
\urldef{\Scgt}\satom{#>} % #>
\urldef{\Scge}\satom{#>=} % #>=
\urldef{\Sclt}\satom{#<} % #<
\urldef{\Scle}\satom{#=<} % #=<
\urldef{\Sceq}\satom{#=} % #=
\urldef{\Scne}\satom{#\=} % #\=
\urldef{\Scnot}\satom{#\} % #\
\urldef{\Scor}\satom{#\/} % #\/
\urldef{\Scand}\satom{#/\} % #/\
\urldef{\Sequiv}\satom{#<=>} % #<=>
\urldef{\Slimpl}\satom{#<=} % #<=
\urldef{\Srimpl}\satom{#=>} % #=>
\urldef{\Slimplies}\satom{#<==} % #<==
\urldef{\Srimplies}\satom{#==>} % #==>
\urldef{\Scequal}\satom{#<==>} % #<==>
\urldef{\Scieq}\satom{#=:=} % #=:=
\urldef{\Scine}\satom{#=\=} % #=\=
\urldef{\Scut}\satom{!} % !
\urldef{\Scomma}\satom{,} % ,
\urldef{\Sifthen}\satom{->} % ->
\urldef{\Ssoftcut}\satom{*->} % *->
\urldef{\Sdot}\satom{.} % .
\urldef{\Ssemicolon}\satom{;} % ;
\urldef{\Slt}\satom{<} % <
\urldef{\Sxor}\satom{><} % ><
\urldef{\Seq}\satom{=} % =
\urldef{\Suniv}\satom{=..} % =..
\urldef{\Saeq}\satom{=:=} % =:=
\urldef{\Sle}\satom{=<} % =<
\urldef{\Sel}\satom{<=} % <=
\urldef{\Sequal}\satom{==} % ==
\urldef{\Sstructeq}\satom{=@=} % =@=
\urldef{\Sstructneq}\satom{\=@=} % \=@=
\urldef{\Sane}\satom{=\=} % =\=
\urldef{\Sgt}\satom{>} % >
\urldef{\Sge}\satom{>=} % >=
\urldef{\Stlt}\satom{@<} % @<
\urldef{\Stle}\satom{@=<} % @=<
\urldef{\Stgt}\satom{@>} % @>
\urldef{\Stge}\satom{@>=} % @>=
\urldef{\Snot}\satom{\+} % \+
\urldef{\Sne}\satom{\=} % \=
\urldef{\Snequal}\satom{\==} % \==
\urldef{\Shat}\satom{^} % ^
\urldef{\Sbar}\satom{|} % |
\urldef{\Stimes}\satom{*} % *
\urldef{\Spow}\satom{**} % **
\urldef{\Splus}\satom{+} % +
\urldef{\Sminus}\satom{-} % -
\urldef{\Sdiv}\satom{/} % /
\urldef{\Sidiv}\satom{//} % //
\urldef{\Sand}\satom{/\} % /\
\urldef{\Slshift}\satom{<<} % <<
\urldef{\Srshift}\satom{>>} % >>
\urldef{\Sneg}\satom{\} % \
\urldef{\Sesc}\satom{\} % \
\urldef{\Sor}\satom{\/} % \/
\urldef{\Sdollar}\satom{$} % $
\urldef{\Squest}\satom{?} % ?
\urldef{\Smodule}\satom{:} % :
\urldef{\Sneck}\satom{:-} % :-
\urldef{\Sdirective}\satom{?-} % ?-
\urldef{\Sdcg}\satom{-->} % -->
\urldef{\Bc}\satom{\c} % \c
\urldef{\Bn}\satom{\n} % \n
\urldef{\Br}\satom{\r} % \r
\urldef{\Bl}\satom{\l} % \l
\urldef{\BB}\satom{\\} % \\
\urldef{\Stilde}\satom{~} % ~
\urldef{\Spercent}\satom{%} % %
\urldef{\Shash}\satom{#} % #
\urldef{\Scurl}\satom{{}} % {}
\urldef{\SxXX}\satom{xXX..\} % xXX..\
\newcommand{\bug}[1]{\footnote{BUG: #1}}
\newcommand{\mod}[2]{#1 \mbox{\rm mod} #2}
\newcommand{\rem}[2]{#1 \mbox{\rm rem} #2}
\newcommand{\pow}[2]{{#1}^{#2}}
\newcommand{\bsl}[0]{\Sesc}
% Index handling
\newcommand{\idxtype}[1]{{\small\em #1}}
% Prolog predicate summary
\newenvironment{summarylist}[1]{\begin{longtable}[l]{#1}}{\end{longtable}}
\newcommand{\predicatesummary}[3]{#1/#2 & #3 \\}
\newcommand{\oppredsummary}[5]{#1/#2 & #5 \\}
\newcommand{\functionsummary}[3]{#1/#2 & #3 \\}
\newcommand{\opfuncsummary}[5]{#1/#2 & #5 \\}
\newcommand{\opsummary}[4]{#3 & #1 & #2 & #4 \\}
\newcommand{\hook}[1]{(hook)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CODE environment %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyvrb}
\usepackage{color}
%\definecolor{codeboxcolor}{rgb}{0.7,0.7,0.7}
\definecolor{codeboxcolor}{rgb}{0.4,0.4,0.4}
\DefineVerbatimEnvironment%
{code}{Verbatim}
{frame=single,
framerule=0.2pt,
rulecolor=\color{codeboxcolor},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INCLUDE FIGURES %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PostScript figures
% \postscriptfig[width=5in]{label}{Title}
\makeatletter
\def\postscriptfig{\@ifnextchar[{\@scaledpostscriptfig}{\@postscriptfig}}
\def\@scaledpostscriptfig[#1]#2#3{%
\begin{figure}%
\centerline{\includegraphics[#1]{#2}}
\caption{#3}
\label{fig:#2}
\end{figure}}
\def\@postscriptfig#1#2{%
\begin{figure}%
\centerline{\includegraphics{#1}}
\caption{#2}
\label{fig:#1}
\end{figure}}
\makeatother
% \begin{tabularlp}{longest-text}
\newlength{\tabDright}
\newlength{\tabDleft}
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
\newcommand{\raggedrightcolumn}{\PreserveBackslash\raggedright\hspace{0pt}}
\newenvironment{tabularlp}[1]%
{\settowidth{\tabDleft}{#1}%
\setlength{\tabDright}{\linewidth-\columnsep*3-\tabDleft}%
\begin{tabular}{|p{\tabDleft}|>{\raggedrightcolumn}p{\tabDright}|}}%
{\end{tabular}}
% \begin{tags} ... \end{tags}
\newenvironment{tags}%
{\begin{quote}\begin{description}%
\setlength{\itemsep}{0pt}%
\footnotesize}%
{\end{description}\end{quote}}
% \begin{parameters} ... \end{parameters}
\newenvironment{parameters}%
{\par%
\makebox[\linewidth]{\hfill\footnotesize Parameters}
\begin{tabular*}{\linewidth}{lp{0.7\linewidth}}
\hline}%
{\end{tabular*}}

32
man/plpage.sty Normal file
View File

@ -0,0 +1,32 @@
%% Define Prolog manual page and header layout
\usepackage{fancyheadings}
\usepackage{fancychap}
% PAGESTYLE
%
% Chapter date
% ---------------------------------------
%
% bla, bla, bla, ...
%
% \bottomleft - page - \bottomright
\def\arabicday{\number\year-\number\month-\number\day}
\providecommand{\runningtitle}{none}
\ifthenelse{\equal{\runningtitle}{none}}{%
\relax}{%
\pagestyle{fancyplain}
\headheight 14pt
\def\chaptermark{\mbox{}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{#1}} % remember chapter title
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\lhead[\fancyplain{}{\bf\thepage}]{\fancyplain{}{\bf\rightmark}}
\rhead[\fancyplain{}{\bf\leftmark}]{\fancyplain{}{\bf\thepage}}
\footrulewidth 0.2pt
\lfoot[\tiny \runningtitle]{}
\rfoot[]{\tiny \runningtitle}
\cfoot{}}

221
man/runtex Executable file
View File

@ -0,0 +1,221 @@
#!/bin/bash
#
# Automate running LaTeX
program=`basename $0`
tex=latex
format=dvi
rerun='Rerun to get cross-references right'
maxruns=4
quiet=false
function texclean
{ rm -f *.idx *.ind *.ilg *.aux *.log *.lof *.out *.toc *.blg
}
# make runtex --clean work without GNU getopt
case "$1" in
--clean)
texclean
exit 0
;;
esac
appbase=`dirname $0`
case "$appbase" in
/*)
;;
.) appbase=`pwd`
;;
./*|../*)
appbase="`pwd`/$appbase"
clean=false
while [ $clean = false ]; do
b=`echo $appbase | sed -e 's@/\./@/@g' -e 's@/[a-z]*/\.\./@/@g'`
if [ "x$b" = "x$appbase" ]; then
clean=true
else
appbase="$b"
fi
done
;;
*) echo "ERROR: runtex must be called with relative or absolute path"
exit 1
;;
esac
echo "runtex application base = $appbase"
function addinput
{ if [ -z "$TEXINPUTS" ]; then
export TEXINPUTS="$1::"
else
export TEXINPUTS=$TEXINPUTS:$1::
fi
}
function addbstinput
{ if [ -z "$BSTINPUTS" ]; then
export BSTINPUTS="$1::"
else
export BSTINPUTS=$BSTINPUTS:$1::
fi
}
function addbibinput
{ if [ -z "$BIBINPUTS" ]; then
export BIBINPUTS="$1::"
else
export BIBINPUTS=$BIBINPUTS:$1::
fi
}
function usage
{ echo "Usage:"
echo ""
echo " $program [options] file"
echo ""
echo "Options:"
echo ""
echo " --pdf Use pdflatex and make .pdf images"
echo " --dvi Use latex"
echo " --help Print this message"
echo " --maxruns=# Specify maximum # runs"
echo " --clean Just remove TeX temporary files"
}
if [ -d $appbase ]; then
addinput $appbase
addbstinput $appbase
addbibinput $appbase
fi
argp=true
while [ $argp = true ] ; do
case "$1" in
--pdf)
tex=pdflatex
format=pdf
shift ;;
--dvi)
tex=latex
format=dvi
shift ;;
--quiet)
quiet=true;
shift ;;
--maxruns=*)
maxruns="`echo $1 | sed 's/--maxruns=//'`"
shift ;;
--inputs=*)
addinput "`echo $1 | sed 's/--inputs=//'`"
shift ;;
--help)
usage
exit 0 ;;
--clean)
texclean
exit 0
;;
--*)
usage
exit 1 ;;
*)
argp=false;
;;
esac
done
if [ -z "$1" ]; then
usage
exit 1
fi
file="$1"
# ensure .tex suffix
if [ ${file%.tex} = $file ]; then
file=$file.tex
fi
doc=${file%.tex}
if [ -r Makefile ] && grep -q '^tex:' Makefile; then
make tex
fi
cont=yes
done=0
while [ $cont != "no" ]; do
cont=maybe
# fix index problems
if [ -r $doc.idx ]; then
cp $doc.idx $doc.idx.$$
if [ -x $appbase/correctindex ]; then
$appbase/correctindex $doc.idx
fi
if [ -r $appbase/makeindex.ist ]; then
makeindex -s $appbase/makeindex.ist $doc
else
makeindex $doc
fi
fi
if test -r $doc.aux && grep -qw bibdata $doc.aux; then
if [ -f $doc.bbl ]; then cp $doc.bbl $doc.bbl$$; fi
echo "%%% Running Bibtex"
bibtex $doc
if [ -r $doc.bbl -a -r $doc.bbl.$$ ]; then
if cmp -s $doc.bbl $doc.bbl.$$; then
true
else
cont=yes
echo "*** Bibtex output changed. Rerunning $tex ***"
fi
fi
rm -f $doc.bbl$$
fi
if [ `basename $tex` = pdflatex -a -r $appbase/Makefile.pdf ]; then
make -f $appbase/Makefile.pdf
fi
rm -f $doc.log
if [ $quiet == true ]; then
$tex $doc -file-line-error -halt-on-error >/dev/null
else
$tex $doc
fi
if [ $? != 0 ]; then
rm -f $doc.idx.$$
exit $?;
fi
if grep -q "$rerun" $doc.log; then
echo "*** Cross-references changed. Rerunning $tex ***"
cont=yes
else
if [ -r $doc.idx -a -r $doc.idx.$$ ]; then
if cmp -s $doc.idx $doc.idx.$$; then
true
else
ls -l $doc.idx $doc.idx.$$
cont=yes
echo "*** Index changed. Rerunning $tex ***"
fi
fi
fi
rm -f $doc.idx.$$
done=$(($done+1))
if [ $done = $maxruns ]; then cont=no; fi
if [ $cont = maybe ]; then cont=no; fi
done
if grep -q Warning $doc.log; then
echo ""
echo "*****************************"
echo "The following warnings remain"
echo "*****************************"
grep Warning $doc.log
fi

View File

@ -164,6 +164,12 @@ TokEntry* tokptr void
TokEntry* toktide void
VarEntry* VarTable void
VarEntry* AnonVarTable void
Term Comments void
CELL* CommentsTail void
CELL* CommentsNextChar void
wchar_t* CommentsBuff void
size_t CommentsBuffPos void
size_t CommentsBuffLim void
sigjmp_buf RestartEnv void
char FileNameBuf[YAP_FILENAME_MAX] void
char FileNameBuf2[YAP_FILENAME_MAX] void

View File

@ -23,7 +23,7 @@ CC=@CC@
CXX=@CXX@
# normal
CXXFLAGS= -std=c++0x @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../../.. -I$(srcdir)/../../../../include @CPPFLAGS@ -DNDEBUG
CXXFLAGS= @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../../.. -I$(srcdir)/../../../../include @CPPFLAGS@ -DNDEBUG
# debug
#CXXFLAGS= -std=c++0x @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../../.. -I$(srcdir)/../../../../include @CPPFLAGS@ -g -O0
@ -63,7 +63,7 @@ HEADERS = \
$(srcdir)/SPSolver.h \
$(srcdir)/Shared.h \
$(srcdir)/xmlParser/xmlParser.h
CPP_SOURCES = \
$(srcdir)/BayesNet.cpp \
$(srcdir)/BayesNode.cpp \
@ -84,23 +84,13 @@ OBJS = \
BPSolver.o \
BpNode.o \
SPSolver.o \
HorusYap.o
HCLI_OBJS = \
BayesNet.o \
BayesNode.o \
FactorGraph.o \
Factor.o \
BPSolver.o \
BpNode.o \
SPSolver.o \
HorusCli.o \
HorusYap.o \
xmlParser.o
SOBJS=horus.@SO@
all: $(SOBJS) hcli
all: $(SOBJS)
# default rule
%.o : $(srcdir)/%.cpp
@ -115,7 +105,7 @@ xmlParser.o : $(srcdir)/xmlParser/xmlParser.cpp
@DO_SECOND_LD@ @SHLIB_CXX_LD@ -o horus.@SO@ $(OBJS) @EXTRA_LIBS_FOR_SWIDLLS@
hcli: $(HCLI_OBJS)
hcli: $(OBJS)
$(CXX) -o hcli $(HCLI_OBJS)

View File

@ -47,15 +47,17 @@ CMFLAGS=@SHLIB_CFLAGS@
CIFLAGS=
CFLAGS=$(COFLAGS) $(CWFLAGS) $(CMFLAGS) $(CIFLAGS) $(PKGCFLAGS) @DEFS@
RUNTEX = true
LDSOFLAGS=@LDFLAGS@ @EXTRA_LIBS_FOR_SWIDLLS@
LDFLAGS=$(PKGLDFLAGS)
MKINDEX=$(PL) -f none -g make -t halt
PUBLICPL=swipl
PLTOTEX=$(PUBLICPL) -q -s pltotex.pl -g pltotex --
.txt.tex:
swipl -f script.pl -g "doc_latex('$*.txt','$*.tex',[stand_alone(false)]),halt" -t "halt(1)"
PUBLICPL=$(PL)
PLTOTEX=$(PUBLICPL) -q -l $(srcdir)/pltotex.pl -g pltotex --
#
# find out how to generate .o files from $(scrdir)

View File

@ -27,6 +27,8 @@ INSTALL_SCRIPT=@INSTALL_SCRIPT@
################################################################
LATEX=latex
DOC2TEX=@abs_top_srcdir@/man/doc2tex
RUNTEX=@abs_top_srcdir@/man/runtex
TEX=$(DOC).tex $(SUBTEX)
DVI=$(DOC).dvi
PDF=$(DOC).pdf
@ -50,12 +52,16 @@ $(HTML): $(TEX)
mv html/index.html $@
$(PDF): $(TEX)
../../man/runtex --pdf $(DOC)
$(srcdir)/../../man/runtex --pdf $(DOC)
$(TEX): $(DOC2TEX)
%.tex : $(srcdir)/%.doc
$(DOC2TEX) $< > $@
.doc.tex:
$(DOC2TEX) $*.doc > $*.tex
%.tex : $(srcdir)/%.txt
$(PUBLICPL) -f none -g "doc_latex('$<','$@',[stand_alone(false)]),halt" -t "halt(1)"
%.tex : $(srcdir)/%.pl
$(PLTOTEX) $< > $@
# Get the Prolog dialect specific part of the Makefiles

View File

@ -329,19 +329,22 @@ initIO()
int i;
#ifdef __YAP_PROLOG__
IOFUNCTIONS buf;
buf = GD->os.iofunctions;
memset(GD, 0, sizeof(gds_t));
GD->os.iofunctions = buf;
memset(LD, 0, sizeof(PL_local_data_t));
#endif
streamAliases = newHTable(16);
streamContext = newHTable(16);
PL_register_blob_type(&stream_blob);
#ifdef __unix__
{ int fd;
{ int fd;
if ( (fd=Sfileno(Sinput)) < 0 || !isatty(fd) ||
(fd=Sfileno(Soutput)) < 0 || !isatty(fd) )
PL_set_prolog_flag("tty_control", PL_BOOL, FALSE);
}
if ( (fd=Sfileno(Sinput)) < 0 || !isatty(fd) ||
(fd=Sfileno(Soutput)) < 0 || !isatty(fd) )
PL_set_prolog_flag("tty_control", PL_BOOL, FALSE);
}
#endif
ResetTty();
#if __YAP_PROLOG__
@ -1304,7 +1307,6 @@ void
PL_write_prompt(int dowrite)
{ GET_LD
IOSTREAM *s = getStream(Suser_output);
if ( s )
{ if ( dowrite )
{ atom_t a = PrologPrompt();

View File

@ -5,7 +5,9 @@
#define O_GMP 1
#endif
#ifndef PL_CONSOLE
#define PL_KERNEL 1
#endif
#ifdef __MINGW32__
#define O_XOS 1

View File

@ -2915,7 +2915,13 @@ Sfileno(IOSTREAM *s)
#ifdef __WINDOWS__
#include "windows/popen.c"
#ifdef popen
#undef popen
#endif
#define popen(cmd, how) pt_popen(cmd, how)
#ifdef pclose
#undef pclose
#endif
#define pclose(fd) pt_pclose(fd)
#endif

@ -1 +1 @@
Subproject commit b0fde37bf3338926ed4f1fd06bbbaa78fb389569
Subproject commit a9c5837d21002a02a73edf2517cb900c56a8f5bc

@ -1 +1 @@
Subproject commit 077a6e787627b03def8f58253c095f19a504245d
Subproject commit cee6c346ba77e046ef1873b9d8c88c52c3baae2d

@ -1 +1 @@
Subproject commit b2eb894ce3e41925070215f800d6df3a356dc29d
Subproject commit 9b0d051d7c1b5a665df6c71b98fde555532aaab4

@ -1 +1 @@
Subproject commit 4b317ca09a06beff1605e185756f08869279ff3e
Subproject commit f6fce313722d2f69e5ce6074f304ce05065bbf40

@ -1 +1 @@
Subproject commit dd614178a5e334aa7f40d157d849514e99a9f48b
Subproject commit 09000f63832736132093b178b1edbe4b617db843

1
packages/pldoc Submodule

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

@ -1 +1 @@
Subproject commit dcdc7f12929bf921ee49f85983c7cd9a9171a32e
Subproject commit aa90b8f8a67e605e82566b719a8f20d125598bd2

@ -1 +1 @@
Subproject commit 652ce8786dfd16f852ef3a30d0365f11375e160f
Subproject commit babcbfe9cc5ab269cd5fd4f024e9d57bd3d0a8db

View File

@ -15,8 +15,8 @@
* *
*************************************************************************/
% This one should come first so that disjunctions and long distance
% cuts are compiled right with co-routining.
%
%
%
true :- true.
@ -144,7 +144,7 @@ true :- true.
*/
/* main execution loop */
'$read_vars'(user_input, Goal, Mod, Pos, Bindings, Prompt) :-
'$read_vars'(user_input, Goal, Mod, Pos, Bindings, Prompt, ReadComments) :-
'$swi_current_prolog_flag'(readline, true),
read_history(h, '!h',
[trace, end_of_file],
@ -154,8 +154,8 @@ true :- true.
;
true
).
'$read_vars'(Stream, T, Mod, Pos, V, _Prompt) :-
'$read'(true, T, Mod, V, Pos, Err, Stream),
'$read_vars'(Stream, T, Mod, Pos, V, _Prompt, ReadComments) :-
'$read'(true, T, Mod, V, Pos, Err, ReadComments, Stream),
(nonvar(Err) ->
print_message(error,Err), fail
;
@ -195,7 +195,7 @@ true :- true.
prompt(_,'| '),
'$run_toplevel_hooks',
prompt1('|: '),
'$read_vars'(user_input,Command,_,Pos,Varnames, ' ?- '),
'$read_vars'(user_input,Command,_,Pos,Varnames, ' ?- ', no),
nb_setval('$spy_gn',1),
% stop at spy-points if debugging is on.
nb_setval('$debug_run',off),
@ -1127,18 +1127,36 @@ bootstrap(F) :-
'$init_path_extensions'.
'$loop'(Stream,Status) :-
(
Status = top
;
'$undefined'(comment_hook(_,_,_),prolog)
;
'$number_of_clauses'(comment_hook(_,_,_),prolog,0)
), !,
repeat,
%VSC ( '$current_stream'(_,_,Stream) -> true
%VSC ; '$abort_loop'(Stream)
%VSC ),
prompt1('| '), prompt(_,'| '),
'$current_module'(OldModule),
'$system_catch'('$enter_command'(Stream,Status), OldModule, Error,
user:'$LoopError'(Error, Status)),
!.
% support comment hook
'$loop'(Stream,Status) :-
repeat,
prompt1('| '), prompt(_,'| '),
'$current_module'(OldModule),
'$system_catch'('$enter_command_with_hook'(Stream,Status), OldModule, Error,
user:'$LoopError'(Error, Status)),
!.
'$enter_command'(Stream,Status) :-
'$read_vars'(Stream,Command,_,Pos,Vars, '|: '),
'$read_vars'(Stream,Command,_,Pos,Vars, '|: ', no),
'$command'(Command,Vars,Pos,Status).
% support SWI hook in a separate predicate, to avoid slow down standard consult.
'$enter_command_with_hook'(Stream,Status) :-
'$read_vars'(Stream,Command,_,Pos,Vars, '|: ', Comments),
('$notrace'(prolog:comment_hook(Comments,Pos,Command)) -> true ; true ),
'$command'(Command,Vars,Pos,Status).
'$abort_loop'(Stream) :-

View File

@ -256,6 +256,10 @@ no_style_check([H|T]) :- no_style_check(H), no_style_check(T).
'$multiple_has_been_defined'(Fil,P,M) :-
print_message(warning,defined_elsewhere(M:P,Fil)).
multifile(P) :-
'$current_module'(OM),
'$multifile'(P, M).
'$multifile'(V, _) :- var(V), !,
'$do_error'(instantiation_error,multifile(V)).
'$multifile'((X,Y), M) :- !, '$multifile'(X, M), '$multifile'(Y, M).

View File

@ -834,8 +834,8 @@ absolute_file_name(File,Opts,TrueFileName) :-
'$to_list_of_atoms'(As, L1, [A|L2]),
'$to_list_of_atoms'(Bs, L2, LF).
'$get_abs_file'(File,opts(_,D0,_,_,_,_,_),AbsFile) :-
operating_system_support:true_file_name(File,D0,AbsFile).
'$get_abs_file'(File,opts(_,_D0,_,_,_,_,_),AbsFile) :-
'$absolute_file_name'(File,AbsFile).
'$search_in_path'(File,opts(Extensions,_,Type,Access,_,_,_),F) :-
'$add_extensions'(Extensions, File, F0),
@ -870,6 +870,9 @@ absolute_file_name(File,Opts,TrueFileName) :-
'$add_type_extensions'(Type,File,F) :-
'$type_extension'(Type,Ext),
atom_concat([File,Ext],F).
'$add_type_extensions'(Type,File,F) :-
user:prolog_file_type(Ext, Type),
atom_concat([File,'.',Ext],F).
'$type_extension'(txt,'').
'$type_extension'(prolog,'.yap').
@ -1047,4 +1050,9 @@ make.
'$fetch_stream_alias'(OldStream,Alias) :-
stream_property(OldStream, alias(Alias)), !.
'$require'(_Ps, _M).
'$require'(_Ps, _M).
'$store_clause'('$source_location'(File, Line):Clause, File) :-
assert_static(Clause).

View File

@ -115,12 +115,14 @@ system_mode(verbose,off) :- set_value('$verbose',off).
:- use_module('dialect.yap').
:- use_module('history.pl').
:- use_module('dbload.yap').
:- use_module('swi.yap').
'$system_module'('$messages').
'$system_module'('$hacks').
'$system_module'('$attributes').
'$system_module'('$coroutining').
'$system_module'('$history').
'$system_module'('$swi').
yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
@ -162,12 +164,24 @@ yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
:- dynamic prolog:message/3.
:- multifile
prolog:comment_hook/3.
:- module(user).
:- multifile goal_expansion/3.
:- dynamic goal_expansion/3.
:- multifile prolog_file_type/2.
:- dynamic prolog_file_type/2.
user:prolog_file_type(pl, prolog).
% user:prolog_file_type(Ext, prolog) :-
% current_prolog_flag(associate, Ext),
% Ext \== pl.
:- multifile goal_expansion/2.
:- dynamic goal_expansion/2.
@ -176,6 +190,10 @@ yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
:- dynamic term_expansion/2.
:- multifile system:term_expansion/2.
:- dynamic system:term_expansion/2.
:- multifile file_search_path/2.
:- dynamic file_search_path/2.

View File

@ -141,6 +141,12 @@ module(N) :-
print_message(warning,import(N/K,Mod,M,private))
),
'$do_import'(N, K, M, Mod).
'$use_preds'(N//K0,Publics,M,Mod) :-
K is K0+2,
( lists:memberchk(N/K,Publics) -> true ;
print_message(warning,import(N/K,Mod,M,private))
),
'$do_import'(N, K, M, Mod).
'$do_import'(N, K, M, T) :-
@ -795,3 +801,28 @@ delete_import_module(Mod, ImportModule) :-
'$do_error'(type_error(atom,Mod),delete_import_module(Mod, ImportModule)).
delete_import_module(Mod, ImportModule) :-
'$do_error'(type_error(atom,ImportModule),delete_import_module(Mod, ImportModule)).
'$set_source_module'(Source0, SourceF) :-
prolog_load_context(module, Source0), !,
module(SourceF).
'$set_source_module'(Source0, SourceF) :-
current_module(Source0, SourceF).
/** '$declare_module'(+Module, +Super, +File, +Line, +Redefine) is det.
Start a new (source-)module
@param Module is the name of the module to declare
@param File is the canonical name of the file from which the module
is loaded
@param Line is the line-number of the :- module/2 directive.
@param Redefine If =true=, allow associating the module to a new file
*/
'$declare_module'(Name, Context, _, _, _) :-
add_import_module(Name, Context, start).
module_property(Mod, file(F)) :-
recorded('$module','$module'(F,Mod,_),_).
module_property(Mod, exports(Es)) :-
recorded('$module','$module'(_,Mod,Es),_).

View File

@ -757,7 +757,7 @@ dynamic_predicate(P,Sem) :-
'$public'([H|L], M) :- !, '$public'(H, M), '$public'(L, M).
'$public'(A//N1, Mod) :- integer(N1), !,
N is N1+2,
'$public'(A//N, Mod).
'$public'(A/N, Mod).
'$public'(A/N, Mod) :- integer(N), atom(A), !,
functor(T,A,N),
'$do_make_public'(T, Mod).

View File

@ -41,5 +41,10 @@
'$hide'('$hacks') :- !, fail.
'$hide'('$source_location') :- !, fail.
'$hide'('$messages') :- !, fail.
'$hide'('$push_input_context') :- !, fail.
'$hide'('$pop_input_context') :- !, fail.
'$hide'('$set_source_module') :- !, fail.
'$hide'('$declare_module') :- !, fail.
'$hide'('$store_clause') :- !, fail.
'$hide'(Name) :- hide(Name), fail.

55
pl/swi.yap Normal file
View File

@ -0,0 +1,55 @@
:- module('$swi',
[]).
%% file_alias_path(-Alias, ?Dir) is nondet.
%
% True if file Alias points to Dir. Multiple solutions are
% generated with the longest directory first.
:- dynamic
alias_cache/2.
prolog:file_alias_path(Alias, Dir) :-
( alias_cache(_, _)
-> true
; build_alias_cache
),
( nonvar(Dir)
-> ensure_slash(Dir, DirSlash),
alias_cache(Alias, DirSlash)
; alias_cache(Alias, Dir)
).
build_alias_cache :-
findall(t(DirLen, AliasLen, Alias, Dir),
search_path(Alias, Dir, AliasLen, DirLen), Ts),
sort(Ts, List0),
reverse(List0, List),
forall(member(t(_, _, Alias, Dir), List),
assert(alias_cache(Alias, Dir))).
search_path('.', Here, 999, DirLen) :-
working_directory(Here0, Here0),
ensure_slash(Here0, Here),
atom_length(Here, DirLen).
search_path(Alias, Dir, AliasLen, DirLen) :-
user:file_search_path(Alias, _),
Alias \== autoload,
Spec =.. [Alias,'.'],
atom_length(Alias, AliasLen0),
AliasLen is 1000 - AliasLen0, % must do reverse sort
absolute_file_name(Spec, Dir0,
[ file_type(directory),
access(read),
solutions(all),
file_errors(fail)
]),
ensure_slash(Dir0, Dir),
atom_length(Dir, DirLen).
ensure_slash(Dir, Dir) :-
sub_atom(Dir, _, _, 0, /), !.
ensure_slash(Dir0, Dir) :-
atom_concat(Dir0, /, Dir).

View File

@ -719,3 +719,21 @@ subsumes_term(A,B) :-
\+ \+ terms:subsumes(A,B).
%% file_name_on_path(+File:atom, -OnPath) is det.
%
% True if OnPath a description of File based on the file search
% path. This performs the inverse of absolute_file_name/3.
file_name_on_path(Path, ShortId) :-
( file_alias_path(Alias, Dir),
atom_concat(Dir, Local, Path)
-> ( Alias == '.'
-> ShortId = Local
; file_name_extension(Base, pl, Local)
-> ShortId =.. [Alias, Base]
; ShortId =.. [Alias, Local]
)
; ShortId = Path
).

View File

@ -42,6 +42,8 @@
'$check_opt_read'(syntax_errors(T), G) :- !,
'$check_read_syntax_errors_arg'(T, G).
'$check_opt_read'(term_position(_), _) :- !.
'$check_opt_read'(term_position(_), _) :- !.
'$check_opt_read'(comments(_), _) :- !.
'$check_opt_read'(module(_), _) :- !.
'$check_opt_read'(A, G) :-
'$do_error'(domain_error(read_option,A),G).
@ -97,7 +99,7 @@ exists(F) :- access_file(F,exist).
/* Term IO */
read(T) :-
'$read'(false,T,_,_,_,Err),
'$read'(false,T,_,_,_,Err,_),
(nonvar(Err) ->
print_message(error,Err), fail
;
@ -105,7 +107,7 @@ read(T) :-
).
read(Stream,T) :-
'$read'(false,T,_,_,_,Err,Stream),
'$read'(false,T,_,_,_,Err,_,Stream),
(nonvar(Err) ->
print_message(error,Err), fail
;
@ -115,29 +117,31 @@ read(Stream,T) :-
read_term(T, Options) :-
'$check_io_opts'(Options,read_term(T, Options)),
current_input(S),
'$preprocess_read_terms_options'(Options,Module),
'$read_vars'(S,T,Module,Pos,VL,'|: '),
'$preprocess_read_terms_options'(Options,Module,DoComments),
'$read_vars'(S,T,Module,Pos,VL,'|: ',DoComments),
'$postprocess_read_terms_options'(Options, T, VL, Pos).
read_term(Stream, T, Options) :-
'$check_io_opts'(Options,read_term(T, Options)),
'$preprocess_read_terms_options'(Options,Module),
'$read_vars'(Stream,T,Module,Pos,VL,'|: '),
'$preprocess_read_terms_options'(Options,Module,DoComments),
'$read_vars'(Stream,T,Module,Pos,VL,'|: ',DoComments),
'$postprocess_read_terms_options'(Options, T, VL, Pos).
%
% support flags to read
%
'$preprocess_read_terms_options'([],_).
'$preprocess_read_terms_options'([syntax_errors(NewVal)|L],Mod) :- !,
'$preprocess_read_terms_options'([], _, no).
'$preprocess_read_terms_options'([syntax_errors(NewVal)|L], Mod, DoComments) :- !,
'$get_read_error_handler'(OldVal),
set_value('$read_term_error_handler', OldVal),
'$set_read_error_handler'(NewVal),
'$preprocess_read_terms_options'(L,Mod).
'$preprocess_read_terms_options'([module(Mod)|L],Mod) :- !,
'$preprocess_read_terms_options'(L,Mod).
'$preprocess_read_terms_options'([_|L],Mod) :-
'$preprocess_read_terms_options'(L,Mod).
'$preprocess_read_terms_options'(L,Mod, DoComments).
'$preprocess_read_terms_options'([module(Mod)|L], Mod, DoComments) :- !,
'$preprocess_read_terms_options'(L, Mod, DoComments).
'$preprocess_read_terms_options'([comments(Val)|L], Mod, Val) :- !,
'$preprocess_read_terms_options'(L, Mod, _).
'$preprocess_read_terms_options'([_|L],Mod, DoComments) :-
'$preprocess_read_terms_options'(L,Mod, DoComments).
'$postprocess_read_terms_options'([], _, _, _).
'$postprocess_read_terms_options'([H|Tail], T, VL, Pos) :- !,
@ -159,6 +163,7 @@ read_term(Stream, T, Options) :-
'$fetch_singleton_names'(Val1,VL,Val).
'$postprocess_read_terms_option'(variables(Val), T, _, _) :-
'$variables_in_term'(T, [], Val).
'$postprocess_read_terms_option'(comments(_), _, _, _).
'$postprocess_read_terms_option'(term_position(Pos), _, _, Pos).
'$postprocess_read_terms_option'(module(_), _, _, _).
%'$postprocess_read_terms_option'(cycles(Val), _, _).