📝 docs(tsl): clarify syntax constraints and enhance test infrastructure
- Add TSF file naming constraint to syntax/02_core_model.md - Clarify semicolon rules: syntax facts vs style preferences - Separate control flow end semicolon rules (syntax allows both) - Add function body semicolon requirements to syntax/05_functions_and_calls.md - Move style preferences to code_style.md (control flow end semicolons) - Remove cross-references from syntax docs to maintain independence - Enhance Gitea workflow emoji for better CI output readability - Fix CI test path from tests/ to test/ - Organize agent test results under test/agent/result/ directory - Add complete Chinese translation of test cases (test_cases_zh.md) - Clean up .gitignore to use unified test/agent/result/ directory - Remove obsolete agent test artifacts (REPORTS_LOCATION.md, old results) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,18 +16,19 @@
|
||||
|
||||
1. 先判断任务需要条件分支、循环、`case`、异常处理还是调试跳转。
|
||||
2. `if` / `for` / `while` / `repeat` 优先照本页文档骨架写,不要套用其他 Pascal 方言。
|
||||
3. 生成带 `else` 的条件分支时,默认用 `begin ... end` 包住 `then` 和 `else` 分支,让分支内部语句正常以分号结尾;控制流块的 `end` 默认不加分号,也不要在 `else` 前提前加分号。
|
||||
3. 生成带 `else` 的条件分支时,默认用 `begin ... end` 包住 `then` 和 `else` 分支,让分支内部语句正常以分号结尾;不要在 `else` 前提前加分号。
|
||||
4. `case` 可写成语句形态,也可写成赋值右侧的表达式形态;表达式形态的分支只能放单条表达式/单条语句,不写 `begin ... end` 语句段。
|
||||
5. 没有文档事实时不要发明控制流写法。
|
||||
|
||||
## 核心规则
|
||||
|
||||
- `if ... then ... else ...` 默认写成块式分支:`then begin ... end else begin ... end`。
|
||||
- 块式分支内部的普通语句照常用分号结尾;语句形态的控制流块 `end` 默认不加分号。
|
||||
- 块式分支内部的普通语句必须用分号结尾。
|
||||
- 控制流块的 `begin ... end` 后可以加分号也可以不加(语法都允许)。
|
||||
- `for` 支持 `to`、`downto`、可选 `step`,以及 `for i, v in array` 遍历。
|
||||
- `while` 和 `repeat ... until` 都可直接使用;`repeat` 至少会先执行一轮再判断结束条件。
|
||||
- `break` 会跳出当前最近一层循环,`continue` 会跳过当前轮剩余语句。
|
||||
- `case ... of ... else ... end` 可作为语句形态生成;语句形态的 `end` 后默认不加分号。
|
||||
- `case ... of ... else ... end` 可作为语句形态生成;`end` 后可以加分号也可以不加。
|
||||
- `value := case ... of ... else ... end;` 可作为表达式形态生成;表达式形态赋值语句本身要用分号结尾。
|
||||
- `case` 分支标签支持逗号并列和 `to` 区间。
|
||||
- `try ... except ... end` 可以捕获 `raise` 产生的错误,并继续执行后续语句。
|
||||
|
||||
Reference in New Issue
Block a user