summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/inputs/cond.yue16
-rw-r--r--spec/outputs/cond.lua30
-rwxr-xr-xsrc/yuescript/yue_compiler.cpp2
-rwxr-xr-xsrc/yuescript/yue_parser.cpp2
4 files changed, 48 insertions, 2 deletions
diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue
index 3dee99b..d33eec4 100644
--- a/spec/inputs/cond.yue
+++ b/spec/inputs/cond.yue
@@ -182,7 +182,23 @@ m = if 1
182 182
183else 6 183else 6
184 184
185do
186 a
187 :b
188 return if a
189 :b
190 else if c
191 d: e
192 else
193 f: 123
185 194
195do
196 c
197 d: e
198 if a
199 :b = tb
200 elseif c
201 d: e = tb
186 202
187nil 203nil
188 204
diff --git a/spec/outputs/cond.lua b/spec/outputs/cond.lua
index 5efa237..8f69e97 100644
--- a/spec/outputs/cond.lua
+++ b/spec/outputs/cond.lua
@@ -269,4 +269,34 @@ if 1 then
269else 269else
270 m = 6 270 m = 6
271end 271end
272do
273 a({
274 b = b
275 })
276 if a then
277 return {
278 b = b
279 }
280 else
281 if c then
282 return {
283 d = e
284 }
285 else
286 return {
287 f = 123
288 }
289 end
290 end
291end
292do
293 c({
294 d = e
295 })
296 if a then
297 b = tb.b
298 elseif c then
299 local e = tb.d
300 end
301end
272return nil 302return nil
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 15a785a..6295eb7 100755
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -60,7 +60,7 @@ using namespace parserlib;
60 60
61typedef std::list<std::string> str_list; 61typedef std::list<std::string> str_list;
62 62
63const std::string_view version = "0.9.4"sv; 63const std::string_view version = "0.9.5"sv;
64const std::string_view extension = "yue"sv; 64const std::string_view extension = "yue"sv;
65 65
66class YueCompilerImpl { 66class YueCompilerImpl {
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index 9257fab..03639c3 100755
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -236,7 +236,7 @@ YueParser::YueParser() {
236 Switch = Space >> key("switch") >> disable_do(Exp) >> -(Space >> key("do")) 236 Switch = Space >> key("switch") >> disable_do(Exp) >> -(Space >> key("do"))
237 >> -Space >> Break >> SwitchBlock; 237 >> -Space >> Break >> SwitchBlock;
238 238
239 IfCond = disable_chain(Exp >> -Assign); 239 IfCond = disable_do_chain(disable_arg_table_block(Exp >> -Assign));
240 IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("elseif") >> IfCond >> plain_body_with("then"); 240 IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("elseif") >> IfCond >> plain_body_with("then");
241 IfElse = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("else") >> plain_body; 241 IfElse = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("else") >> plain_body;
242 IfType = (expr("if") | expr("unless")) >> not_(AlphaNum); 242 IfType = (expr("if") | expr("unless")) >> not_(AlphaNum);