diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-18 14:22:17 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-18 14:22:48 -0800 |
| commit | 10bd72e858a8ffaacafa296dbbc429dc73b0111c (patch) | |
| tree | 3dec18257ac6d1affe78aa33a9b389a25eda1256 /lib/core/errors.nom | |
| parent | 520acd39795766354fc44c6e15f5f33f255ca33a (diff) | |
Added `tree` back as a parameter to compile actions, which helps with
better error reporting, e.g. for (fail) (no arguments). Overall better
error reporting now. Also added shorthand ("Action" tree with ...) for
(SyntaxTree {.type = "Action", .1 = ...}).
Diffstat (limited to 'lib/core/errors.nom')
| -rw-r--r-- | lib/core/errors.nom | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/core/errors.nom b/lib/core/errors.nom index 0b67400..8027228 100644 --- a/lib/core/errors.nom +++ b/lib/core/errors.nom @@ -8,14 +8,15 @@ use "core/control_flow" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -(fail $msg) compiles to - LuaCode - "at_1_fail(\(quote $msg.source), 'Failure: '..\($msg as lua expr))" - ..if $msg else "error('Failure', 0)" +(fail $msg) compiles to (" + at_1_fail(\(quote (this tree).source), 'Failure: \( + "'..\($msg as lua expr)" if $msg else "A failure was triggered here'" + )) +") (assume $condition) compiles to (" if not \($condition as lua expr) then - at_1_fail(\(quote "\($condition.source)"), "Assumption failed: This is not true.") + at_1_fail(\(quote "\($condition.source)"), "Assumption failed: This was not true.") end ") @@ -24,7 +25,7 @@ use "core/control_flow" local _a, _b = \($a as lua expr), \($b as lua expr) if _a ~= _b then at_1_fail(\(quote "\($a.source)"), - "Assumption failed: This value is "..tostring(_a)..", but it was supposed to be "..tostring(_b)..".") + "Assumption failed: This value was "..tostring(_a).." when it was supposed to be "..tostring(_b)..".") end end ") @@ -34,7 +35,7 @@ use "core/control_flow" local _a, _b = \($a as lua expr), \($b as lua expr) if _a == _b then at_1_fail(\(quote "\($a.source)"), - "Assumption failed: This value is "..tostring(_a)..", but it wasn't supposed to be.") + "Assumption failed: This value was "..tostring(_a).." when it wasn't supposed to be.") end end ") |
