]> gitweb.factorcode.org Git - factor.git/commitdiff
parser-combinators: fix 'satisfy' parser for empty strings
authorchris.double <chris.double@double.co.nz>
Sun, 8 Oct 2006 11:31:23 +0000 (11:31 +0000)
committerchris.double <chris.double@double.co.nz>
Sun, 8 Oct 2006 11:31:23 +0000 (11:31 +0000)
contrib/parser-combinators/parser-combinators.factor

index 67523b094cd6fcbb11a5b7f88e681d471e74038b..e1e07b5585f52ed49b6cd9c3eaf0db8b242edc32 100644 (file)
@@ -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 <parse-result> 1list
-  ] [
+  over empty? [
     2drop nil
+  ] [
+    satisfy-parser-quot >r unclip-slice dup r> call [
+      swap <parse-result> 1list
+    ] [
+      2drop nil
+    ] if 
   ] if ;
 
 TUPLE: epsilon-parser ;