errors
This commit is contained in:
parent
563b642672
commit
670c2cbf13
@ -1045,7 +1045,6 @@ static Int query_exception(USES_REGS1) {
|
||||
if (!IsAddressTerm(Deref(ARG2)))
|
||||
return false;
|
||||
yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2));
|
||||
Term t3 = Deref(ARG3);
|
||||
//if (IsVarTerm(t3)) {
|
||||
Term rc = queryErr(query, y);
|
||||
// Yap_DebugPlWriteln(rc);
|
||||
|
@ -728,20 +728,18 @@ return GLOBAL_DIRNAME;
|
||||
|
||||
char *profile_names(int);
|
||||
char *profile_names(int k) {
|
||||
static char *FNAME=NULL;
|
||||
char *FNAME=NULL;
|
||||
int size=200;
|
||||
|
||||
if (GLOBAL_DIRNAME==NULL) set_profile_dir(NULL);
|
||||
size=strlen(GLOBAL_DIRNAME)+40;
|
||||
if (FNAME!=NULL) free(FNAME);
|
||||
FNAME=malloc(size);
|
||||
if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
|
||||
strcpy(FNAME,GLOBAL_DIRNAME);
|
||||
|
||||
if (k==PROFILING_FILE) {
|
||||
sprintf(FNAME,"%s/PROFILING_%d",FNAME,getpid());
|
||||
sprintf(FNAME,"%s/PROFILING_%d",GLOBAL_DIRNAME,getpid());
|
||||
} else {
|
||||
sprintf(FNAME,"%s/PROFPREDS_%d",FNAME,getpid());
|
||||
sprintf(FNAME,"%s/PROFPREDS_%d",GLOBAL_DIRNAME,getpid());
|
||||
}
|
||||
|
||||
// printf("%s\n",FNAME);
|
||||
|
15
C/scanner.c
15
C/scanner.c
@ -1340,7 +1340,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
TokEntry *t, *l, *p;
|
||||
enum TokenKinds kind;
|
||||
int solo_flag = TRUE;
|
||||
int32_t ch, och;
|
||||
int32_t ch, och = ' ';
|
||||
struct qq_struct_t *cur_qq = NULL;
|
||||
int sign = 1;
|
||||
|
||||
@ -1423,12 +1423,13 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
|
||||
case UC:
|
||||
case UL:
|
||||
case LC: {
|
||||
int32_t och = ch;
|
||||
case LC:
|
||||
och = ch;
|
||||
ch = getchr(st);
|
||||
size_t sz = 512;
|
||||
TokImage = Malloc(sz PASS_REGS);
|
||||
scan_name:
|
||||
{
|
||||
size_t sz = 1024;
|
||||
TokImage = Malloc(sz PASS_REGS);
|
||||
charp = (unsigned char *)TokImage;
|
||||
isvar = (chtype(och) != LC);
|
||||
add_ch_to_buff(och);
|
||||
@ -1514,8 +1515,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
case 'e':
|
||||
case 'E':
|
||||
och = cherr;
|
||||
TokImage = Malloc(1024 PASS_REGS);
|
||||
goto scan_name;
|
||||
goto scan_name;
|
||||
break;
|
||||
case '=':
|
||||
case '_':
|
||||
@ -1981,6 +1981,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
return l;
|
||||
|
||||
default: {
|
||||
kind = Error_tok;
|
||||
char err[1024];
|
||||
snprintf(err, 1023, "\n++++ token: unrecognised char %c (%d), type %c\n",
|
||||
ch, ch, chtype(ch));
|
||||
|
@ -885,7 +885,7 @@ static PredEntry *ClauseInfoForCode(yamop *codeptr, void **startp,
|
||||
if (codeptr >= COMMA_CODE && codeptr < FAILCODE) {
|
||||
pp = RepPredProp(Yap_GetPredPropByFunc(FunctorComma, CurrentModule));
|
||||
*startp = (CODEADDR)COMMA_CODE;
|
||||
*endp = (CODEADDR)(FAILCODE - 1);
|
||||
*endp = (CODEADDR)(FAILCODE);
|
||||
return pp;
|
||||
}
|
||||
pc = codeptr;
|
||||
|
@ -205,7 +205,6 @@ typedef enum {
|
||||
op_heapused,
|
||||
op_localsp,
|
||||
op_globalsp,
|
||||
op_b,
|
||||
op_env,
|
||||
op_tr,
|
||||
op_stackfree
|
||||
|
@ -90,6 +90,7 @@ E(DOMAIN_ERROR_WRITE_OPTION, DOMAIN_ERROR, "write_option")
|
||||
E(EVALUATION_ERROR_FLOAT_OVERFLOW, EVALUATION_ERROR, "float_overflow")
|
||||
E(EVALUATION_ERROR_FLOAT_UNDERFLOW, EVALUATION_ERROR, "float_underflow")
|
||||
E(EVALUATION_ERROR_INT_OVERFLOW, EVALUATION_ERROR, "int_overflow")
|
||||
E(EVALUATION_ERROR_READ_STREAM, EVALUATION_ERROR, "read_from_stream")
|
||||
E(EVALUATION_ERROR_UNDEFINED, EVALUATION_ERROR, "undefined")
|
||||
E(EVALUATION_ERROR_UNDERFLOW, EVALUATION_ERROR, "underflow")
|
||||
E(EVALUATION_ERROR_ZERO_DIVISOR, EVALUATION_ERROR, "zero_divisor")
|
||||
|
@ -337,10 +337,8 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
||||
|
||||
Yap_local.ActiveError->errorNo = SYNTAX_ERROR;
|
||||
Yap_local.ActiveError->parserFirstLine = start_line;
|
||||
Yap_local.ActiveError->parserLine = err_line;
|
||||
Yap_local.ActiveError->parserLastLine = end_line;
|
||||
Yap_local.ActiveError->parserFirstPos = startpos;
|
||||
Yap_local.ActiveError->parserPos = errpos;
|
||||
Yap_local.ActiveError->parserLastPos =endpos;
|
||||
Yap_local.ActiveError->parserFile =
|
||||
RepAtom(AtomOfTerm((GLOBAL_Stream+sno)->user_name))->StrOfAE;
|
||||
@ -353,14 +351,34 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
||||
int lvl = push_text_stack();
|
||||
if (GLOBAL_Stream[sno].status & Seekable_Stream_f) {
|
||||
char *o, *o2;
|
||||
while (tok) {
|
||||
if (tok->Tok != Error_tok) {
|
||||
tok = tok->TokNext;
|
||||
}
|
||||
}
|
||||
err_line = tok->TokLine;
|
||||
errpos = tok->TokPos;
|
||||
if (errpos <= startpos) {
|
||||
o = malloc(1);
|
||||
o[0] = '\0';
|
||||
} else {
|
||||
Int sza = (errpos-startpos)+1;
|
||||
Int sza = (errpos-startpos)+1, tot = sza;
|
||||
o = malloc(sza);
|
||||
fread(o,sza-1,1,GLOBAL_Stream[sno].file);
|
||||
o[sza-1] = '\0';
|
||||
char *p = o;
|
||||
while (true)
|
||||
{
|
||||
size_t siz = fread( p,tot-1,1,GLOBAL_Stream[sno].file);
|
||||
if (siz < 0) Yap_Error(EVALUATION_ERROR_READ_STREAM,GLOBAL_Stream[sno].user_name,"%s", strerror(errno) );
|
||||
if (siz < tot -1) {
|
||||
p += siz;
|
||||
tot -= siz;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
} o[sza-1] = '\0';
|
||||
|
||||
}
|
||||
Yap_local.ActiveError->parserTextA = o;
|
||||
@ -368,14 +386,28 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
||||
o2 = malloc(1);
|
||||
o2[0] = '\0';
|
||||
} else {
|
||||
Int sza = (endpos-errpos)+1;
|
||||
Int sza = (endpos-errpos)+1, tot = sza;
|
||||
o2 = malloc(sza);
|
||||
fread(o2,sza-1,1,GLOBAL_Stream[sno].file);
|
||||
o2[sza-1] = '\0';
|
||||
}
|
||||
char *p = o2;
|
||||
while (true)
|
||||
{
|
||||
size_t siz = fread( p,tot-1,1,GLOBAL_Stream[sno].file);
|
||||
if (siz < 0) Yap_Error(EVALUATION_ERROR_READ_STREAM,GLOBAL_Stream[sno].user_name,"%s", strerror(errno) );
|
||||
if (siz < tot -1) {
|
||||
p += siz;
|
||||
tot -= siz;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
} o2[sza-1] = '\0';
|
||||
|
||||
}
|
||||
Yap_local.ActiveError->parserTextB = o2;
|
||||
} else {
|
||||
size_t sz = 1024, total=sz, e;
|
||||
size_t sz = 1024, e;
|
||||
char *o = malloc(1024);
|
||||
char *s = o;
|
||||
o[0] = '\0';
|
||||
@ -384,8 +416,10 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
||||
o = realloc(o, strlen(o)+1);
|
||||
Yap_local.ActiveError->parserTextA= o;
|
||||
o = malloc(1024);
|
||||
total = sz = 1024;
|
||||
tok = tok->TokNext;
|
||||
sz = 1024;
|
||||
err_line = tok->TokLine;
|
||||
errpos = tok->TokPos;
|
||||
tok = tok->TokNext;
|
||||
continue;
|
||||
}
|
||||
const char *ns = Yap_tokText(tok);
|
||||
@ -402,10 +436,11 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
||||
tok = tok->TokNext;
|
||||
}
|
||||
o = realloc(o, strlen(o)+1);
|
||||
Yap_local.ActiveError->parserTextA= o;
|
||||
Yap_local.ActiveError->parserTextB= o;
|
||||
|
||||
}
|
||||
|
||||
Yap_local.ActiveError->parserPos = errpos;
|
||||
Yap_local.ActiveError->parserLine = err_line;
|
||||
/* 0: strat, error, end line */
|
||||
/*2 msg */
|
||||
/* 1: file */
|
||||
|
851
pl/messages.yap
851
pl/messages.yap
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user