newlines can be used to separte function argument declarations

This commit is contained in:
leaf corcoran 2016-09-25 17:52:05 -07:00
parent a5abd2fe1e
commit e698e180ac
4 changed files with 55 additions and 2 deletions

View File

@ -188,7 +188,7 @@ local build_grammar = wrap_env(debug_grammar, function(root)
KeyValueList = KeyValue * (sym(",") * KeyValue) ^ 0, KeyValueList = KeyValue * (sym(",") * KeyValue) ^ 0,
KeyValueLine = CheckIndent * KeyValueList * sym(",") ^ -1, KeyValueLine = CheckIndent * KeyValueList * sym(",") ^ -1,
FnArgsDef = sym("(") * White * Ct(FnArgDefList ^ -1) * (key("using") * Ct(NameList + Space * "nil") + Ct("")) * White * sym(")") + Ct("") * Ct(""), 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), FnArgDef = Ct((Name + SelfName) * (sym("=") * Exp) ^ -1),
FunLit = FnArgsDef * (sym("->") * Cc("slim") + sym("=>") * Cc("fat")) * (Body + Ct("")) / mark("fndef"), FunLit = FnArgsDef * (sym("->") * Cc("slim") + sym("=>") * Cc("fat")) * (Body + Ct("")) / mark("fndef"),
NameList = Name * (sym(",") * Name) ^ 0, NameList = Name * (sym(",") * Name) ^ 0,

View File

@ -296,7 +296,7 @@ build_grammar = wrap_env debug_grammar, (root) ->
(key"using" * Ct(NameList + Space * "nil") + Ct"") * (key"using" * Ct(NameList + Space * "nil") + Ct"") *
White * sym")" + Ct"" * 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) FnArgDef: Ct((Name + SelfName) * (sym"=" * Exp)^-1)
FunLit: FnArgsDef * FunLit: FnArgsDef *

View File

@ -129,6 +129,28 @@ y = (a="hi",
) -> ) ->
print "what" 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"

View File

@ -176,4 +176,35 @@ y = function(a, b, ...)
end end
return print("what") return print("what")
end 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 return nil