From 61b825fa5a8614782c7b4808678ae877da70ff6e Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Mon, 30 Apr 2018 18:21:40 -0700 Subject: [PATCH] dump tree doesn't print by default --- moonscript/cmd/moonc.lua | 6 ++++-- moonscript/cmd/moonc.moon | 6 ++++-- moonscript/dump.lua | 2 +- moonscript/dump.moon | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/moonscript/cmd/moonc.lua b/moonscript/cmd/moonc.lua index 09ac3c7..e7618ef 100644 --- a/moonscript/cmd/moonc.lua +++ b/moonscript/cmd/moonc.lua @@ -74,7 +74,7 @@ compile_file_text = function(text, opts) end if opts.show_parse_tree then local dump = require("moonscript.dump") - dump.tree(tree) + print(dump.tree(tree)) return true end local compile_time @@ -84,7 +84,9 @@ compile_file_text = function(text, opts) do local mod = opts.transform_module if mod then - tree = assert(require(mod)(tree)) + local file = assert(loadfile(mod)) + local fn = assert(file()) + tree = assert(fn(tree)) end end local code, posmap_or_err, err_pos = compile.tree(tree) diff --git a/moonscript/cmd/moonc.moon b/moonscript/cmd/moonc.moon index ba59b06..3e05bb0 100644 --- a/moonscript/cmd/moonc.moon +++ b/moonscript/cmd/moonc.moon @@ -78,14 +78,16 @@ compile_file_text = (text, opts={}) -> if opts.show_parse_tree dump = require "moonscript.dump" - dump.tree tree + print dump.tree tree return true compile_time = if opts.benchmark gettime! if mod = opts.transform_module - tree = assert require(mod) tree + file = assert loadfile mod + fn = assert file! + tree = assert fn tree code, posmap_or_err, err_pos = compile.tree tree diff --git a/moonscript/dump.lua b/moonscript/dump.lua index 1496ed4..1622f38 100644 --- a/moonscript/dump.lua +++ b/moonscript/dump.lua @@ -32,7 +32,7 @@ tree = function(block) local _list_0 = block for _index_0 = 1, #_list_0 do local value = _list_0[_index_0] - print(flat_value(value)) + flat_value(value) end end return { diff --git a/moonscript/dump.moon b/moonscript/dump.moon index a6373da..e651c22 100644 --- a/moonscript/dump.moon +++ b/moonscript/dump.moon @@ -12,7 +12,7 @@ value = (op) -> flat_value op tree = (block) -> - print flat_value value for value in *block + flat_value value for value in *block { :value, :tree }