diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-10-13 16:10:47 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-10-13 16:10:47 -0700 |
| commit | 7435b61380054307148ec2c3a6af6d7ef9187fbe (patch) | |
| tree | e9e752916ea22244073a658a036af20c782ca74a /lib/metaprogramming.nom | |
| parent | 1083273b9f422783a0976cba9ccd4316fd4c3860 (diff) | |
Changed generated code to be less verbose for function and macro defs
(using "foo %" syntax instead of {type="FunctionCall", ...} literals).
Diffstat (limited to 'lib/metaprogramming.nom')
| -rw-r--r-- | lib/metaprogramming.nom | 8 |
1 files changed, 4 insertions, 4 deletions
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; |
