Say NO to duplicated output

This commit is contained in:
Diogo Cordeiro 2018-12-20 04:03:38 +00:00
parent 4264649271
commit 3af7f72aa4

View File

@ -76,20 +76,11 @@ polyplay :-
cons(H, _, NC), cons(H, _, NC),
write(H), write(H),
nl nl
;
(
%% If the debug_print flag is true, print some extract debug info
debug_print(true),
write(LA),
nl,
write(TIn),
nl
; ;
%% Otherwise, process the parse tree and execute the commands within %% Otherwise, process the parse tree and execute the commands within
process_input(TIn) process_input(TIn)
) )
) )
)
; ;
%% Parsing failed %% Parsing failed
writeln("I didn't understand what you want.") writeln("I didn't understand what you want.")
@ -99,13 +90,13 @@ polyplay :-
), ),
!. !.
%% Flag which determines whether to print the parsed input or to process it %% process_input(+Tree) is det
debug_print(false).
%% process_input(+tree) is determines
% %
% Execute the commands from the parse tree % Execute the commands from the parse tree
% %
process_input(command(CL, void)) :-
%% Process only command left
do_process_input(CL).
process_input(command(CL, TCR)) :- process_input(command(CL, TCR)) :-
%% Process first command %% Process first command
do_process_input(CL), do_process_input(CL),
@ -113,11 +104,8 @@ process_input(command(CL, TCR)) :-
TCR \== void, TCR \== void,
%% recurse %% recurse
process_input(TCR). process_input(TCR).
process_input(command(CL, void)) :-
%% Process only command left
do_process_input(CL).
%% do_process_input(+tree) is det %% do_process_input(+Tree) is det
% %
% Process a single command from the input % Process a single command from the input
% Takes, as the only argument, the tree representing % Takes, as the only argument, the tree representing