diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-23 14:02:36 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-23 14:02:36 -0700 |
| commit | 86c0fd47eb4b227446d6ca2286cb4b078176144e (patch) | |
| tree | 01fbe622803c6dcd0ab00a3623f870ba511d10fa /core.moon | |
| parent | ea69b181982a50771af0e6f2be262a63e06790da (diff) | |
Removed some debugging, cleaned up.
Diffstat (limited to 'core.moon')
| -rwxr-xr-x | core.moon | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -11,6 +11,9 @@ g\def [[printf %str]], (args)=> for s in *args.str do io.write(utils.repr(s)) io.write("\n") +g\def [[quote %str]], (vars)=> + return utils.repr(vars.str, true) + g\defmacro "return %retval", (vars,helpers,ftype)=> with helpers switch ftype @@ -25,7 +28,7 @@ g\defmacro "return %retval", (vars,helpers,ftype)=> g\defmacro "let %varname = %value", (vars, helpers, ftype)=> with helpers if ftype == "Expression" then error("Cannot set a variable in an expression.") - .lua "vars[#{.ded(.transform(vars.varname))} = #{.ded(.transform(vars.value))}" + .lua "vars[#{.ded(.transform(vars.varname))}] = #{.ded(.transform(vars.value))}" return nil singleton = (aliases, value)-> @@ -188,11 +191,15 @@ g\def [[do %action]], (vars)=> return vars.action(self,vars) g\defmacro [[lua %lua_code]], (vars,helpers,ftype)=> with helpers lua_code = vars.lua_code.value + escapes = n:"\n", t:"\t", b:"\b", a:"\a", v:"\v", f:"\f", r:"\r" + unescape = (s)-> s\gsub("\\(.)", ((c)-> escapes[c] or c)) switch lua_code.type when "List" - .lua table.concat[i.value.value for i in *lua_code.value] - else - .lua(lua_code.value) + -- TODO: handle subexpressions + .lua table.concat[unescape(i.value.value) for i in *lua_code.value] + when "String" + .lua(unescape(lua_code.value)) + else error("Unknown type: #{lua_code.type}") return nil g\defmacro [[macro %spec %body]], (vars,helpers,ftype)=> |
