aboutsummaryrefslogtreecommitdiff
path: root/src/yuescript/yue_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuescript/yue_parser.cpp')
-rw-r--r--src/yuescript/yue_parser.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index 7cf2ebe..c72c005 100644
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -412,6 +412,9 @@ YueParser::YueParser() {
412 FnArgs = (symx('(') >> *SpaceBreak >> -FnArgsExpList >> *SpaceBreak >> sym(')')) | 412 FnArgs = (symx('(') >> *SpaceBreak >> -FnArgsExpList >> *SpaceBreak >> sym(')')) |
413 (sym('!') >> not_(expr('='))); 413 (sym('!') >> not_(expr('=')));
414 414
415 Metatable = expr('#');
416 Metamethod = Name >> expr('#');
417
415 existential_op = expr('?'); 418 existential_op = expr('?');
416 chain_call = (Callable | String) >> -existential_op >> ChainItems; 419 chain_call = (Callable | String) >> -existential_op >> ChainItems;
417 chain_item = and_(set(".\\")) >> ChainItems; 420 chain_item = and_(set(".\\")) >> ChainItems;
@@ -427,8 +430,8 @@ YueParser::YueParser() {
427 430
428 Index = symx('[') >> Exp >> sym(']'); 431 Index = symx('[') >> Exp >> sym(']');
429 ChainItem = Invoke >> -existential_op | DotChainItem >> -existential_op | Slice | Index >> -existential_op; 432 ChainItem = Invoke >> -existential_op | DotChainItem >> -existential_op | Slice | Index >> -existential_op;
430 DotChainItem = symx('.') >> Name; 433 DotChainItem = symx('.') >> (Name >> not_('#') | Metatable | Metamethod);
431 ColonChainItem = symx('\\') >> (LuaKeyword | Name); 434 ColonChainItem = symx('\\') >> ((LuaKeyword | Name) >> not_('#') | Metamethod);
432 invoke_chain = Invoke >> -existential_op >> -ChainItems; 435 invoke_chain = Invoke >> -existential_op >> -ChainItems;
433 ColonChain = ColonChainItem >> -existential_op >> -invoke_chain; 436 ColonChain = ColonChainItem >> -existential_op >> -invoke_chain;
434 437
@@ -508,7 +511,7 @@ YueParser::YueParser() {
508 }) >> ExpList >> -Assign) 511 }) >> ExpList >> -Assign)
509 | Macro) >> not_(Space >> statement_appendix); 512 | Macro) >> not_(Space >> statement_appendix);
510 513
511 variable_pair = sym(':') >> Variable; 514 variable_pair = sym(':') >> Variable >> not_('#');
512 515
513 normal_pair = ( 516 normal_pair = (
514 KeyName | 517 KeyName |
@@ -520,7 +523,12 @@ YueParser::YueParser() {
520 symx(':') >> 523 symx(':') >>
521 (Exp | TableBlock | +(SpaceBreak) >> Exp); 524 (Exp | TableBlock | +(SpaceBreak) >> Exp);
522 525
523 KeyValue = variable_pair | normal_pair; 526 meta_variable_pair = sym(':') >> Variable >> expr('#');
527
528 meta_normal_pair = Space >> Name >> expr("#:") >>
529 (Exp | TableBlock | +(SpaceBreak) >> Exp);
530
531 KeyValue = variable_pair | normal_pair | meta_variable_pair | meta_normal_pair;
524 532
525 KeyValueList = KeyValue >> *(sym(',') >> KeyValue); 533 KeyValueList = KeyValue >> *(sym(',') >> KeyValue);
526 KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent | Space >> expr('*') >> (Exp | TableBlock)); 534 KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent | Space >> expr('*') >> (Exp | TableBlock));