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,
|
InBlock = Advance * Block * PopIndent,
|
||||||
Local = key("local") * ((op("*") + op("^")) / mark("declare_glob") + Ct(NameList) / mark("declare_with_shadows")),
|
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"),
|
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,
|
ImportNameList = SpaceBreak ^ 0 * ImportName * ((SpaceBreak ^ 1 + sym(",") * SpaceBreak ^ 0) * ImportName) ^ 0,
|
||||||
BreakLoop = Ct(key("break") / trim) + Ct(key("continue") / trim),
|
BreakLoop = Ct(key("break") / trim) + Ct(key("continue") / trim),
|
||||||
Return = key("return") * (ExpListLow / mark("explist") + C("")) / mark("return"),
|
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")
|
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"
|
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
|
ImportNameList: SpaceBreak^0 * ImportName * ((SpaceBreak^1 + sym"," * SpaceBreak^0) * ImportName)^0
|
||||||
|
|
||||||
BreakLoop: Ct(key"break"/trim) + Ct(key"continue"/trim)
|
BreakLoop: Ct(key"break"/trim) + Ct(key"continue"/trim)
|
||||||
|
@ -484,18 +484,18 @@ Statement = Transformer({
|
|||||||
local _len_0 = 1
|
local _len_0 = 1
|
||||||
for _index_0 = 1, #names do
|
for _index_0 = 1, #names do
|
||||||
local name = names[_index_0]
|
local name = names[_index_0]
|
||||||
local dest_val
|
local dest_name
|
||||||
if ntype(name) == "colon_stub" then
|
if ntype(name) == "colon" then
|
||||||
dest_val = name[2]
|
dest_name = name[2]
|
||||||
else
|
else
|
||||||
dest_val = name
|
dest_name = name
|
||||||
end
|
end
|
||||||
local _value_0 = {
|
local _value_0 = {
|
||||||
{
|
{
|
||||||
"key_literal",
|
"key_literal",
|
||||||
name
|
name
|
||||||
},
|
},
|
||||||
dest_val
|
dest_name
|
||||||
}
|
}
|
||||||
_accum_0[_len_0] = _value_0
|
_accum_0[_len_0] = _value_0
|
||||||
_len_0 = _len_0 + 1
|
_len_0 = _len_0 + 1
|
||||||
|
@ -291,12 +291,12 @@ Statement = Transformer {
|
|||||||
import: (node) =>
|
import: (node) =>
|
||||||
_, names, source = unpack node
|
_, names, source = unpack node
|
||||||
table_values = for name in *names
|
table_values = for name in *names
|
||||||
dest_val = if ntype(name) == "colon_stub"
|
dest_name = if ntype(name) == "colon"
|
||||||
name[2]
|
name[2]
|
||||||
else
|
else
|
||||||
name
|
name
|
||||||
|
|
||||||
{{"key_literal", name}, dest_val}
|
{{"key_literal", name}, dest_name}
|
||||||
|
|
||||||
dest = { "table", table_values }
|
dest = { "table", table_values }
|
||||||
{ "assign", {dest}, {source}, [-1]: node[-1] }
|
{ "assign", {dest}, {source}, [-1]: node[-1] }
|
||||||
|
@ -68,7 +68,7 @@ extract_assign_names = function(name, accum, prefix)
|
|||||||
local s
|
local s
|
||||||
if ntype(key) == "key_literal" then
|
if ntype(key) == "key_literal" then
|
||||||
local key_name = key[2]
|
local key_name = key[2]
|
||||||
if ntype(key_name) == "colon_stub" then
|
if ntype(key_name) == "colon" then
|
||||||
s = key_name
|
s = key_name
|
||||||
else
|
else
|
||||||
s = {
|
s = {
|
||||||
|
@ -20,6 +20,7 @@ has_destructure = (names) ->
|
|||||||
false
|
false
|
||||||
|
|
||||||
extract_assign_names = (name, accum={}, prefix={}) ->
|
extract_assign_names = (name, accum={}, prefix={}) ->
|
||||||
|
|
||||||
i = 1
|
i = 1
|
||||||
for tuple in *name[2]
|
for tuple in *name[2]
|
||||||
value, suffix = if #tuple == 1
|
value, suffix = if #tuple == 1
|
||||||
@ -28,9 +29,10 @@ extract_assign_names = (name, accum={}, prefix={}) ->
|
|||||||
tuple[1], s
|
tuple[1], s
|
||||||
else
|
else
|
||||||
key = tuple[1]
|
key = tuple[1]
|
||||||
|
|
||||||
s = if ntype(key) == "key_literal"
|
s = if ntype(key) == "key_literal"
|
||||||
key_name = key[2]
|
key_name = key[2]
|
||||||
if ntype(key_name) == "colon_stub"
|
if ntype(key_name) == "colon"
|
||||||
key_name
|
key_name
|
||||||
else
|
else
|
||||||
{"dot", key_name}
|
{"dot", key_name}
|
||||||
|
Loading…
Reference in New Issue
Block a user