fix error handling for second argument of number_codes and
number_chars/2 git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@626 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
1fe8842094
commit
98d9c42c42
29
C/stdpreds.c
29
C/stdpreds.c
@ -831,6 +831,18 @@ p_atom_split(void)
|
||||
return(unify_constant(ARG3,to1) && unify_constant(ARG4,to2));
|
||||
}
|
||||
|
||||
static Term
|
||||
gen_syntax_error(char *s)
|
||||
{
|
||||
Term ts[6], ti[2];
|
||||
ti[0] = ARG1;
|
||||
ti[1] = ARG2;
|
||||
ts[0] = MkApplTerm(MkFunctor(LookupAtom(s),2),2,ti);
|
||||
ts[1] = ts[4] = ts[5] = MkIntTerm(0);
|
||||
ts[2] = MkAtomTerm(LookupAtom("number syntax"));
|
||||
ts[3] = TermNil;
|
||||
return(MkApplTerm(MkFunctor(LookupAtom("syntax_error"),6),6,ts));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_number_chars(void)
|
||||
@ -893,10 +905,7 @@ p_number_chars(void)
|
||||
Error(INSTANTIATION_ERROR, t1, "number_chars/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (t == TermNil) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!IsPairTerm(t)) {
|
||||
if (!IsPairTerm(t) && t != TermNil) {
|
||||
Error(TYPE_ERROR_LIST, t, "number_chars/2");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -959,7 +968,7 @@ p_number_chars(void)
|
||||
}
|
||||
*s++ = '\0';
|
||||
if ((NewT = get_num(String)) == TermNil) {
|
||||
Error(SYNTAX_ERROR, Deref(ARG2), "number_chars/2", String);
|
||||
Error(SYNTAX_ERROR, gen_syntax_error("number_chars"), "while scanning %s", String);
|
||||
return (FALSE);
|
||||
}
|
||||
return (unify(ARG1, NewT));
|
||||
@ -1013,9 +1022,6 @@ p_number_atom(void)
|
||||
Error(INSTANTIATION_ERROR, t, "number_chars/2");
|
||||
return(FALSE);
|
||||
}
|
||||
if (t == TermNil) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!IsAtomTerm(t)) {
|
||||
Error(TYPE_ERROR_LIST, t, "number_atom/2");
|
||||
return(FALSE);
|
||||
@ -1071,10 +1077,7 @@ p_number_codes(void)
|
||||
if (IsVarTerm(t)) {
|
||||
Error(INSTANTIATION_ERROR, t, "number_codes/2");
|
||||
}
|
||||
if (t == TermNil) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!IsPairTerm(t)) {
|
||||
if (!IsPairTerm(t) && t != TermNil) {
|
||||
Error(TYPE_ERROR_LIST, t, "number_codes/2");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1107,7 +1110,7 @@ p_number_codes(void)
|
||||
}
|
||||
*s++ = '\0';
|
||||
if ((NewT = get_num(String)) == TermNil) {
|
||||
Error(SYNTAX_ERROR, Deref(ARG2), "number_chars/2", String);
|
||||
Error(SYNTAX_ERROR, gen_syntax_error("number_codes"), "while scanning %s", String);
|
||||
return (FALSE);
|
||||
}
|
||||
return (unify(ARG1, NewT));
|
||||
|
@ -112,10 +112,11 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
/* extern int gc_calls; */
|
||||
|
||||
vsc_count++;
|
||||
/* if (vsc_count < 123808900) return; */
|
||||
/* if (vsc_count == 59) {
|
||||
printf("Here I go\n");
|
||||
} */
|
||||
/* if (vsc_count < 24200) return; */
|
||||
/* if (vsc_count == 24340) {
|
||||
printf("Here I go\n");
|
||||
}
|
||||
*/
|
||||
/* if (vsc_count > 500000) exit(0); */
|
||||
/* if (gc_calls < 1) return;*/
|
||||
#if defined(__GNUC__)
|
||||
|
@ -160,6 +160,7 @@ print_message(Level, Mss) :-
|
||||
'$beautify_hidden_goal'('$yes_no',_,_,_,_,[]) :- !.
|
||||
'$beautify_hidden_goal'('$do_yes_no',_,_,_,_,[]) :- !.
|
||||
'$beautify_hidden_goal'('$query',_,_,_,_,[]) :- !.
|
||||
'$beautify_hidden_goal'('$enter_top_level',_,_,_,_,[]) :- !.
|
||||
% The user should never know these exist.
|
||||
'$beautify_hidden_goal'('$csult',_,prolog,ClNo,Gs,NGs) :- !,
|
||||
'$preprocess_stack'(Gs, NGs).
|
||||
@ -293,7 +294,7 @@ print_message(Level, Mss) :-
|
||||
'$format'(user_error,"[ DOMAIN ERROR- ~w: number ~w not newline ]~n",
|
||||
[Where,N]).
|
||||
'$output_error_message'(domain_error(not_zero,N), Where) :-
|
||||
'$format'(user_error,"[ DOMAIN ERROR- ~w: number ~w not zero ]~n",
|
||||
'$format'(user_error,"[ DOMAIN ERROR- ~w: ~w is not allowed in the domain ]~n",
|
||||
[Where,N]).
|
||||
'$output_error_message'(domain_error(operator_priority,N), Where) :-
|
||||
'$format'(user_error,"[ DOMAIN ERROR- ~w: ~w invalid operator priority ]~n",
|
||||
@ -439,6 +440,8 @@ print_message(Level, Mss) :-
|
||||
'$output_error_message'(representation_error(max_arity), Where) :-
|
||||
'$format'(user_error,"[ REPRESENTATION ERROR- ~w: number too big ]~n",
|
||||
[Where]).
|
||||
'$output_error_message'(syntax_error(G,0,Msg,[],0,0), Where) :- !,
|
||||
'$format'(user_error,"[ SYNTAX ERROR in ~w: ~a ]~n",[G,Msg]).
|
||||
'$output_error_message'(syntax_error(_,Position,_,Term,Pos,Start), Where) :-
|
||||
'$format'(user_error,"[ ~w ",[Where]),
|
||||
'$dump_syntax_error_line'(Start,Position),
|
||||
|
Reference in New Issue
Block a user