parser-combinators: fix 'satisfy' parser for empty strings

darcs
chris.double 2006-10-08 11:31:23 +00:00
parent ca33aa9c60
commit da69cc1271
1 changed files with 7 additions and 3 deletions

View 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 ;