mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
newlines can be used to separte function argument declarations
This commit is contained in:
parent
a5abd2fe1e
commit
e698e180ac
@ -188,7 +188,7 @@ local build_grammar = wrap_env(debug_grammar, function(root)
|
||||
KeyValueList = KeyValue * (sym(",") * KeyValue) ^ 0,
|
||||
KeyValueLine = CheckIndent * KeyValueList * sym(",") ^ -1,
|
||||
FnArgsDef = sym("(") * White * Ct(FnArgDefList ^ -1) * (key("using") * Ct(NameList + Space * "nil") + Ct("")) * White * sym(")") + Ct("") * Ct(""),
|
||||
FnArgDefList = FnArgDef * (sym(",") * White * FnArgDef) ^ 0 * (sym(",") * White * Ct(VarArg)) ^ 0 + Ct(VarArg),
|
||||
FnArgDefList = FnArgDef * ((sym(",") + Break) * White * FnArgDef) ^ 0 * ((sym(",") + Break) * White * Ct(VarArg)) ^ 0 + Ct(VarArg),
|
||||
FnArgDef = Ct((Name + SelfName) * (sym("=") * Exp) ^ -1),
|
||||
FunLit = FnArgsDef * (sym("->") * Cc("slim") + sym("=>") * Cc("fat")) * (Body + Ct("")) / mark("fndef"),
|
||||
NameList = Name * (sym(",") * Name) ^ 0,
|
||||
|
@ -296,7 +296,7 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
(key"using" * Ct(NameList + Space * "nil") + Ct"") *
|
||||
White * sym")" + Ct"" * Ct""
|
||||
|
||||
FnArgDefList: FnArgDef * (sym"," * White * FnArgDef)^0 * (sym"," * White * Ct(VarArg))^0 + Ct(VarArg)
|
||||
FnArgDefList: FnArgDef * ((sym"," + Break) * White * FnArgDef)^0 * ((sym"," + Break) * White * Ct(VarArg))^0 + Ct(VarArg)
|
||||
FnArgDef: Ct((Name + SelfName) * (sym"=" * Exp)^-1)
|
||||
|
||||
FunLit: FnArgsDef *
|
||||
|
@ -129,6 +129,28 @@ y = (a="hi",
|
||||
) ->
|
||||
print "what"
|
||||
|
||||
--
|
||||
|
||||
args = (a
|
||||
b) ->
|
||||
print "what"
|
||||
|
||||
|
||||
args = (a="hi"
|
||||
b=23) ->
|
||||
print "what"
|
||||
|
||||
args = (
|
||||
a="hi"
|
||||
b=23) ->
|
||||
print "what"
|
||||
|
||||
|
||||
args = (f,g,m
|
||||
a="hi"
|
||||
b=23
|
||||
) ->
|
||||
print "what"
|
||||
|
||||
|
||||
|
||||
|
@ -176,4 +176,35 @@ y = function(a, b, ...)
|
||||
end
|
||||
return print("what")
|
||||
end
|
||||
local args
|
||||
args = function(a, b)
|
||||
return print("what")
|
||||
end
|
||||
args = function(a, b)
|
||||
if a == nil then
|
||||
a = "hi"
|
||||
end
|
||||
if b == nil then
|
||||
b = 23
|
||||
end
|
||||
return print("what")
|
||||
end
|
||||
args = function(a, b)
|
||||
if a == nil then
|
||||
a = "hi"
|
||||
end
|
||||
if b == nil then
|
||||
b = 23
|
||||
end
|
||||
return print("what")
|
||||
end
|
||||
args = function(f, g, m, a, b)
|
||||
if a == nil then
|
||||
a = "hi"
|
||||
end
|
||||
if b == nil then
|
||||
b = 23
|
||||
end
|
||||
return print("what")
|
||||
end
|
||||
return nil
|
Loading…
Reference in New Issue
Block a user