summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <davet@gnu.org>2015-08-10 16:27:49 -0400
committerDavid Thompson <davet@gnu.org>2015-08-10 16:27:49 -0400
commit8e02ee35745edc88e29159c18e0e28a67778e9e2 (patch)
treedcacbcb60b657b97d1bde8ea22c13d1df4c0c623
parente73158d9d193897d31430c602a4263e7e2bb2019 (diff)
Move parse-end around.HEADmaster
-rw-r--r--parser-combinators.scm13
1 files changed, 7 insertions, 6 deletions
diff --git a/parser-combinators.scm b/parser-combinators.scm
index 1b8c960..27fa176 100644
--- a/parser-combinators.scm
+++ b/parser-combinators.scm
@@ -36,7 +36,6 @@
parse-success?
%parse-failure
parse-fail
- parse-end
parse-bind
parse-return
parse-lift
@@ -46,6 +45,7 @@
parse-match
parse-any
parse-each
+ parse-end
parse-zero-or-more
parse-one-or-more
parse-up-to
@@ -83,11 +83,6 @@
"Always fail to parse STREAM."
%parse-failure)
-(define (parse-end stream)
- (if (stream-null? stream)
- (parse-result #t stream-null)
- %parse-failure))
-
(define (parse-bind proc parser)
(lambda (stream)
(match (parser stream)
@@ -176,6 +171,12 @@ parsers succeed."
all of the input parsers succeed."
(%parse-each (delay parser) ...))
+(define (parse-end stream)
+ "Succeed with #t if STREAM is emtpy or fail otherwise."
+ (if (stream-null? stream)
+ (parse-result #t stream-null)
+ %parse-failure))
+
(define (parse-zero-or-more parser)
"Create a parser that applies PARSER as many times as it can before
failing and returns list of the successful parse results."