Extract mainloop to own file.

This commit is contained in:
Simon Forman
2019-08-11 14:51:13 -07:00
parent 6bc1b5ec8b
commit 9e180e8173
3 changed files with 39 additions and 27 deletions
-25
View File
@@ -20,10 +20,6 @@
% :- dynamic(func/3).
% :- discontiguous(func/3).
:- initialization(loop).
/*
Interpreter
thun(Expression, InputStack, OutputStack)
@@ -194,24 +190,3 @@ prepare_mapping( _, _, [], Out, Out) :- !.
prepare_mapping( P, S, [T|In], Acc, Out) :-
prepare_mapping(P, S, In, [[T|S], P, infrst|Acc], Out).
/*
Main Loop
*/
loop :- line(Line), loop(Line, [], _Out).
loop([eof], S, S) :- !.
loop( Line, In, Out) :-
do_line(Line, In, S),
write(S), nl,
line(NextLine), !,
loop(NextLine, S, Out).
do_line(Line, In, Out) :- phrase(joy_parse(E), Line), thun(E, In, Out).
do_line(_Line, S, S) :- write('Err'), nl.