scan numbers
This commit is contained in:
parent
684e733c8b
commit
1c727bbe45
@ -68,31 +68,6 @@ Term Yap_StringToNumberTerm(char *s, encoding_t *encp) {
|
|||||||
while (*s && isblank(*s++))
|
while (*s && isblank(*s++))
|
||||||
;
|
;
|
||||||
t = Yap_scan_num(GLOBAL_Stream + sno);
|
t = Yap_scan_num(GLOBAL_Stream + sno);
|
||||||
if (t == TermNil) {
|
|
||||||
CACHE_REGS
|
|
||||||
int sign = 1;
|
|
||||||
if (s[0] == '+') {
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
if (s[0] == '-') {
|
|
||||||
s++;
|
|
||||||
sign = -1;
|
|
||||||
}
|
|
||||||
if (strcmp(s, "inf") == 0) {
|
|
||||||
if (sign > 0) {
|
|
||||||
return MkFloatTerm(INFINITY);
|
|
||||||
} else {
|
|
||||||
return MkFloatTerm(-INFINITY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strcmp(s, "nan") == 0) {
|
|
||||||
if (sign > 0) {
|
|
||||||
return MkFloatTerm(NAN);
|
|
||||||
} else {
|
|
||||||
return MkFloatTerm(-NAN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Yap_CloseStream(sno);
|
Yap_CloseStream(sno);
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
return t;
|
return t;
|
||||||
|
@ -225,11 +225,10 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
|
|||||||
|
|
||||||
*tailp = TermNl;
|
*tailp = TermNl;
|
||||||
startline = MkIntegerTerm(cline);
|
startline = MkIntegerTerm(cline);
|
||||||
clean_vars(LOCAL_VarTable);
|
|
||||||
clean_vars(LOCAL_AnonVarTable);
|
|
||||||
if (errtok != LOCAL_toktide) {
|
if (errtok != LOCAL_toktide) {
|
||||||
errtok = LOCAL_toktide;
|
errtok = LOCAL_toktide;
|
||||||
}
|
}
|
||||||
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
errline = MkIntegerTerm(errtok->TokPos);
|
errline = MkIntegerTerm(errtok->TokPos);
|
||||||
while (tok) {
|
while (tok) {
|
||||||
Term ts[2];
|
Term ts[2];
|
||||||
@ -288,10 +287,14 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
|
|||||||
} 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)
|
||||||
|
return 0;
|
||||||
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString, 1), 1, &t0);
|
ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString, 1), 1, &t0);
|
||||||
} break;
|
} break;
|
||||||
case WString_tok: {
|
case WString_tok: {
|
||||||
Term t0 = Yap_WCharsToTDQ((wchar_t *)info, CurrentModule PASS_REGS);
|
Term t0 = Yap_WCharsToTDQ((wchar_t *)info, CurrentModule PASS_REGS);
|
||||||
|
if (!t0)
|
||||||
|
return 0;
|
||||||
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: {
|
||||||
@ -343,9 +346,9 @@ Term Yap_syntax_error(TokEntry *errtok, int sno) {
|
|||||||
tf[0] = MkStringTerm("");
|
tf[0] = MkStringTerm("");
|
||||||
/* file */
|
/* file */
|
||||||
tf[2] = Yap_StreamUserName(sno);
|
tf[2] = Yap_StreamUserName(sno);
|
||||||
tf[1] = Yap_MkApplTerm(FunctorSyntaxError, 4, tf);
|
clean_vars(LOCAL_VarTable);
|
||||||
tf[0] = MkAtomTerm(AtomSyntaxError);
|
clean_vars(LOCAL_AnonVarTable);
|
||||||
return Yap_MkApplTerm(FunctorError, 2, tf);
|
return Yap_MkApplTerm(FunctorSyntaxError, 4, tf);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct FEnv {
|
typedef struct FEnv {
|
||||||
@ -379,6 +382,8 @@ static xarg *setClauseReadEnv(Term opts, FEnv *fe, struct renv *re,
|
|||||||
int inp_stream);
|
int inp_stream);
|
||||||
static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
|
static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
LOCAL_VarTable = NULL;
|
||||||
|
LOCAL_AnonVarTable = NULL;
|
||||||
re->cm = CurrentModule;
|
re->cm = CurrentModule;
|
||||||
xarg *args = Yap_ArgListToVector(opts, read_defs, READ_END);
|
xarg *args = Yap_ArgListToVector(opts, read_defs, READ_END);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
|
Reference in New Issue
Block a user