diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-22 00:51:53 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-22 00:51:53 -0700 |
| commit | d3a5fc73bc9aa37f58b2e159a9959afb53df73e3 (patch) | |
| tree | 0ef73e729107d6c22348fcf21182a276fe996031 /nomsu.moon | |
| parent | 861d5accc0f5f69b2edd098c69bba6abe8587a19 (diff) | |
Tweaks and adjustments.
Diffstat (limited to 'nomsu.moon')
| -rwxr-xr-x | nomsu.moon | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -23,8 +23,7 @@ STRING_ESCAPES = n:"\n", t:"\t", b:"\b", a:"\a", v:"\v", f:"\f", r:"\r" -- Helper "classes" parsetree_mt = {__tostring:=> "#{@type}(#{repr(@value)})"} -ParseTree = (type, src, value, errors)-> - setmetatable({:type, :src, :value, :errors}, parsetree_mt) +ParseTree = (x)-> setmetatable(x, parsetree_mt) functiondef_mt = {__tostring:=> "FunctionDef(#{repr(@aliases)}"} FunctionDef = (fn, aliases, src, is_macro)-> @@ -151,9 +150,9 @@ defs = setmetatable(defs, { __index: (t,key)-> - fn = (src, value, errors)-> ParseTree(key, src, value, errors) - t[key] = fn - return fn + -- Disabled for performance + --with t[key] = (src, value, errors)-> ParseTree({type: key, :src, :value, :errors}) do nil + with t[key] = (src, value, errors)-> {type: key, :src, :value, :errors} do nil }) nomsu = re.compile(nomsu, defs) @@ -176,7 +175,7 @@ class NomsuCompiler if type(aliases) == 'string' aliases = @get_aliases aliases if @debug - @writeln "Defining rule: #{aliases}" + @writeln "Defining rule: #{repr aliases}" fn_def = FunctionDef(fn, {}, src, is_macro) @add_aliases aliases, fn_def @@ -221,7 +220,7 @@ class NomsuCompiler {:fn, :aliases} = fn_def args = {name, select(i,...) for i,name in ipairs(aliases[alias])} if @debug - @writeln "Calling #{alias} with args: #{repr(args)}" + @writeln "Calling #{repr alias} with args: #{repr(args)}" insert @callstack, alias -- TODO: optimize, but still allow multiple return values? rets = {fn(self,args)} @@ -430,9 +429,6 @@ class NomsuCompiler return concat(alias," "), args get_aliases:(x)=> - if self.value - print self - error "WTF" if not x then @error "Nothing to get aliases from" if type(x) == 'string' alias, args = @get_alias(x) |
