diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-11-03 15:04:22 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-11-03 15:04:22 +0800 |
| commit | f641df51ecec17dbd24b476e271a4ee49ed6aded (patch) | |
| tree | f0a83f650a45037d33057dc913ca24ce04986dd3 | |
| parent | e07a2eb9c389f27103872a3b5a5bfe500d0c2d62 (diff) | |
| download | yuescript-f641df51ecec17dbd24b476e271a4ee49ed6aded.tar.gz yuescript-f641df51ecec17dbd24b476e271a4ee49ed6aded.tar.bz2 yuescript-f641df51ecec17dbd24b476e271a4ee49ed6aded.zip | |
fix issue #30
| -rw-r--r-- | spec/inputs/tables.mp | 16 | ||||
| -rw-r--r-- | src/MoonP/moon_ast.h | 2 | ||||
| -rw-r--r-- | src/MoonP/moon_compiler.cpp | 3 | ||||
| -rw-r--r-- | src/MoonP/moon_parser.cpp | 2 |
4 files changed, 20 insertions, 3 deletions
diff --git a/spec/inputs/tables.mp b/spec/inputs/tables.mp index e816003..2c6dff9 100644 --- a/spec/inputs/tables.mp +++ b/spec/inputs/tables.mp | |||
| @@ -203,5 +203,21 @@ items = | |||
| 203 | * [i for i = 1, 3] | 203 | * [i for i = 1, 3] |
| 204 | * "#{if a then b}" | 204 | * "#{if a then b}" |
| 205 | 205 | ||
| 206 | pairs = | ||
| 207 | * | ||
| 208 | * "king" | ||
| 209 | * "queen" | ||
| 210 | * | ||
| 211 | * "hero" | ||
| 212 | * "princess" | ||
| 213 | |||
| 214 | items = | ||
| 215 | * | ||
| 216 | name: "ring" | ||
| 217 | amount: 2 | ||
| 218 | * | ||
| 219 | name: "necklace" | ||
| 220 | amount: 1 | ||
| 221 | |||
| 206 | nil | 222 | nil |
| 207 | 223 | ||
diff --git a/src/MoonP/moon_ast.h b/src/MoonP/moon_ast.h index 02428ca..830234d 100644 --- a/src/MoonP/moon_ast.h +++ b/src/MoonP/moon_ast.h | |||
| @@ -549,7 +549,7 @@ AST_END(TableBlockIndent) | |||
| 549 | 549 | ||
| 550 | AST_NODE(TableBlock) | 550 | AST_NODE(TableBlock) |
| 551 | ast_ptr<true, Seperator_t> sep; | 551 | ast_ptr<true, Seperator_t> sep; |
| 552 | ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t, Exp_t> values; | 552 | ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t, Exp_t, TableBlock_t> values; |
| 553 | AST_MEMBER(TableBlock, &sep, &values) | 553 | AST_MEMBER(TableBlock, &sep, &values) |
| 554 | AST_END(TableBlock) | 554 | AST_END(TableBlock) |
| 555 | 555 | ||
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 138a6bf..6fdaa3c 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
| @@ -53,7 +53,7 @@ inline std::string s(std::string_view sv) { | |||
| 53 | return std::string(sv); | 53 | return std::string(sv); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | const std::string_view version = "0.4.20"sv; | 56 | const std::string_view version = "0.4.21"sv; |
| 57 | const std::string_view extension = "mp"sv; | 57 | const std::string_view extension = "mp"sv; |
| 58 | 58 | ||
| 59 | class MoonCompilerImpl { | 59 | class MoonCompilerImpl { |
| @@ -4785,6 +4785,7 @@ private: | |||
| 4785 | case id<variable_pair_t>(): transform_variable_pair(static_cast<variable_pair_t*>(pair), temp); break; | 4785 | case id<variable_pair_t>(): transform_variable_pair(static_cast<variable_pair_t*>(pair), temp); break; |
| 4786 | case id<normal_pair_t>(): transform_normal_pair(static_cast<normal_pair_t*>(pair), temp); break; | 4786 | case id<normal_pair_t>(): transform_normal_pair(static_cast<normal_pair_t*>(pair), temp); break; |
| 4787 | case id<TableBlockIndent_t>(): transformTableBlockIndent(static_cast<TableBlockIndent_t*>(pair), temp); break; | 4787 | case id<TableBlockIndent_t>(): transformTableBlockIndent(static_cast<TableBlockIndent_t*>(pair), temp); break; |
| 4788 | case id<TableBlock_t>(): transformTableBlock(static_cast<TableBlock_t*>(pair), temp); break; | ||
| 4788 | default: assert(false); break; | 4789 | default: assert(false); break; |
| 4789 | } | 4790 | } |
| 4790 | temp.back() = indent() + temp.back() + (pair == pairs.back() ? Empty : s(","sv)) + nll(pair); | 4791 | temp.back() = indent() + temp.back() + (pair == pairs.back() ? Empty : s(","sv)) + nll(pair); |
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 63eabb3..8b9ead4 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
| @@ -489,7 +489,7 @@ MoonParser::MoonParser() { | |||
| 489 | KeyValue = variable_pair | normal_pair; | 489 | KeyValue = variable_pair | normal_pair; |
| 490 | 490 | ||
| 491 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); | 491 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); |
| 492 | KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent | Space >> expr('*') >> Exp); | 492 | KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent | Space >> expr('*') >> (Exp | TableBlock)); |
| 493 | 493 | ||
| 494 | FnArgDef = (Variable | SelfName) >> -(sym('=') >> Space >> Exp); | 494 | FnArgDef = (Variable | SelfName) >> -(sym('=') >> Space >> Exp); |
| 495 | 495 | ||
