From 3a084cfad7aa8da8d2c4b7849347b0832ef8e87e Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 20 Feb 2020 13:39:26 +0800 Subject: allow value list in assignment to be multiline fixing Moonscript issue 390. --- spec/inputs/class.moon | 16 ++++++++++++++++ spec/inputs/whitespace.moon | 14 +++++++++++++- src/MoonP/moon_parser.cpp | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/spec/inputs/class.moon b/spec/inputs/class.moon index 83f3760..3288dc6 100644 --- a/spec/inputs/class.moon +++ b/spec/inputs/class.moon @@ -210,4 +210,20 @@ class Wowha extends Thing super\hello } +do + class Test + new: => @@if = true + @do: => 1 + test: => @@if and @@do! + test = Test! + test\test! + +do + class Test + new: => @if = true + do: => 1 + test: => @if and @do! + test = Test! + test\test! + nil diff --git a/spec/inputs/whitespace.moon b/spec/inputs/whitespace.moon index 36f14ae..0422443 100644 --- a/spec/inputs/whitespace.moon +++ b/spec/inputs/whitespace.moon @@ -97,6 +97,18 @@ b( c(one, two, three, four) --- +-- + +f = -> + a, + b, + c + +a, + b, + c = 1, + 2, + f + :abc nil diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 1ba8ad3..0b59776 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp @@ -241,7 +241,7 @@ MoonParser::MoonParser() { CompFor = key("for") >> Space >> Variable >> sym('=') >> Exp >> sym(',') >> Exp >> -for_step_value; CompClause = CompFor | CompForEach | key("when") >> Exp; - Assign = sym('=') >> Seperator >> (With | If | Switch | TableBlock | Exp >> *((sym(',') | sym(';')) >> Exp)); + Assign = sym('=') >> Seperator >> (With | If | Switch | TableBlock | Exp >> *((sym(',') | sym(';')) >> White >> Exp)); update_op = expr("..") | -- cgit v1.2.3-55-g6feb