aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-10-21 10:06:31 +0800
committerLi Jin <dragon-fly@qq.com>2022-10-21 10:06:31 +0800
commit3dd607c8887d2fe0186668aabca31bb84a41e2da (patch)
tree49c406e9b48d794f7004b0ddf1945b2c7014bc3a
parent6b6e98d062c7ec5f11be79ed5164aa59047dab30 (diff)
downloadyuescript-3dd607c8887d2fe0186668aabca31bb84a41e2da.tar.gz
yuescript-3dd607c8887d2fe0186668aabca31bb84a41e2da.tar.bz2
yuescript-3dd607c8887d2fe0186668aabca31bb84a41e2da.zip
fix issue #111.
-rw-r--r--spec/inputs/cond.yue7
-rw-r--r--spec/outputs/cond.lua10
-rw-r--r--src/yuescript/yue_compiler.cpp2
-rwxr-xr-xsrc/yuescript/yue_parser.cpp2
4 files changed, 19 insertions, 2 deletions
diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue
index 9981e93..638b5c3 100644
--- a/spec/inputs/cond.yue
+++ b/spec/inputs/cond.yue
@@ -219,6 +219,13 @@ do
219 :Thing = _M 219 :Thing = _M
220 :a, :b = _M 220 :a, :b = _M
221 221
222do
223 v = if 1 and do
224 0 ~= 1
225 1
226 else
227 2
228
222nil 229nil
223 230
224 231
diff --git a/spec/outputs/cond.lua b/spec/outputs/cond.lua
index 7764439..1f6aa63 100644
--- a/spec/outputs/cond.lua
+++ b/spec/outputs/cond.lua
@@ -335,4 +335,14 @@ do
335 end 335 end
336 end 336 end
337end 337end
338do
339 local v
340 if 1 and (function()
341 return 0 ~= 1
342 end)() then
343 v = 1
344 else
345 v = 2
346 end
347end
338return nil 348return nil
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 2be4498..ff55e0e 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -60,7 +60,7 @@ namespace yue {
60 60
61typedef std::list<std::string> str_list; 61typedef std::list<std::string> str_list;
62 62
63const std::string_view version = "0.15.5"sv; 63const std::string_view version = "0.15.6"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 f86afb4..ef700ae 100755
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -249,7 +249,7 @@ YueParser::YueParser() {
249 >> -Space >> Break >> SwitchBlock; 249 >> -Space >> Break >> SwitchBlock;
250 250
251 assignment = ExpList >> Assign; 251 assignment = ExpList >> Assign;
252 IfCond = disable_do_chain_arg_table_block(assignment | Exp); 252 IfCond = disable_chain(disable_arg_table_block(assignment | Exp));
253 IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("elseif") >> IfCond >> plain_body_with("then"); 253 IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("elseif") >> IfCond >> plain_body_with("then");
254 IfElse = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("else") >> plain_body; 254 IfElse = -(Break >> *EmptyLine >> CheckIndent) >> Space >> key("else") >> plain_body;
255 IfType = (expr("if") | expr("unless")) >> not_(AlphaNum); 255 IfType = (expr("if") | expr("unless")) >> not_(AlphaNum);