aboutsummaryrefslogtreecommitdiff
path: root/core/metaprogramming.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-12 13:56:15 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-12 13:56:35 -0700
commit0c9973ff0363e400d3d284339b77197c40c3f60c (patch)
tree00c51a0cea933b1cec28f45561e3ba74dde466ff /core/metaprogramming.nom
parent7cd512d15e5bc22c529d5b4e3e02a41fe1e84208 (diff)
Tidying up exceptions and error reporting. Also simplified the grammar a
tiny bit.
Diffstat (limited to 'core/metaprogramming.nom')
-rw-r--r--core/metaprogramming.nom18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index 8ad9448..83293c1 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -132,15 +132,25 @@ immediately
lua> ".."
local lua = nomsu:tree_to_lua(\%tree)
if not lua.is_value then
- error("Invalid thing to convert to lua expr: "..tostring(\%tree))
+ compile_error(\%tree, "Invalid thing to convert to lua expr:\n%s")
end
return lua
action [%tree as lua statements]
=lua "nomsu:tree_to_lua(\%tree):as_statements()"
+
+ action [%tree as lua return]
+ =lua "nomsu:tree_to_lua(\%tree):as_statements('return ')"
- action [%tree with vars %vars]
- =lua "\%tree:map(\%vars)"
+immediately
+ compile [%tree with vars %vars] to
+ barf "Deprecated"
+
+ compile [%tree with %t -> %replacement] to
+ Lua value ".."
+ \(%tree as lua expr):map(function(\(%t as lua expr))
+ \(%replacement as lua return)
+ end)
compile [declare locals in %code] to
Lua value "\(%code as lua expr):declare_locals()"
@@ -202,6 +212,8 @@ immediately
# Error functions
immediately
+ 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