changeset 20e9a0d2485c in joypy/Joypy details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=20e9a0d2485c user: Simon Forman <sform****@hushm*****> date: Mon Aug 12 21:08:17 2019 -0700 description: assert_defs/1 got upset about not finding combo/5 changeset b94a0e75143b in joypy/Joypy details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=b94a0e75143b user: Simon Forman <sform****@hushm*****> date: Mon Aug 12 21:08:35 2019 -0700 description: swapd function changeset 7f9d45af6c88 in joypy/Joypy details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=7f9d45af6c88 user: Simon Forman <sform****@hushm*****> date: Mon Aug 12 21:13:11 2019 -0700 description: Parse negative numbers. diffstat: thun/gnu-prolog/parser.pl | 5 +++- thun/gnu-prolog/thun.pl | 1 + thun/thun.pl | 48 +++++++++++++++++++++++----------------------- 3 files changed, 29 insertions(+), 25 deletions(-) diffs (98 lines): diff -r b3344d468606 -r 7f9d45af6c88 thun/gnu-prolog/parser.pl --- a/thun/gnu-prolog/parser.pl Mon Aug 12 20:59:02 2019 -0700 +++ b/thun/gnu-prolog/parser.pl Mon Aug 12 21:13:11 2019 -0700 @@ -35,7 +35,7 @@ % TODO: negative numbers, floats, scientific notation. -num(N) --> digits(Codes), !, { number_codes(N, Codes) }. +num(N) --> signed_digits(Codes), !, { number_codes(N, Codes) }. % Groups of characters. @@ -43,6 +43,9 @@ blanks --> blank, !, blanks | []. digits(Digits) --> one_or_more(digit, Digits). +signed_digits([45|Codes]) --> "-", !, digits(Codes). +signed_digits( Codes ) --> digits(Codes). + % Character types. char(Ch) --> [Ch], { nonvar(Ch), Ch =\= 0'[, Ch =\= 0'], between(33, 126, Ch) }. diff -r b3344d468606 -r 7f9d45af6c88 thun/gnu-prolog/thun.pl --- a/thun/gnu-prolog/thun.pl Mon Aug 12 20:59:02 2019 -0700 +++ b/thun/gnu-prolog/thun.pl Mon Aug 12 21:13:11 2019 -0700 @@ -94,6 +94,7 @@ func(thunk, S , [X|S]). func(rolldown, [A, B, C|S], [B, C, A|S]). +func(swapd, [A, B, C|S], [A, C, B|S]). func(dupd, [A, B|S], [A, B, B|S]). func(over, [A, B|S], [B, A, B|S]). func(tuck, [A, B|S], [A, B, A|S]). diff -r b3344d468606 -r 7f9d45af6c88 thun/thun.pl --- a/thun/thun.pl Mon Aug 12 20:59:02 2019 -0700 +++ b/thun/thun.pl Mon Aug 12 21:13:11 2019 -0700 @@ -197,30 +197,6 @@ /* -Definitions -*/ - -joy_def(def(Def, Body)) --> symbol(Def), blanks, "==", joy_parse(Body). - -joy_def --> joy_def(Def), {ignore(assert_def(Def))}. - -joy_defs --> blanks, joy_def, blanks, joy_defs. -joy_defs --> []. - -assert_defs(DefsFile) :- - read_file_to_codes(DefsFile, Codes, []), - phrase(joy_defs, Codes). - -assert_def(def(Def, Body)) :- - \+ func(Def, _, _), - \+ combo(Def, _, _, _, _), - retractall(def(Def, _)), - assertz(def(Def, Body)). - -:- assert_defs("defs.txt"). - - -/* Combinators */ @@ -299,6 +275,30 @@ /* +Definitions +*/ + +joy_def(def(Def, Body)) --> symbol(Def), blanks, "==", joy_parse(Body). + +joy_def --> joy_def(Def), {ignore(assert_def(Def))}. + +joy_defs --> blanks, joy_def, blanks, joy_defs. +joy_defs --> []. + +assert_defs(DefsFile) :- + read_file_to_codes(DefsFile, Codes, []), + phrase(joy_defs, Codes). + +assert_def(def(Def, Body)) :- + \+ func(Def, _, _), + \+ combo(Def, _, _, _, _), + retractall(def(Def, _)), + assertz(def(Def, Body)). + +:- assert_defs("defs.txt"). + + +/* Compiler */