From 7435b61380054307148ec2c3a6af6d7ef9187fbe Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 13 Oct 2017 16:10:47 -0700 Subject: Changed generated code to be less verbose for function and macro defs (using "foo %" syntax instead of {type="FunctionCall", ...} literals). --- lib/metaprogramming.nom | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/metaprogramming.nom') diff --git a/lib/metaprogramming.nom b/lib/metaprogramming.nom index b26deb4..7630088 100644 --- a/lib/metaprogramming.nom +++ b/lib/metaprogramming.nom @@ -5,7 +5,7 @@ # Rule to make rules: lua code ".." |nomsu:defmacro("rule %signature = %body", (function(nomsu, vars) - | local signature = nomsu:typecheck(vars, "signature", "List").value; + | local signature = nomsu:get_stubs(nomsu:typecheck(vars, "signature", "List").value); | local body = nomsu:typecheck(vars, "body", "Thunk"); | return ([[ |nomsu:def(%s, %s, %s) @@ -15,7 +15,7 @@ lua code ".." # Rule to make nomsu macros: rule [escaped parse %shorthand as %longhand] =: lua code ".." - |local aliases = nomsu:typecheck(vars, "shorthand", "List").value; + |local aliases = nomsu:get_stubs(nomsu:typecheck(vars, "shorthand", "List").value); |if #vars.longhand.value ~= 1 then; | nomsu:error("Expected only 1 line to parse to, but got "..tostring(#vars.longhand.value)); |end; @@ -30,13 +30,13 @@ escaped parse \[parse %shorthand as %longhand] as \: escaped parse \%shorthand a # Rule to make lua macros: rule [escaped compile %macro_def to %body] =: lua code ".." - |local aliases = nomsu:typecheck(vars, "macro_def", "List").value; + |local aliases = nomsu:get_stubs(nomsu:typecheck(vars, "macro_def", "List").value); |local body = nomsu:typecheck(vars, "body", "Thunk"); |local thunk = nomsu:tree_to_value(body); |nomsu:defmacro(aliases, thunk, body.src); rule [escaped compile %macro_def to code %body] =: lua code ".." - |local aliases = nomsu:typecheck(vars, "macro_def", "List").value; + |local aliases = nomsu:get_stubs(nomsu:typecheck(vars, "macro_def", "List").value); |local body = nomsu:typecheck(vars, "body", "Thunk"); |local thunk = nomsu:tree_to_value(body); |local thunk_wrapper = function(nomsu, vars) return nil, thunk(nomsu, vars); end; -- cgit v1.2.3