1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 09:47:17 +00:00

Run parser error handler in the correct env in run-context.

This commit is contained in:
Calvin Rose 2020-04-27 20:29:16 -05:00
parent c98e1f3cae
commit 8bbb7907d6

View File

@ -2005,6 +2005,13 @@
(def res (resume f resumeval)) (def res (resume f resumeval))
(when good (when going (set resumeval (onstatus f res)))))) (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 # Loop
(def buf @"") (def buf @"")
(while going (while going
@ -2022,12 +2029,12 @@
(while (parser/has-more p) (while (parser/has-more p)
(eval1 (parser/produce p))) (eval1 (parser/produce p)))
(when (= (parser/status p) :error) (when (= (parser/status p) :error)
(on-parse-error p where)))) (parse-err p where))))
# Check final parser state # Check final parser state
(while (parser/has-more p) (while (parser/has-more p)
(eval1 (parser/produce p))) (eval1 (parser/produce p)))
(when (= (parser/status p) :error) (when (= (parser/status p) :error)
(on-parse-error p where)) (parse-err p where))
(in env :exit-value env)) (in env :exit-value env))