Say NO to duplicated output
This commit is contained in:
parent
4264649271
commit
3af7f72aa4
22
polymani.pl
22
polymani.pl
@ -76,20 +76,11 @@ polyplay :-
|
||||
cons(H, _, NC),
|
||||
write(H),
|
||||
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
|
||||
process_input(TIn)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
%% Parsing failed
|
||||
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
|
||||
debug_print(false).
|
||||
|
||||
%% process_input(+tree) is determines
|
||||
%% process_input(+Tree) is det
|
||||
%
|
||||
% 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 first command
|
||||
do_process_input(CL),
|
||||
@ -113,11 +104,8 @@ process_input(command(CL, TCR)) :-
|
||||
TCR \== void,
|
||||
%% recurse
|
||||
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
|
||||
% Takes, as the only argument, the tree representing
|
||||
|
Reference in New Issue
Block a user