diff options
author | Li Jin <dragon-fly@qq.com> | 2020-08-06 10:32:05 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-08-06 10:32:05 +0800 |
commit | cb5371a7dcfde196db07f5a2a3f144888b73d522 (patch) | |
tree | 65d7a5d031b83a78f3d3e00725dc15b4bfda2176 /src | |
parent | 2506c1b429e952245295e54e71dac4b345e88984 (diff) | |
download | yuescript-cb5371a7dcfde196db07f5a2a3f144888b73d522.tar.gz yuescript-cb5371a7dcfde196db07f5a2a3f144888b73d522.tar.bz2 yuescript-cb5371a7dcfde196db07f5a2a3f144888b73d522.zip |
remove support for escape new line symbol, binary operator expressions can now be written multiline without escape new line symbol.
Diffstat (limited to 'src')
-rw-r--r-- | src/MoonP/moon_compiler.cpp | 2 | ||||
-rw-r--r-- | src/MoonP/moon_parser.cpp | 11 | ||||
-rw-r--r-- | src/MoonP/moon_parser.h | 1 |
3 files changed, 6 insertions, 8 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 6ce4e48..f517e27 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
@@ -49,7 +49,7 @@ inline std::string s(std::string_view sv) { | |||
49 | } | 49 | } |
50 | 50 | ||
51 | const std::string_view version() { | 51 | const std::string_view version() { |
52 | return "0.4.6"sv; | 52 | return "0.4.7"sv; |
53 | } | 53 | } |
54 | 54 | ||
55 | // name of table stored in lua registry | 55 | // name of table stored in lua registry |
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index df7d810..43e6887 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
@@ -43,8 +43,7 @@ MoonParser::MoonParser() { | |||
43 | multi_line_close = expr("]]"); | 43 | multi_line_close = expr("]]"); |
44 | multi_line_content = *(not_(multi_line_close) >> Any); | 44 | multi_line_content = *(not_(multi_line_close) >> Any); |
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 | space_one = set(" \t") | MultiLineComment; |
47 | space_one = set(" \t") | and_(set("-\\")) >> (MultiLineComment | EscapeNewLine); | ||
48 | Space = *space_one >> -Comment; | 47 | Space = *space_one >> -Comment; |
49 | SpaceBreak = Space >> Break; | 48 | SpaceBreak = Space >> Break; |
50 | White = Space >> *(Break >> Space); | 49 | White = Space >> *(Break >> Space); |
@@ -316,7 +315,7 @@ MoonParser::MoonParser() { | |||
316 | unary_exp = *(Space >> unary_operator) >> expo_exp; | 315 | unary_exp = *(Space >> unary_operator) >> expo_exp; |
317 | 316 | ||
318 | BackcallOperator = expr("|>"); | 317 | BackcallOperator = expr("|>"); |
319 | backcall_value = Space >> BackcallOperator >> *SpaceBreak >> unary_exp; | 318 | backcall_value = White >> BackcallOperator >> *SpaceBreak >> unary_exp; |
320 | backcall_exp = unary_exp >> *backcall_value; | 319 | backcall_exp = unary_exp >> *backcall_value; |
321 | 320 | ||
322 | BinaryOperator = | 321 | BinaryOperator = |
@@ -332,7 +331,7 @@ MoonParser::MoonParser() { | |||
332 | expr(">>") | | 331 | expr(">>") | |
333 | expr("//") | | 332 | expr("//") | |
334 | set("+-*/%><|&~"); | 333 | set("+-*/%><|&~"); |
335 | exp_op_value = Space >> BinaryOperator >> *SpaceBreak >> backcall_exp; | 334 | exp_op_value = White >> BinaryOperator >> *SpaceBreak >> backcall_exp; |
336 | Exp = Seperator >> backcall_exp >> *exp_op_value; | 335 | Exp = Seperator >> backcall_exp >> *exp_op_value; |
337 | 336 | ||
338 | ChainValue = Seperator >> (Chain | Callable) >> -existential_op >> -InvokeArgs; | 337 | ChainValue = Seperator >> (Chain | Callable) >> -existential_op >> -InvokeArgs; |
@@ -522,8 +521,8 @@ MoonParser::MoonParser() { | |||
522 | fn_arrow_back = expr('<') >> set("-="); | 521 | fn_arrow_back = expr('<') >> set("-="); |
523 | Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; | 522 | Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; |
524 | 523 | ||
525 | ExpList = Seperator >> Exp >> *(sym(',') >> White >> Exp); | 524 | ExpList = Seperator >> Exp >> *(White >> expr(',') >> White >> Exp); |
526 | ExpListLow = Seperator >> Exp >> *((sym(',') | sym(';')) >> White >> Exp); | 525 | ExpListLow = Seperator >> Exp >> *(White >> set(",;") >> White >> Exp); |
527 | 526 | ||
528 | ArgLine = CheckIndent >> Exp >> *(sym(',') >> Exp); | 527 | ArgLine = CheckIndent >> Exp >> *(sym(',') >> Exp); |
529 | ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; | 528 | ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; |
diff --git a/src/MoonP/moon_parser.h b/src/MoonP/moon_parser.h index c6a03f8..d7fa24b 100644 --- a/src/MoonP/moon_parser.h +++ b/src/MoonP/moon_parser.h | |||
@@ -111,7 +111,6 @@ private: | |||
111 | rule multi_line_content; | 111 | rule multi_line_content; |
112 | rule MultiLineComment; | 112 | rule MultiLineComment; |
113 | rule Indent; | 113 | rule Indent; |
114 | rule EscapeNewLine; | ||
115 | rule space_one; | 114 | rule space_one; |
116 | rule Space; | 115 | rule Space; |
117 | rule SpaceBreak; | 116 | rule SpaceBreak; |