From 2c563f0deada6e10b87b71a500ff98d4bdc1ecf6 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 13 Jan 2020 14:24:07 +0800 Subject: remove codes to be compatible with old version. --- src/MoonP/moon_compiler.cpp | 24 +++++++----------------- src/MoonP/moon_compiler.h | 5 +---- src/MoonP/moon_parser.cpp | 2 +- 3 files changed, 9 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 0a5babe..d30f413 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp @@ -288,11 +288,11 @@ private: } std::string indent() { - return _config.spaceOverTab ? std::string((_scopes.size() - 1 + _indentOffset) * 2, ' ') : std::string(_scopes.size() - 1 + _indentOffset, '\t'); + return std::string(_scopes.size() - 1 + _indentOffset, '\t'); } std::string indent(int offset) { - return _config.spaceOverTab ? std::string((_scopes.size() - 1 + _indentOffset + offset) * 2, ' ') : std::string(_scopes.size() - 1 + _indentOffset + offset, '\t'); + return std::string(_scopes.size() - 1 + _indentOffset + offset, '\t'); } std::string clearBuf() { @@ -707,16 +707,7 @@ private: } } } - if (_config.allowExprNotInTheEndOfBody) { - auto assign = x->new_ptr(); - assign->values.dup(expList->exprs); - auto assignment = x->new_ptr(); - assignment->expList.set(toAst("_", ExpList, x)); - assignment->action.set(assign); - transformAssignment(assignment, out); - } else { - throw std::logic_error(debugInfo("Expression list must appear at the end of body block."sv, expList)); - } + throw std::logic_error(debugInfo("Expression list must appear at the end of body block."sv, expList)); } break; } @@ -2456,8 +2447,7 @@ private: switch (loopTarget->getId()) { case "star_exp"_id: { auto star_exp = static_cast(loopTarget); - std::string listVar; - if (_config.reuseVariable) listVar = singleVariableFrom(star_exp->value); + auto listVar = singleVariableFrom(star_exp->value); auto indexVar = getUnusedName("_index_"); varAfter.push_back(indexVar); auto value = singleValueFrom(star_exp->value); @@ -3279,7 +3269,7 @@ private: checkAssignable(with->valueList); auto vars = getAssignVars(with); if (vars.front().empty()) { - if (_config.reuseVariable && with->assigns->values.objects().size() == 1) { + if (with->assigns->values.objects().size() == 1) { auto var = singleVariableFrom(with->assigns->values.objects().front()); if (!var.empty()) { withVar = var; @@ -3326,7 +3316,7 @@ private: transformAssignment(assignment, temp); } } else { - if (_config.reuseVariable) withVar = singleVariableFrom(with->valueList); + withVar = singleVariableFrom(with->valueList); if (withVar.empty()) { withVar = getUnusedName("_with_"); auto assignment = x->new_ptr(); @@ -3882,7 +3872,7 @@ private: const std::string MoonCompliler::Empty; -std::tuple moonCompile(const std::string& codes, const MoonConfig& config) { +std::tuple moonCompile(const std::string& codes, const MoonConfig& config) { auto compiler = MoonCompliler{}; auto result = compiler.complile(codes, config); auto globals = std::make_unique>(); diff --git a/src/MoonP/moon_compiler.h b/src/MoonP/moon_compiler.h index cb1990c..0739a59 100644 --- a/src/MoonP/moon_compiler.h +++ b/src/MoonP/moon_compiler.h @@ -20,10 +20,7 @@ const char* moonScriptVersion(); struct MoonConfig { bool lintGlobalVariable = false; bool implicitReturnRoot = true; - bool reserveLineNumber = false; - bool spaceOverTab = false; - bool reuseVariable = false; - bool allowExprNotInTheEndOfBody = false; + bool reserveLineNumber = true; }; struct GlobalVar { diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 7b5183e..1005463 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp @@ -236,7 +236,7 @@ extern rule CompInner; rule Comprehension = sym('[') >> Exp >> CompInner >> sym(']'); rule comp_value = sym(',') >> Exp; -rule TblComprehension = sym('{') >> (Exp >> -comp_value) >> CompInner >> sym('}'); +rule TblComprehension = sym('{') >> (Exp >> -comp_value) >> CompInner >> sym('}'); extern rule CompForEach, CompFor, CompClause; -- cgit v1.2.3-55-g6feb