mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
remove some duplicated rules #257
This commit is contained in:
parent
dfbe6b7a87
commit
33dfdad81e
@ -131,8 +131,10 @@ local build_grammar = wrap_env(debug_grammar, function(root)
|
||||
SwitchCase = key("when") * Ct(ExpList) * key("then") ^ -1 * Body / mark("case"),
|
||||
SwitchElse = key("else") * Body / mark("else"),
|
||||
IfCond = Exp * Assign ^ -1 / format_single_assign,
|
||||
If = key("if") * IfCond * key("then") ^ -1 * Body * ((Break * CheckIndent) ^ -1 * EmptyLine ^ 0 * key("elseif") * pos(IfCond) * key("then") ^ -1 * Body / mark("elseif")) ^ 0 * ((Break * CheckIndent) ^ -1 * EmptyLine ^ 0 * key("else") * Body / mark("else")) ^ -1 / mark("if"),
|
||||
Unless = key("unless") * IfCond * key("then") ^ -1 * Body * ((Break * CheckIndent) ^ -1 * EmptyLine ^ 0 * key("elseif") * pos(IfCond) * key("then") ^ -1 * Body / mark("elseif")) ^ 0 * ((Break * CheckIndent) ^ -1 * EmptyLine ^ 0 * key("else") * Body / mark("else")) ^ -1 / mark("unless"),
|
||||
IfElse = (Break * CheckIndent) ^ -1 * EmptyLine ^ 0 * key("else") * Body / mark("else"),
|
||||
IfElseIf = (Break * CheckIndent) ^ -1 * EmptyLine ^ 0 * key("elseif") * pos(IfCond) * key("then") ^ -1 * Body / mark("elseif"),
|
||||
If = key("if") * IfCond * key("then") ^ -1 * Body * IfElseIf ^ 0 * IfElse ^ -1 / mark("if"),
|
||||
Unless = key("unless") * IfCond * key("then") ^ -1 * Body * IfElseIf ^ 0 * IfElse ^ -1 / mark("unless"),
|
||||
While = key("while") * DisableDo * ensure(Exp, PopDo) * key("do") ^ -1 * Body / mark("while"),
|
||||
For = key("for") * DisableDo * ensure(Name * sym("=") * Ct(Exp * sym(",") * Exp * (sym(",") * Exp) ^ -1), PopDo) * key("do") ^ -1 * Body / mark("for"),
|
||||
ForEach = key("for") * Ct(AssignableNameList) * key("in") * DisableDo * ensure(Ct(sym("*") * Exp / mark("unpack") + ExpList), PopDo) * key("do") ^ -1 * Body / mark("foreach"),
|
||||
|
@ -150,13 +150,11 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
|
||||
IfCond: Exp * Assign^-1 / format_single_assign
|
||||
|
||||
If: key"if" * IfCond * key"then"^-1 * Body *
|
||||
((Break * CheckIndent)^-1 * EmptyLine^0 * key"elseif" * pos(IfCond) * key"then"^-1 * Body / mark"elseif")^0 *
|
||||
((Break * CheckIndent)^-1 * EmptyLine^0 * key"else" * Body / mark"else")^-1 / mark"if"
|
||||
IfElse: (Break * CheckIndent)^-1 * EmptyLine^0 * key"else" * Body / mark"else"
|
||||
IfElseIf: (Break * CheckIndent)^-1 * EmptyLine^0 * key"elseif" * pos(IfCond) * key"then"^-1 * Body / mark"elseif"
|
||||
|
||||
Unless: key"unless" * IfCond * key"then"^-1 * Body *
|
||||
((Break * CheckIndent)^-1 * EmptyLine^0 * key"elseif" * pos(IfCond) * key"then"^-1 * Body / mark"elseif")^0 *
|
||||
((Break * CheckIndent)^-1 * EmptyLine^0 * key"else" * Body / mark"else")^-1 / mark"unless"
|
||||
If: key"if" * IfCond * key"then"^-1 * Body * IfElseIf^0 * IfElse^-1 / mark"if"
|
||||
Unless: key"unless" * IfCond * key"then"^-1 * Body * IfElseIf^0 * IfElse^-1 / mark"unless"
|
||||
|
||||
While: key"while" * DisableDo * ensure(Exp, PopDo) * key"do"^-1 * Body / mark"while"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user