changeset c5823e327a83 in joypy/Joypy details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=c5823e327a83 user: Simon Forman <sform****@hushm*****> date: Mon Aug 12 21:29:26 2019 -0700 description: Numbers can be followed by space or [. changeset 7ceff2f7af14 in joypy/Joypy details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=7ceff2f7af14 user: Simon Forman <sform****@hushm*****> date: Mon Aug 12 21:59:19 2019 -0700 description: minor cleanup diffstat: thun/gnu-prolog/parser.pl | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) diffs (50 lines): diff -r 7f9d45af6c88 -r 7ceff2f7af14 thun/gnu-prolog/parser.pl --- a/thun/gnu-prolog/parser.pl Mon Aug 12 21:13:11 2019 -0700 +++ b/thun/gnu-prolog/parser.pl Mon Aug 12 21:59:19 2019 -0700 @@ -21,8 +21,10 @@ */ + :- set_prolog_flag(double_quotes, codes). + joy_parse([T|J]) --> blanks, joy_term(T), blanks, joy_parse(J). joy_parse([]) --> []. @@ -30,12 +32,10 @@ joy_term(J) --> "[", !, joy_parse(J), "]". joy_term(C) --> symbol(C). -symbol(C) --> chars(Chars), !, {Chars \= "==", atom_codes(C, Chars)}. - -% TODO: negative numbers, floats, scientific notation. - -num(N) --> signed_digits(Codes), !, { number_codes(N, Codes) }. +symbol(C) --> chars(Chars), !, { Chars \= "==", atom_codes(C, Chars) }. +num(N) --> signed_digits(Codes), !, end_num, { number_codes(N, Codes) }. +% TODO: floats, scientific notation. % Groups of characters. @@ -48,9 +48,16 @@ % Character types. -char(Ch) --> [Ch], { nonvar(Ch), Ch =\= 0'[, Ch =\= 0'], between(33, 126, Ch) }. -blank --> [Ch], { nonvar(Ch),(Ch =:= 32 ; between(9, 13, Ch)) }. -digit(Ch) --> [Ch], { nonvar(Ch), between(48, 57, Ch) }. +char(Ch) --> [Ch], { nonvar(Ch), is_glyph(Ch)}. +blank --> [Ch], { nonvar(Ch), is_space(Ch) }. +digit(Ch) --> [Ch], { nonvar(Ch), between(0'0, 0'9, Ch) }. + + +end_num, [Ch] --> [Ch], { [Ch] = "[" ; is_space(Ch) }. +end_num([], []). + +is_glyph(Ch) :- Ch =\= 0'[, Ch =\= 0'], between(0'!, 0'~, Ch). +is_space(Ch) :- Ch =:= 32 ; between(9, 13, Ch). % Line is the next new-line delimited line from standard input stream as