indenting
This commit is contained in:
parent
a3c09d66be
commit
7468de4553
@ -263,14 +263,12 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
|
|||||||
}
|
}
|
||||||
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, t0);
|
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, t0);
|
||||||
} break;
|
} break;
|
||||||
case QuasiQuotes_tok:
|
case QuasiQuotes_tok: {
|
||||||
{
|
|
||||||
Term t0[2];
|
Term t0[2];
|
||||||
t0[0] = MkAtomTerm(Yap_LookupAtom("<QQ>"));
|
t0[0] = MkAtomTerm(Yap_LookupAtom("<QQ>"));
|
||||||
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, t0);
|
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, t0);
|
||||||
} break;
|
} break;
|
||||||
case WQuasiQuotes_tok:
|
case WQuasiQuotes_tok: {
|
||||||
{
|
|
||||||
Term t0[2];
|
Term t0[2];
|
||||||
t0[0] = MkAtomTerm(Yap_LookupAtom("<WideQQ>"));
|
t0[0] = MkAtomTerm(Yap_LookupAtom("<WideQQ>"));
|
||||||
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, t0);
|
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomAtom, 1), 1, t0);
|
||||||
@ -287,7 +285,8 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
|
|||||||
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomGVar, 2), 2, t);
|
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomGVar, 2), 2, t);
|
||||||
} break;
|
} break;
|
||||||
case String_tok: {
|
case String_tok: {
|
||||||
Term t0 = Yap_CharsToTDQ((char *)info, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
Term t0 =
|
||||||
|
Yap_CharsToTDQ((char *)info, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
||||||
if (!t0) {
|
if (!t0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -300,7 +299,8 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
|
|||||||
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString, 1), 1, &t0);
|
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString, 1), 1, &t0);
|
||||||
} break;
|
} break;
|
||||||
case BQString_tok: {
|
case BQString_tok: {
|
||||||
Term t0 = Yap_CharsToTBQ((char *)info, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
Term t0 =
|
||||||
|
Yap_CharsToTBQ((char *)info, CurrentModule, ENC_ISO_LATIN1 PASS_REGS);
|
||||||
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString, 1), 1, &t0);
|
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString, 1), 1, &t0);
|
||||||
} break;
|
} break;
|
||||||
case WBQString_tok: {
|
case WBQString_tok: {
|
||||||
@ -632,7 +632,8 @@ static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
|
|||||||
if (LOCAL_Error_TYPE)
|
if (LOCAL_Error_TYPE)
|
||||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, NULL);
|
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, NULL);
|
||||||
fe->t = 0;
|
fe->t = 0;
|
||||||
return YAP_PARSING_FINISHED;;
|
return YAP_PARSING_FINISHED;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
if (GLOBAL_Stream[inp_stream].status & Push_Eof_Stream_f) {
|
if (GLOBAL_Stream[inp_stream].status & Push_Eof_Stream_f) {
|
||||||
fe->t = MkAtomTerm(AtomEof);
|
fe->t = MkAtomTerm(AtomEof);
|
||||||
@ -1186,8 +1187,7 @@ Term Yap_ReadFromAtom(Atom a, Term opts) {
|
|||||||
char *s = a->StrOfAE;
|
char *s = a->StrOfAE;
|
||||||
size_t len = strlen(s);
|
size_t len = strlen(s);
|
||||||
encoding_t enc = ENC_ISO_LATIN1;
|
encoding_t enc = ENC_ISO_LATIN1;
|
||||||
sno =
|
sno = Yap_open_buf_read_stream((char *)s, len, &enc, MEM_BUF_USER);
|
||||||
Yap_open_buf_read_stream((char *)s, len, &enc, MEM_BUF_USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rval = Yap_read_term(sno, opts, 3);
|
rval = Yap_read_term(sno, opts, 3);
|
||||||
@ -1199,8 +1199,8 @@ static Term readFromBuffer(const char *s, Term opts) {
|
|||||||
Term rval;
|
Term rval;
|
||||||
int sno;
|
int sno;
|
||||||
encoding_t enc = ENC_ISO_UTF8;
|
encoding_t enc = ENC_ISO_UTF8;
|
||||||
sno = Yap_open_buf_read_stream((char *)s, strlen_utf8((unsigned char *)s), &enc,
|
sno = Yap_open_buf_read_stream((char *)s, strlen_utf8((unsigned char *)s),
|
||||||
MEM_BUF_USER);
|
&enc, MEM_BUF_USER);
|
||||||
|
|
||||||
rval = Yap_read_term(sno, opts, 3);
|
rval = Yap_read_term(sno, opts, 3);
|
||||||
Yap_CloseStream(sno);
|
Yap_CloseStream(sno);
|
||||||
@ -1246,16 +1246,16 @@ static Int atom_to_term(USES_REGS1) {
|
|||||||
* @param _T_ the output term _T_, may be any term
|
* @param _T_ the output term _T_, may be any term
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int term_to_string(USES_REGS1) {
|
||||||
term_to_string(USES_REGS1) {
|
|
||||||
Term t2 = Deref(ARG2), rc = false, t1 = Deref(ARG1);
|
Term t2 = Deref(ARG2), rc = false, t1 = Deref(ARG1);
|
||||||
const char *s;
|
const char *s;
|
||||||
if (IsVarTerm(t2)) {
|
if (IsVarTerm(t2)) {
|
||||||
size_t length;
|
size_t length;
|
||||||
s = Yap_TermToString(ARG1, NULL, 0, &length, NULL, Quote_illegal_f|Handle_vars_f);
|
s = Yap_TermToString(ARG1, NULL, 0, &length, NULL,
|
||||||
if (!s || !
|
Quote_illegal_f | Handle_vars_f);
|
||||||
MkStringTerm(s)) {
|
if (!s || !MkStringTerm(s)) {
|
||||||
Yap_Error(RESOURCE_ERROR_HEAP,t1,"Could not get memory from the operating system");
|
Yap_Error(RESOURCE_ERROR_HEAP, t1,
|
||||||
|
"Could not get memory from the operating system");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Yap_unify(ARG2, MkStringTerm(s));
|
return Yap_unify(ARG2, MkStringTerm(s));
|
||||||
@ -1268,7 +1268,6 @@ term_to_string(USES_REGS1) {
|
|||||||
return (rc = readFromBuffer(s, TermNil)) != 0L && Yap_unify(rc, ARG1);
|
return (rc = readFromBuffer(s, TermNil)) != 0L && Yap_unify(rc, ARG1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pred atom_to_term( ?_Atom_ , ? _T_ )
|
* @pred atom_to_term( ?_Atom_ , ? _T_ )
|
||||||
*
|
*
|
||||||
@ -1279,16 +1278,16 @@ term_to_string(USES_REGS1) {
|
|||||||
* @param _T_ the output term _T_, may be any term
|
* @param _T_ the output term _T_, may be any term
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int term_to_atom(USES_REGS1) {
|
||||||
term_to_atom(USES_REGS1) {
|
|
||||||
Term t1 = Deref(ARG2), ctl, rc = false;
|
Term t1 = Deref(ARG2), ctl, rc = false;
|
||||||
Atom at;
|
Atom at;
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
size_t length;
|
size_t length;
|
||||||
char * s =
|
char *s = Yap_TermToString(t1, NULL, 0, &length, NULL,
|
||||||
Yap_TermToString(t1, NULL, 0, &length, NULL, Quote_illegal_f|Handle_vars_f);
|
Quote_illegal_f | Handle_vars_f);
|
||||||
if (!s || !(at = Yap_LookupAtom(s))) {
|
if (!s || !(at = Yap_LookupAtom(s))) {
|
||||||
Yap_Error(RESOURCE_ERROR_HEAP,t1,"Could not get memory from the operating system");
|
Yap_Error(RESOURCE_ERROR_HEAP, t1,
|
||||||
|
"Could not get memory from the operating system");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Yap_unify(ARG2, MkAtomTerm(at));
|
return Yap_unify(ARG2, MkAtomTerm(at));
|
||||||
@ -1299,8 +1298,7 @@ term_to_atom(USES_REGS1) {
|
|||||||
at = AtomOfTerm(t1);
|
at = AtomOfTerm(t1);
|
||||||
}
|
}
|
||||||
ctl = TermNil;
|
ctl = TermNil;
|
||||||
return Yap_ReadFromAtom(at, ctl) == 0L
|
return Yap_ReadFromAtom(at, ctl) == 0L && Yap_unify(rc, ARG1);
|
||||||
&& Yap_unify(rc, ARG1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1417,7 +1415,6 @@ void Yap_InitReadTPreds(void) {
|
|||||||
Yap_InitCPred("read_clause", 2, read_clause2, SyncPredFlag);
|
Yap_InitCPred("read_clause", 2, read_clause2, SyncPredFlag);
|
||||||
Yap_InitCPred("read_clause", 3, read_clause, 0);
|
Yap_InitCPred("read_clause", 3, read_clause, 0);
|
||||||
|
|
||||||
|
|
||||||
Yap_InitCPred("term_to_string", 2, term_to_string, 0);
|
Yap_InitCPred("term_to_string", 2, term_to_string, 0);
|
||||||
Yap_InitCPred("term_to_atom", 2, term_to_atom, 0);
|
Yap_InitCPred("term_to_atom", 2, term_to_atom, 0);
|
||||||
Yap_InitCPred("atom_to_term", 3, atom_to_term, 0);
|
Yap_InitCPred("atom_to_term", 3, atom_to_term, 0);
|
||||||
|
Reference in New Issue
Block a user