mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
fixes #286
This commit is contained in:
parent
330f5491d6
commit
92b269c0cc
@ -183,7 +183,7 @@ local build_grammar = wrap_env(debug_grammar, function(root)
|
||||
ClassBlock = SpaceBreak ^ 1 * Advance * Ct(ClassLine * (SpaceBreak ^ 1 * ClassLine) ^ 0) * PopIndent,
|
||||
ClassLine = CheckIndent * ((KeyValueList / mark("props") + Statement / mark("stm") + Exp / mark("stm")) * sym(",") ^ -1),
|
||||
Export = key("export") * (Cc("class") * ClassDecl + op("*") + op("^") + Ct(NameList) * (sym("=") * Ct(ExpListLow)) ^ -1) / mark("export"),
|
||||
KeyValue = (sym(":") * -SomeSpace * Name * lpeg.Cp()) / self_assign + Ct((KeyName + sym("[") * Exp * sym("]") + DoubleString + SingleString) * symx(":") * (Exp + TableBlock + SpaceBreak ^ 1 * Exp)),
|
||||
KeyValue = (sym(":") * -SomeSpace * Name * lpeg.Cp()) / self_assign + Ct((KeyName + sym("[") * Exp * sym("]") + Space * DoubleString + Space * SingleString) * symx(":") * (Exp + TableBlock + SpaceBreak ^ 1 * Exp)),
|
||||
KeyValueList = KeyValue * (sym(",") * KeyValue) ^ 0,
|
||||
KeyValueLine = CheckIndent * KeyValueList * sym(",") ^ -1,
|
||||
FnArgsDef = sym("(") * Ct(FnArgDefList ^ -1) * (key("using") * Ct(NameList + Space * "nil") + Ct("")) * sym(")") + Ct("") * Ct(""),
|
||||
|
@ -280,7 +280,13 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
op"*" + op"^" +
|
||||
Ct(NameList) * (sym"=" * Ct(ExpListLow))^-1) / mark"export"
|
||||
|
||||
KeyValue: (sym":" * -SomeSpace * Name * lpeg.Cp!) / self_assign + Ct((KeyName + sym"[" * Exp * sym"]" + DoubleString + SingleString) * symx":" * (Exp + TableBlock + SpaceBreak^1 * Exp))
|
||||
KeyValue: (sym":" * -SomeSpace * Name * lpeg.Cp!) / self_assign +
|
||||
Ct(
|
||||
(KeyName + sym"[" * Exp * sym"]" +Space * DoubleString + Space * SingleString) *
|
||||
symx":" *
|
||||
(Exp + TableBlock + SpaceBreak^1 * Exp)
|
||||
)
|
||||
|
||||
KeyValueList: KeyValue * (sym"," * KeyValue)^0
|
||||
KeyValueLine: CheckIndent * KeyValueList * sym","^-1
|
||||
|
||||
|
@ -140,4 +140,22 @@ thing what:
|
||||
"more"
|
||||
okay: 123 -- a anon table
|
||||
|
||||
|
||||
--
|
||||
|
||||
k = { "hello": "world" }
|
||||
k = { 'hello': 'world' }
|
||||
k = { "hello": 'world', "hat": "zat" }
|
||||
|
||||
please "hello": "world"
|
||||
k = "hello": "world", "one": "zone"
|
||||
|
||||
f = "one", "two": three, "four"
|
||||
f = "two": three, "four"
|
||||
f = { "one", "two": three, "four" }
|
||||
|
||||
|
||||
j = "one", "two": three, "four": five, 6, 7
|
||||
|
||||
|
||||
nil
|
||||
|
@ -171,4 +171,36 @@ thing({
|
||||
local _ = {
|
||||
okay = 123
|
||||
}
|
||||
local k = {
|
||||
["hello"] = "world"
|
||||
}
|
||||
k = {
|
||||
['hello'] = 'world'
|
||||
}
|
||||
k = {
|
||||
["hello"] = 'world',
|
||||
["hat"] = "zat"
|
||||
}
|
||||
please({
|
||||
["hello"] = "world"
|
||||
})
|
||||
k = {
|
||||
["hello"] = "world",
|
||||
["one"] = "zone"
|
||||
}
|
||||
local f = "one", {
|
||||
["two"] = three
|
||||
}, "four"
|
||||
f = {
|
||||
["two"] = three
|
||||
}, "four"
|
||||
f = {
|
||||
"one",
|
||||
["two"] = three,
|
||||
"four"
|
||||
}
|
||||
local j = "one", {
|
||||
["two"] = three,
|
||||
["four"] = five
|
||||
}, 6, 7
|
||||
return nil
|
Loading…
Reference in New Issue
Block a user