aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/unicode/macro_export.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/macro_export.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/macro_export.yue')
-rw-r--r--spec/inputs/unicode/macro_export.yue49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/inputs/unicode/macro_export.yue b/spec/inputs/unicode/macro_export.yue
new file mode 100644
index 0000000..3c9a942
--- /dev/null
+++ b/spec/inputs/unicode/macro_export.yue
@@ -0,0 +1,49 @@
1import "unicode.macro_todo" as $
2import "unicode.macro_todo" as {$, $todo: $待办}
3
4export macro 配置 = (调试 = true)->
5 global 调试模式 = 调试 == "true"
6 global 调试宏 = true
7 ""
8
9export macro 显示宏 = (名称, 结果)->
10 if 调试宏 then "
11do
12 文本 = #{结果}
13 print '[宏 ' .. #{名称} .. ']'
14 print 文本
15 文本
16"
17 else
18 结果
19
20export macro 断言集 = (条件)->
21 if 调试模式
22 $显示宏 "断言集", "assert #{条件}"
23 else
24 ""
25
26export macro 断言 = (条件)->
27 if 调试模式
28 $显示宏 "断言", "assert #{条件}"
29 else
30 "#{条件}"
31
32export macro 复制 = (源, 目标, ...)->
33 $断言集(
34 源 != "_源_" and 源 != "_目标_" and 目标 != "_源_" and 目标 != "_目标_"
35 "复制目标的参数不能是 _源_ or _目标_"
36 )
37 "
38do
39 local _源_, _目标_
40 with _目标_ = #{目标}
41 with _源_ = #{源}
42#{table.concat for 字段 in *{...} do "
43 _目标_.#{字段} = _源_.#{字段}
44"}"
45
46$ ->
47 global 调试模式 = true
48 global 调试宏 = true
49