From f641df51ecec17dbd24b476e271a4ee49ed6aded Mon Sep 17 00:00:00 2001
From: Li Jin <dragon-fly@qq.com>
Date: Tue, 3 Nov 2020 15:04:22 +0800
Subject: fix issue #30

---
 spec/inputs/tables.mp       | 16 ++++++++++++++++
 src/MoonP/moon_ast.h        |  2 +-
 src/MoonP/moon_compiler.cpp |  3 ++-
 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 =
 	* [i for i = 1, 3]
 	* "#{if a then b}"
 
+pairs =
+	*
+		* "king"
+		* "queen"
+	*
+		* "hero"
+		* "princess"
+
+items =
+	*
+		name: "ring"
+		amount: 2
+	*
+		name: "necklace"
+		amount: 1
+
 nil
 
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)
 
 AST_NODE(TableBlock)
 	ast_ptr<true, Seperator_t> sep;
-	ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t, Exp_t> values;
+	ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t, Exp_t, TableBlock_t> values;
 	AST_MEMBER(TableBlock, &sep, &values)
 AST_END(TableBlock)
 
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) {
 	return std::string(sv);
 }
 
-const std::string_view version = "0.4.20"sv;
+const std::string_view version = "0.4.21"sv;
 const std::string_view extension = "mp"sv;
 
 class MoonCompilerImpl {
@@ -4785,6 +4785,7 @@ private:
 				case id<variable_pair_t>(): transform_variable_pair(static_cast<variable_pair_t*>(pair), temp); break;
 				case id<normal_pair_t>(): transform_normal_pair(static_cast<normal_pair_t*>(pair), temp); break;
 				case id<TableBlockIndent_t>(): transformTableBlockIndent(static_cast<TableBlockIndent_t*>(pair), temp); break;
+				case id<TableBlock_t>(): transformTableBlock(static_cast<TableBlock_t*>(pair), temp); break;
 				default: assert(false); break;
 			}
 			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() {
 	KeyValue = variable_pair | normal_pair;
 
 	KeyValueList = KeyValue >> *(sym(',') >> KeyValue);
-	KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent | Space >> expr('*') >> Exp);
+	KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent | Space >> expr('*') >> (Exp | TableBlock));
 
 	FnArgDef = (Variable | SelfName) >> -(sym('=') >> Space >> Exp);
 
-- 
cgit v1.2.3-55-g6feb