• R/O
  • SSH

Joypy: Commit

Main interpreter and library.


Commit MetaInfo

Revision6f359630c98a8bf4e312fc7875769c677dd2ec12 (tree)
Time2019-08-13 14:29:09
AuthorSimon Forman <sforman@hush...>
CommiterSimon Forman

Log Message

minor cleanup

Change Summary

Incremental Difference

diff -r 7ceff2f7af14 -r 6f359630c98a thun/gnu-prolog/parser.pl
--- a/thun/gnu-prolog/parser.pl Mon Aug 12 21:59:19 2019 -0700
+++ b/thun/gnu-prolog/parser.pl Mon Aug 12 22:29:09 2019 -0700
@@ -37,28 +37,32 @@
3737 num(N) --> signed_digits(Codes), !, end_num, { number_codes(N, Codes) }.
3838 % TODO: floats, scientific notation.
3939
40+signed_digits([45|Codes]) --> "-", !, digits(Codes).
41+signed_digits( Codes ) --> digits(Codes).
42+
43+end_num, [Ch] --> [Ch], { [Ch] = "[" ; is_space(Ch) }.
44+end_num([], []).
45+
4046 % Groups of characters.
4147
4248 chars(Chars) --> one_or_more(char, Chars).
4349 blanks --> blank, !, blanks | [].
4450 digits(Digits) --> one_or_more(digit, Digits).
4551
46-signed_digits([45|Codes]) --> "-", !, digits(Codes).
47-signed_digits( Codes ) --> digits(Codes).
48-
4952 % Character types.
5053
51-char(Ch) --> [Ch], { nonvar(Ch), is_glyph(Ch)}.
54+char(Ch) --> [Ch], { nonvar(Ch), is_glyph(Ch) }.
5255 blank --> [Ch], { nonvar(Ch), is_space(Ch) }.
5356 digit(Ch) --> [Ch], { nonvar(Ch), between(0'0, 0'9, Ch) }.
5457
55-
56-end_num, [Ch] --> [Ch], { [Ch] = "[" ; is_space(Ch) }.
57-end_num([], []).
58-
5958 is_glyph(Ch) :- Ch =\= 0'[, Ch =\= 0'], between(0'!, 0'~, Ch).
6059 is_space(Ch) :- Ch =:= 32 ; between(9, 13, Ch).
6160
61+one_or_more(E, List) --> one_or_more_(List, E).
62+
63+one_or_more_([Ch|Rest], P) --> call(P, Ch), one_or_more_(Rest, P).
64+one_or_more_([Ch], P) --> call(P, Ch).
65+
6266
6367 % Line is the next new-line delimited line from standard input stream as
6468 % a list of character codes.
@@ -69,10 +73,6 @@
6973 line(-1, [eof]) :- !. % break on EOF
7074 line(X, [X|Line]) :- get_code(Y), !, line(Y, Line).
7175
72-one_or_more(E, List) --> one_or_more_(List, E).
73-
74-one_or_more_([Ch|Rest], P) --> call(P, Ch), one_or_more_(Rest, P).
75-one_or_more_([Ch], P) --> call(P, Ch).
7676
7777 /*
7878
Show on old repository browser