mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
19 lines
396 B
Plaintext
19 lines
396 B
Plaintext
|
|
flat_value = (op, depth=1) ->
|
|
return '"'..op..'"' if type(op) == "string"
|
|
return tostring(op) if type(op) != "table"
|
|
|
|
items = [flat_value item, depth + 1 for item in *op]
|
|
pos = op[-1]
|
|
|
|
"{"..(pos and "["..pos.."] " or "")..table.concat(items, ", ").."}"
|
|
|
|
value = (op) ->
|
|
flat_value op
|
|
|
|
tree = (block) ->
|
|
table.concat [flat_value value for value in *block], "\n"
|
|
|
|
{ :value, :tree }
|
|
|