diff options
Diffstat (limited to '')
| -rw-r--r-- | src/yuescript/yue_parser.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 0d9a183..758865e 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
| @@ -406,10 +406,10 @@ YueParser::YueParser() { | |||
| 406 | simple_table = Seperator >> KeyValue >> *(sym(',') >> KeyValue); | 406 | simple_table = Seperator >> KeyValue >> *(sym(',') >> KeyValue); |
| 407 | Value = SimpleValue | simple_table | ChainValue | Space >> String; | 407 | Value = SimpleValue | simple_table | ChainValue | Space >> String; |
| 408 | 408 | ||
| 409 | single_string_inner = expr("\\'") | "\\\\" | not_(expr('\'')) >> Any; | 409 | single_string_inner = expr('\\') >> set("'\\") | not_(expr('\'')) >> Any; |
| 410 | SingleString = symx('\'') >> *single_string_inner >> symx('\''); | 410 | SingleString = symx('\'') >> *single_string_inner >> symx('\''); |
| 411 | interp = symx("#{") >> Exp >> sym('}'); | 411 | interp = symx("#{") >> Exp >> sym('}'); |
| 412 | double_string_plain = expr("\\\"") | "\\\\" | not_(expr('"')) >> Any; | 412 | double_string_plain = expr('\\') >> set("\"\\") | not_(expr('"')) >> Any; |
| 413 | double_string_inner = +(not_(interp) >> double_string_plain); | 413 | double_string_inner = +(not_(interp) >> double_string_plain); |
| 414 | double_string_content = double_string_inner | interp; | 414 | double_string_content = double_string_inner | interp; |
| 415 | DoubleString = symx('"') >> Seperator >> *double_string_content >> symx('"'); | 415 | DoubleString = symx('"') >> Seperator >> *double_string_content >> symx('"'); |
| @@ -484,7 +484,13 @@ YueParser::YueParser() { | |||
| 484 | 484 | ||
| 485 | SpreadExp = sym("...") >> Exp; | 485 | SpreadExp = sym("...") >> Exp; |
| 486 | 486 | ||
| 487 | TableValue = ((KeyValue | SpreadExp | Exp) >> not_(sym('='))) | meta_default_pair | default_pair; | 487 | TableValue = |
| 488 | variable_pair_def | | ||
| 489 | normal_pair_def | | ||
| 490 | meta_variable_pair_def | | ||
| 491 | meta_normal_pair_def | | ||
| 492 | SpreadExp | | ||
| 493 | normal_def; | ||
| 488 | 494 | ||
| 489 | table_lit_lines = SpaceBreak >> TableLitLine >> *(-sym(',') >> SpaceBreak >> TableLitLine) >> -sym(','); | 495 | table_lit_lines = SpaceBreak >> TableLitLine >> *(-sym(',') >> SpaceBreak >> TableLitLine) >> -sym(','); |
| 490 | 496 | ||
| @@ -564,21 +570,16 @@ YueParser::YueParser() { | |||
| 564 | symx(':') >> not_(':') >> | 570 | symx(':') >> not_(':') >> |
| 565 | (Exp | TableBlock | +SpaceBreak >> Exp); | 571 | (Exp | TableBlock | +SpaceBreak >> Exp); |
| 566 | 572 | ||
| 567 | default_pair = ( | ||
| 568 | sym(':') >> Variable >> Seperator | | ||
| 569 | KeyName >> symx(':') >> not_(':') >> Seperator >> exp_not_tab | | ||
| 570 | Space >> String >> symx(':') >> not_(':') >> Seperator >> exp_not_tab | | ||
| 571 | exp_not_tab >> Seperator) >> sym('=') >> Exp; | ||
| 572 | |||
| 573 | meta_variable_pair = sym(":<") >> Space >> Variable >> sym('>'); | 573 | meta_variable_pair = sym(":<") >> Space >> Variable >> sym('>'); |
| 574 | 574 | ||
| 575 | meta_normal_pair = sym('<') >> Space >> -meta_index >> sym(">:") >> | 575 | meta_normal_pair = sym('<') >> Space >> -meta_index >> sym(">:") >> |
| 576 | (Exp | TableBlock | +(SpaceBreak) >> Exp); | 576 | (Exp | TableBlock | +(SpaceBreak) >> Exp); |
| 577 | 577 | ||
| 578 | meta_default_pair = ( | 578 | variable_pair_def = variable_pair >> -(sym('=') >> Exp); |
| 579 | sym(":<") >> Space >> Variable >> sym('>') >> Seperator | | 579 | normal_pair_def = normal_pair >> -(sym('=') >> Exp); |
| 580 | sym('<') >> Space >> -meta_index >> sym(">:") >> Seperator >> exp_not_tab | 580 | meta_variable_pair_def = meta_variable_pair >> -(sym('=') >> Exp); |
| 581 | ) >> sym('=') >> Exp; | 581 | meta_normal_pair_def = meta_normal_pair >> -(sym('=') >> Exp); |
| 582 | normal_def = Exp >> Seperator >> -(sym('=') >> Exp); | ||
| 582 | 583 | ||
| 583 | KeyValue = variable_pair | normal_pair | meta_variable_pair | meta_normal_pair; | 584 | KeyValue = variable_pair | normal_pair | meta_variable_pair | meta_normal_pair; |
| 584 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); | 585 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); |
