diff options
Diffstat (limited to '')
| -rw-r--r-- | src/MoonP/moon_ast.h | 7 | ||||
| -rw-r--r-- | src/MoonP/moon_compiler.cpp | 5 | ||||
| -rw-r--r-- | src/MoonP/moon_parser.cpp | 3 | ||||
| -rw-r--r-- | src/MoonP/moon_parser.h | 1 | ||||
| -rw-r--r-- | src/moonp.cpp | 2 |
5 files changed, 13 insertions, 5 deletions
diff --git a/src/MoonP/moon_ast.h b/src/MoonP/moon_ast.h index 917429e..dd01165 100644 --- a/src/MoonP/moon_ast.h +++ b/src/MoonP/moon_ast.h | |||
| @@ -135,12 +135,17 @@ AST_NODE(Import) | |||
| 135 | AST_END(Import) | 135 | AST_END(Import) |
| 136 | 136 | ||
| 137 | class FnArgsDef_t; | 137 | class FnArgsDef_t; |
| 138 | |||
| 139 | AST_LEAF(fn_arrow_back) | ||
| 140 | AST_END(fn_arrow_back) | ||
| 141 | |||
| 138 | class ChainValue_t; | 142 | class ChainValue_t; |
| 139 | 143 | ||
| 140 | AST_NODE(Backcall) | 144 | AST_NODE(Backcall) |
| 141 | ast_ptr<false, FnArgsDef_t> argsDef; | 145 | ast_ptr<false, FnArgsDef_t> argsDef; |
| 146 | ast_ptr<true, fn_arrow_back_t> arrow; | ||
| 142 | ast_ptr<true, ChainValue_t> value; | 147 | ast_ptr<true, ChainValue_t> value; |
| 143 | AST_MEMBER(Backcall, &argsDef, &value) | 148 | AST_MEMBER(Backcall, &argsDef, &arrow, &value) |
| 144 | AST_END(Backcall) | 149 | AST_END(Backcall) |
| 145 | 150 | ||
| 146 | AST_NODE(ExpListLow) | 151 | AST_NODE(ExpListLow) |
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index a39bfd0..83b91e6 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
| @@ -32,7 +32,7 @@ inline std::string s(std::string_view sv) { | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | const char* moonScriptVersion() { | 34 | const char* moonScriptVersion() { |
| 35 | return "0.5.0-r0.1.4"; | 35 | return "0.5.0-r0.1.5"; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | class MoonCompilerImpl { | 38 | class MoonCompilerImpl { |
| @@ -1740,7 +1740,8 @@ private: | |||
| 1740 | body->content.set(block); | 1740 | body->content.set(block); |
| 1741 | auto funLit = x->new_ptr<FunLit_t>(); | 1741 | auto funLit = x->new_ptr<FunLit_t>(); |
| 1742 | funLit->argsDef.set(backcall->argsDef); | 1742 | funLit->argsDef.set(backcall->argsDef); |
| 1743 | funLit->arrow.set(toAst<fn_arrow_t>("->"sv, x)); | 1743 | auto arrow = _parser.toString(backcall->arrow); |
| 1744 | funLit->arrow.set(toAst<fn_arrow_t>(arrow == "<-"sv ? "->"sv : "=>"sv, x)); | ||
| 1744 | funLit->body.set(body); | 1745 | funLit->body.set(body); |
| 1745 | auto simpleValue = x->new_ptr<SimpleValue_t>(); | 1746 | auto simpleValue = x->new_ptr<SimpleValue_t>(); |
| 1746 | simpleValue->value.set(funLit); | 1747 | simpleValue->value.set(funLit); |
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 1502f3c..fecf869 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
| @@ -434,7 +434,8 @@ MoonParser::MoonParser() { | |||
| 434 | NameOrDestructure = Space >> Variable | TableLit; | 434 | NameOrDestructure = Space >> Variable | TableLit; |
| 435 | AssignableNameList = Seperator >> NameOrDestructure >> *(sym(',') >> White >> NameOrDestructure); | 435 | AssignableNameList = Seperator >> NameOrDestructure >> *(sym(',') >> White >> NameOrDestructure); |
| 436 | 436 | ||
| 437 | Backcall = -FnArgsDef >> Space >> symx("<-") >> Space >> ChainValue; | 437 | fn_arrow_back = expr('<') >> set("-="); |
| 438 | Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; | ||
| 438 | 439 | ||
| 439 | ExpList = Seperator >> Exp >> *(sym(',') >> White >> Exp); | 440 | ExpList = Seperator >> Exp >> *(sym(',') >> White >> Exp); |
| 440 | ExpListLow = Seperator >> Exp >> *((sym(',') | sym(';')) >> White >> Exp); | 441 | ExpListLow = Seperator >> Exp >> *((sym(',') | sym(';')) >> White >> Exp); |
diff --git a/src/MoonP/moon_parser.h b/src/MoonP/moon_parser.h index 215c6a4..12f735b 100644 --- a/src/MoonP/moon_parser.h +++ b/src/MoonP/moon_parser.h | |||
| @@ -191,6 +191,7 @@ private: | |||
| 191 | AST_RULE(ImportFrom) | 191 | AST_RULE(ImportFrom) |
| 192 | AST_RULE(ImportAs) | 192 | AST_RULE(ImportAs) |
| 193 | AST_RULE(Import) | 193 | AST_RULE(Import) |
| 194 | AST_RULE(fn_arrow_back) | ||
| 194 | AST_RULE(Backcall) | 195 | AST_RULE(Backcall) |
| 195 | AST_RULE(ExpListLow) | 196 | AST_RULE(ExpListLow) |
| 196 | AST_RULE(ExpList) | 197 | AST_RULE(ExpList) |
diff --git a/src/moonp.cpp b/src/moonp.cpp index 3f36d9d..ade1a1b 100644 --- a/src/moonp.cpp +++ b/src/moonp.cpp | |||
| @@ -247,7 +247,7 @@ static int moontolua(lua_State* L) { | |||
| 247 | } else { | 247 | } else { |
| 248 | lua_pushlstring(L, err.c_str(), err.size()); | 248 | lua_pushlstring(L, err.c_str(), err.size()); |
| 249 | } | 249 | } |
| 250 | if (globals && !globals->empty()) { | 250 | if (globals) { |
| 251 | lua_createtable(L, static_cast<int>(globals->size()), 0); | 251 | lua_createtable(L, static_cast<int>(globals->size()), 0); |
| 252 | int i = 1; | 252 | int i = 1; |
| 253 | for (const auto& var : *globals) { | 253 | for (const auto& var : *globals) { |
