Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Dec 30, 2013
1 parent dd1a06f commit 23a99aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
24 changes: 11 additions & 13 deletions moonscript/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ do
end
local Set
Set = function(items)
local self = { }
local _tbl_0 = { }
for _index_0 = 1, #items do
local key = items[_index_0]
self[key] = true
local k = items[_index_0]
_tbl_0[k] = true
end
return self
return _tbl_0
end
local Stack
do
Expand All @@ -21,9 +21,13 @@ do
pop = function(self)
return remove(self)
end,
push = function(self, value)
push = function(self, value, ...)
insert(self, value)
return value
if ... then
return self:push(...)
else
return value
end
end,
top = function(self)
return self[#self]
Expand All @@ -32,13 +36,7 @@ do
_base_0.__index = _base_0
local _class_0 = setmetatable({
__init = function(self, ...)
local _list_0 = {
...
}
for _index_0 = 1, #_list_0 do
local v = _list_0[_index_0]
self:push(v)
end
self:push(...)
return nil
end,
__base = _base_0,
Expand Down
20 changes: 10 additions & 10 deletions moonscript/data.moon
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

import concat, remove, insert from table

Set = (items) ->
self = {}
self[key] = true for key in *items
self
Set = (items) -> {k,true for k in *items}

class Stack
__tostring: => "<Stack {"..concat(self, ", ").."}>"

new: (...) =>
@push v for v in *{...}
@push ...
nil

pop: =>
remove self
remove @

push: (value) =>
insert self, value
value
push: (value, ...) =>
insert @, value
if ...
@push ...
else
value

top: =>
self[#self]


lua_keywords = Set{
lua_keywords = Set {
'and', 'break', 'do', 'else', 'elseif',
'end', 'false', 'for', 'function', 'if',
'in', 'local', 'nil', 'not', 'or',
Expand Down

0 comments on commit 23a99aa

Please sign in to comment.