From 260b17a878d6c8a0acefdcceeae5fc26356cc969 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Sat, 14 Jan 2012 01:38:30 -0800 Subject: [PATCH] can specify scope to tree compile --- moonscript/compile.lua | 8 +++++--- moonscript/compile.moon | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/moonscript/compile.lua b/moonscript/compile.lua index a363f92..b7550a0 100644 --- a/moonscript/compile.lua +++ b/moonscript/compile.lua @@ -450,7 +450,6 @@ Block = (function() _base_0.__class = _class_0 return _class_0 end)() -local RootBlock RootBlock = (function() local _parent_0 = Block local _base_0 = { @@ -515,8 +514,11 @@ value = function(value) end return out end -tree = function(tree) - local scope = RootBlock() +tree = function(tree, scope) + if scope == nil then + scope = RootBlock() + end + assert(tree, "missing tree") local runner = coroutine.create(function() local _list_0 = tree for _index_0 = 1, #_list_0 do diff --git a/moonscript/compile.moon b/moonscript/compile.moon index d19d961..9422a0e 100644 --- a/moonscript/compile.moon +++ b/moonscript/compile.moon @@ -17,7 +17,7 @@ import concat, insert from table import pos_to_line, get_closest_line, trim from util export tree, value, format_error -export Block +export Block, RootBlock -- buffer for building up a line class Line @@ -300,8 +300,8 @@ value = (value) -> out = \render! out -tree = (tree) -> - scope = RootBlock! +tree = (tree, scope=RootBlock!) -> + assert tree, "missing tree" runner = coroutine.create -> scope\stm line for line in *tree