diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-12-09 15:34:52 -0800 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-12-09 15:34:52 -0800 |
| commit | 96441251c4bdbb2d9296866e6c84624ce85c2f45 (patch) | |
| tree | 7b390648a594517fb66735c9824a4f9d2cca3bb6 /lib/metaprogramming.nom | |
| parent | 28b6bc188370fe3c20b26c483b48ab70673bd35b (diff) | |
Pretty much everything is working??
Diffstat (limited to 'lib/metaprogramming.nom')
| -rw-r--r-- | lib/metaprogramming.nom | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/metaprogramming.nom b/lib/metaprogramming.nom index d1236fe..4ea70c0 100644 --- a/lib/metaprogramming.nom +++ b/lib/metaprogramming.nom @@ -5,12 +5,15 @@ # Rule to make rules: lua> ".." |nomsu:defmacro("rule %signature = %body", (function(nomsu, vars) - | local signature = nomsu:get_stubs(nomsu:typecheck(vars, "signature", "List").value); + | local signature = {}; + | for i, alias in ipairs(nomsu:typecheck(vars, "signature", "List").value) do + | signature[i] = alias.src; + | end | local body = nomsu:typecheck(vars, "body", "Thunk"); | return ([[ |nomsu:def(%s, %s, %s) - |]]):format(nomsu:repr(signature), nomsu:tree_to_lua(body), nomsu:repr(\(__src__))), nil; - |end)); + |]]):format(nomsu:repr(signature), nomsu:tree_to_lua(body), nomsu:repr(nomsu:dedent(nomsu.defs["#macro_tree"].src))), nil; + |end), \(__src__)); # Rule to make nomsu macros: rule [parse \%shorthand as \%longhand] =: @@ -109,10 +112,7 @@ rule [help %rule] =: |if not fn_def then | nomsu:writeln("Rule not found: "..nomsu:repr(vars.rule)); |else - | local template = fn_def.is_macro and "compile %s to%s" or "rule %s =%s"; - | local src = fn_def.src or ":\\n <unknown source code>"; - | if src:sub(1,1) ~= ":" and fn_def.is_macro then template = "parse %s as: %s"; end - | nomsu:writeln(template:format(nomsu:repr(fn_def.stub), src)); + | nomsu:writeln(fn_def.src or "<unknown source code>"); |end # Compiler tools |
