This commit is contained in:
leaf corcoran 2016-09-25 11:59:08 -07:00
parent 330f5491d6
commit 92b269c0cc
4 changed files with 58 additions and 2 deletions

View File

@ -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(""),

View File

@ -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

View File

@ -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

View File

@ -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