diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-03-06 16:50:20 -0800 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-03-06 16:50:25 -0800 |
| commit | 972de38421d14882de192ddbd51afd89c4ffb06c (patch) | |
| tree | 7d4807fd0f5e6bce6a34a747dabe32d1ce46de20 | |
| parent | 4bc1f59725cfa0f765467c968cbaa7700fddf820 (diff) | |
Minor cleanup.
| -rw-r--r-- | nomsu.lua | 18 | ||||
| -rwxr-xr-x | nomsu.moon | 3 |
2 files changed, 4 insertions, 17 deletions
@@ -23,21 +23,6 @@ do local _obj_0 = table insert, remove, concat = _obj_0.insert, _obj_0.remove, _obj_0.concat end -local Tuple = immutable(nil, { - name = "Tuple", - __tostring = function(self) - return "Tuple(" .. tostring(concat((function() - local _accum_0 = { } - local _len_0 = 1 - for _index_0 = 1, #self do - local x = self[_index_0] - _accum_0[_len_0] = repr(x) - _len_0 = _len_0 + 1 - end - return _accum_0 - end)(), ", ")) .. ")" - end -}) do local STRING_METATABLE = getmetatable("") STRING_METATABLE.__add = function(self, other) @@ -70,6 +55,9 @@ type_tostring = function(self) return _accum_0 end)(), ", ")) .. ")" end +local Tuple = immutable(nil, { + name = "Tuple" +}) local _list_0 = { "File", "Nomsu", @@ -21,8 +21,6 @@ colors = setmetatable({}, {__index:->""}) colored = setmetatable({}, {__index:(_,color)-> ((msg)-> colors[color]..(msg or '')..colors.reset)}) {:insert, :remove, :concat} = table -Tuple = immutable(nil, {name:"Tuple", __tostring:=> "Tuple(#{concat [repr(x) for x in *@], ", "})"}) - -- Use + operator for string coercive concatenation (note: "asdf" + 3 == "asdf3") -- Use [] for accessing string characters, or s[{3,4}] for s:sub(3,4) -- Note: This globally affects all strings in this instance of Lua! @@ -52,6 +50,7 @@ lpeg.setmaxstack 10000 -- whoa Types = {} type_tostring = => "#{@name}(#{concat [repr(x) for x in *@], ", "})" +Tuple = immutable(nil, {name:"Tuple"}) for t in *{"File", "Nomsu", "Block", "List", "FunctionCall", "Text", "Dict", "Number", "Word", "Var", "Comment"} Types[t] = immutable({"id","value"}, {type:t, name:t, __tostring:type_tostring}) Types.DictEntry = immutable({"key","value"}, {name:"DictEntry"}) |
