📝 docs(tsl): align agent-facing guidance

This commit is contained in:
csh
2026-05-28 19:12:34 +08:00
parent c48354e0cb
commit d8eb418277
63 changed files with 1921 additions and 371 deletions
+15 -1
View File
@@ -14,6 +14,14 @@
回答“`if``case``for``while``repeat``break``continue``try``raise` 这些流程结构在 TSL 里到底怎么写,哪些写法已经被当前解释器实测验证过”。
## Agent 控制流判断流程
1. 先判断任务需要条件分支、循环、`case`、异常处理还是调试跳转。
2. `if` / `for` / `while` / `repeat` 优先照本页已验证骨架写,不要套用其他 Pascal 方言。
3. 需要多条语句时再补 `begin ... end`,不要在 `else` 前提前加分号。
4. `case` 表达式和 `case` 语句分开判断;`@case` 不作为默认主写法。
5. 没有已验证代码块时不要发明控制流写法。
## 必须记住的规则
- `if ... then ... else ...` 可以直接跟单条语句;需要多条语句时再补 `begin ... end`
@@ -78,6 +86,12 @@ WriteLn(s);
- 输出 `9`
代码块身份:已验证输出片段
```text
9
```
`step``downto` 递减循环:
代码块身份:已验证可执行示例
@@ -365,7 +379,7 @@ end;
WriteLn(b);
```
我在 `2026-04-13` 用当前解释器实测,上面这类最小例子输出的是 `<STREXP>`,不能把它当成普通 `case` 表达式的可靠主语法写进新 session 默认生成结果。
当前已验证结果显示,上面这类最小例子输出的是 `<STREXP>`,不能把它当成普通 `case` 表达式的可靠主语法写进新 session 默认生成结果。
## 跳转指引