From 8e02ee35745edc88e29159c18e0e28a67778e9e2 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 10 Aug 2015 16:27:49 -0400 Subject: Move parse-end around. --- parser-combinators.scm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'parser-combinators.scm') 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." -- cgit v1.2.3