diff options
author | Li Jin <dragon-fly@qq.com> | 2020-02-02 22:27:42 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-02-02 22:27:42 +0800 |
commit | aa57156b2c711bf4781d097d4748e9bc57f937b8 (patch) | |
tree | 382e2bfc6be8c855cdf2b7af9f287db1b1f76421 | |
parent | 57191ed45bb7bd0ffcd917f00df2e940c900fb3c (diff) | |
download | yuescript-aa57156b2c711bf4781d097d4748e9bc57f937b8.tar.gz yuescript-aa57156b2c711bf4781d097d4748e9bc57f937b8.tar.bz2 yuescript-aa57156b2c711bf4781d097d4748e9bc57f937b8.zip |
add MultiLineComment support in EscapeNewLine.
-rw-r--r-- | spec/inputs/syntax.moon | 22 | ||||
-rw-r--r-- | src/MoonP/moon_parser.cpp | 4 |
2 files changed, 24 insertions, 2 deletions
diff --git a/spec/inputs/syntax.moon b/spec/inputs/syntax.moon index 3ac9991..abee3e3 100644 --- a/spec/inputs/syntax.moon +++ b/spec/inputs/syntax.moon | |||
@@ -280,3 +280,25 @@ It's OK. | |||
280 | 280 | ||
281 | func --[[port]] 3000, --[[ip]] "192.168.1.1" | 281 | func --[[port]] 3000, --[[ip]] "192.168.1.1" |
282 | 282 | ||
283 | f = -> | ||
284 | a,b, \ | ||
285 | c,d, \ | ||
286 | e,f | ||
287 | |||
288 | with obj | ||
289 | invoke \ | ||
290 | --[[arg1]] \func!, | ||
291 | --[[arg2]] 123, | ||
292 | --[[arg3]] "abc" | ||
293 | |||
294 | invokeA \ | ||
295 | invokeB \ | ||
296 | invokeC 123 | ||
297 | |||
298 | 123 \ | ||
299 | |> invokeC \ | ||
300 | |> invokeB \ | ||
301 | |> invokeA | ||
302 | |||
303 | nil | ||
304 | |||
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index b2aba20..358b660 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
@@ -37,13 +37,13 @@ MoonParser::MoonParser() { | |||
37 | Any = Break | any(); | 37 | Any = Break | any(); |
38 | White = *(set(" \t") | Break); | 38 | White = *(set(" \t") | Break); |
39 | Stop = Break | eof(); | 39 | Stop = Break | eof(); |
40 | Indent = plain_space; | ||
40 | Comment = "--" >> *(not_(set("\r\n")) >> Any) >> and_(Stop); | 41 | Comment = "--" >> *(not_(set("\r\n")) >> Any) >> and_(Stop); |
41 | multi_line_open = expr("--[["); | 42 | multi_line_open = expr("--[["); |
42 | multi_line_close = expr("]]"); | 43 | multi_line_close = expr("]]"); |
43 | multi_line_content = *(not_(multi_line_close) >> Any); | 44 | multi_line_content = *(not_(multi_line_close) >> Any); |
44 | MultiLineComment = multi_line_open >> multi_line_content >> multi_line_close; | 45 | MultiLineComment = multi_line_open >> multi_line_content >> multi_line_close; |
45 | Indent = plain_space; | 46 | EscapeNewLine = expr('\\') >> *(set(" \t") | MultiLineComment) >> -Comment >> Break; |
46 | EscapeNewLine = expr('\\') >> plain_space >> -Comment >> Break; | ||
47 | Space = *(set(" \t") | MultiLineComment | EscapeNewLine) >> -Comment; | 47 | Space = *(set(" \t") | MultiLineComment | EscapeNewLine) >> -Comment; |
48 | SomeSpace = +set(" \t") >> -Comment; | 48 | SomeSpace = +set(" \t") >> -Comment; |
49 | SpaceBreak = Space >> Break; | 49 | SpaceBreak = Space >> Break; |