• R/O
  • SSH

Joypy: Commit

Main interpreter and library.


Commit MetaInfo

Revisiond22e7f2be31b1040e143098377ff77cbd99d57e9 (tree)
Time2019-08-12 06:51:13
AuthorSimon Forman <sforman@hush...>
CommiterSimon Forman

Log Message

Extract mainloop to own file.

Change Summary

Incremental Difference

diff -r d971151a2c99 -r d22e7f2be31b thun/gnu-prolog/Makefile
--- a/thun/gnu-prolog/Makefile Sat Aug 10 22:21:57 2019 -0700
+++ b/thun/gnu-prolog/Makefile Sun Aug 11 14:51:13 2019 -0700
@@ -1,7 +1,7 @@
11 GPLC_OPTIONS="--min-size"
22
3-thun: thun.pl parser.pl defs.pl
4- gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl defs.pl
3+thun: thun.pl parser.pl defs.pl main.pl
4+ gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl defs.pl main.pl
55
66 defs.pl: meta-defs.pl parser.pl defs.txt
77 gprolog --consult-file meta-defs.pl --consult-file parser.pl --query-goal do
diff -r d971151a2c99 -r d22e7f2be31b thun/gnu-prolog/main.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/thun/gnu-prolog/main.pl Sun Aug 11 14:51:13 2019 -0700
@@ -0,0 +1,37 @@
1+/*
2+ Copyright 2019 Simon Forman
3+
4+ This file is part of Thun
5+
6+ Thun is free software: you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation, either version 3 of the License, or
9+ (at your option) any later version.
10+
11+ Thun is distributed in the hope that it will be useful,
12+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ GNU General Public License for more details.
15+
16+ You should have received a copy of the GNU General Public License
17+ along with Thun. If not see <http://www.gnu.org/licenses/>.
18+
19+Main Loop
20+
21+*/
22+
23+:- initialization(loop).
24+
25+loop :- line(Line), loop(Line, [], _Out).
26+
27+loop([eof], S, S) :- !.
28+loop( Line, In, Out) :-
29+ do_line(Line, In, S),
30+ write(S), nl,
31+ line(NextLine), !,
32+ loop(NextLine, S, Out).
33+
34+
35+do_line(Line, In, Out) :- phrase(joy_parse(E), Line), thun(E, In, Out).
36+do_line(_Line, S, S) :- write('Err'), nl.
37+
diff -r d971151a2c99 -r d22e7f2be31b thun/gnu-prolog/thun.pl
--- a/thun/gnu-prolog/thun.pl Sat Aug 10 22:21:57 2019 -0700
+++ b/thun/gnu-prolog/thun.pl Sun Aug 11 14:51:13 2019 -0700
@@ -20,10 +20,6 @@
2020 % :- dynamic(func/3).
2121 % :- discontiguous(func/3).
2222
23-
24-:- initialization(loop).
25-
26-
2723 /*
2824 Interpreter
2925 thun(Expression, InputStack, OutputStack)
@@ -194,24 +190,3 @@
194190 prepare_mapping( P, S, [T|In], Acc, Out) :-
195191 prepare_mapping(P, S, In, [[T|S], P, infrst|Acc], Out).
196192
197-
198-
199-/*
200-Main Loop
201-*/
202-
203-loop :- line(Line), loop(Line, [], _Out).
204-
205-loop([eof], S, S) :- !.
206-loop( Line, In, Out) :-
207- do_line(Line, In, S),
208- write(S), nl,
209- line(NextLine), !,
210- loop(NextLine, S, Out).
211-
212-
213-do_line(Line, In, Out) :- phrase(joy_parse(E), Line), thun(E, In, Out).
214-do_line(_Line, S, S) :- write('Err'), nl.
215-
216-
217-
Show on old repository browser