From 25e06d1fce660e7c8144425b440f7b1c698e2fb7 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 13 Apr 2018 15:29:16 -0700 Subject: Getting closer. --- core/metaprogramming.nom | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'core/metaprogramming.nom') diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom index 0c7cada..8b1546b 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -82,7 +82,7 @@ immediately: for i, a in ipairs(args) do replacements[i] = a.."="..a; end replacements = "{"..table.concat(replacements, ", ").."}"; lua:append([[) - local template = nomsu_parse(]]..template..[[, ]]..repr(tree.source.filename)..[[); + local template = nomsu:parse(]]..template..[[, ]]..repr(tree.source.filename)..[[); local replacement = nomsu:tree_with_replaced_vars(template, ]]..replacements..[[); return nomsu:tree_to_lua(replacement, nomsu.compilestack[#nomsu.compilestack].source.filename); end); @@ -190,6 +190,13 @@ immediately: if not \(%condition as lua expr) then error(\(repr %assumption), 0); end + + # TODO: factor this out and replace with "unless %condition: barf %message" + compile [assume %condition or barf %message] to: + Lua ".." + if not \(%condition as lua expr) then + error(\(%message as lua expr), 0); + end # Literals immediately: -- cgit v1.2.3