diff options
Diffstat (limited to 'src/yuescript/yue_parser.cpp')
-rw-r--r-- | src/yuescript/yue_parser.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 2234a59..c76b574 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -495,13 +495,13 @@ YueParser::YueParser() { | |||
495 | State* st = reinterpret_cast<State*>(item.user_data); | 495 | State* st = reinterpret_cast<State*>(item.user_data); |
496 | st->exportCount++; | 496 | st->exportCount++; |
497 | return true; | 497 | return true; |
498 | }) >> ((pl::user(export_default, [](const item_t& item) { | 498 | }) >> (pl::user(export_default >> Exp, [](const item_t& item) { |
499 | State* st = reinterpret_cast<State*>(item.user_data); | 499 | State* st = reinterpret_cast<State*>(item.user_data); |
500 | bool isValid = !st->exportDefault && st->exportCount == 1; | 500 | bool isValid = !st->exportDefault && st->exportCount == 1; |
501 | st->exportDefault = true; | 501 | st->exportDefault = true; |
502 | return isValid; | 502 | return isValid; |
503 | }) >> Exp) | 503 | }) |
504 | | (pl::user(true_(), [](const item_t& item) { | 504 | | (not_(export_default) >> pl::user(true_(), [](const item_t& item) { |
505 | State* st = reinterpret_cast<State*>(item.user_data); | 505 | State* st = reinterpret_cast<State*>(item.user_data); |
506 | if (st->exportDefault && st->exportCount > 1) { | 506 | if (st->exportDefault && st->exportCount > 1) { |
507 | return false; | 507 | return false; |
@@ -611,12 +611,13 @@ YueParser::YueParser() { | |||
611 | 611 | ||
612 | Body = InBlock | Statement; | 612 | Body = InBlock | Statement; |
613 | 613 | ||
614 | empty_line_stop = Space >> and_(Stop); | 614 | empty_line_stop = Space >> and_(Break); |
615 | Line = and_(check_indent >> Space >> not_(BackcallOperator)) >> Statement | Advance >> ensure(and_(Space >> BackcallOperator) >> Statement, PopIndent) | empty_line_stop; | 615 | Line = and_(check_indent >> Space >> not_(BackcallOperator)) >> Statement | Advance >> ensure(and_(Space >> BackcallOperator) >> Statement, PopIndent) | empty_line_stop; |
616 | Block = Seperator >> Line >> *(+Break >> Line); | 616 | Block = Seperator >> Line >> *(+Break >> Line); |
617 | 617 | ||
618 | Shebang = expr("#!") >> *(not_(Stop) >> Any); | 618 | Shebang = expr("#!") >> *(not_(Stop) >> Any); |
619 | File = White >> -Shebang >> Block >> eof(); | 619 | BlockEnd = Block >> -(+Break >> Space >> and_(Stop)) >> Stop; |
620 | File = White >> -Shebang >> Block >> -(+Break >> Space >> and_(eof())) >> eof(); | ||
620 | } | 621 | } |
621 | 622 | ||
622 | ParseInfo YueParser::parse(std::string_view codes, rule& r) { | 623 | ParseInfo YueParser::parse(std::string_view codes, rule& r) { |