diff options
Diffstat (limited to '')
-rwxr-xr-x | src/yuescript/yue_parser.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index e5209ef..153babe 100755 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -351,7 +351,7 @@ YueParser::YueParser() { | |||
351 | 351 | ||
352 | unary_operator = | 352 | unary_operator = |
353 | expr('-') >> not_(set(">=") | space_one) | | 353 | expr('-') >> not_(set(">=") | space_one) | |
354 | expr('#') >> not_(':') | | 354 | expr('#') | |
355 | expr('~') >> not_(expr('=') | space_one) | | 355 | expr('~') >> not_(expr('=') | space_one) | |
356 | expr("not") >> not_(AlphaNum); | 356 | expr("not") >> not_(AlphaNum); |
357 | unary_exp = *(Space >> unary_operator) >> expo_exp; | 357 | unary_exp = *(Space >> unary_operator) >> expo_exp; |
@@ -435,8 +435,9 @@ YueParser::YueParser() { | |||
435 | FnArgs = (symx('(') >> *SpaceBreak >> -FnArgsExpList >> *SpaceBreak >> sym(')')) | | 435 | FnArgs = (symx('(') >> *SpaceBreak >> -FnArgsExpList >> *SpaceBreak >> sym(')')) | |
436 | (sym('!') >> not_(expr('='))); | 436 | (sym('!') >> not_(expr('='))); |
437 | 437 | ||
438 | Metatable = expr('#'); | 438 | meta_index = Name | Index | String; |
439 | Metamethod = Name >> expr('#'); | 439 | Metatable = expr('<') >> sym('>'); |
440 | Metamethod = expr('<') >> Space >> meta_index >> sym('>'); | ||
440 | 441 | ||
441 | existential_op = expr('?') >> not_(expr('?')); | 442 | existential_op = expr('?') >> not_(expr('?')); |
442 | table_appending_op = expr("[]"); | 443 | table_appending_op = expr("[]"); |
@@ -453,8 +454,8 @@ YueParser::YueParser() { | |||
453 | 454 | ||
454 | Index = symx('[') >> not_('[') >> Exp >> sym(']'); | 455 | Index = symx('[') >> not_('[') >> Exp >> sym(']'); |
455 | ChainItem = Invoke >> -existential_op | DotChainItem >> -existential_op | Slice | Index >> -existential_op; | 456 | ChainItem = Invoke >> -existential_op | DotChainItem >> -existential_op | Slice | Index >> -existential_op; |
456 | DotChainItem = symx('.') >> (Name >> not_('#') | Metatable | Metamethod); | 457 | DotChainItem = symx('.') >> (Name | Metatable | Metamethod); |
457 | ColonChainItem = (expr('\\') | expr("::")) >> ((LuaKeyword | Name) >> not_('#') | Metamethod); | 458 | ColonChainItem = (expr('\\') | expr("::")) >> (LuaKeyword | Name | Metamethod); |
458 | invoke_chain = Invoke >> -existential_op >> -ChainItems; | 459 | invoke_chain = Invoke >> -existential_op >> -ChainItems; |
459 | ColonChain = ColonChainItem >> -existential_op >> -invoke_chain; | 460 | ColonChain = ColonChainItem >> -existential_op >> -invoke_chain; |
460 | 461 | ||
@@ -542,26 +543,31 @@ YueParser::YueParser() { | |||
542 | return true; | 543 | return true; |
543 | })) >> not_(Space >> statement_appendix); | 544 | })) >> not_(Space >> statement_appendix); |
544 | 545 | ||
545 | variable_pair = sym(':') >> Variable >> not_('#'); | 546 | variable_pair = sym(':') >> Variable; |
546 | 547 | ||
547 | normal_pair = ( | 548 | normal_pair = ( |
548 | KeyName | | 549 | KeyName | |
549 | sym('[') >> not_('[') >> Exp >> sym(']') | | 550 | sym('[') >> not_('[') >> Exp >> sym(']') | |
550 | Space >> DoubleString | | 551 | Space >> String |
551 | Space >> SingleString | | ||
552 | Space >> LuaString | ||
553 | ) >> | 552 | ) >> |
554 | symx(':') >> not_(':') >> | 553 | symx(':') >> not_(':') >> |
555 | (Exp | TableBlock | +SpaceBreak >> Exp); | 554 | (Exp | TableBlock | +SpaceBreak >> Exp); |
556 | 555 | ||
557 | default_pair = (sym(':') >> Variable >> not_('#') >> Seperator | KeyName >> symx(':') >> Seperator >> exp_not_tab | exp_not_tab >> Seperator) >> sym('=') >> Exp; | 556 | default_pair = ( |
557 | sym(':') >> Variable >> Seperator | | ||
558 | KeyName >> symx(':') >> not_(':') >> Seperator >> exp_not_tab | | ||
559 | Space >> String >> symx(':') >> not_(':') >> Seperator >> exp_not_tab | | ||
560 | exp_not_tab >> Seperator) >> sym('=') >> Exp; | ||
558 | 561 | ||
559 | meta_variable_pair = sym(':') >> Variable >> expr('#'); | 562 | meta_variable_pair = sym(":<") >> Space >> Variable >> sym('>'); |
560 | 563 | ||
561 | meta_normal_pair = Space >> -(Name | symx('[') >> not_('[') >> Exp >> sym(']')) >> expr("#:") >> | 564 | meta_normal_pair = sym('<') >> Space >> -meta_index >> sym(">:") >> |
562 | (Exp | TableBlock | +(SpaceBreak) >> Exp); | 565 | (Exp | TableBlock | +(SpaceBreak) >> Exp); |
563 | 566 | ||
564 | meta_default_pair = (sym(':') >> Variable >> expr('#') >> Seperator | Space >> -Name >> expr("#:") >> Seperator >> exp_not_tab) >> sym('=') >> Exp; | 567 | meta_default_pair = ( |
568 | sym(":<") >> Space >> Variable >> sym('>') >> Seperator | | ||
569 | sym('<') >> Space >> -meta_index >> sym(">:") >> Seperator >> exp_not_tab | ||
570 | ) >> sym('=') >> Exp; | ||
565 | 571 | ||
566 | KeyValue = variable_pair | normal_pair | meta_variable_pair | meta_normal_pair; | 572 | KeyValue = variable_pair | normal_pair | meta_variable_pair | meta_normal_pair; |
567 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); | 573 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); |