engine: resources, lang: funcs, parser: Add panic magic

It's valuable to check your runtime values and to shut down the entire
engine in case something doesn't match. This patch adds some magic
plumbing to support a "panic" mechanism.

A new "panic" statement gets transparently converted into a panic
function and panic resource. The former errors if the input is not
empty. The latter must be present to consume the value, but doesn't
actually do anything.
This commit is contained in:
James Shubin
2023-11-28 13:49:31 -05:00
parent 64e6e686e0
commit 2cbce963b7
12 changed files with 328 additions and 17 deletions

View File

@@ -25,4 +25,10 @@ const (
// VarPrefix is the prefix character that precedes the variables
// identifier. For example, `$foo` or for a lambda, `$fn(42)`.
VarPrefix = "$"
// PanicResKind is the kind string used for the panic resource.
PanicResKind = "_panic"
// PanicVarName is the magic name used for the panic output var.
PanicVarName = "_panic"
)