From 79aa2f972d6f8ad87f8323eccf95902c83caa7b3 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sun, 11 Aug 2019 18:45:57 -0700 Subject: [PATCH] Multifile func/3. --- thun/gnu-prolog/Makefile | 7 ++++--- thun/gnu-prolog/main.pl | 4 +++- thun/gnu-prolog/math.pl | 1 + thun/gnu-prolog/meta-math.pl | 1 + thun/gnu-prolog/thun.pl | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/thun/gnu-prolog/Makefile b/thun/gnu-prolog/Makefile index 2c80052..d8b9db4 100644 --- a/thun/gnu-prolog/Makefile +++ b/thun/gnu-prolog/Makefile @@ -1,7 +1,8 @@ -GPLC_OPTIONS="--min-size" +#GPLC_OPTIONS=--min-size +GPLC_OPTIONS=--no-top-level -thun: thun.pl parser.pl defs.pl main.pl - gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl defs.pl main.pl +thun: thun.pl parser.pl defs.pl main.pl math.pl Makefile + gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl defs.pl main.pl math.pl defs.pl: meta-defs.pl parser.pl defs.txt thun.pl gprolog \ diff --git a/thun/gnu-prolog/main.pl b/thun/gnu-prolog/main.pl index 595bc57..5f5856a 100644 --- a/thun/gnu-prolog/main.pl +++ b/thun/gnu-prolog/main.pl @@ -33,7 +33,9 @@ loop( Line, In, Out) :- loop(NextLine, S, Out). -do_line(Line, In, Out) :- phrase(joy_parse(E), Line), thun(E, In, 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? `). diff --git a/thun/gnu-prolog/math.pl b/thun/gnu-prolog/math.pl index da60453..6a41cd2 100644 --- a/thun/gnu-prolog/math.pl +++ b/thun/gnu-prolog/math.pl @@ -1,3 +1,4 @@ +:- multifile(func/3). func(+, [A, B|C], [D|C]) :- E =.. [+, B, A], catch(D is E, _, D = E). diff --git a/thun/gnu-prolog/meta-math.pl b/thun/gnu-prolog/meta-math.pl index 0d76518..3ac327f 100644 --- a/thun/gnu-prolog/meta-math.pl +++ b/thun/gnu-prolog/meta-math.pl @@ -61,6 +61,7 @@ writeln(Stream, Thing) :- do :- open(`math.pl`, write, Stream), + write(Stream, `:- multifile(func/3).`), nl(Stream), print_o(Stream, math_operator(Op)), print_o(Stream, comparison_operator(Op)), print_o(Stream, comparison_operator(Op, Po)), diff --git a/thun/gnu-prolog/thun.pl b/thun/gnu-prolog/thun.pl index d4ab2b6..dacef59 100644 --- a/thun/gnu-prolog/thun.pl +++ b/thun/gnu-prolog/thun.pl @@ -19,6 +19,7 @@ */ % :- dynamic(func/3). % :- discontiguous(func/3). +:- multifile(func/3). /* Interpreter