(chibi parse): Ensure reason is always a string

While testing a `(chibi parser)`-based parser I noticed that
`parse-string` is the only provided parser combinator which uses a list,
instead of a string, as a failure reason. It is not explicitly
documented but since all other standard parser combinator use a string
for the error reason I assume this to be a bug and have adjusted the
`parse-string` combinator accordingly in this commit.
This commit is contained in:
Sören Tempel 2022-04-09 10:55:20 +02:00
parent e7486dd7df
commit 1503217e86

View file

@ -663,7 +663,7 @@
(define (parse-string str) (define (parse-string str)
(parse-map (parse-with-failure-reason (parse-map (parse-with-failure-reason
(parse-seq-list (map parse-char (string->list str))) (parse-seq-list (map parse-char (string->list str)))
`(expected ,str)) (string-append "expected '" str "'"))
list->string)) list->string))
;;> Parse a sequence of characters matching \var{x} as with ;;> Parse a sequence of characters matching \var{x} as with