diff options
author | Li Jin <dragon-fly@qq.com> | 2020-09-11 14:55:22 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-09-11 14:55:22 +0800 |
commit | dfd4e3b2b2abc0137d26ed3df303a398741bb6a0 (patch) | |
tree | 59a1690ad02d56d3f303f6ac1dea9e5d6cdc8f20 /src/MoonP/moon_parser.cpp | |
parent | eba73a696c65932534fd5aefbe2ca4c7260c0fb6 (diff) | |
download | yuescript-dfd4e3b2b2abc0137d26ed3df303a398741bb6a0.tar.gz yuescript-dfd4e3b2b2abc0137d26ed3df303a398741bb6a0.tar.bz2 yuescript-dfd4e3b2b2abc0137d26ed3df303a398741bb6a0.zip |
add implicit objects support while writing tables.
Diffstat (limited to 'src/MoonP/moon_parser.cpp')
-rw-r--r-- | src/MoonP/moon_parser.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index a13a779..53a6b8f 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
@@ -430,12 +430,14 @@ MoonParser::MoonParser() { | |||
430 | Space | 430 | Space |
431 | ); | 431 | ); |
432 | 432 | ||
433 | TableBlockInner = Seperator >> KeyValueLine >> *(+(SpaceBreak) >> KeyValueLine); | 433 | TableBlockInner = Seperator >> KeyValueLine >> *(+SpaceBreak >> KeyValueLine); |
434 | TableBlock = +(SpaceBreak) >> Advance >> ensure(TableBlockInner, PopIndent); | 434 | TableBlock = +SpaceBreak >> Advance >> ensure(TableBlockInner, PopIndent); |
435 | TableBlockIndent = sym('#') >> Seperator >> KeyValueList >> -sym(',') >> | ||
436 | -(+SpaceBreak >> Advance >> ensure(KeyValueList >> -sym(',') >> *(+SpaceBreak >> KeyValueLine), PopIndent)); | ||
435 | 437 | ||
436 | class_member_list = Seperator >> KeyValue >> *(sym(',') >> KeyValue); | 438 | class_member_list = Seperator >> KeyValue >> *(sym(',') >> KeyValue); |
437 | ClassLine = CheckIndent >> (class_member_list | Statement) >> -sym(','); | 439 | ClassLine = CheckIndent >> (class_member_list | Statement) >> -sym(','); |
438 | ClassBlock = +(SpaceBreak) >> Advance >>Seperator >> ClassLine >> *(+(SpaceBreak) >> ClassLine) >> PopIndent; | 440 | ClassBlock = +SpaceBreak >> Advance >> Seperator >> ClassLine >> *(+SpaceBreak >> ClassLine) >> PopIndent; |
439 | 441 | ||
440 | ClassDecl = | 442 | ClassDecl = |
441 | key("class") >> not_(expr(':')) >> | 443 | key("class") >> not_(expr(':')) >> |
@@ -489,7 +491,7 @@ MoonParser::MoonParser() { | |||
489 | }); | 491 | }); |
490 | 492 | ||
491 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); | 493 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); |
492 | KeyValueLine = CheckIndent >> KeyValueList >> -sym(','); | 494 | KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent); |
493 | 495 | ||
494 | FnArgDef = (Variable | SelfName) >> -(sym('=') >> Space >> Exp); | 496 | FnArgDef = (Variable | SelfName) >> -(sym('=') >> Space >> Exp); |
495 | 497 | ||