diff options
author | Li Jin <dragon-fly@qq.com> | 2020-02-03 11:25:11 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-02-03 11:25:11 +0800 |
commit | d8901102a1e39e651b08b66257c176b5803b9bc0 (patch) | |
tree | 8df65bfdcae6a65e5f6d0189b0745df521ca1bf9 | |
parent | 6eb2c2a58f36196d162433b5412b15aea1e6ba9e (diff) | |
download | yuescript-d8901102a1e39e651b08b66257c176b5803b9bc0.tar.gz yuescript-d8901102a1e39e651b08b66257c176b5803b9bc0.tar.bz2 yuescript-d8901102a1e39e651b08b66257c176b5803b9bc0.zip |
enable explist to be multi-line without backslash. confirmed there is no similar issue like Moonscript issue 202 or issue 391.
-rw-r--r-- | spec/inputs/assign.moon | 3 | ||||
-rw-r--r-- | spec/inputs/destructure.moon | 9 | ||||
-rw-r--r-- | spec/inputs/syntax.moon | 9 | ||||
-rw-r--r-- | src/MoonP/moon_parser.cpp | 9 | ||||
-rw-r--r-- | src/MoonP/moon_parser.h | 1 |
5 files changed, 21 insertions, 10 deletions
diff --git a/spec/inputs/assign.moon b/spec/inputs/assign.moon index 4e50147..e8fcbfd 100644 --- a/spec/inputs/assign.moon +++ b/spec/inputs/assign.moon | |||
@@ -26,5 +26,4 @@ else | |||
26 | print "the other" | 26 | print "the other" |
27 | "nothing", "yeah" | 27 | "nothing", "yeah" |
28 | 28 | ||
29 | 29 | c, d = 1, 2 if true | |
30 | |||
diff --git a/spec/inputs/destructure.moon b/spec/inputs/destructure.moon index e0f2198..d61b6ae 100644 --- a/spec/inputs/destructure.moon +++ b/spec/inputs/destructure.moon | |||
@@ -103,3 +103,12 @@ do | |||
103 | 103 | ||
104 | do | 104 | do |
105 | {if:{a,b,c}} = thing | 105 | {if:{a,b,c}} = thing |
106 | |||
107 | do | ||
108 | {:a, :b} = {a: "Hello", b: "World"} if true | ||
109 | |||
110 | {days, hours, mins, secs} = [tonumber a for a in *{ | ||
111 | string.match "1 2 3 4", "(.+)%s(.+)%s(.+)%s(.+)" | ||
112 | }] | ||
113 | |||
114 | {:one, :two, :three} = {w,true for w in foo\gmatch("%S+")} | ||
diff --git a/spec/inputs/syntax.moon b/spec/inputs/syntax.moon index abee3e3..ae3fc0c 100644 --- a/spec/inputs/syntax.moon +++ b/spec/inputs/syntax.moon | |||
@@ -281,10 +281,15 @@ It's OK. | |||
281 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 281 | func --[[port]] 3000, --[[ip]] "192.168.1.1" |
282 | 282 | ||
283 | f = -> | 283 | f = -> |
284 | a,b, \ | 284 | a,b, |
285 | c,d, \ | 285 | c,d, |
286 | e,f | 286 | e,f |
287 | 287 | ||
288 | f = -> | ||
289 | a,b \ | ||
290 | ,c,d \ | ||
291 | ,e,f | ||
292 | |||
288 | with obj | 293 | with obj |
289 | invoke \ | 294 | invoke \ |
290 | --[[arg1]] \func!, | 295 | --[[arg1]] \func!, |
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 358b660..0ea6e12 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
@@ -45,7 +45,6 @@ MoonParser::MoonParser() { | |||
45 | MultiLineComment = multi_line_open >> multi_line_content >> multi_line_close; | 45 | MultiLineComment = multi_line_open >> multi_line_content >> multi_line_close; |
46 | EscapeNewLine = expr('\\') >> *(set(" \t") | MultiLineComment) >> -Comment >> Break; | 46 | EscapeNewLine = expr('\\') >> *(set(" \t") | MultiLineComment) >> -Comment >> Break; |
47 | Space = *(set(" \t") | MultiLineComment | EscapeNewLine) >> -Comment; | 47 | Space = *(set(" \t") | MultiLineComment | EscapeNewLine) >> -Comment; |
48 | SomeSpace = +set(" \t") >> -Comment; | ||
49 | SpaceBreak = Space >> Break; | 48 | SpaceBreak = Space >> Break; |
50 | EmptyLine = SpaceBreak; | 49 | EmptyLine = SpaceBreak; |
51 | AlphaNum = range('a', 'z') | range('A', 'Z') | range('0', '9') | '_'; | 50 | AlphaNum = range('a', 'z') | range('A', 'Z') | range('0', '9') | '_'; |
@@ -396,7 +395,7 @@ MoonParser::MoonParser() { | |||
396 | export_op = expr('*') | expr('^'); | 395 | export_op = expr('*') | expr('^'); |
397 | Export = key("export") >> (ClassDecl | (Space >> export_op) | export_values); | 396 | Export = key("export") >> (ClassDecl | (Space >> export_op) | export_values); |
398 | 397 | ||
399 | variable_pair = sym(':') >> not_(SomeSpace) >> Space >> Variable; | 398 | variable_pair = sym(':') >> Variable; |
400 | 399 | ||
401 | normal_pair = ( | 400 | normal_pair = ( |
402 | KeyName | | 401 | KeyName | |
@@ -436,8 +435,8 @@ MoonParser::MoonParser() { | |||
436 | 435 | ||
437 | Backcall = -FnArgsDef >> Space >> symx("<-") >> Space >> ChainValue; | 436 | Backcall = -FnArgsDef >> Space >> symx("<-") >> Space >> ChainValue; |
438 | 437 | ||
439 | ExpList = Seperator >> Exp >> *(sym(',') >> Exp); | 438 | ExpList = Seperator >> Exp >> *(sym(',') >> White >> Exp); |
440 | ExpListLow = Seperator >> Exp >> *((sym(',') | sym(';')) >> Exp); | 439 | ExpListLow = Seperator >> Exp >> *((sym(',') | sym(';')) >> White >> Exp); |
441 | 440 | ||
442 | ArgLine = CheckIndent >> Exp >> *(sym(',') >> Exp); | 441 | ArgLine = CheckIndent >> Exp >> *(sym(',') >> Exp); |
443 | ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; | 442 | ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; |
@@ -457,7 +456,7 @@ MoonParser::MoonParser() { | |||
457 | ); | 456 | ); |
458 | 457 | ||
459 | const_value = (expr("nil") | expr("true") | expr("false")) >> not_(AlphaNum); | 458 | const_value = (expr("nil") | expr("true") | expr("false")) >> not_(AlphaNum); |
460 | minus_exp = expr('-') >> not_(SomeSpace) >> Exp; | 459 | minus_exp = expr('-') >> not_(set(" \t")) >> Exp; |
461 | sharp_exp = expr('#') >> Exp; | 460 | sharp_exp = expr('#') >> Exp; |
462 | tilde_exp = expr('~') >> Exp; | 461 | tilde_exp = expr('~') >> Exp; |
463 | not_exp = expr("not") >> not_(AlphaNum) >> Exp; | 462 | not_exp = expr("not") >> not_(AlphaNum) >> Exp; |
diff --git a/src/MoonP/moon_parser.h b/src/MoonP/moon_parser.h index a0ad2fa..2107a14 100644 --- a/src/MoonP/moon_parser.h +++ b/src/MoonP/moon_parser.h | |||
@@ -107,7 +107,6 @@ private: | |||
107 | rule Indent; | 107 | rule Indent; |
108 | rule EscapeNewLine; | 108 | rule EscapeNewLine; |
109 | rule Space; | 109 | rule Space; |
110 | rule SomeSpace; | ||
111 | rule SpaceBreak; | 110 | rule SpaceBreak; |
112 | rule EmptyLine; | 111 | rule EmptyLine; |
113 | rule AlphaNum; | 112 | rule AlphaNum; |