From 43dde2fff316051d03968e8efd313f19b53112fc Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 21 Nov 2025 12:21:04 +0800 Subject: Updated syntax. * Added error check for mixed use of tabs and spaces. * Supported SimpleTable destructuring for ForEach syntax. --- spec/inputs/destructure.yue | 10 ++++++++++ spec/inputs/funcs.yue | 4 ++-- spec/inputs/string.yue | 4 ++-- spec/inputs/unicode/funcs.yue | 2 +- spec/inputs/unicode/vararg.yue | 4 ++-- spec/inputs/vararg.yue | 4 ++-- spec/inputs/with.yue | 4 ++-- 7 files changed, 21 insertions(+), 11 deletions(-) (limited to 'spec/inputs') diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue index b6250d0..179056c 100644 --- a/spec/inputs/destructure.yue +++ b/spec/inputs/destructure.yue @@ -278,5 +278,15 @@ do do {a, :abc, b, :def, ...sub, d, e} = tb +do + for {:a, :b} in *items + print a, b + + for :a, :b in *items + print a, b + + for :body in pairs data + print body if body + nil diff --git a/spec/inputs/funcs.yue b/spec/inputs/funcs.yue index 6b1669b..d19c2d1 100644 --- a/spec/inputs/funcs.yue +++ b/spec/inputs/funcs.yue @@ -98,7 +98,7 @@ f( x = (a, b) -> - print "what" + print "what" y = (a="hi", @@ -211,7 +211,7 @@ do print "kv:", k, v print "rest count:", select "#", ... macro gen = (fname) -> | - #{fname} = ({:a, :b = 0}) -> print a, b + #{fname} = ({:a, :b = 0}) -> print a, b $gen foo t1 = (:a, x) -> print a, x t2 = (:a) -> print a diff --git a/spec/inputs/string.yue b/spec/inputs/string.yue index 1f0fba8..611205d 100644 --- a/spec/inputs/string.yue +++ b/spec/inputs/string.yue @@ -100,8 +100,8 @@ do next: 123 str = | list: - - "one" - - "two" + - "one" + - "two" str = | -- comment content text diff --git a/spec/inputs/unicode/funcs.yue b/spec/inputs/unicode/funcs.yue index c563356..cb35500 100644 --- a/spec/inputs/unicode/funcs.yue +++ b/spec/inputs/unicode/funcs.yue @@ -98,7 +98,7 @@ _无效变量 = -> 真名 if 某物 变量x = (参数a, 参数b) -> - 打印 "什么" + 打印 "什么" 变量y = (参数a="hi", diff --git a/spec/inputs/unicode/vararg.yue b/spec/inputs/unicode/vararg.yue index e59e114..b508fbb 100644 --- a/spec/inputs/unicode/vararg.yue +++ b/spec/inputs/unicode/vararg.yue @@ -55,12 +55,12 @@ _ = -> 列表 = {1, 2, 3, 4, 5} 函数名 = (确定) -> - 确定, table.unpack 列表 + 确定, table.unpack 列表 确定, ... = 函数名 true 打印 确定, ... 多参数函数 = -> - 10, nil, 20, nil, 30 + 10, nil, 20, nil, 30 ... = 多参数函数! 打印 select "#", ... diff --git a/spec/inputs/vararg.yue b/spec/inputs/vararg.yue index 941cd97..6100250 100644 --- a/spec/inputs/vararg.yue +++ b/spec/inputs/vararg.yue @@ -55,12 +55,12 @@ join = (...) -> _ = -> list = {1, 2, 3, 4, 5} fn = (ok) -> - ok, table.unpack list + ok, table.unpack list ok, ... = fn true print ok, ... fn_many_args = -> - 10, nil, 20, nil, 30 + 10, nil, 20, nil, 30 ... = fn_many_args! print select "#", ... diff --git a/spec/inputs/with.yue b/spec/inputs/with.yue index 2256833..19ed2a7 100644 --- a/spec/inputs/with.yue +++ b/spec/inputs/with.yue @@ -167,7 +167,7 @@ do do a = for i = 1, 100 - with? x := tb[i] - break x if .id := 1 + with? x := tb[i] + break x if .id := 1 nil -- cgit v1.2.3-55-g6feb