mirror of
https://github.com/leafo/moonscript.git
synced 2024-12-08 01:54:24 +00:00
use colon instead of colon stub for bound import
This commit is contained in:
parent
02a20ea695
commit
2f71fbc13f
@ -120,7 +120,7 @@ local build_grammar = wrap_env(debug_grammar, function(root)
|
||||
InBlock = Advance * Block * PopIndent,
|
||||
Local = key("local") * ((op("*") + op("^")) / mark("declare_glob") + Ct(NameList) / mark("declare_with_shadows")),
|
||||
Import = key("import") * Ct(ImportNameList) * SpaceBreak ^ 0 * key("from") * Exp / mark("import"),
|
||||
ImportName = (sym("\\") * Ct(Cc("colon_stub") * Name) + Name),
|
||||
ImportName = (sym("\\") * Ct(Cc("colon") * Name) + Name),
|
||||
ImportNameList = SpaceBreak ^ 0 * ImportName * ((SpaceBreak ^ 1 + sym(",") * SpaceBreak ^ 0) * ImportName) ^ 0,
|
||||
BreakLoop = Ct(key("break") / trim) + Ct(key("continue") / trim),
|
||||
Return = key("return") * (ExpListLow / mark("explist") + C("")) / mark("return"),
|
||||
|
@ -134,7 +134,7 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
Local: key"local" * ((op"*" + op"^") / mark"declare_glob" + Ct(NameList) / mark"declare_with_shadows")
|
||||
|
||||
Import: key"import" * Ct(ImportNameList) * SpaceBreak^0 * key"from" * Exp / mark"import"
|
||||
ImportName: (sym"\\" * Ct(Cc"colon_stub" * Name) + Name)
|
||||
ImportName: (sym"\\" * Ct(Cc"colon" * Name) + Name)
|
||||
ImportNameList: SpaceBreak^0 * ImportName * ((SpaceBreak^1 + sym"," * SpaceBreak^0) * ImportName)^0
|
||||
|
||||
BreakLoop: Ct(key"break"/trim) + Ct(key"continue"/trim)
|
||||
|
@ -484,18 +484,18 @@ Statement = Transformer({
|
||||
local _len_0 = 1
|
||||
for _index_0 = 1, #names do
|
||||
local name = names[_index_0]
|
||||
local dest_val
|
||||
if ntype(name) == "colon_stub" then
|
||||
dest_val = name[2]
|
||||
local dest_name
|
||||
if ntype(name) == "colon" then
|
||||
dest_name = name[2]
|
||||
else
|
||||
dest_val = name
|
||||
dest_name = name
|
||||
end
|
||||
local _value_0 = {
|
||||
{
|
||||
"key_literal",
|
||||
name
|
||||
},
|
||||
dest_val
|
||||
dest_name
|
||||
}
|
||||
_accum_0[_len_0] = _value_0
|
||||
_len_0 = _len_0 + 1
|
||||
|
@ -291,12 +291,12 @@ Statement = Transformer {
|
||||
import: (node) =>
|
||||
_, names, source = unpack node
|
||||
table_values = for name in *names
|
||||
dest_val = if ntype(name) == "colon_stub"
|
||||
dest_name = if ntype(name) == "colon"
|
||||
name[2]
|
||||
else
|
||||
name
|
||||
|
||||
{{"key_literal", name}, dest_val}
|
||||
{{"key_literal", name}, dest_name}
|
||||
|
||||
dest = { "table", table_values }
|
||||
{ "assign", {dest}, {source}, [-1]: node[-1] }
|
||||
|
@ -68,7 +68,7 @@ extract_assign_names = function(name, accum, prefix)
|
||||
local s
|
||||
if ntype(key) == "key_literal" then
|
||||
local key_name = key[2]
|
||||
if ntype(key_name) == "colon_stub" then
|
||||
if ntype(key_name) == "colon" then
|
||||
s = key_name
|
||||
else
|
||||
s = {
|
||||
|
@ -20,6 +20,7 @@ has_destructure = (names) ->
|
||||
false
|
||||
|
||||
extract_assign_names = (name, accum={}, prefix={}) ->
|
||||
|
||||
i = 1
|
||||
for tuple in *name[2]
|
||||
value, suffix = if #tuple == 1
|
||||
@ -28,9 +29,10 @@ extract_assign_names = (name, accum={}, prefix={}) ->
|
||||
tuple[1], s
|
||||
else
|
||||
key = tuple[1]
|
||||
|
||||
s = if ntype(key) == "key_literal"
|
||||
key_name = key[2]
|
||||
if ntype(key_name) == "colon_stub"
|
||||
if ntype(key_name) == "colon"
|
||||
key_name
|
||||
else
|
||||
{"dot", key_name}
|
||||
|
Loading…
Reference in New Issue
Block a user