🐛 fix(tsl_syntax): repair lookup engine and reconcile reference facts

lookup.py: exempt code-anchored ASCII identifiers from the mixed
zh/en gate so exact hits are no longer dropped; dedup parent/child
sections in results; validate write-prelude anchors in --check.

references: correct interpreter-verified facts (case-as-expression,
control-flow semicolons, __line__/__stack_frame, tslObjects order,
destroy timing, ErrDefine, truncated outputs), fix headings, scope
qualifiers and reversed quotes; strip dead preamble metadata from all
24 pages.

packaging: exclude __pycache__/*.pyc from playbook and bundle copies;
update build test file-count assertion to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
csh
2026-07-13 09:16:57 +08:00
co-authored by Claude Fable 5
parent 923bce91b0
commit b597edfc70
29 changed files with 356 additions and 256 deletions
@@ -1,10 +1,5 @@
# TSL 运行时上下文、服务与全局缓存
文档类型:语法主线
是否可直接用于生成代码:仅部分
是否含可直接照写示例:是
是否含不可照写反例:是
这一篇只处理运行时环境参数、块环境 `with` 语句、`with` 后缀、`#` 网格调用、`timeout` 后缀、`dupvalue(...)` 和全局缓存,不处理任何金融业务语义。
## 本篇职责
@@ -48,6 +43,8 @@
## 可直接照写示例
### `setSysParam` / `getSysParam` / `sysParams[...]` 基础读写
直接设置和读取系统参数:
代码块身份:可直接照写示例
@@ -163,7 +160,9 @@ writeLn(getSysParam("b"));
- 块后输出 `1``9`
- 说明 `with **` 不继承未传入的外层系统参数,并且块结束后恢复外层系统参数
沿用同一个 `TestDo.tsf`,看 `with array(...)` 的覆盖边界:
### 后缀 `with array(...)`:网格调用的临时覆盖
`#Func(...) with array(...)` 在一次网格调用里临时覆盖系统参数,调用结束后恢复外层原值。下面用一个 `TestDo.tsf` 演示覆盖边界:
代码块身份:配置片段 / 概念骨架
代码块说明:多文件结构骨架;依赖函数文件查找路径,不是可直接复制的单文件最小示例。
@@ -193,7 +192,7 @@ writeLn(getSysParam("b"));
- 调用结束后,外层 `getSysParam("b")` 输出 `8`
- 说明 `with array(...)` 是“只在该次调用里临时覆盖,再恢复外部原值”
沿用上一个 `TestDo.tsf`,只把 `main.tsl` 改成下面这样:
沿用上面的 `TestDo.tsf`,只把 `main.tsl` 改成下面这样(外层未预设参数)
代码块身份:配置片段 / 概念骨架
代码块说明:多文件结构骨架;依赖函数文件查找路径,不是可直接复制的单文件最小示例。
@@ -231,7 +230,7 @@ end;
结果说明:
- `#AddOne(5)` 可以执行
- `dupvalue(r)` 返回最终结果 `6`
- `dupvalue(#AddOne(5))` 返回最终结果 `6`
代码块身份:输出片段
@@ -303,9 +302,7 @@ writeLn(cached_data[0], ',', cached_data[1], ',', cached_data[2]);
说明:
- TSL 标识符大小写无关,`setGlobalCache``SetGlobalCache` 等价
- 推荐使用小写 `setGlobalCache``getGlobalCache` 以保持一致性
- `setGlobalCache(key, value)` 写入缓存,可选第三参数指定过期时间(秒)
- `getGlobalCache(key, out_var)` 读取缓存到输出变量
- 示例只展示 `setGlobalCache(key, value)` / `getGlobalCache(key, out_var)` 的最小调用形态;完整参数规格(含过期时间等可选参数)用 `tsl-api-reference` skill 按名查询
### `checkGlobalCacheExpired`
@@ -324,7 +321,7 @@ writeLn(checkGlobalCacheExpired(cache_ref));
- 刚取出的缓存引用上,`checkGlobalCacheExpired(cache_ref)` 返回 `0`
- 同名缓存被重新设置后,旧引用上的 `checkGlobalCacheExpired(cache_ref)` 返回 `1`
### 写入后会实例化
### 缓存值本地写入后会实例化
代码块身份:可直接照写示例
@@ -398,7 +395,7 @@ begin
end;
```
需要缓存时, `setGlobalCache` / `getGlobalCache` 那一节选择模板
需要缓存时,默认模板是 `setGlobalCache(key, value)` 写入、`getGlobalCache(key, out_var)` 读取
## 禁止项