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/MoonP/moon_parser.cpp | |
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/MoonP/moon_parser.cpp')
-rw-r--r-- | src/MoonP/moon_parser.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
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; |