From da69cc127107c608c65fcdf2a69dc21accf3d99d Mon Sep 17 00:00:00 2001 From: "chris.double" Date: Sun, 8 Oct 2006 11:31:23 +0000 Subject: [PATCH] parser-combinators: fix 'satisfy' parser for empty strings --- contrib/parser-combinators/parser-combinators.factor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contrib/parser-combinators/parser-combinators.factor b/contrib/parser-combinators/parser-combinators.factor index 67523b094c..e1e07b5585 100644 --- a/contrib/parser-combinators/parser-combinators.factor +++ b/contrib/parser-combinators/parser-combinators.factor @@ -35,10 +35,14 @@ M: satisfy-parser (parse) ( input parser -- list ) #! A parser that succeeds if the predicate, #! when passed the first character in the input, returns #! true. - satisfy-parser-quot >r unclip-slice dup r> call [ - swap 1list - ] [ + over empty? [ 2drop nil + ] [ + satisfy-parser-quot >r unclip-slice dup r> call [ + swap 1list + ] [ + 2drop nil + ] if ] if ; TUPLE: epsilon-parser ;