Merge pull request #1891 from triska/initialization_goals

ENHANCED: use newly available read_term_from_chars/3 for better errors
This commit is contained in:
Mark Thom
2023-07-16 10:26:13 -06:00
committed by GitHub

View File

@@ -115,18 +115,27 @@ layout_and_dot([C|Cs]) :-
layout_and_dot(Cs). layout_and_dot(Cs).
run_goals([]). run_goals([]).
run_goals([g(Gs0)|Goals]) :- run_goals([g(Gs0)|Goals]) :- !,
( ends_with_dot(Gs0) -> Gs1 = Gs0 ( ends_with_dot(Gs0) -> Gs1 = Gs0
; append(Gs0, ".", Gs1) ; append(Gs0, ".", Gs1)
), ),
read_from_chars(Gs1, Goal), double_quotes_option(DQ),
( catch( catch(read_term_from_chars(Gs1, Goal, [variable_names(VNs)]),
user:Goal, E,
Exception, ( write_term(Gs0, [double_quotes(DQ)]),
(write(Goal), write(' causes: '), write(Exception), nl) % halt? write(' cannot be read: '), write(E), nl,
) halt
; write('Warning: initialization failed for '), )
write(Gs0), nl ),
( catch(user:Goal,
Exception,
( write_term(Goal, [variable_names(VNs),double_quotes(DQ)]),
write(' causes: '),
write_term(Exception, [double_quotes(DQ)]), nl % halt?
)
) -> true
; write('Warning: initialization failed for: '),
write_term(Goal, [variable_names(VNs),double_quotes(DQ)]), nl
), ),
run_goals(Goals). run_goals(Goals).
run_goals([Goal|_]) :- run_goals([Goal|_]) :-