Merge branch 'master' of ssh://git.dcc.fc.up.pt/yap-6.3

This commit is contained in:
Vítor Santos Costa 2015-02-10 09:20:12 +00:00
commit 9743c81f05
20 changed files with 6953 additions and 2086 deletions

View File

@ -737,6 +737,8 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep USES_REGS)
break;
case Var_tok:
case String_tok:
case WString_tok:
case StringTerm_tok:
if (IsOldTrail(tks->TokInfo))
tks->TokInfo = TrailAdjust(tks->TokInfo);
break;

View File

@ -356,6 +356,12 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString,1),1,&t0);
}
break;
case StringTerm_tok:
{
Term t0 = MkStringTerm((const char *)info);
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString,1),1,&t0);
}
break;
case WString_tok:
{
Term t0 = Yap_WCharsToListOfCodes((const wchar_t *)info PASS_REGS);

View File

@ -136,7 +136,6 @@ dot with single quotes.
*
*/
#include "Yap.h"
#include "Yatom.h"
#include "YapHeap.h"
@ -157,12 +156,9 @@ dot with single quotes.
#define Volatile
#endif
/* weak backtraking mechanism based on long_jump */
typedef struct jmp_buff_struct {
sigjmp_buf JmpBuff;
} JMPBUFF;
typedef struct jmp_buff_struct { sigjmp_buf JmpBuff; } JMPBUFF;
static void GNextToken(CACHE_TYPE1);
static void checkfor(wchar_t, JMPBUFF *CACHE_TYPE);
@ -170,9 +166,9 @@ static Term ParseArgs(read_data *, Atom, wchar_t, JMPBUFF *, Term CACHE_TYPE);
static Term ParseList(read_data *, JMPBUFF *CACHE_TYPE);
static Term ParseTerm(read_data *, int, JMPBUFF *CACHE_TYPE);
#define TRY(S, P) \
{ Volatile JMPBUFF *saveenv, newenv; \
{ \
Volatile JMPBUFF *saveenv, newenv; \
Volatile TokEntry *saveT = LOCAL_tokptr; \
Volatile CELL *saveH = HR; \
Volatile int savecurprio = curprio; \
@ -182,8 +178,8 @@ static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE);
S; \
FailBuff = saveenv; \
P; \
} \
else { FailBuff=saveenv; \
} else { \
FailBuff = saveenv; \
HR = saveH; \
curprio = savecurprio; \
LOCAL_tokptr = saveT; \
@ -191,7 +187,8 @@ static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE);
}
#define TRY3(S, P, F) \
{ Volatile JMPBUFF *saveenv, newenv; \
{ \
Volatile JMPBUFF *saveenv, newenv; \
Volatile TokEntry *saveT = LOCAL_tokptr; \
Volatile CELL *saveH = HR; \
saveenv = FailBuff; \
@ -200,19 +197,17 @@ static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE);
S; \
FailBuff = saveenv; \
P; \
} \
else { \
} else { \
FailBuff = saveenv; \
HR = saveH; \
LOCAL_tokptr = saveT; \
F } \
F \
} \
}
#define FAIL siglongjmp(FailBuff->JmpBuff, 1)
VarEntry *
Yap_LookupVar(char *var) /* lookup variable in variables table */
VarEntry *Yap_LookupVar(char *var) /* lookup variable in variables table */
{
CACHE_REGS
VarEntry *p;
@ -271,9 +266,7 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
return (p);
}
static Term
VarNames(VarEntry *p,Term l USES_REGS)
{
static Term VarNames(VarEntry *p, Term l USES_REGS) {
if (p != NULL) {
if (strcmp(p->VarRep, "_") != 0) {
Term t[2];
@ -297,16 +290,12 @@ VarNames(VarEntry *p,Term l USES_REGS)
}
}
Term
Yap_VarNames(VarEntry *p,Term l)
{
Term Yap_VarNames(VarEntry *p, Term l) {
CACHE_REGS
return VarNames(p, l PASS_REGS);
}
static Term
Singletons(VarEntry *p,Term l USES_REGS)
{
static Term Singletons(VarEntry *p, Term l USES_REGS) {
if (p != NULL) {
if (p->VarRep && p->VarRep[0] != '_' && p->refs == 1) {
Term t[2];
@ -315,7 +304,8 @@ Singletons(VarEntry *p,Term l USES_REGS)
t[0] = MkAtomTerm(Yap_LookupAtom(p->VarRep));
t[1] = p->VarAdr;
o = Yap_MkApplTerm(FunctorEq, 2, t);
o = MkPairTerm(o, Singletons(p->VarRight,
o = MkPairTerm(o,
Singletons(p->VarRight,
Singletons(p->VarLeft, l PASS_REGS) PASS_REGS));
if (HR > ASP - 4096) {
save_machine_regs();
@ -323,27 +313,25 @@ Singletons(VarEntry *p,Term l USES_REGS)
}
return (o);
} else {
return Singletons(p->VarRight,Singletons(p->VarLeft,l PASS_REGS) PASS_REGS);
return Singletons(p->VarRight,
Singletons(p->VarLeft, l PASS_REGS) PASS_REGS);
}
} else {
return (l);
}
}
Term
Yap_Singletons(VarEntry *p,Term l)
{
Term Yap_Singletons(VarEntry *p, Term l) {
CACHE_REGS
return Singletons(p, l PASS_REGS);
}
static Term
Variables(VarEntry *p,Term l USES_REGS)
{
static Term Variables(VarEntry *p, Term l USES_REGS) {
if (p != NULL) {
Term o;
o = MkPairTerm(p->VarAdr, Variables(p->VarRight,Variables(p->VarLeft,l PASS_REGS) PASS_REGS));
o = MkPairTerm(
p->VarAdr,
Variables(p->VarRight, Variables(p->VarLeft, l PASS_REGS) PASS_REGS));
if (HR > ASP - 4096) {
save_machine_regs();
siglongjmp(LOCAL_IOBotch, 1);
@ -354,23 +342,18 @@ Variables(VarEntry *p,Term l USES_REGS)
}
}
Term
Yap_Variables(VarEntry *p,Term l)
{
Term Yap_Variables(VarEntry *p, Term l) {
CACHE_REGS
return Variables(p, l PASS_REGS);
}
static int
IsPrefixOp(Atom op,int *pptr, int *rpptr USES_REGS)
{
static int IsPrefixOp(Atom op, int *pptr, int *rpptr USES_REGS) {
int p;
OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP PASS_REGS);
if (!opp)
return FALSE;
if (opp->OpModule &&
opp->OpModule != CurrentModule) {
if (opp->OpModule && opp->OpModule != CurrentModule) {
READ_UNLOCK(opp->OpRWLock);
return FALSE;
}
@ -386,23 +369,18 @@ IsPrefixOp(Atom op,int *pptr, int *rpptr USES_REGS)
}
}
int
Yap_IsPrefixOp(Atom op,int *pptr, int *rpptr)
{
int Yap_IsPrefixOp(Atom op, int *pptr, int *rpptr) {
CACHE_REGS
return IsPrefixOp(op, pptr, rpptr PASS_REGS);
}
static int
IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS)
{
static int IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS) {
int p;
OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS);
if (!opp)
return FALSE;
if (opp->OpModule &&
opp->OpModule != CurrentModule) {
if (opp->OpModule && opp->OpModule != CurrentModule) {
READ_UNLOCK(opp->OpRWLock);
return FALSE;
}
@ -420,23 +398,18 @@ IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS)
}
}
int
Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr)
{
int Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr) {
CACHE_REGS
return IsInfixOp(op, pptr, lpptr, rpptr PASS_REGS);
}
static int
IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS)
{
static int IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS) {
int p;
OpEntry *opp = Yap_GetOpProp(op, POSFIX_OP PASS_REGS);
if (!opp)
return FALSE;
if (opp->OpModule &&
opp->OpModule != CurrentModule) {
if (opp->OpModule && opp->OpModule != CurrentModule) {
READ_UNLOCK(opp->OpRWLock);
return FALSE;
}
@ -452,16 +425,12 @@ IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS)
}
}
int
Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr)
{
int Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr) {
CACHE_REGS
return IsPosfixOp(op, pptr, lpptr PASS_REGS);
}
inline static void
GNextToken( USES_REGS1 )
{
inline static void GNextToken(USES_REGS1) {
if (LOCAL_tokptr->Tok == Ord(eot_tok))
return;
if (LOCAL_tokptr == LOCAL_toktide)
@ -470,21 +439,17 @@ GNextToken( USES_REGS1 )
LOCAL_tokptr = LOCAL_tokptr->TokNext;
}
inline static void
checkfor(wchar_t c, JMPBUFF *FailBuff USES_REGS)
{
if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok)
|| LOCAL_tokptr->TokInfo != (Term)c)
inline static void checkfor(wchar_t c, JMPBUFF *FailBuff USES_REGS) {
if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok) ||
LOCAL_tokptr->TokInfo != (Term)c)
FAIL;
NextToken;
}
#ifdef O_QUASIQUOTATIONS
static int
is_quasi_quotation_syntax(Term goal, ReadData _PL_rd, Atom *pat)
{ CACHE_REGS
static int is_quasi_quotation_syntax(Term goal, ReadData _PL_rd, Atom *pat) {
CACHE_REGS
Term m = CurrentModule, t;
Atom at;
UInt arity;
@ -499,19 +464,18 @@ is_quasi_quotation_syntax(Term goal, ReadData _PL_rd, Atom *pat)
return FALSE;
}
static int
get_quasi_quotation(term_t t, unsigned char **here, unsigned char *ein,
ReadData _PL_rd)
{ unsigned char *in, *start = *here;
static int get_quasi_quotation(term_t t, unsigned char **here,
unsigned char *ein, ReadData _PL_rd) {
unsigned char *in, *start = *here;
for(in=start; in <= ein; in++)
{ if ( in[0] == '}' &&
in[-1] == '|' )
{ *here = in+1; /* after } */
for (in = start; in <= ein; in++) {
if (in[0] == '}' && in[-1] == '|') {
*here = in + 1; /* after } */
in--; /* Before | */
if (_PL_rd->quasi_quotations) /* option; must return strings */
{ PL_chars_t txt;
{
PL_chars_t txt;
int rc;
txt.text.t = (char *)start;
@ -524,10 +488,9 @@ get_quasi_quotation(term_t t, unsigned char **here, unsigned char *ein,
PL_free_text(&txt);
return rc;
} else
{ return PL_unify_term(t, PL_FUNCTOR, FUNCTOR_dquasi_quotation3,
PL_POINTER, _PL_rd,
PL_INTPTR, (intptr_t)(start),
} else {
return PL_unify_term(t, PL_FUNCTOR, FUNCTOR_dquasi_quotation3,
PL_POINTER, _PL_rd, PL_INTPTR, (intptr_t)(start),
PL_INTPTR, (intptr_t)(in - start));
}
}
@ -537,10 +500,8 @@ get_quasi_quotation(term_t t, unsigned char **here, unsigned char *ein,
}
#endif /*O_QUASIQUOTATIONS*/
static Term
ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USES_REGS)
{
static Term ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff,
Term arg1 USES_REGS) {
int nargs = 0;
Term *p, t;
Functor func;
@ -554,8 +515,8 @@ ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USE
*p = arg1;
nargs++;
ParserAuxSp = (char *)(p + 1);
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)
&& LOCAL_tokptr->TokInfo == close) {
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) &&
LOCAL_tokptr->TokInfo == close) {
func = Yap_MkFunctor(a, 1);
if (func == NULL) {
@ -620,8 +581,7 @@ ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USE
return t;
}
static Term MakeAccessor( Term t, Functor f USES_REGS )
{
static Term MakeAccessor(Term t, Functor f USES_REGS) {
UInt arity = ArityOfFunctor(FunctorOfTerm(t)), i;
Term tf[2], tl = TermNil;
@ -633,9 +593,7 @@ static Term MakeAccessor( Term t, Functor f USES_REGS )
return Yap_MkApplTerm(f, 2, tf);
}
static Term
ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS)
{
static Term ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS) {
Term o;
CELL *to_store;
o = AbsPair(HR);
@ -646,8 +604,8 @@ ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS)
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
if (((int)LOCAL_tokptr->TokInfo) == ',') {
NextToken;
if (LOCAL_tokptr->Tok == Ord(Name_tok)
&& strcmp(RepAtom((Atom)(LOCAL_tokptr->TokInfo))->StrOfAE, "..") == 0) {
if (LOCAL_tokptr->Tok == Ord(Name_tok) &&
strcmp(RepAtom((Atom)(LOCAL_tokptr->TokInfo))->StrOfAE, "..") == 0) {
NextToken;
to_store[1] = ParseTerm(rd, 999, FailBuff PASS_REGS);
} else {
@ -672,9 +630,7 @@ ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS)
return (o);
}
static Term
ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
{
static Term ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) {
/* parse term with priority prio */
Volatile Term t;
Volatile Functor func;
@ -705,10 +661,9 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
break;
}
}
if ((LOCAL_tokptr->Tok != Ord(Ponctuation_tok)
|| Unsigned(LOCAL_tokptr->TokInfo) != 'l')
&& IsPrefixOp((Atom)t, &opprio, &oprprio PASS_REGS)
) {
if ((LOCAL_tokptr->Tok != Ord(Ponctuation_tok) ||
Unsigned(LOCAL_tokptr->TokInfo) != 'l') &&
IsPrefixOp((Atom)t, &opprio, &oprprio PASS_REGS)) {
if (LOCAL_tokptr->Tok == Name_tok) {
Atom at = (Atom)LOCAL_tokptr->TokInfo;
#ifndef _MSC_VER
@ -743,22 +698,18 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
if (func == NULL) {
LOCAL_ErrorMessage = "Heap Overflow";
FAIL;
}
t = ParseTerm(rd, oprprio, FailBuff PASS_REGS);
} t = ParseTerm(rd, oprprio, FailBuff PASS_REGS);
t = Yap_MkApplTerm(func, 1, &t);
/* check for possible overflow against local stack */
if (HR > ASP - 4096) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
curprio = opprio;
,
break;
)
} curprio = opprio;
, break;)
}
}
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)
&& Unsigned(LOCAL_tokptr->TokInfo) == 'l')
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) &&
Unsigned(LOCAL_tokptr->TokInfo) == 'l')
t = ParseArgs(rd, (Atom)t, ')', FailBuff, 0L PASS_REGS);
else
t = MkAtomTerm((Atom)t);
@ -777,8 +728,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
FAIL;
}
NextToken;
}
break;
} break;
case WString_tok: /* build list on the heap */
{
@ -788,8 +738,17 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
FAIL;
}
NextToken;
} break;
case StringTerm_tok: /* build list on the heap */
{
Volatile char *p = (char *)LOCAL_tokptr->TokInfo;
t = Yap_CharsToString(p PASS_REGS);
if (!t) {
FAIL;
}
break;
NextToken;
} break;
case Var_tok:
varinfo = (VarEntry *)(LOCAL_tokptr->TokInfo);
@ -843,8 +802,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
}
break;
case QuasiQuotes_tok:
{
case QuasiQuotes_tok: {
qq_t *qq = (qq_t *)(LOCAL_tokptr->TokInfo);
term_t pv, positions = rd->subtpos, to;
Atom at;
@ -855,23 +813,21 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
/* prepare (if we are the first in term) */
if (!rd->varnames)
rd->varnames = PL_new_term_ref();
if ( !rd->qq )
{ if ( rd->quasi_quotations )
{ rd->qq = rd->quasi_quotations;
} else
{ if ( !(rd->qq = PL_new_term_ref()) )
if (!rd->qq) {
if (rd->quasi_quotations) {
rd->qq = rd->quasi_quotations;
} else {
if (!(rd->qq = PL_new_term_ref()))
return FALSE;
}
// create positions term
if ( positions )
{ if ( !(pv = PL_new_term_refs(3)) ||
!PL_unify_term(positions,
PL_FUNCTOR, FUNCTOR_quasi_quotation_position5,
PL_INTPTR, qq->start.charno,
PL_VARIABLE,
PL_TERM, pv+0, // leave three open slots
PL_TERM, pv+1,
PL_TERM, pv+2) )
if (positions) {
if (!(pv = PL_new_term_refs(3)) ||
!PL_unify_term(positions, PL_FUNCTOR,
FUNCTOR_quasi_quotation_position5, PL_INTPTR,
qq->start.charno, PL_VARIABLE, PL_TERM,
pv + 0, // leave three open slots
PL_TERM, pv + 1, PL_TERM, pv + 2))
return FALSE;
} else
pv = 0;
@ -892,21 +848,24 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
tn = Yap_MkNewApplTerm(SWIFunctorToFunctor(FUNCTOR_quasi_quotation4), 4);
tnp = RepAppl(tn) + 1;
tnp[0] = MkAtomTerm(at);
if ( !get_quasi_quotation(Yap_InitSlot( ArgOfTerm(2, tn) PASS_REGS), &qq->text, qq->text+strlen((const char *)qq->text), rd) )
if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn) PASS_REGS),
&qq->text,
qq->text + strlen((const char *)qq->text), rd))
FAIL;
if ( positions )
{ intptr_t qqend = qq->end.charno;
if (positions) {
intptr_t qqend = qq->end.charno;
// set_range_position(positions, -1, qqend PASS_LD);
if ( !PL_unify_term( Yap_InitSlot( ArgOfTerm(2, t) PASS_REGS),
PL_FUNCTOR, FUNCTOR_minus2,
PL_INTPTR, qq->mid.charno+2, /* end of | token */
if (!PL_unify_term(Yap_InitSlot(ArgOfTerm(2, t) PASS_REGS), PL_FUNCTOR,
FUNCTOR_minus2, PL_INTPTR,
qq->mid.charno + 2, /* end of | token */
PL_INTPTR, qqend - 2)) /* end minus "|}" */
FAIL;
}
tnp[2] = Yap_GetFromSlot(rd->varnames PASS_REGS); /* Arg 3: the var dictionary */
tnp[2] =
Yap_GetFromSlot(rd->varnames PASS_REGS); /* Arg 3: the var dictionary */
/* Arg 4: the result */
t = ArgOfTerm(4, tn);
if (!(to = PL_new_term_ref()) ||
@ -923,20 +882,18 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
/* main loop to parse infix and posfix operators starts here */
while (TRUE) {
if (LOCAL_tokptr->Tok == Ord(Name_tok)
&& Yap_HasOp((Atom)(LOCAL_tokptr->TokInfo))) {
if (LOCAL_tokptr->Tok == Ord(Name_tok) &&
Yap_HasOp((Atom)(LOCAL_tokptr->TokInfo))) {
Atom save_opinfo = opinfo = (Atom)(LOCAL_tokptr->TokInfo);
if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio PASS_REGS) &&
opprio <= prio && oplprio >= curprio) {
/* try parsing as infix operator */
Volatile int oldprio = curprio;
TRY3(
func = Yap_MkFunctor((Atom) LOCAL_tokptr->TokInfo, 2);
TRY3(func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 2);
if (func == NULL) {
LOCAL_ErrorMessage = "Heap Overflow";
FAIL;
}
NextToken;
} NextToken;
{
Term args[2];
args[0] = t;
@ -949,15 +906,11 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
}
},
curprio = opprio;
opinfo = save_opinfo;
continue;
,
opinfo = save_opinfo;
curprio = oldprio;
)
opinfo = save_opinfo; continue;, opinfo = save_opinfo;
curprio = oldprio;)
}
if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS) && opprio <= prio &&
oplprio >= curprio) {
/* parse as posfix operator */
Functor func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 1);
if (func == NULL) {
@ -977,8 +930,8 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
break;
}
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) {
if (Unsigned(LOCAL_tokptr->TokInfo) == ',' &&
prio >= 1000 && curprio <= 999) {
if (Unsigned(LOCAL_tokptr->TokInfo) == ',' && prio >= 1000 &&
curprio <= 999) {
Volatile Term args[2];
NextToken;
args[0] = t;
@ -992,8 +945,8 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
curprio = 1000;
continue;
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '|' &&
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS) &&
opprio <= prio && oplprio >= curprio) {
Volatile Term args[2];
NextToken;
args[0] = t;
@ -1007,21 +960,23 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
curprio = opprio;
continue;
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '(' &&
IsPosfixOp(AtomEmptyBrackets, &opprio, &oplprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
IsPosfixOp(AtomEmptyBrackets, &opprio, &oplprio PASS_REGS) &&
opprio <= prio && oplprio >= curprio) {
t = ParseArgs(rd, AtomEmptyBrackets, ')', FailBuff, t PASS_REGS);
curprio = opprio;
continue;
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '[' &&
IsPosfixOp(AtomEmptySquareBrackets, &opprio, &oplprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
IsPosfixOp(AtomEmptySquareBrackets, &opprio,
&oplprio PASS_REGS) &&
opprio <= prio && oplprio >= curprio) {
t = ParseArgs(rd, AtomEmptySquareBrackets, ']', FailBuff, t PASS_REGS);
t = MakeAccessor(t, FunctorEmptySquareBrackets PASS_REGS);
curprio = opprio;
continue;
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '{' &&
IsPosfixOp(AtomEmptyCurlyBrackets, &opprio, &oplprio PASS_REGS)
&& opprio <= prio && oplprio >= curprio) {
IsPosfixOp(AtomEmptyCurlyBrackets, &opprio,
&oplprio PASS_REGS) &&
opprio <= prio && oplprio >= curprio) {
t = ParseArgs(rd, AtomEmptyCurlyBrackets, '}', FailBuff, t PASS_REGS);
t = MakeAccessor(t, FunctorEmptyCurlyBrackets PASS_REGS);
curprio = opprio;
@ -1043,10 +998,7 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS)
return t;
}
Term
Yap_Parse(read_data *rd)
{
Term Yap_Parse(read_data *rd) {
CACHE_REGS
Volatile Term t;
JMPBUFF FailBuff;
@ -1061,4 +1013,3 @@ Yap_Parse(read_data *rd)
}
//! @}

View File

@ -104,7 +104,8 @@ Floating-point numbers are described by:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
where \a \\\<dot\\\> denotes the decimal-point character '.',
\a \\\<exponent-marker\\\> denotes one of 'e' or 'E', and \a \\\<sign\\\> denotes
\a \\\<exponent-marker\\\> denotes one of 'e' or 'E', and \a \\\<sign\\\>
denotes
one of '+' or '-'.
Examples:
@ -122,8 +123,10 @@ Strings are described by the following rules:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string --> '"' string_quoted_characters '"'
string --> '`' string_quoted_characters '`'
string_quoted_characters --> '"' '"' string_quoted_characters
string_quoted_characters --> '`' '`' string_quoted_characters
string_quoted_characters --> '\'
escape_sequence string_quoted_characters
string_quoted_characters -->
@ -172,6 +175,15 @@ versions of YAP up to 4.2.0. Escape sequences can be disable by using:
:- yap_flag(character_escapes,false).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since 6.3.4 YAP supports compact strings, that are not represented as
lists of codes, but instead as a sequence of UTF-8 encoded characters
in the execution stack. These strings do not require allocating a
symbol, as atoms do, but are much more compact than using lists of
codes.
+ Atoms Atoms
Atoms are defined by one of the following rules:
@ -249,7 +261,8 @@ a token are ignored.
All the text appearing in a line after the character \a % is taken to
be a comment and ignored (including \a %). Comments can also be
inserted by using the sequence `/\*` to start the comment and
`\*` followed by `/` to finish it. In the presence of any sequence of comments or
`\*` followed by `/` to finish it. In the presence of any sequence of comments
or
layout characters, the YAP parser behaves as if it had found a
single blank character. The end of a file also counts as a blank
character for this purpose.
@ -390,7 +403,6 @@ writing, writing a BOM can be requested using the option
*/
#include "Yap.h"
#include "Yatom.h"
#include "YapHeap.h"
@ -420,8 +432,8 @@ writing, writing a BOM can be requested using the option
#endif
/* You just can't trust some machines */
#define my_isxdigit(C,SU,SL) (chtype(C) == NU || (C >= 'A' && \
C <= (SU)) || (C >= 'a' && C <= (SL)))
#define my_isxdigit(C, SU, SL) \
(chtype(C) == NU || (C >= 'A' && C <= (SU)) || (C >= 'a' && C <= (SL)))
#define my_isupper(C) (C >= 'A' && C <= 'Z')
#define my_islower(C) (C >= 'a' && C <= 'z')
@ -429,85 +441,106 @@ static Term float_send(char *, int);
static Term get_num(int *, int *, IOSTREAM *, char *, UInt, int);
/* token table with some help from Richard O'Keefe's PD scanner */
static char chtype0[NUMBER_OF_CHARS+1] =
{
static char chtype0[NUMBER_OF_CHARS + 1] = {
EF,
/* nul soh stx etx eot enq ack bel bs ht nl vt np cr so si */
BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS,
/* nul soh stx etx eot enq ack bel bs ht nl vt np cr so si
*/
BS, BS, BS, BS, BS, BS, BS, BS, BS,
BS, BS, BS, BS, BS, BS, BS,
/* dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us */
BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS,
/* dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us
*/
BS, BS, BS, BS, BS, BS, BS, BS, BS,
BS, BS, BS, BS, BS, BS, BS,
/* sp ! " # $ % & ' ( ) * + , - . / */
BS, SL, DC, SY, LC, CC, SY, QT, BK, BK, SY, SY, BK, SY, SY, SY,
BS, SL, DC, SY, LC, CC, SY, QT, BK,
BK, SY, SY, BK, SY, SY, SY,
/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, SY, SL, SY, SY, SY, SY,
NU, NU, NU, NU, NU, NU, NU, NU, NU,
NU, SY, SL, SY, SY, SY, SY,
/* @ A B C D E F G H I J K L M N O */
SY, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC,
SY, UC, UC, UC, UC, UC, UC, UC, UC,
UC, UC, UC, UC, UC, UC, UC,
/* P Q R S T U V W X Y Z [ \ ] ^ _ */
UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, BK, SY, BK, SY, UL,
UC, UC, UC, UC, UC, UC, UC, UC, UC,
UC, UC, BK, SY, BK, SY, UL,
/* ` a b c d e f g h i j k l m n o */
SY, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC,
SY, LC, LC, LC, LC, LC, LC, LC, LC,
LC, LC, LC, LC, LC, LC, LC,
/* p q r s t u v w x y z { | } ~ del */
LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, BK, BK, BK, SY, BS,
LC, LC, LC, LC, LC, LC, LC, LC, LC,
LC, LC, BK, BK, BK, SY, BS,
/* 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 */
BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS,
/* 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
*/
BS, BS, BS, BS, BS, BS, BS, BS, BS,
BS, BS, BS, BS, BS, BS, BS,
/* 144 145 ’ 147 148 149 150 151 152 153 154 155 156 157 158 159 */
BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS,
/* 144 145 ’ 147 148 149 150 151 152 153 154 155 156 157 158 159
*/
BS, BS, BS, BS, BS, BS, BS, BS, BS,
BS, BS, BS, BS, BS, BS, BS,
/*   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ */
BS, SY, SY, SY, SY, SY, SY, SY, SY, SY, LC, SY, SY, SY, SY, SY,
BS, SY, SY, SY, SY, SY, SY, SY, SY,
SY, LC, SY, SY, SY, SY, SY,
/* ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ */
SY, SY, LC, LC, SY, SY, SY, SY, SY, LC, LC, SY, SY, SY, SY, SY,
SY, SY, LC, LC, SY, SY, SY, SY, SY,
LC, LC, SY, SY, SY, SY, SY,
/* À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï */
UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC,
UC, UC, UC, UC, UC, UC, UC, UC, UC,
UC, UC, UC, UC, UC, UC, UC,
/* Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß */
#ifdef vms
UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, LC,
UC, UC, UC, UC, UC, UC, UC, UC, UC,
UC, UC, UC, UC, UC, UC, LC,
#else
UC, UC, UC, UC, UC, UC, UC, SY, UC, UC, UC, UC, UC, UC, UC, LC,
UC, UC, UC, UC, UC, UC, UC, SY, UC,
UC, UC, UC, UC, UC, UC, LC,
#endif
/* à á â ã ä å æ ç è é ê ë ì í î ï */
LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC,
LC, LC, LC, LC, LC, LC, LC, LC, LC,
LC, LC, LC, LC, LC, LC, LC,
/* ð ñ ò ó ô õ ö ÷ ø ù ú û ü cannot write the last three because of lcc */
/* ð ñ ò ó ô õ ö ÷ ø ù ú û ü cannot write the last
* three because of lcc */
#ifdef vms
LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC
LC, LC, LC, LC, LC, LC, LC, LC, LC,
LC, LC, LC, LC, LC, LC, LC
#else
LC, LC, LC, LC, LC, LC, LC, SY, LC, LC, LC, LC, LC, LC, LC, LC
LC, LC, LC, LC, LC, LC, LC, SY, LC,
LC, LC, LC, LC, LC, LC, LC
#endif
};
char *Yap_chtype = chtype0 + 1;
int
Yap_wide_chtype(Int ch) {
int Yap_wide_chtype(Int ch) {
#if HAVE_WCTYPE_H
if (iswalnum(ch)) {
if (iswlower(ch)) return LC;
if (iswdigit(ch)) return NU;
if (iswlower(ch))
return LC;
if (iswdigit(ch))
return NU;
return UC;
}
if (iswpunct(ch)) return SY;
if (iswpunct(ch))
return SY;
#endif
return BS;
}
static inline int
getchr__(IOSTREAM *inp)
{ int c = Sgetcode(inp);
static inline int getchr__(IOSTREAM *inp) {
int c = Sgetcode(inp);
if (!CharConversionTable || c < 0 || c >= 256)
return c;
@ -515,27 +548,20 @@ getchr__(IOSTREAM *inp)
return CharConversionTable[c];
}
#define getchr(inp) getchr__(inp)
#define getchrq(inp) Sgetcode(inp)
static int
GetCurInpPos (IOSTREAM *inp_stream)
{
static int GetCurInpPos(IOSTREAM *inp_stream) {
return inp_stream->posbuf.lineno;
}
/* in case there is an overflow */
typedef struct scanner_extra_alloc {
struct scanner_extra_alloc *next;
void *filler;
} ScannerExtraBlock;
static char *
AllocScannerMemory(unsigned int size)
{
static char *AllocScannerMemory(unsigned int size) {
CACHE_REGS
char *AuxSpScan;
@ -544,7 +570,8 @@ AllocScannerMemory(unsigned int size)
if (LOCAL_ScannerExtraBlocks) {
struct scanner_extra_alloc *ptr;
if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) {
if (!(ptr = (struct scanner_extra_alloc *)malloc(
size + sizeof(ScannerExtraBlock)))) {
return NULL;
}
ptr->next = LOCAL_ScannerExtraBlocks;
@ -558,7 +585,8 @@ AllocScannerMemory(unsigned int size)
if (!Yap_growtrail(alloc_size, TRUE)) {
struct scanner_extra_alloc *ptr;
if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) {
if (!(ptr = (struct scanner_extra_alloc *)malloc(
size + sizeof(ScannerExtraBlock)))) {
return NULL;
}
ptr->next = LOCAL_ScannerExtraBlocks;
@ -570,9 +598,7 @@ AllocScannerMemory(unsigned int size)
return AuxSpScan;
}
static void
PopScannerMemory(char *block, unsigned int size)
{
static void PopScannerMemory(char *block, unsigned int size) {
CACHE_REGS
if (block == LOCAL_ScannerStack - size) {
LOCAL_ScannerStack -= size;
@ -584,18 +610,14 @@ PopScannerMemory(char *block, unsigned int size)
}
}
char *
Yap_AllocScannerMemory(unsigned int size)
{
char *Yap_AllocScannerMemory(unsigned int size) {
/* I assume memory has been initialised */
return AllocScannerMemory(size);
}
extern double atof(const char *);
static Term
float_send(char *s, int sign)
{
static Term float_send(char *s, int sign) {
GET_LD
Float f = (Float)(sign * atof(s));
#if HAVE_ISFINITE || defined(isfinite)
@ -617,9 +639,7 @@ float_send(char *s, int sign)
}
/* we have an overflow at s */
static Term
read_int_overflow(const char *s, Int base, Int val, int sign)
{
static Term read_int_overflow(const char *s, Int base, Int val, int sign) {
#ifdef USE_GMP
/* try to scan it as a bignum */
mpz_t new;
@ -638,17 +658,13 @@ read_int_overflow(const char *s, Int base, Int val, int sign)
#endif
}
static int
send_error_message(char s[])
{
static int send_error_message(char s[]) {
CACHE_REGS
LOCAL_ErrorMessage = s;
return 0;
}
static wchar_t
read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
{
static wchar_t read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream) {
GET_LD
int ch;
@ -665,7 +681,8 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
case 'b':
return '\b';
case 'c':
while (chtype((ch = getchrq(inp_stream))) == BS);
while (chtype((ch = getchrq(inp_stream))) == BS)
;
{
if (ch == '\\') {
goto do_switch;
@ -686,8 +703,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
return ' ';
case 't':
return '\t';
case 'u':
{
case 'u': {
int i;
wchar_t wc = '\0';
@ -705,8 +721,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
}
return wc;
}
case 'U':
{
case 'U': {
int i;
wchar_t wc = '\0';
@ -789,12 +804,16 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
unsigned char so_far = 0;
ch = getchrq(inp_stream);
if (my_isxdigit(ch, 'f', 'F')) { /* hexa */
so_far = so_far * 16 + (chtype(ch) == NU ? ch - '0' :
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
so_far =
so_far * 16 + (chtype(ch) == NU
? ch - '0'
: (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
ch = getchrq(inp_stream);
if (my_isxdigit(ch, 'f', 'F')) { /* hexa */
so_far = so_far * 16 + (chtype(ch) == NU ? ch - '0' :
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
so_far =
so_far * 16 + (chtype(ch) == NU
? ch - '0'
: (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
ch = getchrq(inp_stream);
if (ch == '\\') {
return so_far;
@ -820,9 +839,7 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream)
}
}
static int
num_send_error_message(char s[])
{
static int num_send_error_message(char s[]) {
CACHE_REGS
LOCAL_ErrorMessage = s;
return TermNil;
@ -830,10 +847,8 @@ num_send_error_message(char s[])
/* reads a number, either integer or float */
static Term
get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, int sign)
{
static Term get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s,
UInt max_size, int sign) {
GET_LD
char *sp = s;
int ch = *chp;
@ -886,8 +901,9 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
while (my_isxdigit(ch, upper_case, lower_case)) {
Int oval = val;
int chval = (chtype(ch) == NU ? ch - '0' :
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
int chval =
(chtype(ch) == NU ? ch - '0'
: (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
if (--max_size == 0) {
return num_send_error_message("Number Too Long");
}
@ -907,8 +923,9 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
ch = getchr(inp_stream);
while (my_isxdigit(ch, 'F', 'f')) {
Int oval = val;
int chval = (chtype(ch) == NU ? ch - '0' :
(my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
int chval =
(chtype(ch) == NU ? ch - '0'
: (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10);
if (--max_size == 0) {
return num_send_error_message("Number Too Long");
}
@ -919,8 +936,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
ch = getchr(inp_stream);
}
*chp = ch;
}
else if (ch == 'o' && base == 0) {
} else if (ch == 'o' && base == 0) {
might_be_float = FALSE;
base = 8;
ch = getchr(inp_stream);
@ -959,7 +975,8 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
if (chtype(ch = getchr(inp_stream)) != NU) {
if (ch == 'e' || ch == 'E') {
if (truePrologFlag(PLFLAG_ISO))
return num_send_error_message("Float format not allowed in ISO mode");
return num_send_error_message(
"Float format not allowed in ISO mode");
} else { /* followed by a letter, end of term? */
sp[0] = '\0';
*chbuffp = '.';
@ -972,7 +989,8 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
}
}
#if O_LOCALE
if ((decimalpoint = (unsigned char*) ( localeconv()->decimal_point )) == NULL)
if ((decimalpoint = (unsigned char *)(localeconv()->decimal_point)) ==
NULL)
#endif
decimalpoint = (const unsigned char *)".";
dp = (unsigned char *)decimalpoint;
@ -990,8 +1008,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
return num_send_error_message("Number Too Long");
}
*sp++ = ch;
}
while (chtype(ch = getchr(inp_stream)) == NU);
} while (chtype(ch = getchr(inp_stream)) == NU);
}
}
if (ch == 'e' || ch == 'E') {
@ -1047,9 +1064,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in
/* given a function getchr scan until we either find the number
or end of file */
Term
Yap_scan_num(IOSTREAM *inp)
{
Term Yap_scan_num(IOSTREAM *inp) {
CACHE_REGS
Term out;
int sign = 1;
@ -1089,7 +1104,6 @@ Yap_scan_num(IOSTREAM *inp)
return out;
}
#define CHECK_SPACE() \
if (ASP - HR < 1024) { \
LOCAL_ErrorMessage = "Stack Overflow"; \
@ -1101,9 +1115,7 @@ Yap_scan_num(IOSTREAM *inp)
return l; \
}
static void
open_comment(int ch, IOSTREAM *inp_stream USES_REGS) {
static void open_comment(int ch, IOSTREAM *inp_stream USES_REGS) {
CELL *h0 = HR;
HR += 5;
h0[0] = AbsAppl(h0 + 2);
@ -1127,18 +1139,17 @@ open_comment(int ch, IOSTREAM *inp_stream USES_REGS) {
LOCAL_CommentsBuffPos = 1;
}
static void
extend_comment(int ch USES_REGS) {
static void extend_comment(int ch USES_REGS) {
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_CommentsBuff = (wchar_t *)realloc(
LOCAL_CommentsBuff, sizeof(wchar_t) * (LOCAL_CommentsBuffLim + 4096));
LOCAL_CommentsBuffLim += 4096;
}
}
static void
close_comment( USES_REGS1 ) {
static void close_comment(USES_REGS1) {
LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = '\0';
*LOCAL_CommentsNextChar = Yap_WCharsToString(LOCAL_CommentsBuff PASS_REGS);
free(LOCAL_CommentsBuff);
@ -1146,16 +1157,15 @@ close_comment( USES_REGS1 ) {
LOCAL_CommentsBuffLim = 0;
}
static wchar_t *
ch_to_wide(char *base, char *charp)
{
static wchar_t *ch_to_wide(char *base, char *charp) {
CACHE_REGS
int n = charp - base, i;
wchar_t *nb = (wchar_t *)base;
if ((nb + n) + 1024 > (wchar_t *)AuxSp) {
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
LOCAL_ErrorMessage =
"Heap Overflow While Scanning: please increase code space (-h)";
return NULL;
}
for (i = n; i > 0; i--) {
@ -1165,23 +1175,37 @@ ch_to_wide(char *base, char *charp)
}
#define add_ch_to_buff(ch) \
if (wcharp) { *wcharp++ = (ch); if (wcharp >= (wchar_t *)AuxSp-1024) goto huge_var_error; charp = (char *)wcharp; } \
else { \
if (wcharp) { \
*wcharp++ = (ch); \
if (wcharp >= (wchar_t *)AuxSp - 1024) \
goto huge_var_error; \
charp = (char *)wcharp; \
} else { \
if (ch > MAX_ISO_LATIN1 && !wcharp) { \
/* does not fit in ISO-LATIN */ \
wcharp = ch_to_wide(TokImage, charp); \
if (!wcharp) goto huge_var_error; \
*wcharp++ = (ch); charp = (char *)wcharp; \
} else { if (charp >= (char *)AuxSp-1024) goto huge_var_error; *charp++ = ch; } \
if (!wcharp) \
goto huge_var_error; \
*wcharp++ = (ch); \
charp = (char *)wcharp; \
} else { \
if (charp >= (char *)AuxSp - 1024) \
goto huge_var_error; \
*charp++ = ch; \
} \
}
#define add_ch_to_utf8_buff(ch) \
{ if ( (ch &0xff) == ch) { *charp++ = ch; } else \
{ charp = _PL__utf8_put_char(charp, ch); } }
{ \
if ((ch & 0xff) == ch) { \
*charp++ = ch; \
} else { \
charp = _PL__utf8_put_char(charp, ch); \
} \
}
TokEntry *
Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
{
TokEntry *Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp,
void *rd0) {
GET_LD
TokEntry *t, *l, *p;
enum TokenKinds kind;
@ -1213,7 +1237,6 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
unsigned int len;
char *TokImage = NULL;
t = (TokEntry *)AllocScannerMemory(sizeof(TokEntry));
t->TokNext = NULL;
if (t == NULL) {
@ -1257,7 +1280,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
}
close_comment(PASS_REGS1);
} else {
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF);
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF)
;
}
if (chtype(ch) != EF) {
/* blank space */
@ -1341,8 +1365,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
}
break;
case NU:
{
case NU: {
int cherr;
int cha = ch;
char *ptr;
@ -1357,7 +1380,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
return l;
}
CHECK_SPACE();
if ((t->TokInfo = get_num(&cha,&cherr,inp_stream,ptr,4096,1)) == 0L) {
if ((t->TokInfo = get_num(&cha, &cherr, inp_stream, ptr, 4096, 1)) ==
0L) {
if (p)
p->Tok = Ord(kind = eot_tok);
/* serious error now */
@ -1450,11 +1474,11 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
} else {
t->Tok = Ord(kind = Number_tok);
}
}
break;
} break;
case QT:
case DC:
quoted_string:
TokImage = ((AtomEntry *)(Yap_PreAllocCodeSpace()))->StrOfAE;
charp = TokImage;
quote = ch;
@ -1465,7 +1489,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
while (TRUE) {
if (charp + 1024 > (char *)AuxSp) {
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)";
LOCAL_ErrorMessage =
"Heap Overflow While Scanning: please increase code space (-h)";
break;
}
if (ch == 10 && truePrologFlag(PLFLAG_ISO)) {
@ -1479,7 +1504,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
break;
add_ch_to_buff(ch);
ch = getchrq(inp_stream);
} else if (ch == '\\' && Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) {
} else if (ch == '\\' &&
Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) {
int scan_next = TRUE;
if ((ch = read_quoted_char(&scan_next, inp_stream))) {
add_ch_to_buff(ch);
@ -1499,7 +1525,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
if (charp > (char *)AuxSp - 1024) {
/* Not enough space to read in the string. */
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "not enough space to read in string or quoted atom";
LOCAL_ErrorMessage =
"not enough space to read in string or quoted atom";
/* serious error now */
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
@ -1518,15 +1545,17 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
mp = AllocScannerMemory(len + 1);
}
if (mp == NULL) {
LOCAL_ErrorMessage = "not enough heap space to read in string or quoted atom";
LOCAL_ErrorMessage =
"not enough heap space to read in string or quoted atom";
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
return l;
}
if (wcharp)
if (wcharp) {
wcscpy((wchar_t *)mp, (wchar_t *)TokImage);
else
} else {
strcpy(mp, TokImage);
}
t->TokInfo = Unsigned(mp);
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
if (wcharp) {
@ -1534,6 +1563,27 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
} else {
t->Tok = Ord(kind = String_tok);
}
} else if (quote == '`') {
if (wcharp) {
mp = AllocScannerMemory( utf8_strlen1(TokImage) + 1 );
} else {
mp = AllocScannerMemory(len + 1);
}
if (mp == NULL) {
LOCAL_ErrorMessage =
"not enough heap space to read in string or quoted atom";
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
return l;
}
if (wcharp) {
utf8_wcscpy(mp, (const wchar_t *)TokImage);
} else {
strcpy(mp, TokImage);
}
t->TokInfo = Unsigned(mp);
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = StringTerm_tok);
} else {
if (wcharp) {
t->TokInfo = Unsigned(Yap_LookupWideAtom((wchar_t *)TokImage));
@ -1556,6 +1606,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
break;
case SY:
if (ch == '`' && truePrologFlag(PLFLAG_BACKQUOTED_STRING))
goto quoted_string;
och = ch;
ch = getchr(inp_stream);
if (och == '/' && ch == '*') {
@ -1597,10 +1649,11 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
goto restart;
}
enter_symbol:
if (och == '.' && (chtype(ch) == BS || chtype(ch) == EF
|| chtype(ch) == CC)) {
if (och == '.' &&
(chtype(ch) == BS || chtype(ch) == EF || chtype(ch) == CC)) {
if (chtype(ch) == CC)
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF);
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF)
;
t->Tok = Ord(kind = eot_tok);
} else {
Atom ae;
@ -1646,8 +1699,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
}
break;
case SL:
{
case SL: {
char chs[2];
chs[0] = ch;
chs[1] = '\0';
@ -1656,15 +1708,16 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
t->Tok = Ord(kind = Name_tok);
if (ch == '(')
solo_flag = FALSE;
}
break;
} break;
case BK:
och = ch;
ch = getchr(inp_stream);
t->TokInfo = och;
if (och == '(') {
while (chtype(ch) == BS) { ch = getchr(inp_stream); };
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
};
if (ch == ')') {
t->TokInfo = Unsigned(AtomEmptyBrackets);
t->Tok = Ord(kind = Name_tok);
@ -1676,7 +1729,9 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
solo_flag = TRUE;
}
} else if (och == '[') {
while (chtype(ch) == BS) { ch = getchr(inp_stream); };
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
};
if (ch == ']') {
t->TokInfo = Unsigned(AtomNil);
t->Tok = Ord(kind = Name_tok);
@ -1712,7 +1767,9 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
solo_flag = FALSE;
break;
}
while (chtype(ch) == BS) { ch = getchr(inp_stream); };
while (chtype(ch) == BS) {
ch = getchr(inp_stream);
};
if (ch == '}') {
t->TokInfo = Unsigned(AtomBraces);
t->Tok = Ord(kind = Name_tok);
@ -1741,7 +1798,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
TokImage = Yap_PreAllocCodeSpace();
if (!TokImage) {
LOCAL_ErrorMessage = "not enough heap space to read in a quasi quoted atom";
LOCAL_ErrorMessage =
"not enough heap space to read in a quasi quoted atom";
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
return l;
@ -1773,7 +1831,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
if (charp > (char *)AuxSp - 1024) {
/* Not enough space to read in the string. */
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
LOCAL_ErrorMessage = "not enough space to read in string or quoted atom";
LOCAL_ErrorMessage =
"not enough space to read in string or quoted atom";
/* serious error now */
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = eot_tok);
@ -1821,7 +1880,9 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
t->Tok = Ord(kind = eot_tok);
}
#if DEBUG
if(GLOBAL_Option[2]) fprintf(stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)t->TokInfo);
if (GLOBAL_Option[2])
fprintf(stderr, "[Token %d %ld]", Ord(kind),
(unsigned long int)t->TokInfo);
#endif
if (LOCAL_ErrorMessage) {
/* insert an error token to inform the system of what happened */
@ -1845,9 +1906,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
return (l);
}
void
Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable, Term commentable)
{
void Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable,
VarEntry *anonvartable, Term commentable) {
CACHE_REGS
struct scanner_extra_alloc *ptr = LOCAL_ScannerExtraBlocks;
while (ptr) {
@ -1864,5 +1924,4 @@ Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartab
LOCAL_CommentsBuffLim = 0;
}
/// @}

273
C/write.c
View File

@ -60,7 +60,6 @@ typedef struct union_direct {
CELL *ptr;
} udirect;
typedef struct rewind_term {
struct rewind_term *parent;
union {
@ -83,23 +82,22 @@ typedef struct write_globs {
#define lastw wglb->lw
#define last_minus wglb->last_atom_minus
static bool
callPortray(Term t, struct DB_TERM **old_EXp USES_REGS)
{
static bool callPortray(Term t, struct DB_TERM **old_EXp USES_REGS) {
PredEntry *pe;
Int b0 = LCL0 - (CELL *)B;
EX = NULL;
if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorPortray, USER_MODULE))) &&
pe->OpcodeOfPred != FAIL_OPCODE &&
pe->OpcodeOfPred != UNDEF_OPCODE &&
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
Yap_execute_pred(pe, &t PASS_REGS)) {
choiceptr B0 = (choiceptr)(LCL0 - b0);
if (EX && !*old_EXp) *old_EXp = EX;
if (EX && !*old_EXp)
*old_EXp = EX;
Yap_fail_all(B0 PASS_REGS);
return true;
}
if (EX && !*old_EXp) *old_EXp = EX;
if (EX && !*old_EXp)
*old_EXp = EX;
return false;
}
@ -111,7 +109,8 @@ static int legalAtom(unsigned char *);
static int RightOpToProtect(Atom, int);*/
static wtype AtomIsSymbols(unsigned char *);
static void putAtom(Atom, int, struct write_globs *);
static void writeTerm(Term, int, int, int, struct write_globs *, struct rewind_term *);
static void writeTerm(Term, int, int, int, struct write_globs *,
struct rewind_term *);
#define wrputc(X, WF) Sputcode(X, WF) /* writes a character */
@ -119,9 +118,7 @@ static void writeTerm(Term, int, int, int, struct write_globs *, struct rewind_t
protect bracket from merging with previoous character.
avoid stuff like not (2,3) -> not(2,3) or
*/
static void
wropen_bracket(struct write_globs *wglb, int protect)
{
static void wropen_bracket(struct write_globs *wglb, int protect) {
wrf stream = wglb->stream;
if (lastw != separator && protect)
@ -130,33 +127,27 @@ wropen_bracket(struct write_globs *wglb, int protect)
lastw = separator;
}
static void
wrclose_bracket(struct write_globs *wglb, int protect)
{
static void wrclose_bracket(struct write_globs *wglb, int protect) {
wrf stream = wglb->stream;
wrputc(')', stream);
lastw = separator;
}
static int
protect_open_number(struct write_globs *wglb, int lm, int minus_required)
{
static int protect_open_number(struct write_globs *wglb, int lm,
int minus_required) {
wrf stream = wglb->stream;
if (lastw == symbol && lm && !minus_required) {
wropen_bracket(wglb, TRUE);
return TRUE;
} else if (lastw == alphanum ||
(lastw == symbol && minus_required)) {
} else if (lastw == alphanum || (lastw == symbol && minus_required)) {
wrputc(' ', stream);
}
return FALSE;
}
static void
protect_close_number(struct write_globs *wglb, int used_bracket)
{
static void protect_close_number(struct write_globs *wglb, int used_bracket) {
if (used_bracket) {
wrclose_bracket(wglb, TRUE);
} else {
@ -165,8 +156,8 @@ protect_close_number(struct write_globs *wglb, int used_bracket)
last_minus = FALSE;
}
static void
wrputn(Int n, struct write_globs *wglb) /* writes an integer */
static void wrputn(Int n,
struct write_globs *wglb) /* writes an integer */
{
wrf stream = wglb->stream;
@ -187,9 +178,7 @@ wrputn(Int n, struct write_globs *wglb) /* writes an integer */
#define wrputs(s, stream) Sfputs(s, stream)
static void
wrputws(wchar_t *s, wrf stream) /* writes a string */
static void wrputws(wchar_t *s, wrf stream) /* writes a string */
{
while (*s)
wrputc(*s++, stream);
@ -197,8 +186,7 @@ wrputws(wchar_t *s, wrf stream) /* writes a string */
#ifdef USE_GMP
static char *
ensure_space(size_t sz) {
static char *ensure_space(size_t sz) {
CACHE_REGS
char *s;
@ -228,15 +216,15 @@ ensure_space(size_t sz) {
if (!s) {
s = (char *)HR;
if (s + sz >= (char *)ASP) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"not enough space to write bignum: it requires %d bytes", sz);
Yap_Error(OUT_OF_STACK_ERROR, TermNil,
"not enough space to write bignum: it requires %d bytes", sz);
s = NULL;
}
}
return s;
}
static void
write_mpint(MP_INT *big, struct write_globs *wglb) {
static void write_mpint(MP_INT *big, struct write_globs *wglb) {
char *s;
int has_minus = mpz_sgn(big);
int ob;
@ -258,9 +246,8 @@ write_mpint(MP_INT *big, struct write_globs *wglb) {
#endif
/* writes a bignum */
static void
writebig(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, struct rewind_term *rwt)
{
static void writebig(Term t, int p, int depth, int rinfixarg,
struct write_globs *wglb, struct rewind_term *rwt) {
CELL *pt = RepAppl(t) + 1;
CELL big_tag = pt[0];
@ -271,8 +258,7 @@ writebig(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, stru
lastw = separator;
return;
#ifdef USE_GMP
} else if (big_tag == BIG_INT)
{
} else if (big_tag == BIG_INT) {
MP_INT *big = Yap_BigIntOfTerm(t);
write_mpint(big, wglb);
return;
@ -295,8 +281,7 @@ writebig(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, stru
wrputs("0", wglb->stream);
}
static void
wrputf(Float f, struct write_globs *wglb) /* writes a float */
static void wrputf(Float f, struct write_globs *wglb) /* writes a float */
{
char s[256];
@ -304,7 +289,6 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
int sgn;
int ob;
#if HAVE_ISNAN || defined(__WIN32)
if (isnan(f)) {
wrputs("(nan)", stream);
@ -332,8 +316,8 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
int ch;
/* always use C locale for writing numbers */
#if O_LOCALE
const unsigned char *decimalpoint = (unsigned char*)
localeconv()->decimal_point;
const unsigned char *decimalpoint =
(unsigned char *)localeconv()->decimal_point;
size_t l1 = strlen((const char *)decimalpoint + 1);
#else
const unsigned char decimalpoint[2] = ".";
@ -354,7 +338,8 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
}
while ((ch = *pt) != '\0') {
// skip locale
if (ch == decimalpoint[0] && !strncmp(pt+1, (char *)decimalpoint+1, l1)) {
if (ch == decimalpoint[0] &&
!strncmp(pt + 1, (char *)decimalpoint + 1, l1)) {
found_dot = TRUE;
pt += l1;
ch = '.';
@ -381,15 +366,14 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
}
/* use SWI's format_float */
buf = format_float(f, s);
if (!buf) return;
if (!buf)
return;
wrputs(buf, stream);
#endif
protect_close_number(wglb, ob);
}
int
Yap_FormatFloat( Float f, const char *s, size_t sz )
{
int Yap_FormatFloat(Float f, const char *s, size_t sz) {
struct write_globs wglb;
char *ws = (char *)s;
IOSTREAM *smem = Sopenmem(&ws, &sz, "w");
@ -401,11 +385,9 @@ Yap_FormatFloat( Float f, const char *s, size_t sz )
return TRUE;
}
/* writes a data base reference */
static void
wrputref(CODEADDR ref, int Quote_illegal, struct write_globs *wglb)
{
static void wrputref(CODEADDR ref, int Quote_illegal,
struct write_globs *wglb) {
char s[256];
wrf stream = wglb->stream;
@ -420,9 +402,8 @@ wrputref(CODEADDR ref, int Quote_illegal, struct write_globs *wglb)
}
/* writes a blob (default) */
static int
wrputblob(AtomEntry * ref, int Quote_illegal, struct write_globs *wglb)
{
static int wrputblob(AtomEntry *ref, int Quote_illegal,
struct write_globs *wglb) {
char s[256];
wrf stream = wglb->stream;
PL_blob_t *type = RepBlobProp(ref->PropsOfAE)->blob_t;
@ -443,8 +424,7 @@ wrputblob(AtomEntry * ref, int Quote_illegal, struct write_globs *wglb)
return 1;
}
static int
legalAtom(unsigned char *s) /* Is this a legal atom ? */
static int legalAtom(unsigned char *s) /* Is this a legal atom ? */
{
wchar_t ch = *s;
@ -461,7 +441,8 @@ legalAtom(unsigned char *s) /* Is this a legal atom ? */
return FALSE;
} else {
if (ch == '/') {
if (s[1] == '*') return FALSE;
if (s[1] == '*')
return FALSE;
}
while (ch) {
if (Yap_chtype[ch] != SY) {
@ -491,9 +472,7 @@ AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */
return symbol;
}
static void
write_quoted(wchar_t ch, wchar_t quote, wrf stream)
{
static void write_quoted(wchar_t ch, wchar_t quote, wrf stream) {
CACHE_REGS
if (!(Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE)) {
wrputc(ch, stream);
@ -501,7 +480,7 @@ write_quoted(wchar_t ch, wchar_t quote, wrf stream)
wrputc('\'', stream); /* be careful about quotes */
return;
}
if (!(ch < 0xff && chtype(ch) == BS) && ch != '\'' && ch != '\\') {
if (!(ch < 0xff && chtype(ch) == BS) && ch != '\'' && ch != '\\' && ch != '`') {
wrputc(ch, stream);
} else {
switch (ch) {
@ -519,6 +498,11 @@ write_quoted(wchar_t ch, wchar_t quote, wrf stream)
wrputc('\\', stream);
wrputc(ch, stream);
break;
case '`':
if (ch == quote)
wrputc('`', stream);
wrputc(ch, stream);
break;
case 7:
wrputc('\\', stream);
wrputc('a', stream);
@ -563,33 +547,29 @@ write_quoted(wchar_t ch, wchar_t quote, wrf stream)
}
}
static void
write_string(const char *s, struct write_globs *wglb) /* writes an integer */
static void write_string(const char *s,
struct write_globs *wglb) /* writes an integer */
{
IOSTREAM *stream = wglb->stream;
int chr;
int chr, qt;
char *ptr = (char *)s;
if (wglb->Write_strings)
wrputc('`', stream);
qt = '`';
else
wrputc('"', stream);
qt = '"';
wrputc(qt, stream);
do {
ptr = utf8_get_char(ptr, &chr);
if (chr == '\0') break;
write_quoted(chr, '"', stream);
if (chr == '\0')
break;
write_quoted(chr, qt, stream);
} while (TRUE);
if (wglb->Write_strings)
wrputc('`', stream);
else
wrputc('"', stream);
wrputc(qt, stream);
}
/* writes an atom */
static void
putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
{
static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) {
unsigned char *s;
wtype atom_or_symbol;
wrf stream = wglb->stream;
@ -616,7 +596,8 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
s = (unsigned char *)RepAtom(atom)->StrOfAE;
/* #define CRYPT_FOR_STEVE 1*/
#ifdef CRYPT_FOR_STEVE
if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) {
if (Yap_GetValue(AtomCryptAtoms) != TermNil &&
Yap_GetAProp(atom, OpProperty) == NIL) {
char s[16];
sprintf(s, "x%x", (CELL)s);
wrputs(s, stream);
@ -641,17 +622,14 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
}
}
void
Yap_WriteAtom(IOSTREAM *s, Atom atom)
{
void Yap_WriteAtom(IOSTREAM *s, Atom atom) {
struct write_globs wglb;
wglb.stream = s;
wglb.Quote_illegal = FALSE;
putAtom(atom, 0, &wglb);
}
static int
IsCodesTerm(Term string) /* checks whether this is a string */
static int IsCodesTerm(Term string) /* checks whether this is a string */
{
if (IsVarTerm(string))
return FALSE;
@ -659,22 +637,25 @@ IsCodesTerm(Term string) /* checks whether this is a string */
Term hd;
int ch;
if (!IsPairTerm(string)) return(FALSE);
if (!IsPairTerm(string))
return (FALSE);
hd = HeadOfTerm(string);
if (IsVarTerm(hd)) return(FALSE);
if (!IsIntTerm(hd)) return(FALSE);
if (IsVarTerm(hd))
return (FALSE);
if (!IsIntTerm(hd))
return (FALSE);
ch = IntOfTerm(HeadOfTerm(string));
if ((ch < ' ' || ch > MAX_ISO_LATIN1) && ch != '\n' && ch != '\t')
return (FALSE);
string = TailOfTerm(string);
if (IsVarTerm(string)) return(FALSE);
if (IsVarTerm(string))
return (FALSE);
} while (string != TermNil);
return (TRUE);
}
/* writes a string */
static void
putString(Term string, struct write_globs *wglb)
static void putString(Term string, struct write_globs *wglb)
{
wrf stream = wglb->stream;
@ -689,8 +670,7 @@ putString(Term string, struct write_globs *wglb)
}
/* writes a string */
static void
putUnquotedString(Term string, struct write_globs *wglb)
static void putUnquotedString(Term string, struct write_globs *wglb)
{
wrf stream = wglb->stream;
@ -702,10 +682,8 @@ putUnquotedString(Term string, struct write_globs *wglb)
lastw = alphanum;
}
static Term
from_pointer(CELL *ptr0, struct rewind_term *rwt, struct write_globs *wglb)
{
static Term from_pointer(CELL *ptr0, struct rewind_term *rwt,
struct write_globs *wglb) {
CACHE_REGS
Term t;
CELL *ptr = ptr0;
@ -742,9 +720,8 @@ from_pointer(CELL *ptr0, struct rewind_term *rwt, struct write_globs *wglb)
return t;
}
static CELL *
restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
{
static CELL *restore_from_write(struct rewind_term *rwt,
struct write_globs *wglb) {
CACHE_REGS
CELL *ptr;
@ -760,9 +737,8 @@ restore_from_write(struct rewind_term *rwt, struct write_globs *wglb)
}
/* writes an unbound variable */
static void
write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
{
static void write_var(CELL *t, struct write_globs *wglb,
struct rewind_term *rwt) {
CACHE_REGS
if (lastw == alphanum) {
wrputc(' ', wglb->stream);
@ -804,9 +780,8 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
}
}
static Term
check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
{
static Term check_infinite_loop(Term t, struct rewind_term *x,
struct write_globs *wglb) {
CACHE_REGS
if (wglb->Keep_terms) {
while (x) {
@ -824,9 +799,8 @@ check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
return t;
}
static void
write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt)
{
static void write_list(Term t, int direction, int depth,
struct write_globs *wglb, struct rewind_term *rwt) {
Term ti;
struct rewind_term nrwt;
nrwt.parent = rwt;
@ -836,7 +810,8 @@ write_list(Term t, int direction, int depth, struct write_globs *wglb, struct re
int ndirection;
int do_jump;
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth+1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE,
wglb, &nrwt);
t = AbsPair(restore_from_write(&nrwt, wglb));
ti = TailOfTerm(t);
if (IsVarTerm(ti))
@ -884,14 +859,14 @@ write_list(Term t, int direction, int depth, struct write_globs *wglb, struct re
} else if (ti != MkAtomTerm(AtomNil)) {
wrputc('|', wglb->stream);
lastw = separator;
writeTerm(from_pointer(RepPair(t)+1, &nrwt, wglb), 999, depth, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth, FALSE,
wglb, &nrwt);
restore_from_write(&nrwt, wglb);
}
}
static void
writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, struct rewind_term *rwt)
static void writeTerm(Term t, int p, int depth, int rinfixarg,
struct write_globs *wglb, struct rewind_term *rwt)
/* term to write */
/* context priority */
@ -920,16 +895,19 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
wrputs("'.'(", wglb->stream);
lastw = separator;
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE,
wglb, &nrwt);
t = AbsPair(restore_from_write(&nrwt, wglb));
wrputs(",", wglb->stream);
writeTerm(from_pointer(RepPair(t)+1, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth + 1,
FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
wrclose_bracket(wglb, TRUE);
return;
}
if (wglb->Use_portray)
if (callPortray(t, &EX PASS_REGS) ) return;
if (callPortray(t, &EX PASS_REGS))
return;
if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsCodesTerm(t)) {
putString(t, wglb);
} else {
@ -988,7 +966,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
*p++;
lastw = separator;
/* cannot use the term directly with the SBA */
writeTerm(from_pointer(p, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(p, &nrwt, wglb), 999, depth + 1, FALSE, wglb,
&nrwt);
p = restore_from_write(&nrwt, wglb) + 1;
if (*p)
wrputc(',', wglb->stream);
@ -999,15 +978,12 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
}
#endif
if (wglb->Use_portray) {
if (callPortray(t, &EX PASS_REGS) ) return;
if (callPortray(t, &EX PASS_REGS))
return;
}
if (!wglb->Ignore_ops &&
Arity == 1 &&
Yap_IsPrefixOp(atom, &op, &rp)
) {
if (!wglb->Ignore_ops && Arity == 1 && Yap_IsPrefixOp(atom, &op, &rp)) {
Term tright = ArgOfTerm(1, t);
int bracket_right =
!IsVarTerm(tright) && IsAtomTerm(tright) &&
int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) &&
Yap_IsOp(AtomOfTerm(tright));
if (op > p) {
wropen_bracket(wglb, TRUE);
@ -1019,7 +995,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
} else if (atom == AtomMinus) {
last_minus = TRUE;
}
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), rp, depth + 1, TRUE, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), rp, depth + 1, TRUE,
wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (bracket_right) {
wrclose_bracket(wglb, TRUE);
@ -1028,7 +1005,10 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
wrclose_bracket(wglb, TRUE);
}
} else if (!wglb->Ignore_ops &&
( Arity == 1 || ((atom == AtomEmptyBrackets || atom == AtomEmptyCurlyBrackets || atom == AtomEmptySquareBrackets) && Yap_IsListTerm(ArgOfTerm(1, t)))) &&
(Arity == 1 ||
((atom == AtomEmptyBrackets || atom == AtomEmptyCurlyBrackets ||
atom == AtomEmptySquareBrackets) &&
Yap_IsListTerm(ArgOfTerm(1, t)))) &&
Yap_IsPosfixOp(atom, &op, &lp)) {
Term tleft = ArgOfTerm(1, t);
@ -1042,9 +1022,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
offset = 1;
}
bracket_left =
!IsVarTerm(tleft) &&
IsAtomTerm(tleft) &&
Yap_IsOp(AtomOfTerm(tleft));
!IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft));
if (op > p) {
/* avoid stuff such as \+ (a,b) being written as \+(a,b) */
wropen_bracket(wglb, TRUE);
@ -1052,7 +1030,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (bracket_left) {
wropen_bracket(wglb, TRUE);
}
writeTerm(from_pointer(RepAppl(t)+offset, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + offset, &nrwt, wglb), lp, depth + 1,
rinfixarg, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (bracket_left) {
wrclose_bracket(wglb, TRUE);
@ -1081,16 +1060,13 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (op > p) {
wrclose_bracket(wglb, TRUE);
}
} else if (!wglb->Ignore_ops &&
Arity == 2 && Yap_IsInfixOp(atom, &op, &lp,
&rp) ) {
} else if (!wglb->Ignore_ops && Arity == 2 &&
Yap_IsInfixOp(atom, &op, &lp, &rp)) {
Term tleft = ArgOfTerm(1, t);
Term tright = ArgOfTerm(2, t);
int bracket_left =
!IsVarTerm(tleft) && IsAtomTerm(tleft) &&
Yap_IsOp(AtomOfTerm(tleft));
int bracket_right =
!IsVarTerm(tright) && IsAtomTerm(tright) &&
!IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft));
int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) &&
Yap_IsOp(AtomOfTerm(tright));
if (op > p) {
@ -1101,7 +1077,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (bracket_left) {
wropen_bracket(wglb, TRUE);
}
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), lp, depth + 1,
rinfixarg, wglb, &nrwt);
t = AbsAppl(restore_from_write(&nrwt, wglb) - 1);
if (bracket_left) {
wrclose_bracket(wglb, TRUE);
@ -1118,7 +1095,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (bracket_right) {
wropen_bracket(wglb, TRUE);
}
writeTerm(from_pointer(RepAppl(t)+2, &nrwt, wglb), rp, depth + 1, TRUE, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + 2, &nrwt, wglb), rp, depth + 1, TRUE,
wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (bracket_right) {
wrclose_bracket(wglb, TRUE);
@ -1131,7 +1109,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (lastw == alphanum) {
wrputc(' ', wglb->stream);
}
if (!IsVarTerm(ti) && (IsIntTerm(ti) || IsCodesTerm(ti) || IsAtomTerm(ti))) {
if (!IsVarTerm(ti) &&
(IsIntTerm(ti) || IsCodesTerm(ti) || IsAtomTerm(ti))) {
if (IsIntTerm(ti)) {
Int k = IntOfTerm(ti);
if (k == -1) {
@ -1155,14 +1134,16 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
} else {
wrputs("'$VAR'(", wglb->stream);
lastw = separator;
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), 999, depth + 1,
FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
wrclose_bracket(wglb, TRUE);
}
} else if (!wglb->Ignore_ops && functor == FunctorBraces) {
wrputc('{', wglb->stream);
lastw = separator;
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), 1200, depth + 1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), 1200, depth + 1,
FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
wrputc('}', wglb->stream);
lastw = separator;
@ -1174,7 +1155,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
wrputs("...", wglb->stream);
break;
}
writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1,
FALSE, wglb, &nrwt);
t = AbsAppl(restore_from_write(&nrwt, wglb) - op);
if (op != Arity) {
wrputc(',', wglb->stream);
@ -1194,7 +1176,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
wrputc('.', wglb->stream);
break;
}
writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1,
FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (op != Arity) {
wrputc(',', wglb->stream);
@ -1206,8 +1189,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
}
}
void
Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority)
void Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority)
/* term to be written */
/* consumer */
/* write options */
@ -1239,4 +1221,3 @@ Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority)
writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt);
restore_from_write(&rwt, &wglb);
}

View File

@ -509,13 +509,18 @@ ADD_SUBDIRECTORY(swi/library)
# ADD_SUBDIRECTORY(os)
# ADD_SUBDIRECTORY(packages)
if (BUILD_JIT)
macro_optional_find_package (LLVM ON)
macro_log_feature (LLVM_FOUND "LLVM JIT generator"
"The LLVM Compiler Infrastructure" "http://www.llvm.org")
if (LLVM_FOUND)
add_definitions (-DYAP_JIT=1)
INCLUDE_DIRECTORIES(JIT JIT/HPP)
macro_optional_add_subdirectory(JIT ON)
macro_optional_add_subdirectory(JIT)
endif()
macro_optional_add_subdirectory(library/mpi)
macro_optional_add_subdirectory(library/lammpi)
macro_optional_add_subdirectory (packages/gecode)

View File

@ -4,6 +4,7 @@ typedef enum TokenKinds {
Var_tok,
String_tok,
WString_tok,
StringTerm_tok,
Ponctuation_tok,
Error_tok,
QuasiQuotes_tok,
@ -29,4 +30,3 @@ typedef struct VARSTRUCT {
struct VARSTRUCT *VarLeft, *VarRight;
char VarRep[1];
} VarEntry;

View File

@ -336,7 +336,7 @@ typedef struct environment {
#if YAP_JIT
/* Enumeration for types of basic blocks -- used on trace construction */
typedef enum {
typedef enum block_try {
NONE, // untyped
SIMPLE_ENTRY, // first basic block of any yaam opcode
SIMPLE, // any other basic block of any yaam opcode

View File

@ -149,36 +149,6 @@ extern YP_FILE yp_iob[YP_MAX_FILES];
typedef YP_FILE *YP_File;
/* ricardo
typedef enum TokenKinds {
Name_tok,
Number_tok,
Var_tok,
String_tok,
WString_tok,
Ponctuation_tok,
Error_tok,
eot_tok
} tkinds;
typedef struct TOKEN {
enum TokenKinds Tok;
Term TokInfo;
int TokPos;
struct TOKEN *TokNext;
} TokEntry;
#define Ord(X) ((enum TokenKinds) (X))
#define NextToken GNextToken( PASS_REGS1 )
typedef struct VARSTRUCT {
Term VarAdr;
CELL hv;
struct VARSTRUCT *VarLeft, *VarRight;
char VarRep[1];
} VarEntry;
*/
#ifndef _PL_WRITE_
@ -351,5 +321,3 @@ WideHashFunction(wchar_t *CHP)
#define QUIET_ON_PARSER_ERROR 1
#define CONTINUE_ON_PARSER_ERROR 2
#define EXCEPTION_ON_PARSER_ERROR 3

View File

@ -16,11 +16,6 @@ set(LIBJIT_SOURCES
JIT_Init.cpp
)
macro_optional_find_package (LLVM ON)
macro_log_feature (LLVM_FOUND "LLVM JIT generator"
"The LLVM Compiler Infrastructure" "http://www.llvm.org")
# The following variables are defined:
# LLVM_FOUND - true if LLVM was found
# LLVM_CXXFLAGS - C++ compiler flags for files that include LLVM headers.

View File

@ -1194,7 +1194,7 @@ initPrologFlags(void)
setPrologFlag("colon_sets_calling_context", FT_BOOL|FF_READONLY, TRUE, 0);
setPrologFlag("character_escapes", FT_BOOL, TRUE, PLFLAG_CHARESCAPE);
setPrologFlag("char_conversion", FT_BOOL, FALSE, PLFLAG_CHARCONVERSION);
setPrologFlag("backquoted_string", FT_BOOL, FALSE, PLFLAG_BACKQUOTED_STRING);
setPrologFlag("backquoted_string", FT_BOOL, TRUE, PLFLAG_BACKQUOTED_STRING);
#ifdef O_QUASIQUOTATIONS
setPrologFlag("quasi_quotations", FT_BOOL, TRUE, PLFLAG_QUASI_QUOTES);
#endif
@ -1329,4 +1329,3 @@ BeginPredDefs(prologflag)
EndPredDefs
//! @}

View File

@ -252,3 +252,21 @@ utf8_strprefix(const char *s1, const char *s2)
return 0;
}
char *
utf8_wcscpy(char *sf, const wchar_t *s0)
{
char *sf0 = sf;
while(1)
{ int chr1;
chr1 = * s0++;
if (chr1 == '\0') {
*sf++ = '\0';
return sf0;
}
sf = utf8_put_char(sf, chr1);
}
return NULL;
}

View File

@ -26,6 +26,8 @@
#ifndef UTF8_H_INCLUDED
#define UTF8_H_INCLUDED
#include <wchar.h>
#define PL_MB_LEN_MAX 16
#define UTF8_MALFORMED_REPLACEMENT 0xfffd
@ -66,6 +68,8 @@ extern size_t utf8_strlen1(const char *s);
extern const char * utf8_skip(const char *s, int n);
extern int utf8_strncmp(const char *s1, const char *s2, size_t n);
extern int utf8_strprefix(const char *s1, const char *s2);
/// copy a wide string to an UTF-8 version.
extern char *utf8_wcscpy(char *sf, const wchar_t *s0);
typedef enum {
S_ASCII,

View File

@ -711,7 +711,7 @@ pl_write_canonical2(term_t stream, term_t term)
rc = ( numberVars(term, &options, 0 PASS_LD) >= 0 &&
do_write2(stream, term,
PL_WRT_QUOTED|PL_WRT_IGNOREOPS|PL_WRT_NUMBERVARS)
PL_WRT_QUOTED|PL_WRT_IGNOREOPS|PL_WRT_NUMBERVARS|PLFLAG_BACKQUOTED_STRING)
);
END_NUMBERVARS(TRUE);
@ -796,5 +796,3 @@ pl_writeln(term_t term)
BeginPredDefs(write)
EndPredDefs

@ -1 +1 @@
Subproject commit 849232fea0f549f6704b16afa1c986e0d50ec177
Subproject commit 8257467ff9a7bb901d1688e6a75ad072e0246aba

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit d0d1ee4d58373cc611676103e0a50a3ae451a023
Subproject commit 9972458293415b2d72276bd67875767bfeed00df

View File

@ -1,4 +1,7 @@
#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE // python does its own thing
#endif
#include <Python.h>
#include <SWI-Stream.h>
#include <SWI-Prolog.h>
@ -1677,4 +1680,3 @@ install_python(void)
PL_register_foreign("python_run_command", 1, python_run_command, 0);
PL_register_foreign("python_main_module", 1, python_main_module, 0);
}

@ -1 +1 @@
Subproject commit 34d9f645721645aac9f4f40c815fe4fe2c6511e6
Subproject commit 36f99e3c3c978fef25f899dc4fab1ffee334d73c

View File

@ -1,5 +1,30 @@
package pt.up.fc.dcc.yap;
/**** using sqlite
For example,the following:
import android.database.sqlite.SQLiteDatabase;
should be replaced with:
import org.sqlite.database.sqlite.SQLiteDatabase;
As well as replacing all uses of the classes in the android.database.sqlite.* namespace, the application must also be sure to use the following two:
org.sqlite.database.SQLException
org.sqlite.database.DatabaseErrorHandler
instead of:
android.database.SQLException
android.database.DatabaseErrorHandler
Aside from namespace changes, there are other differences from the stock Android interface that applications need to be aware of:
The SQLiteStatement.simpleQueryForBlobFileDescriptor() API is not available. The collation sequence "UNICODE" is not available. The collation sequence "LOCALIZED", which normally changes with the system's current locale, is always equivalent to SQLite's built in collation BINARY.
****/
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
@ -18,6 +43,7 @@ import org.sqlite.database.sqlite.SQLiteStatement;
import org.sqlite.database.sqlite.SQLiteDatabaseCorruptException;
import org.sqlite.database.sqlite.SQLiteOpenHelper;
import org.sqlite.database.SQLException;
import org.sqlite.database.DatabaseErrorHandler;
class DoNotDeleteErrorHandler implements DatabaseErrorHandler {
private static final String TAG = "DoNotDeleteErrorHandler";
@ -49,7 +75,7 @@ public class JavaYap extends Activity
// text.setText("");
if (vs0.nil()) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "q=");
Log.i(TAG, "q0=\n");
}
if (q.next()) {
outputText.append( "yes\n" );
@ -59,12 +85,12 @@ public class JavaYap extends Activity
} else {
int i=1;
if (BuildConfig.DEBUG) {
Log.i(TAG, "q=");
Log.i(TAG, "q1= "+vs0.text()+"\n");
}
while (rc = q.next()) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "q=");
Log.i(TAG, "q= "+vs0.text()+"\n");
}
YAPListTerm vs = vs0;