swoncat and fiddling with parser.

This commit is contained in:
Simon Forman 2019-08-12 19:09:49 -07:00
parent 2e1f598aa2
commit cae79ded8f
3 changed files with 4 additions and 2 deletions

View File

@ -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]).

View File

@ -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

View File

@ -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.