diff --git a/moonscript/parse.lua b/moonscript/parse.lua index a930246..2775afe 100644 --- a/moonscript/parse.lua +++ b/moonscript/parse.lua @@ -270,8 +270,8 @@ local build_grammar = wrap(function() With = key"with" * Exp * key"do"^-1 * Body / mark"with", If = key"if" * Exp * key"then"^-1 * Body * - ((Break * Cmt(Indent, check_indent))^-1 * key"elseif" * Exp * key"then"^-1 * Body / mark"elseif")^0 * - ((Break * Cmt(Indent, check_indent))^-1 * key"else" * Body / mark"else")^-1 / mark"if", + ((Break * Cmt(Indent, check_indent))^-1 * EmptyLine^0 * key"elseif" * Exp * key"then"^-1 * Body / mark"elseif")^0 * + ((Break * Cmt(Indent, check_indent))^-1 * EmptyLine^0 * key"else" * Body / mark"else")^-1 / mark"if", While = key"while" * Exp * key"do"^-1 * Body / mark"while", diff --git a/tests/inputs/syntax.moon b/tests/inputs/syntax.moon index 05e4fb1..e77dcb7 100644 --- a/tests/inputs/syntax.moon +++ b/tests/inputs/syntax.moon @@ -164,4 +164,24 @@ x = hello - world - something \cool 100) -> print something)! +if something + 03589 + +-- okay what about this + +else + 3434 + + +if something + yeah + + +elseif "ymmm" + + print "cool" + +else + + okay diff --git a/tests/outputs/syntax.lua b/tests/outputs/syntax.lua index d4eb144..fa6ba7b 100644 --- a/tests/outputs/syntax.lua +++ b/tests/outputs/syntax.lua @@ -174,4 +174,16 @@ x = hello - world - something end end return print(something) -end)() \ No newline at end of file +end)() +if something then + _ = 3589 +else + _ = 3434 +end +if something then + _ = yeah +elseif "ymmm" then + print("cool") +else + _ = okay +end \ No newline at end of file diff --git a/todo b/todo index 4597bf4..05ff209 100644 --- a/todo +++ b/todo @@ -39,6 +39,3 @@ or * any/every keywords for comprehensions? - -fix error when blank line is before else block -