aboutsummaryrefslogtreecommitdiff
path: root/core/metaprogramming.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-18 17:55:29 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-18 17:56:15 -0700
commitbf67a610135c0803187cf6ed896638962f142d14 (patch)
treea0b126c954168282c8c69ea728d4abbae712ac33 /core/metaprogramming.nom
parentacb86f78c3f79479ac3a73f0e5862f8f5d8f31f5 (diff)
Updating to version 2.4.4.3, with new syntax for multi-statement 'if'
and switch statements.
Diffstat (limited to 'core/metaprogramming.nom')
-rw-r--r--core/metaprogramming.nom16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index 8328d26..028a914 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -1,9 +1,9 @@
-#!/usr/bin/env nomsu -V2.3.4.3
+#!/usr/bin/env nomsu -V2.4.4.3
#
This File contains actions for making actions and compile-time actions and some helper
functions to make that easier.
-lua> "NOMSU_CORE_VERSION = 3"
+lua> "NOMSU_CORE_VERSION = 4"
lua> ".."
nomsu.COMPILE_ACTIONS["% -> %"] = function(nomsu, tree, \%args, \%body)
local lua = LuaCode.Value(tree.source, "function(")
@@ -119,8 +119,16 @@ compile [parse %actions as %body] to (..)
local ret = \(compile as (compile %actions to %new_body))
return ret
-compile [%tree as lua expr] to (..)
- Lua value "nomsu:compile(\(=lua "nomsu:compile(\%tree):as_expr()")):as_expr()"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+action [%tree as lua expr]:
+ lua> ".."
+ \%tree_lua = nomsu:compile(\%tree)
+ if not \%tree_lua.is_value then
+ nomsu:compile_error(\%tree.source, "Could not convert %s to a Lua expression",
+ nomsu:tree_to_nomsu(\%tree))
+ end
+ return \%tree_lua
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~