diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e91fe39..5710b712 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? -- Added `os/cpu-count` to get the number of available processors on a machine +- Add `parse-all` as a generalization of the `parse` function. +- Add `os/cpu-count` to get the number of available processors on a machine ## 1.22.0 - 2022-05-09 - Prohibit negative size argument to `table/new`. diff --git a/src/boot/boot.janet b/src/boot/boot.janet index d7113da5..8d78fd12 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -2575,6 +2575,20 @@ (error (parser/error p)) (error "no value"))))) +(defn parse-all + `Parse a string and return all parsed values. For complex parsing, such as for a repl with error handling, + use the parser api.` + [str] + (let [p (parser/new) + ret @[]] + (parser/consume p str) + (parser/eof p) + (while (parser/has-more p) + (array/push ret (parser/produce p))) + (if (= :error (parser/status p)) + (error (parser/error p)) + ret))) + (def load-image-dict ``A table used in combination with `unmarshal` to unmarshal byte sequences created by `make-image`, such that `(load-image bytes)` is the same as `(unmarshal bytes load-image-dict)`.``