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, #! A parser that succeeds if the predicate,
#! when passed the first character in the input, returns #! when passed the first character in the input, returns
#! true. #! true.
over empty? [
2drop nil
] [
satisfy-parser-quot >r unclip-slice dup r> call [ satisfy-parser-quot >r unclip-slice dup r> call [
swap <parse-result> 1list swap <parse-result> 1list
] [ ] [
2drop nil 2drop nil
] if
] if ; ] if ;
TUPLE: epsilon-parser ; TUPLE: epsilon-parser ;