fix parsing of input strings.

This commit is contained in:
Vitor Santos Costa 2012-10-09 16:31:43 +01:00
parent 7c178d2644
commit 48f07ad338

View File

@ -628,21 +628,22 @@ true :- true.
'$write_vars_and_goals'(NLAnsw, first, FLAnsw). '$write_vars_and_goals'(NLAnsw, first, FLAnsw).
'$purge_dontcares'([],[]). '$purge_dontcares'([],[]).
'$purge_dontcares'([[[95|_]|_]|Vs],NVs) :- !, '$purge_dontcares'([Name=_|Vs],NVs) :-
atom_codes(Name, [C|_]), C is "_", !,
'$purge_dontcares'(Vs,NVs). '$purge_dontcares'(Vs,NVs).
'$purge_dontcares'([V|Vs],[V|NVs]) :- '$purge_dontcares'([V|Vs],[V|NVs]) :-
'$purge_dontcares'(Vs,NVs). '$purge_dontcares'(Vs,NVs).
'$prep_answer_var_by_var'([], L, L). '$prep_answer_var_by_var'([], L, L).
'$prep_answer_var_by_var'([[Name|Value]|L], LF, L0) :- '$prep_answer_var_by_var'([Name=Value|L], LF, L0) :-
'$delete_identical_answers'(L, Value, NL, Names), '$delete_identical_answers'(L, Value, NL, Names),
'$prep_answer_var'([Name|Names], Value, LF, LI), '$prep_answer_var'([Name|Names], Value, LF, LI),
'$prep_answer_var_by_var'(NL, LI, L0). '$prep_answer_var_by_var'(NL, LI, L0).
% fetch all cases that have the same solution. % fetch all cases that have the same solution.
'$delete_identical_answers'([], _, [], []). '$delete_identical_answers'([], _, [], []).
'$delete_identical_answers'([[Name|Value]|L], Value0, FL, [Name|Names]) :- '$delete_identical_answers'([(Name=Value)|L], Value0, FL, [Name|Names]) :-
Value == Value0, !, Value == Value0, !,
'$delete_identical_answers'(L, Value0, FL, Names). '$delete_identical_answers'(L, Value0, FL, Names).
'$delete_identical_answers'([VV|L], Value0, [VV|FL], Names) :- '$delete_identical_answers'([VV|L], Value0, [VV|FL], Names) :-
@ -678,11 +679,11 @@ true :- true.
'$write_goal_output'(var([V|VL]), First, [var([V|VL])|L], next, L) :- !, '$write_goal_output'(var([V|VL]), First, [var([V|VL])|L], next, L) :- !,
( First = first -> true ; format(user_error,',~n',[]) ), ( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error,'~s',[V]), format(user_error,'~a',[V]),
'$write_output_vars'(VL). '$write_output_vars'(VL).
'$write_goal_output'(nonvar([V|VL],B), First, [nonvar([V|VL],B)|L], next, L) :- !, '$write_goal_output'(nonvar([V|VL],B), First, [nonvar([V|VL],B)|L], next, L) :- !,
( First = first -> true ; format(user_error,',~n',[]) ), ( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error,'~s',[V]), format(user_error,'~a',[V]),
'$write_output_vars'(VL), '$write_output_vars'(VL),
format(user_error,' = ', []), format(user_error,' = ', []),
( recorded('$print_options','$toplevel'(Opts),_) -> ( recorded('$print_options','$toplevel'(Opts),_) ->