From 303834e1b1e6cd9cae64b66c2ae44dcd7185238f Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sun, 24 Jul 2022 22:13:08 +0800 Subject: add option --target=5.1 to generate Lua 5.1 compatible codes. add const destructure. make import item const by default. --- spec/inputs/destructure.yue | 5 ++++- spec/inputs/export.yue | 4 ++-- spec/inputs/import.yue | 2 +- spec/inputs/macro.yue | 2 +- spec/inputs/metatable.yue | 2 +- spec/inputs/syntax.yue | 10 +++++----- spec/inputs/tables.yue | 8 ++++---- spec/inputs/with.yue | 2 +- 8 files changed, 19 insertions(+), 16 deletions(-) (limited to 'spec/inputs') diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue index 3007adf..24282c0 100644 --- a/spec/inputs/destructure.yue +++ b/spec/inputs/destructure.yue @@ -11,7 +11,7 @@ do {:a,:b,:c,:d} = yeah - {a} = one, two + {a}, b = one, two {b}, c = one {d}, e = one, two @@ -184,3 +184,6 @@ do do {x: a.b = 1, y: a.c = 2} = x.x.x +do + const :width, :height = View.size + const {:x = 0.0, :y = 0.0} = point diff --git a/spec/inputs/export.yue b/spec/inputs/export.yue index 9113508..15ffbcb 100644 --- a/spec/inputs/export.yue +++ b/spec/inputs/export.yue @@ -55,7 +55,7 @@ f switch a f [i for i = 1,10] f for i = 1,10 do i f {k,v for k,v in pairs tb} -f for k,v in pairs tb do k,v +f for k,v in pairs tb do {k,v} f while a do true f with a .b = 123 @@ -70,7 +70,7 @@ _ = "#{switch a _ = "#{[i for i = 1,10]}" _ = "#{for i = 1,10 do i}" _ = "#{{k,v for k,v in pairs tb}}" -_ = "#{for k,v in pairs tb do k,v}" +_ = "#{for k,v in pairs tb do {k,v}}" _ = "#{while a do true}" _ = "#{with a .b = 123}" diff --git a/spec/inputs/import.yue b/spec/inputs/import.yue index 8e82a01..e206d04 100644 --- a/spec/inputs/import.yue +++ b/spec/inputs/import.yue @@ -70,7 +70,7 @@ do do import "m" as {a#: b} - import "m" as {e: f, a#: b} + import "m" as {e: f, a#: c} import "m" as {c: d} import "m" as {g, {h#: i}} diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue index 7bbb06d..3c89c1c 100644 --- a/spec/inputs/macro.yue +++ b/spec/inputs/macro.yue @@ -279,7 +279,7 @@ do macro skip = -> "while false do break" -_ = -> +_1 = -> print 1 <- $skip print 2 diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue index ed68a17..7e9b4f2 100644 --- a/spec/inputs/metatable.yue +++ b/spec/inputs/metatable.yue @@ -23,7 +23,7 @@ do = 123, a.b.c, func! x.abc, a.b.# = 123, {} -func!.# = mt, extra +func!.# = mt --, extra a, b.c.#, d, e = 1, mt, "abc" is_same = a.#.__index == a.index# diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index f212bec..d18bd0e 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue @@ -71,10 +71,10 @@ _ = something[======[hey]======] * 2 _ = something[ [======[hey]======] ] * 2 -_ = something'else', 2 -_ = something"else", 2 -_ = something[[else]], 2 -_ = something[ [[else]] ], 2 +_, _ = something'else', 2 +_, _ = something"else", 2 +_, _ = something[[else]], 2 +_, _ = something[ [[else]] ], 2 something 'else', 2 something "else", 2 @@ -157,7 +157,7 @@ y = #"hello" x = #{#{},#{1},#{1,2}} -_ = hello, world +_, _ = hello, world something\hello(what) a,b something\hello what diff --git a/spec/inputs/tables.yue b/spec/inputs/tables.yue index e1b9e1d..0b5af46 100644 --- a/spec/inputs/tables.yue +++ b/spec/inputs/tables.yue @@ -152,12 +152,12 @@ k = { "hello": 'world', "hat": "zat" } please "hello": "world" k = "hello": "world", "one": "zone" -f = "one", "two": three, "four" -f = "two": three, "four" -f = { "one", "two": three, "four" } +f1, f2, f3 = "one", "two": three, "four" +f1, f2 = "two": three, "four" +f1 = { "one", "two": three, "four" } -j = "one", "two": three, "four": five, 6, 7 +j1, j2, j3, j4 = "one", "two": three, "four": five, 6, 7 heroine = name: "Christina" diff --git a/spec/inputs/with.yue b/spec/inputs/with.yue index 6f3e3ba..5da0980 100644 --- a/spec/inputs/with.yue +++ b/spec/inputs/with.yue @@ -45,7 +45,7 @@ do -- do - with a, b -- b is lost + with a -- only one value allowed print .world mod = with _M = {} -- cgit v1.2.3-55-g6feb