Implement table semantic T0-T4: map/records/footnote get

- 1-col table stays a List; >=2-col becomes a column-oriented Map
  (1 data row -> scalar values, >=2 -> Map of Lists).
- First header @ / 行 / row opts into row-oriented List of Maps
  (marker column excluded); missing field cols is a diagnostic.
- Footnote index: `xs`[^1] (1-based list), `m`[^key] (map key), chained.
  Errors for [^0], out-of-range, missing key, duplicate headers.
- foreach walks list items or map keys; Map values now display as {k: v}.
- Sync both tree and bytecode backends; new gold + error fixtures, docs
  (markdown-mapping, roadmap, skill, public), and public 07/08 pages.
- Fix subtask-spawn fixture return value to child_ok (child-ok parses as
  subtraction).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-10 09:50:21 +08:00
1 parent 3463628165
commit a23fdedfa2
37 files changed
+846 -51

No files matched your search

+1 -1
View File
@@ -54,7 +54,7 @@
| [roadmap/okf-near-match.md](roadmap/okf-near-match.md) | **规划:OKF 相近任务命中**(精确 sig 之外的可选软复用) |
| [roadmap/agent-streaming.md](roadmap/agent-streaming.md) | **规划:智能体 / LLM 流式输出**(事件模型 + step/plan 透传) |
| [roadmap/object-inheritance.md](roadmap/object-inheritance.md) | **规划:对象继承**(`# 子类 = > 父类`) |
| [roadmap/tables-maps-footnotes.md](roadmap/tables-maps-footnotes.md) | **规划:表格语义**(竖表列表 / 横表字典 / 脚注取元) |
| [roadmap/tables-maps-footnotes.md](roadmap/tables-maps-footnotes.md) | **表格语义**(竖表 / 横表字典 / 脚注取元 / 行向记录;T0–T4 已落地) |
| [roadmap/ext-web.md](roadmap/ext-web.md) | **规划:`ext/web` 动态网页**(env/DB init·迁移·样式脚手架·ABI) |
| [roadmap/ext-quantum.md](roadmap/ext-quantum.md) | **规划:`ext/quantum` 量子模拟**(基础门·电路·ABI·`ext add`) |
| [research/okf-and-marqdo.md](research/okf-and-marqdo.md) | OKF 调研 |
+34 -2
View File
@@ -242,9 +242,41 @@ Markdown **标记即语法**。输出**不是**语言架构原语,而是内置
## 9. 集合(表格)
同 v0。`` `篮子` = `` 后接 GFM 表;**当前落地:单列竖表 → 列表**。
`` `名` = `` 后接 GFM 表;几何决定值类型(详见 [tables-maps-footnotes.md](../roadmap/tables-maps-footnotes.md)):
横表字典、多行嵌套、脚注取元属未来规划,见 [tables-maps-footnotes.md](../roadmap/tables-maps-footnotes.md)。
| 形状 | 值 |
|------|-----|
| **1 列**(竖表) | `List`(表头 = foreach 元素名,不进入元素) |
| **≥2 列 + 1 行数据**(横表) | `Map`:键 = 表头,值 = 该列标量 |
| **≥2 列 + ≥2 行数据** | `Map`:键 = 表头,值 = 该列 `List`(列向) |
| **≥2 列 + 0 行数据** | `Map`:键存在,值为空列表 |
| **首列表头 `@` / `行` / `row`** | **行向** `List` of `Map`(标记列不进入字段;任意数据行数) |
| 重复表头 | 诊断错误 |
行向示例:
```markdown
`订单` =
| 行 | 品名 | 数量 |
|----|------|------|
| 1 | 苹果 | 2 |
| 2 | 梨 | 3 |
*`名` = `订单`[^1][^品名] *
```
**脚注取元**(表达式级,1-based 列表下标 / 字典键;可链式):
```markdown
*`第一` = `篮子`[^1] *
*`种` = `分类`[^苹果] *
*`第一种苹果` = `货架`[^苹果][^1] *
```
- 文末 `[^1]: …` 定义块仍是注释,与取元无关。
- `[^0]`、越界、缺键 → 报错。
- foreach:`List` 遍历元素;`Map` 遍历**键**(值用脚注取)。
---
+34 -9
View File
@@ -2,8 +2,8 @@
| | |
|---|---|
| 状态 | **规划 / 未开工** |
| 日期 | 2026-08-09 |
| 状态 | **T0–T4 已落地** |
| 日期 | 2026-08-10 |
| 相关 | [markdown-mapping.md](../design/markdown-mapping.md) §9 · [objects.md](../design/objects.md) · [stdlib.md](../design/stdlib.md)(`lib/table`) · [keywords.md](../design/keywords.md) |
| 现状金样 | [tests/structure/collection.mq.md](../../tests/structure/collection.mq.md) |
@@ -137,9 +137,33 @@
| ≥2 | ≥2 | `Map`(值均为 `List`) |
| ≥2 | 0 | `Map`(键存在,值空列表或错误——开工时锁定为「空列表」) |
### 3.5 显式形态标记(可选,二期)
### 3.5 显式形态标记(行向记录)— **已落地**
若必须支持行向记录,可用表标题行或首列表头约定,例如首列表头为 `@` / `行` 时改行向——**仅当默认列向不够用再开**;v1 文档只教默认。
首列表头为下列之一时,整表改为**行向**(不静默混用列向默认):
| 标记 | 说明 |
|------|------|
| `@` | ASCII 短标记 |
| `行` | 中文 |
| `row` | 英文 |
规则:
1. 标记列**不进入**记录字段(数据格可写行号给人看)。
2. 其余列 → 每行一个 `Map`;整体为 `List`。
3. 须至少有一列字段(仅 `| 行 |` → 诊断)。
4. 数据行数任意(含 0 → 空列表;1 行仍是 `List` of one `Map`,不是列向 `Map`)。
```markdown
`订单` =
| 行 | 品名 | 数量 |
|----|------|------|
| 1 | 苹果 | 2 |
| 2 | 梨 | 3 |
```
→ `[{品名: 苹果, 数量: 2}, {品名: 梨, 数量: 3}]`。取元:`` `订单`[^1][^品名] ``。
---
@@ -228,11 +252,11 @@
## 6. 推荐落地顺序
```text
T0 横表单行 → Map;金样;竖表回归
T1 横表多行 → Map of List(列向);嵌套金样
T2 脚注取元:List [^n]、Map [^键]、链式
T3 文档:markdown-mapping §9 重写;Skill / examples;table 库说明对齐
T4 (可选)行向记录表显式标记
T0 横表单行 → Map;金样;竖表回归 ✅
T1 横表多行 → Map of List(列向);嵌套金样 ✅
T2 脚注取元:List [^n]、Map [^键]、链式 ✅
T3 文档:markdown-mapping §9;Skill / examples;table 库 ✅(本批)
T4 行向记录表:首列 `@` / `行` / `row` ✅
```
验收:
@@ -251,6 +275,7 @@ T4 (可选)行向记录表显式标记
| 单列竖表 | 列表 | `` `a`[^1] `` |
| 多列 + 一行 | 字典 | `` `m`[^键] `` |
| 多列 + 多行 | 字典 → 列表 | `` `m`[^键][^1] `` |
| 首列 `@`/`行`/`row` | 记录列表 | `` `r`[^1][^字段] `` |
竖表表头是「元素名」;横表表头是「键名」——几何决定角色,减少「这张表到底是啥」的歧义。