From c241ea241e8e9c152f6eb14f163b2ae39749f7bf Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 7 Feb 2020 17:29:34 +0800 Subject: releasing moonplus as a lib. --- src/MoonP/moon_compiler.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/MoonP') diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index d3427d3..30adbae 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp @@ -690,7 +690,7 @@ private: break; } } - throw std::logic_error(_info.errorMessage("Expression list must appear at the end of body block."sv, expList)); + throw std::logic_error(_info.errorMessage("Expression list must appear at the end of body or block."sv, expList)); } break; } @@ -1252,26 +1252,31 @@ private: bool oneLined = defs.size() == expList->exprs.objects().size() && traversal::Stop != action->traverse([&](ast_node* n) { switch (n->getId()) { - case "Callable"_id: { - auto callable = static_cast(n); - switch (callable->item->getId()) { - case "Variable"_id: - for (const auto& def : defs) { + case "ChainValue"_id: { + auto chainValue = static_cast(n); + const auto& items = chainValue->items.objects(); + BLOCK_START + auto callable = ast_cast(*items.begin()); + BREAK_IF(!callable); + auto next = items.begin(); ++next; + BREAK_IF(next == items.end()); + BREAK_IF((!ast_is(*next))); + for (const auto& def : defs) { + switch (callable->item->getId()) { + case "Variable"_id: if (def == _parser.toString(callable->item)) { return traversal::Stop; } - } - return traversal::Return; - case "SelfName"_id: - for (const auto& def : defs) { + return traversal::Return; + case "SelfName"_id: if (def == "self"sv) { return traversal::Stop; } - } - return traversal::Return; - default: - return traversal::Continue; + return traversal::Return; + } } + BLOCK_END + return traversal::Continue; } default: return traversal::Continue; -- cgit v1.2.3-55-g6feb