aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/unicode/metatable.yue
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-08-17 10:36:15 +0800
committerLi Jin <dragon-fly@qq.com>2023-08-17 10:36:15 +0800
commite61cce21ef7def2c2e52dd6cb6a5b540ebcac29d (patch)
tree6e7c5e7e6f13157e9f8db26c38f6d8cba75683e5 /spec/inputs/unicode/metatable.yue
parent289faf45ac26f7e0ac1a1e4305e5c42fc1e5b866 (diff)
downloadyuescript-e61cce21ef7def2c2e52dd6cb6a5b540ebcac29d.tar.gz
yuescript-e61cce21ef7def2c2e52dd6cb6a5b540ebcac29d.tar.bz2
yuescript-e61cce21ef7def2c2e52dd6cb6a5b540ebcac29d.zip
add unicode identifier support, fix more issue from #144
Diffstat (limited to 'spec/inputs/unicode/metatable.yue')
-rw-r--r--spec/inputs/unicode/metatable.yue87
1 files changed, 87 insertions, 0 deletions
diff --git a/spec/inputs/unicode/metatable.yue b/spec/inputs/unicode/metatable.yue
new file mode 100644
index 0000000..1b7cb7b
--- /dev/null
+++ b/spec/inputs/unicode/metatable.yue
@@ -0,0 +1,87 @@
1变量a = 关闭: true, <close>: => 打印 "离开作用域"
2变量b = <add>: (左, 右)-> 右 - 左
3变量c = 键1: true, :<add>, 键2: true
4变量w = <[名称]>:123, <"新建">:(值)=> {值}
5变量w.<>["新建"] 变量w.<>[名称]
6
7do close _ = <close>: -> 打印 "离开作用域"
8
9变量d, 变量e = 变量a.关闭, 变量a.<close>
10
11变量f = 变量a\<close> 1
12变量a.<add> = (x, y)-> x + y
13
14do
15 {:新, :<close>, <close>: 关闭A} = 变量a
16 打印 新, close, 关闭A
17
18do
19 local *
20 变量x, \
21 {:新, :变量, :<close>, <close>: 关闭A}, \
22 :num, :<add>, :<sub> \
23 = 123, 变量a.变量b.变量c, 函数!
24
25变量x.abc, 变量a.变量b.<> = 123, {}
26函数!.<> = mt --, 额外
27变量a, 变量b.变量c.<>, 变量d, 变量e = 1, mt, "abc", nil
28
29相同 = 变量a.<>.__index == 变量a.<index>
30
31--
32变量a.<> = __index: 表
33变量a.<>.__index = 表
34变量a.<index> = 表
35--
36
37mt = 变量a.<>
38
39表\函数 #列表
40表\<"函数">列表
41表\<"函数"> 列表
42
43import "模块" as :<index>, <newindex>:设置函数
44
45with 表
46 打印 .<add>, .x\<index> "key"
47 变量a = .<index>.<add>\<"新建"> 123
48 变量b = t#.<close>.测试
49 变量c = t #.<close> .测试
50
51<>:mt = 变量a
52变量a = <>:mt
53变量a = <>:__index:mt
54
55local index
56<>:__index:索引 = 变量a
57:<index> = 变量a
58
59do <>:{新:构造, :更新} = 变量a
60do {新:构造, :更新} = 变量a.<>
61
62表 = {}
63do
64 变量f = 表\<"值#{x < y}">(123, ...)
65 变量f 表\<'值'> 123, ...
66 表\<[[
67
68 1
69 ]]>(123, ...)
70 return 表\<["值" .. tostring x > y]>(123, ...)
71
72do
73 变量f = 表\<'值'>(123, ...)
74 变量f 表\<'值'>(123, ...)
75 表\<'值'>(123, ...)
76 return 表\<'值'> 123, ...
77
78do
79 变量f = 表.<["值"]> 123, ...
80 变量f = 表.<"值#{x < y}">(123, ...)
81 变量f 表.<'值'> 123, ...
82 表.<[[ 值
831]]>(123, ...)
84 return 表.<["值" .. tostring x > y]>(123, ...)
85
86nil
87