From 4789892824237dfb45d5f1cfb3442bfede34eeac Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 30 Dec 2017 14:31:07 -0800 Subject: Got everything mostly working. --- lib/control_flow.nom | 4 ++-- lib/metaprogramming.nom | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/control_flow.nom b/lib/control_flow.nom index b7b5f19..7658ae1 100644 --- a/lib/control_flow.nom +++ b/lib/control_flow.nom @@ -31,10 +31,10 @@ compile [go to %label] to code: ".." rule [tree %tree has function call %call] =: lua> ".." - local target = (\(%call)).value; + local target = (\(%call)).stub; for subtree,_ in coroutine.wrap(function() nomsu:walk_tree(\(%tree)); end) do if type(subtree) == 'table' and subtree.type == "FunctionCall" - and nomsu.utils.equivalent(subtree.value, target, 2) then + and subtree.stub == target then return true; end end diff --git a/lib/metaprogramming.nom b/lib/metaprogramming.nom index 95deb0c..e86b904 100644 --- a/lib/metaprogramming.nom +++ b/lib/metaprogramming.nom @@ -27,6 +27,11 @@ rule [compile \%macro_def to \%body] =: local thunk = nomsu:tree_to_value(body); nomsu:defmacro(signature, thunk, ("compile %s\\n..to %s"):format(vars.macro_def.src, body.src)); +compile [fizz %n] to: + "print(\(%n as lua))" +compile [pumpo] to: + "print('pumpo')" + rule [compile \%macro_def to code \%body] =: lua> ".." local signature = {}; -- cgit v1.2.3