From 440a2f0cef6b342fa430bd0ca42d1a2ec47324dc Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 18 Sep 2017 13:54:07 -0700 Subject: Added repr to core and made some tweaks. --- nomsu.moon | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'nomsu.moon') diff --git a/nomsu.moon b/nomsu.moon index 64d16b0..1c56897 100755 --- a/nomsu.moon +++ b/nomsu.moon @@ -108,7 +108,7 @@ class NomsuCompiler if fn_info == nil @error "Attempt to call undefined function: #{fn_name}" if fn_info.is_macro - @error "Attempt to call macro at runtime: #{fn_name}" + @error "Attempt to call macro at runtime: #{fn_name}\nThis can be caused by using a macro in a function that is defined before the macro." unless @check_permission(fn_name) @error "You do not have the authority to call: #{fn_name}" table.insert @callstack, fn_name @@ -130,11 +130,11 @@ class NomsuCompiler return true return false - def: (spec, fn)=> + def: (spec, fn, src)=> if @debug @writeln "Defining rule: #{spec}" invocations,arg_names = @get_invocations spec - fn_info = {:fn, :arg_names, :invocations, is_macro:false} + fn_info = {:fn, :arg_names, :invocations, :src, is_macro:false} for invocation in *invocations @defs[invocation] = fn_info @@ -154,9 +154,9 @@ class NomsuCompiler arg_names[invocation] = _arg_names return invocations, arg_names - defmacro: (spec, lua_gen_fn)=> + defmacro: (spec, lua_gen_fn, src)=> invocations,arg_names = @get_invocations spec - fn_info = {fn:lua_gen_fn, :arg_names, :invocations, is_macro:true} + fn_info = {fn:lua_gen_fn, :arg_names, :invocations, :src, is_macro:true} for invocation in *invocations @defs[invocation] = fn_info @@ -167,6 +167,7 @@ class NomsuCompiler code, retval = @compile(text) if @debug @writeln "\nGENERATED LUA CODE:\n#{code}" + @writeln "\nPRODUCED RETURN VALUE:\n#{retval}" return retval serialize: (obj)=> @@ -192,7 +193,7 @@ class NomsuCompiler if not lua_thunk error("Failed to compile generated code:\n#{str}\n\n#{err}") return (lua_thunk!)(self, {}) - + parse: (str)=> if @debug @writeln("PARSING:\n#{str}") -- cgit v1.2.3