From 86bf87584112a43d88dc0280426ca4d949b94406 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Mon, 12 Aug 2019 21:29:26 -0700 Subject: [PATCH] Numbers can be followed by space or [. --- thun/gnu-prolog/parser.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/thun/gnu-prolog/parser.pl b/thun/gnu-prolog/parser.pl index 25142d9..0824fe7 100644 --- a/thun/gnu-prolog/parser.pl +++ b/thun/gnu-prolog/parser.pl @@ -35,7 +35,7 @@ symbol(C) --> chars(Chars), !, {Chars \= "==", atom_codes(C, Chars)}. % TODO: negative numbers, floats, scientific notation. -num(N) --> signed_digits(Codes), !, { number_codes(N, Codes) }. +num(N) --> signed_digits(Codes), !, end_num, { number_codes(N, Codes) }. % Groups of characters. @@ -49,10 +49,16 @@ signed_digits( Codes ) --> digits(Codes). % 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)) }. +blank --> [Ch], { nonvar(Ch), is_space(Ch) }. digit(Ch) --> [Ch], { nonvar(Ch), between(48, 57, Ch) }. +end_num, [Ch] --> [Ch], { [Ch] = "[" ; is_space(Ch) }. +end_num([], []). + +is_space(Ch) :- Ch =:= 32 ; between(9, 13, Ch). + + % Line is the next new-line delimited line from standard input stream as % a list of character codes.