From cae79ded8fe59d22de968bffe9df335c43353396 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Mon, 12 Aug 2019 19:09:49 -0700 Subject: [PATCH] swoncat and fiddling with parser. --- thun/gnu-prolog/defs.pl | 1 + thun/gnu-prolog/defs.txt | 1 + thun/gnu-prolog/parser.pl | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/thun/gnu-prolog/defs.pl b/thun/gnu-prolog/defs.pl index 43851e2..5575c41 100644 --- a/thun/gnu-prolog/defs.pl +++ b/thun/gnu-prolog/defs.pl @@ -58,6 +58,7 @@ def(split_at,[[drop],[take],clop]). def(sqr,[dup,*]). def(step_zero,[0,rollup,step]). def(sum,[0,swap,[+],step]). +def(swoncat,[swap,concat]). def(swons,[swap,cons]). def(take,[[],rolldown,[shift],times,pop]). def(ternary,[binary,popd]). diff --git a/thun/gnu-prolog/defs.txt b/thun/gnu-prolog/defs.txt index 7be86c2..039ecd2 100644 --- a/thun/gnu-prolog/defs.txt +++ b/thun/gnu-prolog/defs.txt @@ -61,6 +61,7 @@ split_at == [drop] [take] clop sqr == dup * step_zero == 0 rollup step sum == 0 swap [+] step +swoncat == swap concat swons == swap cons take == [] rolldown [shift] times pop ternary == binary popd diff --git a/thun/gnu-prolog/parser.pl b/thun/gnu-prolog/parser.pl index fadd6c9..2d3fa18 100644 --- a/thun/gnu-prolog/parser.pl +++ b/thun/gnu-prolog/parser.pl @@ -46,13 +46,13 @@ line(X, [X|Line]) :- get_code(Y), !, line(Y, Line). chars([Ch|Rest]) --> char(Ch), chars(Rest). chars([Ch]) --> char(Ch). -char(Ch) --> [Ch], { Ch \== 0'[, Ch \== 0'], Ch >= 33, Ch =< 126 }. +char(Ch) --> [Ch], { Ch \== 0'[, Ch \== 0'], between(33, 126, Ch) }. blanks --> blank, !, blanks. blanks --> []. -blank --> [32] | [13] | [10]. +blank --> [Ch], { Ch =:= 32 ; between(9, 13, Ch) }. % TODO: negative numbers, floats, scientific notation.