mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Merge pull request #824 from nmeum/parse-commit-fk
`(chibi parse)`: allow (optionally) passing custom fk to parse-commit
This commit is contained in:
commit
899a6bace3
1 changed files with 8 additions and 3 deletions
|
@ -520,10 +520,15 @@
|
||||||
|
|
||||||
;;> Parse with \var{f} once, keep the first result, and commit to the
|
;;> Parse with \var{f} once, keep the first result, and commit to the
|
||||||
;;> current parse path, discarding any prior backtracking options.
|
;;> current parse path, discarding any prior backtracking options.
|
||||||
|
;;> Since prior backtracking options are discarded, prior failure
|
||||||
|
;;> continuations are also not used. By default, \scheme{#f} is
|
||||||
|
;;> returned on failure, a custom failure continuation can be passed
|
||||||
|
;;> as the second argument.
|
||||||
|
|
||||||
(define (parse-commit f)
|
(define (parse-commit f . o)
|
||||||
(lambda (source index sk fk)
|
(let ((commit-fk (if (pair? o) (car o) (lambda (s i r) #f))))
|
||||||
(f source index (lambda (res s i fk) (sk res s i (lambda (s i r) #f))) fk)))
|
(lambda (source index sk fk)
|
||||||
|
(f source index (lambda (res s i fk) (sk res s i commit-fk)) fk))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue