aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/inputs/whitespace.yue23
-rw-r--r--spec/outputs/whitespace.lua12
-rw-r--r--src/yuescript/stacktraceplus.h2
-rw-r--r--src/yuescript/yue_compiler.cpp2
-rw-r--r--src/yuescript/yue_parser.cpp18
-rw-r--r--src/yuescript/yue_parser.h4
6 files changed, 54 insertions, 7 deletions
diff --git a/spec/inputs/whitespace.yue b/spec/inputs/whitespace.yue
index 329280f..2655961 100644
--- a/spec/inputs/whitespace.yue
+++ b/spec/inputs/whitespace.yue
@@ -97,6 +97,29 @@ b(
97c(one, two, 97c(one, two,
98 three, four) 98 three, four)
99 99
100d(
101 one -- one
102 two -- two
103 three -- three
104 four -- four
105)
106
107e(
108 ->
109 ->
110 ->
111)
112e{
113 ->
114 ->
115 ->
116}
117e[
118 ->
119 ->
120 ->
121]
122
100-- 123--
101 124
102v = -> 125v = ->
diff --git a/spec/outputs/whitespace.lua b/spec/outputs/whitespace.lua
index 1bc4503..0251968 100644
--- a/spec/outputs/whitespace.lua
+++ b/spec/outputs/whitespace.lua
@@ -77,6 +77,18 @@ end
77a(one, two, three) 77a(one, two, three)
78b(one, two, three) 78b(one, two, three)
79c(one, two, three, four) 79c(one, two, three, four)
80d(one, two, three, four)
81e(function() end, function() end, function() end)
82e({
83 function() end,
84 function() end,
85 function() end
86})
87e({
88 function() end,
89 function() end,
90 function() end
91})
80local v 92local v
81v = function() 93v = function()
82 return a, b, c 94 return a, b, c
diff --git a/src/yuescript/stacktraceplus.h b/src/yuescript/stacktraceplus.h
index 6025daa..3167ba8 100644
--- a/src/yuescript/stacktraceplus.h
+++ b/src/yuescript/stacktraceplus.h
@@ -345,7 +345,7 @@ local function getYueLineNumber(fname, line)
345 if source then 345 if source then
346 local current, target = 1, tonumber(line) 346 local current, target = 1, tonumber(line)
347 local findLine = line 347 local findLine = line
348 for lineCode in source:gmatch("[^\n\r]*") do 348 for lineCode in source:gmatch("([^\r\n]*)\r?\n?") do
349 local num = lineCode:match("--%s*(%d+)%s*$") 349 local num = lineCode:match("--%s*(%d+)%s*$")
350 if num then 350 if num then
351 findLine = num 351 findLine = num
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 8c4afce..69a028f 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -75,7 +75,7 @@ static std::unordered_set<std::string> Metamethods = {
75 "close"s // Lua 5.4 75 "close"s // Lua 5.4
76}; 76};
77 77
78const std::string_view version = "0.20.6"sv; 78const std::string_view version = "0.20.7"sv;
79const std::string_view extension = "yue"sv; 79const std::string_view extension = "yue"sv;
80 80
81class CompileError : public std::logic_error { 81class CompileError : public std::logic_error {
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index 11c7627..2206686 100644
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -617,11 +617,21 @@ YueParser::YueParser() {
617 617
618 Parens = '(' >> *space_break >> space >> Exp >> *space_break >> space >> ')'; 618 Parens = '(' >> *space_break >> space >> Exp >> *space_break >> space >> ')';
619 Callable = Variable | SelfItem | MacroName | Parens; 619 Callable = Variable | SelfItem | MacroName | Parens;
620 fn_args_exp_list = space >> Exp >> space >> *((line_break | ',') >> white >> Exp); 620
621 fn_args_value_list = Exp >> *(space >> ',' >> space >> Exp);
622
623 fn_args_lit_line = (
624 push_indent_match >> (space >> fn_args_value_list >> pop_indent | pop_indent)
625 ) | (
626 space
627 );
628
629 fn_args_lit_lines = space_break >> fn_args_lit_line >> *(-(space >> ',') >> space_break >> fn_args_lit_line) >> -(space >> ',');
621 630
622 fn_args = 631 fn_args =
623 '(' >> *space_break >> -fn_args_exp_list >> *space_break >> space >> ')' | 632 '(' >> -(space >> fn_args_value_list >> -(space >> ',')) >>
624 space >> '!' >> not_('='); 633 -fn_args_lit_lines >>
634 white >> ')' | space >> '!' >> not_('=');
625 635
626 meta_index = Name | index | String; 636 meta_index = Name | index | String;
627 Metatable = '<' >> space >> '>'; 637 Metatable = '<' >> space >> '>';
@@ -701,7 +711,7 @@ YueParser::YueParser() {
701 table_lit_lines = space_break >> table_lit_line >> *(-(space >> ',') >> space_break >> table_lit_line) >> -(space >> ','); 711 table_lit_lines = space_break >> table_lit_line >> *(-(space >> ',') >> space_break >> table_lit_line) >> -(space >> ',');
702 712
703 TableLit = 713 TableLit =
704 space >> '{' >> Seperator >> 714 '{' >> Seperator >>
705 -(space >> table_value_list >> -(space >> ',')) >> 715 -(space >> table_value_list >> -(space >> ',')) >>
706 -table_lit_lines >> 716 -table_lit_lines >>
707 white >> '}'; 717 white >> '}';
diff --git a/src/yuescript/yue_parser.h b/src/yuescript/yue_parser.h
index 8156ae2..16b57b2 100644
--- a/src/yuescript/yue_parser.h
+++ b/src/yuescript/yue_parser.h
@@ -217,7 +217,9 @@ private:
217 NONE_AST_RULE(double_string_plain); 217 NONE_AST_RULE(double_string_plain);
218 NONE_AST_RULE(lua_string_open); 218 NONE_AST_RULE(lua_string_open);
219 NONE_AST_RULE(lua_string_close); 219 NONE_AST_RULE(lua_string_close);
220 NONE_AST_RULE(fn_args_exp_list); 220 NONE_AST_RULE(fn_args_value_list);
221 NONE_AST_RULE(fn_args_lit_line);
222 NONE_AST_RULE(fn_args_lit_lines);
221 NONE_AST_RULE(fn_args); 223 NONE_AST_RULE(fn_args);
222 NONE_AST_RULE(destruct_def); 224 NONE_AST_RULE(destruct_def);
223 NONE_AST_RULE(macro_args_def); 225 NONE_AST_RULE(macro_args_def);