continue compilation in broken let statements

This commit is contained in:
XeroOl 2024-03-01 14:51:18 -06:00
parent 186c388344
commit 284983657f
2 changed files with 13 additions and 8 deletions

View File

@ -230,14 +230,20 @@ identifiers are declared / referenced in which places."
(where [sym] (multisym? sym) (: (tostring sym) :find ":"))
(reference sym scope :read)))
recoverable? [msg]
attempt-to-recover! [msg ?ast]
(or (= 1 (msg:find "unknown identifier"))
(= 1 (msg:find "expected closing delimiter"))
(= 1 (msg:find "expected body expression"))
(= 1 (msg:find "expected condition and body"))
(= 1 (msg:find "expected whitespace before opening delimiter"))
(= 1 (msg:find "malformed multisym"))
(= 1 (msg:find "expected at least one pattern/body pair"))))
(= 1 (msg:find "expected at least one pattern/body pair"))
(when (and (sequence? ?ast)
(= 1 (% (length ?ast ) 2))
(= 1 (msg:find "expected even number of name/value bindings")))
(table.insert ?ast (sym :nil))
true)))
(λ on-compile-error [_ msg ast call-me-to-reset-the-compiler]
(let [range (or (message.ast->range self file ast)
@ -248,7 +254,7 @@ identifiers are declared / referenced in which places."
:severity message.severity.ERROR
:code 201
:codeDescription "compiler error"}))
(if (recoverable? msg)
(if (attempt-to-recover! msg ast)
true
(do
(call-me-to-reset-the-compiler)
@ -263,7 +269,7 @@ identifiers are declared / referenced in which places."
:severity message.severity.ERROR
:code 101
:codeDescription "parse error"}))
(if (recoverable? msg)
(if (attempt-to-recover! msg)
true
(do
(call-me-to-reset-the-compiler)

View File

@ -88,10 +88,9 @@
fo|" [:foo :bar] [])
(check "(local foo 10)
(local bar (let [y foo] |" [:foo :y] [])
;; TODO add compile check for incomplete let
; (check "(let [foo 10
; bar 20
; _ |" [:foo :bar] [])
(check "(let [foo 10
bar 20
_ |" [:foo :bar] [])
(check "(let [foo 10
bar 20
_ fo|" [:foo :bar] [])