• R/O
  • SSH

Joypy: Commit

Main interpreter and library.


Commit MetaInfo

Revisionfa294f364037540527f2b2c2b01a683e81ee2204 (tree)
Time2019-07-21 09:32:03
AuthorSimon Forman <sforman@hush...>
CommiterSimon Forman

Log Message

Replace ≡ with plain ol' def/2.

As much fun as it was using ≡ as an operator, now that all the defs live in a text file you don't see it in the Prolog code anymore.

This way I get to use sweet sweet ASCII (except for the © symbol in the copyright notice.)

Change Summary

Incremental Difference

diff -r e270947ee8c7 -r fa294f364037 thun/thun.pl
--- a/thun/thun.pl Sat Jul 20 17:19:35 2019 -0700
+++ b/thun/thun.pl Sat Jul 20 17:32:03 2019 -0700
@@ -18,9 +18,8 @@
1818 %
1919 :- use_module(library(clpfd)).
2020 :- use_module(library(dcg/basics)).
21-:- op(990, xfy, ≡). % for Joy definitions.
2221 :- dynamic func/3.
23-:- dynamic '≡'/2.
22+:- dynamic def/2.
2423
2524
2625 /*
@@ -83,17 +82,21 @@
8382
8483 thun([], S, S).
8584 thun( [Lit|E], Si, So) :- literal(Lit), !, thun(E, [Lit|Si], So).
86-thun( [Def|E], Si, So) :- Def ≡ Body, !, append(Body, E, Eo), thun(Eo, Si, So).
85+thun( [Def|E], Si, So) :- def(Def, Body), !, append(Body, E, Eo), thun(Eo, Si, So).
8786 thun( [Func|E], Si, So) :- func(Func, Si, S), thun(E, S, So).
8887 thun([Combo|E], Si, So) :- combo(Combo, Si, S, E, Eo), thun(Eo, S, So).
8988
9089 % Some error handling.
9190
92-thun([Unknown|E], Si, So) :- damned_thing(Unknown), write("wtf? "), writeln(Unknown), So = [[Unknown|E]|Si].
91+thun([Unknown|E], Si, So) :-
92+ damned_thing(Unknown),
93+ write("wtf? "),
94+ writeln(Unknown),
95+ So = [[Unknown|E]|Si].
9396
9497 damned_thing(It) :-
9598 \+ literal(It),
96- \+ (It ≡ _),
99+ \+ def(It, _),
97100 \+ func(It, _, _),
98101 \+ combo(It, _, _, _, _).
99102
@@ -172,7 +175,7 @@
172175 Definitions
173176 */
174177
175-joy_def(Def ≡ Body) --> symbol(Def), blanks, "==", joy_parse(Body).
178+joy_def(def(Def, Body)) --> symbol(Def), blanks, "==", joy_parse(Body).
176179
177180 joy_defs([Def|Defs]) --> blanks, joy_def(Def), blanks, joy_defs(Defs).
178181 joy_defs([]) --> [].
@@ -185,7 +188,9 @@
185188 read_defs(DefsFile, Defs),
186189 forall(member(Def, Defs), assert_def(Def)).
187190
188-assert_def(Def≡Body) :- retractall(Def≡_), assertz(Def≡Body).
191+assert_def(def(Def, Body)) :-
192+ retractall(def(Def, _)),
193+ assertz(def(Def, Body)).
189194
190195 :- assert_defs("defs.txt").
191196
@@ -254,8 +259,8 @@
254259
255260 % Simple DCGs to expand/contract definitions.
256261
257-expando, Body --> [Def], {Def ≡ Body}.
258-contracto, [Def] --> {Def ≡ Body}, Body.
262+expando, Body --> [Def], {def(Def, Body)}.
263+contracto, [Def] --> {def(Def, Body)}, Body.
259264
260265 % phrase(expando, ExprIn, ExprOut).
261266
Show on old repository browser