diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-14 22:17:26 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-14 22:17:37 -0700 |
| commit | 49f1eb3d08caf7605046373b7b3a001f28aa8aab (patch) | |
| tree | 2894703fd312bd4202a3cbe225d19a958e2f24b2 /core/errors.nom | |
| parent | 82cfd3e54b5910843c091a9fb6ef3ad6b64ba757 (diff) | |
Reshuffling some files.
Diffstat (limited to 'core/errors.nom')
| -rw-r--r-- | core/errors.nom | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/errors.nom b/core/errors.nom new file mode 100644 index 0000000..dc585be --- /dev/null +++ b/core/errors.nom @@ -0,0 +1,22 @@ +# + This file contains basic error reporting code + +use "core/metaprogramming.nom" + +compile [traceback] to: Lua value "debug.traceback()" +compile [traceback %] to: Lua value "debug.traceback('', \(% as lua expr))" +compile [barf] to: Lua "error(nil, 0);" +compile [barf %msg] to: Lua "error(\(%msg as lua expr), 0);" +compile [assume %condition] to + lua> "local \%assumption = 'Assumption failed: '..tostring(nomsu:tree_to_nomsu(\%condition));" + return + Lua ".." + if not \(%condition as lua expr) then + error(\(quote "\%assumption"), 0); + end + +compile [assume %condition or barf %message] to + Lua ".." + if not \(%condition as lua expr) then + error(\(%message as lua expr), 0); + end |
