[Joypy-announce] joypy/Joypy: minor cleanup

Back to archive index
scmno****@osdn***** scmno****@osdn*****
Wed Aug 21 14:00:58 JST 2019


changeset c745734dea14 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=c745734dea14
user: Simon Forman <sform****@hushm*****>
date: Tue Aug 20 22:00:27 2019 -0700
description: minor cleanup

diffstat:

 thun/gnu-prolog/fork.pl      |  22 ++++++++++++++++++++++
 thun/gnu-prolog/main.pl      |  11 +++++------
 thun/gnu-prolog/math.pl      |   1 +
 thun/gnu-prolog/meta-math.pl |   3 ++-
 thun/gnu-prolog/parser.pl    |   6 ++----
 5 files changed, 32 insertions(+), 11 deletions(-)

diffs (127 lines):

diff -r ddbab0c8a528 -r c745734dea14 thun/gnu-prolog/fork.pl
--- a/thun/gnu-prolog/fork.pl	Mon Aug 19 22:02:06 2019 -0700
+++ b/thun/gnu-prolog/fork.pl	Tue Aug 20 22:00:27 2019 -0700
@@ -1,9 +1,31 @@
+/*
+    Copyright 2019 Simon Forman
+
+    This file is part of Thun
+
+    Thun is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    Thun is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Thun.  If not see <http://www.gnu.org/licenses/>.
+
+A fork function that actually forks.  Experimental.
+
+*/
 :- multifile(func/3).
 
 func(fork, [F, G|S], [X, Y|S]) :-
     fork(F, S, R, ChildPID), % Send F off to the child,
     thun(G, S, [Y|_]),       % Run G locally,
     read_pipe(R, X),         % Collect the result from F,
+    % FIXME deal with X=timeout...
     wait(ChildPID, Status).  % FIXME check status!!!
 
 fork(Expr, Stack, In, ChildPID) :-
diff -r ddbab0c8a528 -r c745734dea14 thun/gnu-prolog/main.pl
--- a/thun/gnu-prolog/main.pl	Mon Aug 19 22:02:06 2019 -0700
+++ b/thun/gnu-prolog/main.pl	Tue Aug 20 22:00:27 2019 -0700
@@ -25,27 +25,26 @@
 
 :- initialization(loop).
 
-loop :- prompt, line(Line), loop(Line, [], _Out).
+loop :- prompt(Line), loop(Line, [], _Out).
 
 loop([eof],  S,   S) :- !.
 loop( Line, In, Out) :-
   do_line(Line, In, S),
   show_stack(S),
-  prompt,
-  line(NextLine), !,
+  prompt(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.
 
-prompt :- write(`joy? `).
+prompt(Line) :- write(`joy? `), get_line(Line).
 show_stack(S) :- nl, print_stack(S), write(` <-top`), nl, nl.
 
 
-% Line is the next new-line delimited line from standard input stream as
+% Line is the next newget_line-delimited line from standard input stream as
 % a list of character codes.
 
-line(Line) :- get_code(X), line(X, Line).
+get_line(Line) :- get_code(X), line(X, Line).
 
 line(10,      []) :- !.  % break on new-lines.
 line(-1,   [eof]) :- !.  % break on EOF
diff -r ddbab0c8a528 -r c745734dea14 thun/gnu-prolog/math.pl
--- a/thun/gnu-prolog/math.pl	Mon Aug 19 22:02:06 2019 -0700
+++ b/thun/gnu-prolog/math.pl	Tue Aug 20 22:00:27 2019 -0700
@@ -1,4 +1,5 @@
 :- multifile(func/3).
+
 func(+, [A, B|C], [D|C]) :-
 	E =.. [+, B, A],
 	catch(D is E, _, D = E).
diff -r ddbab0c8a528 -r c745734dea14 thun/gnu-prolog/meta-math.pl
--- a/thun/gnu-prolog/meta-math.pl	Mon Aug 19 22:02:06 2019 -0700
+++ b/thun/gnu-prolog/meta-math.pl	Tue Aug 20 22:00:27 2019 -0700
@@ -78,7 +78,8 @@
 
 do :-
     open(`math.pl`, write, Stream),
-    write(Stream, `:- multifile(func/3).`), nl(Stream),
+    write(Stream, `:- multifile(func/3).`),
+    nl(Stream), nl(Stream),
     print_o(Stream, math_operator(Op)),
     print_o(Stream, comparison_operator(Op)),
     print_o(Stream, comparison_operator(Op, Po)),
diff -r ddbab0c8a528 -r c745734dea14 thun/gnu-prolog/parser.pl
--- a/thun/gnu-prolog/parser.pl	Mon Aug 19 22:02:06 2019 -0700
+++ b/thun/gnu-prolog/parser.pl	Tue Aug 20 22:00:27 2019 -0700
@@ -38,6 +38,8 @@
 
 number_digits(Codes) --> signed_float_or_integer(Codes), !, end_num.
 
+% At the end of a number look ahead one character for a space
+% or '[' character, or the end of the code list.
 end_num, [Ch] --> [Ch], { [Ch] = "[" ; is_space(Ch) }.
 end_num([], []).
 
@@ -54,7 +56,6 @@
     phrase(format_joy(Expression), ExpressionCodes),
     append(RStackCodes, [32, 46, 32|ExpressionCodes], Codes).
 
-
 frump(Stack, Expression) :-
     format_state(Stack, Expression, Codes),
     maplist(put_code, Codes), nl.
@@ -64,8 +65,6 @@
     phrase(format_joy(RStack), Codes),
     maplist(put_code, Codes).
 
-
-
 % Print Joy expressions as text.
 
 format_joy(Tail)  --> {var(Tail)}, !, [46, 46, 46].
@@ -79,4 +78,3 @@
 format_term([A|As]) --> "[", format_joy([A|As]), "]".
 format_term(F) --> {    write_to_codes(Codes, F)}, Codes.
 
-



More information about the Joypy-announce mailing list
Back to archive index