errors
This commit is contained in:
parent
563b642672
commit
670c2cbf13
@ -1045,7 +1045,6 @@ static Int query_exception(USES_REGS1) {
|
|||||||
if (!IsAddressTerm(Deref(ARG2)))
|
if (!IsAddressTerm(Deref(ARG2)))
|
||||||
return false;
|
return false;
|
||||||
yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2));
|
yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2));
|
||||||
Term t3 = Deref(ARG3);
|
|
||||||
//if (IsVarTerm(t3)) {
|
//if (IsVarTerm(t3)) {
|
||||||
Term rc = queryErr(query, y);
|
Term rc = queryErr(query, y);
|
||||||
// Yap_DebugPlWriteln(rc);
|
// Yap_DebugPlWriteln(rc);
|
||||||
|
@ -728,20 +728,18 @@ return GLOBAL_DIRNAME;
|
|||||||
|
|
||||||
char *profile_names(int);
|
char *profile_names(int);
|
||||||
char *profile_names(int k) {
|
char *profile_names(int k) {
|
||||||
static char *FNAME=NULL;
|
char *FNAME=NULL;
|
||||||
int size=200;
|
int size=200;
|
||||||
|
|
||||||
if (GLOBAL_DIRNAME==NULL) set_profile_dir(NULL);
|
if (GLOBAL_DIRNAME==NULL) set_profile_dir(NULL);
|
||||||
size=strlen(GLOBAL_DIRNAME)+40;
|
size=strlen(GLOBAL_DIRNAME)+40;
|
||||||
if (FNAME!=NULL) free(FNAME);
|
|
||||||
FNAME=malloc(size);
|
FNAME=malloc(size);
|
||||||
if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
|
if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); }
|
||||||
strcpy(FNAME,GLOBAL_DIRNAME);
|
|
||||||
|
|
||||||
if (k==PROFILING_FILE) {
|
if (k==PROFILING_FILE) {
|
||||||
sprintf(FNAME,"%s/PROFILING_%d",FNAME,getpid());
|
sprintf(FNAME,"%s/PROFILING_%d",GLOBAL_DIRNAME,getpid());
|
||||||
} else {
|
} else {
|
||||||
sprintf(FNAME,"%s/PROFPREDS_%d",FNAME,getpid());
|
sprintf(FNAME,"%s/PROFPREDS_%d",GLOBAL_DIRNAME,getpid());
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("%s\n",FNAME);
|
// printf("%s\n",FNAME);
|
||||||
|
13
C/scanner.c
13
C/scanner.c
@ -1340,7 +1340,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
|||||||
TokEntry *t, *l, *p;
|
TokEntry *t, *l, *p;
|
||||||
enum TokenKinds kind;
|
enum TokenKinds kind;
|
||||||
int solo_flag = TRUE;
|
int solo_flag = TRUE;
|
||||||
int32_t ch, och;
|
int32_t ch, och = ' ';
|
||||||
struct qq_struct_t *cur_qq = NULL;
|
struct qq_struct_t *cur_qq = NULL;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
|
|
||||||
@ -1423,12 +1423,13 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
|||||||
|
|
||||||
case UC:
|
case UC:
|
||||||
case UL:
|
case UL:
|
||||||
case LC: {
|
case LC:
|
||||||
int32_t och = ch;
|
och = ch;
|
||||||
ch = getchr(st);
|
ch = getchr(st);
|
||||||
size_t sz = 512;
|
|
||||||
TokImage = Malloc(sz PASS_REGS);
|
|
||||||
scan_name:
|
scan_name:
|
||||||
|
{
|
||||||
|
size_t sz = 1024;
|
||||||
|
TokImage = Malloc(sz PASS_REGS);
|
||||||
charp = (unsigned char *)TokImage;
|
charp = (unsigned char *)TokImage;
|
||||||
isvar = (chtype(och) != LC);
|
isvar = (chtype(och) != LC);
|
||||||
add_ch_to_buff(och);
|
add_ch_to_buff(och);
|
||||||
@ -1514,7 +1515,6 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
|||||||
case 'e':
|
case 'e':
|
||||||
case 'E':
|
case 'E':
|
||||||
och = cherr;
|
och = cherr;
|
||||||
TokImage = Malloc(1024 PASS_REGS);
|
|
||||||
goto scan_name;
|
goto scan_name;
|
||||||
break;
|
break;
|
||||||
case '=':
|
case '=':
|
||||||
@ -1981,6 +1981,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
|||||||
return l;
|
return l;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
kind = Error_tok;
|
||||||
char err[1024];
|
char err[1024];
|
||||||
snprintf(err, 1023, "\n++++ token: unrecognised char %c (%d), type %c\n",
|
snprintf(err, 1023, "\n++++ token: unrecognised char %c (%d), type %c\n",
|
||||||
ch, ch, chtype(ch));
|
ch, ch, chtype(ch));
|
||||||
|
@ -885,7 +885,7 @@ static PredEntry *ClauseInfoForCode(yamop *codeptr, void **startp,
|
|||||||
if (codeptr >= COMMA_CODE && codeptr < FAILCODE) {
|
if (codeptr >= COMMA_CODE && codeptr < FAILCODE) {
|
||||||
pp = RepPredProp(Yap_GetPredPropByFunc(FunctorComma, CurrentModule));
|
pp = RepPredProp(Yap_GetPredPropByFunc(FunctorComma, CurrentModule));
|
||||||
*startp = (CODEADDR)COMMA_CODE;
|
*startp = (CODEADDR)COMMA_CODE;
|
||||||
*endp = (CODEADDR)(FAILCODE - 1);
|
*endp = (CODEADDR)(FAILCODE);
|
||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
pc = codeptr;
|
pc = codeptr;
|
||||||
|
@ -205,7 +205,6 @@ typedef enum {
|
|||||||
op_heapused,
|
op_heapused,
|
||||||
op_localsp,
|
op_localsp,
|
||||||
op_globalsp,
|
op_globalsp,
|
||||||
op_b,
|
|
||||||
op_env,
|
op_env,
|
||||||
op_tr,
|
op_tr,
|
||||||
op_stackfree
|
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_OVERFLOW, EVALUATION_ERROR, "float_overflow")
|
||||||
E(EVALUATION_ERROR_FLOAT_UNDERFLOW, EVALUATION_ERROR, "float_underflow")
|
E(EVALUATION_ERROR_FLOAT_UNDERFLOW, EVALUATION_ERROR, "float_underflow")
|
||||||
E(EVALUATION_ERROR_INT_OVERFLOW, EVALUATION_ERROR, "int_overflow")
|
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_UNDEFINED, EVALUATION_ERROR, "undefined")
|
||||||
E(EVALUATION_ERROR_UNDERFLOW, EVALUATION_ERROR, "underflow")
|
E(EVALUATION_ERROR_UNDERFLOW, EVALUATION_ERROR, "underflow")
|
||||||
E(EVALUATION_ERROR_ZERO_DIVISOR, EVALUATION_ERROR, "zero_divisor")
|
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->errorNo = SYNTAX_ERROR;
|
||||||
Yap_local.ActiveError->parserFirstLine = start_line;
|
Yap_local.ActiveError->parserFirstLine = start_line;
|
||||||
Yap_local.ActiveError->parserLine = err_line;
|
|
||||||
Yap_local.ActiveError->parserLastLine = end_line;
|
Yap_local.ActiveError->parserLastLine = end_line;
|
||||||
Yap_local.ActiveError->parserFirstPos = startpos;
|
Yap_local.ActiveError->parserFirstPos = startpos;
|
||||||
Yap_local.ActiveError->parserPos = errpos;
|
|
||||||
Yap_local.ActiveError->parserLastPos =endpos;
|
Yap_local.ActiveError->parserLastPos =endpos;
|
||||||
Yap_local.ActiveError->parserFile =
|
Yap_local.ActiveError->parserFile =
|
||||||
RepAtom(AtomOfTerm((GLOBAL_Stream+sno)->user_name))->StrOfAE;
|
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();
|
int lvl = push_text_stack();
|
||||||
if (GLOBAL_Stream[sno].status & Seekable_Stream_f) {
|
if (GLOBAL_Stream[sno].status & Seekable_Stream_f) {
|
||||||
char *o, *o2;
|
char *o, *o2;
|
||||||
|
while (tok) {
|
||||||
|
if (tok->Tok != Error_tok) {
|
||||||
|
tok = tok->TokNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err_line = tok->TokLine;
|
||||||
|
errpos = tok->TokPos;
|
||||||
if (errpos <= startpos) {
|
if (errpos <= startpos) {
|
||||||
o = malloc(1);
|
o = malloc(1);
|
||||||
o[0] = '\0';
|
o[0] = '\0';
|
||||||
} else {
|
} else {
|
||||||
Int sza = (errpos-startpos)+1;
|
Int sza = (errpos-startpos)+1, tot = sza;
|
||||||
o = malloc(sza);
|
o = malloc(sza);
|
||||||
fread(o,sza-1,1,GLOBAL_Stream[sno].file);
|
char *p = o;
|
||||||
o[sza-1] = '\0';
|
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;
|
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 = malloc(1);
|
||||||
o2[0] = '\0';
|
o2[0] = '\0';
|
||||||
} else {
|
} else {
|
||||||
Int sza = (endpos-errpos)+1;
|
Int sza = (endpos-errpos)+1, tot = sza;
|
||||||
o2 = malloc(sza);
|
o2 = malloc(sza);
|
||||||
fread(o2,sza-1,1,GLOBAL_Stream[sno].file);
|
char *p = o2;
|
||||||
o2[sza-1] = '\0';
|
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;
|
Yap_local.ActiveError->parserTextB = o2;
|
||||||
} else {
|
} else {
|
||||||
size_t sz = 1024, total=sz, e;
|
size_t sz = 1024, e;
|
||||||
char *o = malloc(1024);
|
char *o = malloc(1024);
|
||||||
char *s = o;
|
char *s = o;
|
||||||
o[0] = '\0';
|
o[0] = '\0';
|
||||||
@ -384,7 +416,9 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
|||||||
o = realloc(o, strlen(o)+1);
|
o = realloc(o, strlen(o)+1);
|
||||||
Yap_local.ActiveError->parserTextA= o;
|
Yap_local.ActiveError->parserTextA= o;
|
||||||
o = malloc(1024);
|
o = malloc(1024);
|
||||||
total = sz = 1024;
|
sz = 1024;
|
||||||
|
err_line = tok->TokLine;
|
||||||
|
errpos = tok->TokPos;
|
||||||
tok = tok->TokNext;
|
tok = tok->TokNext;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -402,10 +436,11 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
|||||||
tok = tok->TokNext;
|
tok = tok->TokNext;
|
||||||
}
|
}
|
||||||
o = realloc(o, strlen(o)+1);
|
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 */
|
/* 0: strat, error, end line */
|
||||||
/*2 msg */
|
/*2 msg */
|
||||||
/* 1: file */
|
/* 1: file */
|
||||||
|
@ -280,12 +280,14 @@ location( error(_,Info), Level, LC ) -->
|
|||||||
query_exception(prologPredLine, Desc, FilePos),
|
query_exception(prologPredLine, Desc, FilePos),
|
||||||
query_exception(prologPredModule, Desc, M),
|
query_exception(prologPredModule, Desc, M),
|
||||||
query_exception(prologPredName, Desc, Na),
|
query_exception(prologPredName, Desc, Na),
|
||||||
query_exception(prologPredArity, Desc, Ar)
|
query_exception(prologPredArity, Desc, Ar),
|
||||||
|
query_exception(prologStack, Desc, St)
|
||||||
},
|
},
|
||||||
!,
|
!,
|
||||||
display_consulting( File, Level, Info, LC ),
|
display_consulting( File, Level, Info, LC ),
|
||||||
{simplify_pred(M:Na/Ar,FF)},
|
{simplify_pred(M:Na/Ar,FF)},
|
||||||
[ '~a:~d:0 ~a while executing ~q:'-[File, FilePos,Level,FF] ].
|
[ '~a:~d:0 ~a while executing ~q:'-[File, FilePos,Level,FF] ],
|
||||||
|
[ 'Execution stack is: ~a' - [St]].
|
||||||
location( error(_,Info), Level, LC ) -->
|
location( error(_,Info), Level, LC ) -->
|
||||||
{ '$error_descriptor'(Info, Desc) },
|
{ '$error_descriptor'(Info, Desc) },
|
||||||
{
|
{
|
||||||
@ -296,7 +298,7 @@ location( error(_,Info), Level, LC ) -->
|
|||||||
!,
|
!,
|
||||||
display_consulting( File, Level, Info, LC ),
|
display_consulting( File, Level, Info, LC ),
|
||||||
{simplify_pred(F,FF)},
|
{simplify_pred(F,FF)},
|
||||||
[ '~a:~d:0 ~a while executing ~a():'-[File, FilePos,Level,FF] ].
|
[ '~a:~d:0 ~a while executing ~a().'-[File, FilePos,Level,FF] ].
|
||||||
location( _Ball, _Level, _LC ) --> [].
|
location( _Ball, _Level, _LC ) --> [].
|
||||||
|
|
||||||
event(redo, _Info) --> {fail}.
|
event(redo, _Info) --> {fail}.
|
||||||
@ -1082,3 +1084,4 @@ query_exception(M,K,V) :-
|
|||||||
/**
|
/**
|
||||||
@}
|
@}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user