Build defs.pl from defs.txt.
This commit is contained in:
parent
90bccece6a
commit
e49b0b70cb
|
|
@ -1,8 +1,8 @@
|
|||
GPLC_OPTIONS="--min-size"
|
||||
|
||||
thun: thun.pl parser.pl defs.pl
|
||||
gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl
|
||||
gplc $(GPLC_OPTIONS) -o thun thun.pl parser.pl defs.pl
|
||||
|
||||
defs.pl: meta-defs.pl parser.pl defs.txt
|
||||
gprolog --consult-file meta-defs.pl --consult-file parser.pl --query-goal do > defs.pl
|
||||
gprolog --consult-file meta-defs.pl --consult-file parser.pl --query-goal do
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
GNU Prolog 1.4.4 (64 bits)
|
||||
Compiled Oct 11 2018, 14:29:28 with cc
|
||||
By Daniel Diaz
|
||||
Copyright (C) 1999-2013 Daniel Diaz
|
||||
compiling /home/sforman/src/Joypy/thun/gnu-prolog/meta-defs.pl for byte code...
|
||||
/home/sforman/src/Joypy/thun/gnu-prolog/meta-defs.pl compiled, 40 lines read - 4480 bytes written, 6 ms
|
||||
compiling /home/sforman/src/Joypy/thun/gnu-prolog/parser.pl for byte code...
|
||||
/home/sforman/src/Joypy/thun/gnu-prolog/parser.pl compiled, 72 lines read - 7481 bytes written, 8 ms
|
||||
| ?- do.
|
||||
def(--,[1,-]).
|
||||
def(?,[dup,bool]).
|
||||
def(++,[1,+]).
|
||||
|
|
@ -16,7 +7,6 @@ def(app2,[[grba,swap,grba,swap],dip,[infrst],cons,ii]).
|
|||
def(app3,[3,appN]).
|
||||
def(appN,[[grabN],cons,dip,map,disenstacken]).
|
||||
def(at,[drop,first]).
|
||||
def(average,[[sum,1,.0,*],[size],cleave,/]).
|
||||
def(b,[[i],dip,i]).
|
||||
def(binary,[unary,popd]).
|
||||
def(ccons,[cons,cons]).
|
||||
|
|
@ -67,7 +57,7 @@ def(shunt,[[swons],step]).
|
|||
def(size,[0,swap,[pop,++],step]).
|
||||
def(split_at,[[drop],[take],clop]).
|
||||
def(sqr,[dup,*]).
|
||||
def(step_zero,[0,roll>,step]).
|
||||
def(step_zero,[0,rollup,step]).
|
||||
def(sum,[0,swap,[+],step]).
|
||||
def(swons,[swap,cons]).
|
||||
def(take,[[],rolldown,[shift],times,pop]).
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ app2 == [grba swap grba swap] dip [infrst] cons ii
|
|||
app3 == 3 appN
|
||||
appN == [grabN] cons dip map disenstacken
|
||||
at == drop first
|
||||
average == [sum 1.0 *] [size] cleave /
|
||||
b == [i] dip i
|
||||
binary == unary popd
|
||||
ccons == cons cons
|
||||
|
|
@ -58,7 +57,7 @@ shunt == [swons] step
|
|||
size == 0 swap [pop ++] step
|
||||
split_at == [drop] [take] clop
|
||||
sqr == dup *
|
||||
step_zero == 0 roll> step
|
||||
step_zero == 0 rollup step
|
||||
sum == 0 swap [+] step
|
||||
swons == swap cons
|
||||
take == [] rolldown [shift] times pop
|
||||
|
|
@ -69,4 +68,4 @@ unit == [] cons
|
|||
unquoted == [i] dip
|
||||
unswons == uncons swap
|
||||
while == swap [nullary] cons dup dipd concat loop
|
||||
x == dup i
|
||||
x == dup i
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ stream_to_codes(Ch, Stream, [Ch|Codes]) :- stream_to_codes(Stream, Codes).
|
|||
|
||||
print_defs :-
|
||||
findall(def(Name, Body), def(Name, Body), List),
|
||||
maplist(print_def, List).
|
||||
open(`defs.pl`, write, Stream),
|
||||
maplist(print_def(Stream), List),
|
||||
close(Stream).
|
||||
|
||||
print_def(Def) :- write(Def), write(`.`), nl.
|
||||
print_def(Stream, Def) :- write(Stream, Def), write(Stream, `.`), nl(Stream).
|
||||
|
||||
|
|
|
|||
|
|
@ -196,16 +196,6 @@ prepare_mapping( P, S, [T|In], Acc, Out) :-
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Definitions
|
||||
*/
|
||||
|
||||
def(x, [dup, i]).
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Main Loop
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue