mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
allow whitespace around function arguments when in parens, fixes #274
This commit is contained in:
parent
e0da63c501
commit
d8830b17f3
@ -164,7 +164,8 @@ local build_grammar = wrap_env(debug_grammar, function(root)
|
||||
LuaStringClose = "]" * P("=") ^ 0 * "]",
|
||||
Callable = pos(Name / mark("ref")) + SelfName + VarArg + Parens / mark("parens"),
|
||||
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"),
|
||||
ChainItems = ChainItem ^ 1 * ColonChain ^ -1 + ColonChain,
|
||||
ChainItem = Invoke + DotChainItem + Slice + symx("[") * Exp / mark("index") * sym("]"),
|
||||
|
@ -227,7 +227,8 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
Callable: pos(Name / mark"ref") + SelfName + VarArg + Parens / mark"parens"
|
||||
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"
|
||||
|
@ -81,3 +81,22 @@ if hello 1,2,3,
|
||||
print "hello"
|
||||
|
||||
|
||||
--
|
||||
|
||||
a(
|
||||
one, two, three
|
||||
)
|
||||
|
||||
b(
|
||||
one,
|
||||
two,
|
||||
three
|
||||
)
|
||||
|
||||
|
||||
c(one, two,
|
||||
three, four)
|
||||
|
||||
--
|
||||
|
||||
nil
|
||||
|
@ -72,5 +72,9 @@ if hello(1, 2, 3, world, world) then
|
||||
print("hello")
|
||||
end
|
||||
if hello(1, 2, 3, world, world) then
|
||||
return print("hello")
|
||||
end
|
||||
print("hello")
|
||||
end
|
||||
a(one, two, three)
|
||||
b(one, two, three)
|
||||
c(one, two, three, four)
|
||||
return nil
|
Loading…
Reference in New Issue
Block a user