allow whitespace around function arguments when in parens, fixes #274

This commit is contained in:
leaf corcoran 2016-09-25 14:33:55 -07:00
parent e0da63c501
commit d8830b17f3
4 changed files with 29 additions and 4 deletions

View File

@ -164,7 +164,8 @@ local build_grammar = wrap_env(debug_grammar, function(root)
LuaStringClose = "]" * P("=") ^ 0 * "]", LuaStringClose = "]" * P("=") ^ 0 * "]",
Callable = pos(Name / mark("ref")) + SelfName + VarArg + Parens / mark("parens"), Callable = pos(Name / mark("ref")) + SelfName + VarArg + Parens / mark("parens"),
Parens = sym("(") * SpaceBreak ^ 0 * Exp * SpaceBreak ^ 0 * sym(")"), Parens = sym("(") * SpaceBreak ^ 0 * Exp * SpaceBreak ^ 0 * sym(")"),
FnArgs = symx("(") * SpaceBreak ^ 0 * Ct(ExpList ^ -1) * SpaceBreak ^ 0 * sym(")") + sym("!") * -P("=") * Ct(""), FnArgs = symx("(") * SpaceBreak ^ 0 * Ct(FnArgsExpList ^ -1) * SpaceBreak ^ 0 * sym(")") + sym("!") * -P("=") * Ct(""),
FnArgsExpList = Exp * (sym(",") * White * Exp) ^ 0,
Chain = (Callable + String + -S(".\\")) * ChainItems / mark("chain") + Space * (DotChainItem * ChainItems ^ -1 + ColonChain) / mark("chain"), Chain = (Callable + String + -S(".\\")) * ChainItems / mark("chain") + Space * (DotChainItem * ChainItems ^ -1 + ColonChain) / mark("chain"),
ChainItems = ChainItem ^ 1 * ColonChain ^ -1 + ColonChain, ChainItems = ChainItem ^ 1 * ColonChain ^ -1 + ColonChain,
ChainItem = Invoke + DotChainItem + Slice + symx("[") * Exp / mark("index") * sym("]"), ChainItem = Invoke + DotChainItem + Slice + symx("[") * Exp / mark("index") * sym("]"),

View File

@ -227,7 +227,8 @@ build_grammar = wrap_env debug_grammar, (root) ->
Callable: pos(Name / mark"ref") + SelfName + VarArg + Parens / mark"parens" Callable: pos(Name / mark"ref") + SelfName + VarArg + Parens / mark"parens"
Parens: sym"(" * SpaceBreak^0 * Exp * SpaceBreak^0 * sym")" Parens: sym"(" * SpaceBreak^0 * Exp * SpaceBreak^0 * sym")"
FnArgs: symx"(" * SpaceBreak^0 * Ct(ExpList^-1) * SpaceBreak^0 * sym")" + sym"!" * -P"=" * Ct"" FnArgs: symx"(" * SpaceBreak^0 * Ct(FnArgsExpList^-1) * SpaceBreak^0 * sym")" + sym"!" * -P"=" * Ct""
FnArgsExpList: Exp * (sym"," * White * Exp)^0
Chain: (Callable + String + -S".\\") * ChainItems / mark"chain" + Chain: (Callable + String + -S".\\") * ChainItems / mark"chain" +
Space * (DotChainItem * ChainItems^-1 + ColonChain) / mark"chain" Space * (DotChainItem * ChainItems^-1 + ColonChain) / mark"chain"

View File

@ -81,3 +81,22 @@ if hello 1,2,3,
print "hello" print "hello"
--
a(
one, two, three
)
b(
one,
two,
three
)
c(one, two,
three, four)
--
nil

View File

@ -72,5 +72,9 @@ if hello(1, 2, 3, world, world) then
print("hello") print("hello")
end end
if hello(1, 2, 3, world, world) then if hello(1, 2, 3, world, world) then
return print("hello") print("hello")
end end
a(one, two, three)
b(one, two, three)
c(one, two, three, four)
return nil