diff options
author | Li Jin <dragon-fly@qq.com> | 2020-09-18 17:24:03 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-09-18 17:24:03 +0800 |
commit | 5b656d2913e4f9f0017698ec835ce4ddda1dc81f (patch) | |
tree | d5e4239aa264175b78f3c6aa72291c0c94f5055e | |
parent | 5e032607d83070ff6968a3fa3eabaf86a0ea2c2e (diff) | |
download | yuescript-5b656d2913e4f9f0017698ec835ce4ddda1dc81f.tar.gz yuescript-5b656d2913e4f9f0017698ec835ce4ddda1dc81f.tar.bz2 yuescript-5b656d2913e4f9f0017698ec835ce4ddda1dc81f.zip |
support inserting common expression item started with * symbol into a table block.
-rw-r--r-- | spec/inputs/tables.moon | 23 | ||||
-rw-r--r-- | src/MoonP/moon_ast.h | 2 | ||||
-rw-r--r-- | src/MoonP/moon_compiler.cpp | 2 | ||||
-rw-r--r-- | src/MoonP/moon_parser.cpp | 2 |
4 files changed, 26 insertions, 3 deletions
diff --git a/spec/inputs/tables.moon b/spec/inputs/tables.moon index 6375660..e816003 100644 --- a/spec/inputs/tables.moon +++ b/spec/inputs/tables.moon | |||
@@ -180,5 +180,28 @@ heroine = | |||
180 | * attribute: "mana" | 180 | * attribute: "mana" |
181 | value: 100 | 181 | value: 100 |
182 | 182 | ||
183 | inventory = | ||
184 | equipment: | ||
185 | * "sword" | ||
186 | * "shield" | ||
187 | items: | ||
188 | * name: "potion" | ||
189 | count: 10 | ||
190 | * name: "bread" | ||
191 | count: 3 | ||
192 | |||
193 | items = | ||
194 | * func! | ||
195 | * with tb | ||
196 | .abc = 123 | ||
197 | * {1, 2, 3} | ||
198 | * f {1, 2, 3} | ||
199 | * f | ||
200 | * 1 | ||
201 | * 2 | ||
202 | * 3 | ||
203 | * [i for i = 1, 3] | ||
204 | * "#{if a then b}" | ||
205 | |||
183 | nil | 206 | nil |
184 | 207 | ||
diff --git a/src/MoonP/moon_ast.h b/src/MoonP/moon_ast.h index 16f7801..90508a5 100644 --- a/src/MoonP/moon_ast.h +++ b/src/MoonP/moon_ast.h | |||
@@ -535,7 +535,7 @@ AST_END(TableBlockIndent) | |||
535 | 535 | ||
536 | AST_NODE(TableBlock) | 536 | AST_NODE(TableBlock) |
537 | ast_ptr<true, Seperator_t> sep; | 537 | ast_ptr<true, Seperator_t> sep; |
538 | ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t> values; | 538 | ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t, Exp_t> values; |
539 | AST_MEMBER(TableBlock, &sep, &values) | 539 | AST_MEMBER(TableBlock, &sep, &values) |
540 | AST_END(TableBlock) | 540 | AST_END(TableBlock) |
541 | 541 | ||
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 510b47e..8c0746f 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
@@ -54,7 +54,7 @@ inline std::string s(std::string_view sv) { | |||
54 | } | 54 | } |
55 | 55 | ||
56 | const std::string_view version() { | 56 | const std::string_view version() { |
57 | return "0.4.14"sv; | 57 | return "0.4.15"sv; |
58 | } | 58 | } |
59 | 59 | ||
60 | class MoonCompilerImpl { | 60 | class MoonCompilerImpl { |
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 394ce50..41db324 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
@@ -491,7 +491,7 @@ MoonParser::MoonParser() { | |||
491 | }); | 491 | }); |
492 | 492 | ||
493 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); | 493 | KeyValueList = KeyValue >> *(sym(',') >> KeyValue); |
494 | KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent); | 494 | KeyValueLine = CheckIndent >> (KeyValueList >> -sym(',') | TableBlockIndent | Space >> expr('*') >> Exp); |
495 | 495 | ||
496 | FnArgDef = (Variable | SelfName) >> -(sym('=') >> Space >> Exp); | 496 | FnArgDef = (Variable | SelfName) >> -(sym('=') >> Space >> Exp); |
497 | 497 | ||