Run parser error handler in the correct env in run-context.
(def res (resume f resumeval))
(when good (when going (set resumeval (onstatus f res))))))
+ (defn parse-err
+ "Handle parser error in the correct environment"
+ [p where]
+ (def f (coro (on-parse-error p where)))
+ (fiber/setenv f env)
+ (resume f))
+
# Loop
(def buf @"")
(while going
(while (parser/has-more p)
(eval1 (parser/produce p)))
(when (= (parser/status p) :error)
- (on-parse-error p where))))
+ (parse-err p where))))
# Check final parser state
(while (parser/has-more p)
(eval1 (parser/produce p)))
(when (= (parser/status p) :error)
- (on-parse-error p where))
+ (parse-err p where))
(in env :exit-value env))
