feat(migrate): M7 迁移与版本门 — per-file markup + migrate labels + 全仓迁移
原计划的"翻转默认 + 旧形硬报错"不可行:`[键](集合)` 与 `[描述](实现)` 外形相同, 翻转会让 506 处取元静默变义,硬报错又拿不到证据。改为**按文件声明**。 一、per-file markup - frontmatter `markup: occlusion`(或 `标记: 遮蔽`)决定该文件模式 - load.rs 先取模式,用 parse::expr::with_markup(线程局部压栈)包住解析 - 同一进程可同时加载两种模式的文件(imports);MARQDO_MARKUP 仍作进程默认 - 好处:迁移逐文件、可增量、可回滚,不存在半迁移的静默错义 二、`marqdo migrate labels [--write|--json]` 改写规则: [键](集合) → [键](access(集合, "键")) [`名`](集合) → [名](access(集合, `名`)) - [项](集合) → - [项](遍历 集合 为 项) 安全模型:改写 → 重解析 → 证明等价 → 才写 - 原文件按 classic 解析得 AST-A;改写后按 occlusion 解析得 AST-B - 反归一化 B(标签与键同名且 payload 为 access 的遮蔽还原成 Index) - Debug(A) == Debug(反归一化(B))(抹掉行号)才写入,否则原文件一字不动 只改代码行(LineKind::Code);表格行只改 **…** 单元格,散文 markdown 链接不碰; 链式索引由内向外改写,已迁移的有守卫不二次改。 三、access 提升为宿主函数 HostFn::Access(u16 id 212) 与旧取元逐字一致(Map 按键 / List 1-based / 缺键 missing map key); 进 HostFn 是为了两个后端共用同一实现,interp 里的特例已删除。 四、顺带修的两处真实语义缺陷 1. payload 继承外层"文本模式":`f text=[k](access(c,k))` 中 access 不被当调用 → `()` 内永远允许 callee(args) 2. 遮蔽形状判定过宽:`[问候] ([格式化] "Bo")` 误判为遮蔽 → 要求 `]` 后紧跟 `(`,否则落回方括号调用 五、全仓迁移结果 migrate labels: 256 index, 23 loop, 80 file written;0 文件被等价性拒绝; 迁移后 cargo test --release → 604 passed / 0 failed;再跑迁移幂等。 等价性检查先后抓出 4 类改写 bug(表格散文链接、payload 文本模式、链式索引、 遮蔽与方括号调用混淆),每类都是先拦下再修工具,未污染文件。 测试:6 个单测 + 3 个集成(干跑不写盘 / 写入后运行输出不变且幂等 / 等价失败文件不动);全量 604 passed / 0 failed(M3 后 595 + 9);双后端一致。 文档:doc/design/change-m7-migration.md
This commit is contained in:
1 parent
9dbcc728b6
commit
4488a3cb70
98 files changed
+1354
-278
No files matched your search
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Mid stdlib — csv and text
|
||||
description: lib/csv + thickened lib/text (Mid M4)
|
||||
import csv:lib/csv.mq.md
|
||||
@@ -14,8 +15,8 @@ Parse a tiny CSV, normalize a field, print — no plugins.
|
||||
**raw = "name,city\nAda,london\nBob,PARIS\n"**
|
||||
**rows = > csv.parse text=`raw`**
|
||||
**r0 = > at value=`rows` index=0**
|
||||
**city = > text.to_upper text=[city](`r0`)**
|
||||
> print text=[name](`r0`)
|
||||
**city = > text.to_upper text=[city](access(`r0`, "city"))**
|
||||
> print text=[name](access(`r0`, "name"))
|
||||
> print text=`city`
|
||||
**n = > len `rows`**
|
||||
1. `n` == 2
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: 中层标准库 — 逗号表与文本
|
||||
description: lib/逗号表 + 加厚 lib/文本(中层 M4)
|
||||
导入 逗号表:lib/逗号表.mq.md
|
||||
@@ -14,8 +15,8 @@ description: lib/逗号表 + 加厚 lib/文本(中层 M4)
|
||||
**raw = "name,city\nAda,london\nBob,PARIS\n"**
|
||||
**rows = > 逗号表.解析 内容=`raw`**
|
||||
**r0 = > at value=`rows` index=0**
|
||||
**city = > 文本.大写 内容=[city](`r0`)**
|
||||
> 打印 内容=[name](`r0`)
|
||||
**city = > 文本.大写 内容=[city](access(`r0`, "city"))**
|
||||
> 打印 内容=[name](access(`r0`, "name"))
|
||||
> 打印 内容=`city`
|
||||
**n = > 长度 `rows`**
|
||||
1. `n` == 2
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Mid stdlib — lists and cli
|
||||
description: table sort/unique/zip + cli.parse (Mid M5)
|
||||
import table:lib/table.mq.md
|
||||
@@ -16,12 +17,12 @@ Zero plugins: parse CSV, sort by key, parse `--input`.
|
||||
**rows = > csv.parse text=`raw`**
|
||||
**rows = > table.sort_by list=`rows` key="name"**
|
||||
**r0 = > at value=`rows` index=0**
|
||||
> print text=[name](`r0`)
|
||||
> print text=[name](access(`r0`, "name"))
|
||||
|
||||
**args = > split value="--input,scores.csv,--pretty" sep=","**
|
||||
**flags = > cli.parse args=`args`**
|
||||
> print text=[input](`flags`)
|
||||
1. [pretty](`flags`)
|
||||
> print text=[input](access(`flags`, "input"))
|
||||
1. [pretty](access(`flags`, "pretty"))
|
||||
> print text=mid-m5-ok
|
||||
2. *
|
||||
> print text=mid-m5-fail
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: 中层标准库 — 列表与命令行
|
||||
description: 表排序/去重 + 命令行解析(中层 M5)
|
||||
导入 表:lib/表.mq.md
|
||||
@@ -16,12 +17,12 @@ description: 表排序/去重 + 命令行解析(中层 M5)
|
||||
**rows = > 逗号表.解析 内容=`raw`**
|
||||
**rows = > 表.按键排序 list=`rows` key="name"**
|
||||
**r0 = > at value=`rows` index=0**
|
||||
> 打印 内容=[name](`r0`)
|
||||
> 打印 内容=[name](access(`r0`, "name"))
|
||||
|
||||
**args = > split value="--input,scores.csv,--pretty" sep=","**
|
||||
**flags = > 命令行.解析 参数=`args`**
|
||||
> 打印 内容=[input](`flags`)
|
||||
1. [pretty](`flags`)
|
||||
> 打印 内容=[input](access(`flags`, "input"))
|
||||
1. [pretty](access(`flags`, "pretty"))
|
||||
> 打印 内容=mid-m5-ok
|
||||
2. *
|
||||
> 打印 内容=mid-m5-fail
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Mid stdlib — datetime and url
|
||||
description: Calendar moments + URL/query parse (Mid2 M7)
|
||||
import dt:lib/datetime.mq.md
|
||||
@@ -12,8 +13,8 @@ Moments are maps `{unix, zone, iso}`. Parse HTTPS URLs and round-trip query stri
|
||||
# main
|
||||
|
||||
**epoch = > dt.from_unix unix=0 zone="Asia/Shanghai"**
|
||||
> print text=[iso](`epoch`)
|
||||
> print text=[iso](access(`epoch`, "iso"))
|
||||
|
||||
**u = > url.parse text="https://example.com/path?q=1#top"**
|
||||
> print text=[host](`u`)
|
||||
> print text=[query](`u`)
|
||||
> print text=[host](access(`u`, "host"))
|
||||
> print text=[query](access(`u`, "query"))
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: 中层标准库 — 日期时间与地址
|
||||
description: 日历时刻 + URL/查询串(Mid2 M7)
|
||||
导入 日时:lib/日期时间.mq.md
|
||||
@@ -12,8 +13,8 @@ description: 日历时刻 + URL/查询串(Mid2 M7)
|
||||
# main
|
||||
|
||||
**epoch = > 日时.自戳 秒=0 区="Asia/Shanghai"**
|
||||
> print text=[iso](`epoch`)
|
||||
> print text=[iso](access(`epoch`, "iso"))
|
||||
|
||||
**u = > 址.解析 内容="https://example.com/path?q=1"**
|
||||
> print text=[host](`u`)
|
||||
> print text=[query](`u`)
|
||||
> print text=[host](access(`u`, "host"))
|
||||
> print text=[query](access(`u`, "query"))
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Mid stdlib — toml, html, base32
|
||||
description: Config TOML + HTML escape + base32 (Mid2 M8)
|
||||
import toml:lib/toml.mq.md
|
||||
@@ -13,9 +14,9 @@ Parse a TOML subset for tools, escape HTML before assembly, encode with base32.
|
||||
# main
|
||||
|
||||
**cfg = > toml.parse text="app = \"demo\"\n[server]\nport = 8080\n"**
|
||||
> print text=[app](`cfg`)
|
||||
**srv = [server](`cfg`)**
|
||||
> print text=[port](`srv`)
|
||||
> print text=[app](access(`cfg`, "app"))
|
||||
**srv = [server](access(`cfg`, "server"))**
|
||||
> print text=[port](access(`srv`, "port"))
|
||||
|
||||
**safe = > html.escape text="<tag>"**
|
||||
> print text=`safe`
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: 中层标准库 — 配置表、超文本、基32
|
||||
description: TOML 配置 + HTML 转义 + base32(Mid2 M8)
|
||||
导入 配置:lib/配置表.mq.md
|
||||
@@ -11,7 +12,7 @@ description: TOML 配置 + HTML 转义 + base32(Mid2 M8)
|
||||
# main
|
||||
|
||||
**cfg = > 配置.解析 内容="app = \"演示\"\n"**
|
||||
> print text=[app](`cfg`)
|
||||
> print text=[app](access(`cfg`, "app"))
|
||||
|
||||
**safe = > 超.转义 内容="<tag>"**
|
||||
> print text=`safe`
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Mid stdlib — fs make_dirs, walk, stat
|
||||
description: Recursive dirs, walk, and file metadata (Mid2 M9)
|
||||
import fs:lib/fs.mq.md
|
||||
@@ -15,7 +16,7 @@ import fs:lib/fs.mq.md
|
||||
> fs.write_text path="m9-demo/readme.txt" text="ok"
|
||||
|
||||
**st = > fs.stat path="m9-demo/readme.txt"**
|
||||
> print text=[size](`st`)
|
||||
> print text=[size](access(`st`, "size"))
|
||||
|
||||
**w = > fs.walk path="m9-demo"**
|
||||
**n = > len `w`**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: 中层标准库 — 文件目录树与状态
|
||||
description: 递归目录、遍历与元数据(Mid2 M9)
|
||||
导入 文件:lib/文件.mq.md
|
||||
@@ -13,7 +14,7 @@ description: 递归目录、遍历与元数据(Mid2 M9)
|
||||
> 文件.写文本 路径="m9-演示/说明.txt" 内容="好"
|
||||
|
||||
**st = > 文件.状态 路径="m9-演示/说明.txt"**
|
||||
> print text=[size](`st`)
|
||||
> print text=[size](access(`st`, "size"))
|
||||
|
||||
**w = > 文件.遍历 路径="m9-演示"**
|
||||
**n = > 长度 `w`**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Foreign kernels v2 — Python analysis in view
|
||||
description: Kernel state, Marqdo-to-kernel values and view cells — without a stdin-only demo
|
||||
import foreign:lib/foreign.mq.md
|
||||
@@ -14,8 +15,8 @@ Probe the interpreter first. The result is ordinary Marqdo data.
|
||||
|
||||
**python = > foreign.probe lang="python"**
|
||||
|
||||
> print text=[ok](`python`)
|
||||
> print text=[version](`python`)
|
||||
> print text=[ok](access(`python`, "ok"))
|
||||
> print text=[version](access(`python`, "version"))
|
||||
|
||||
---
|
||||
|
||||
@@ -45,7 +46,7 @@ round(sum(float(row["金额"]) for row in orders), 2)
|
||||
|
||||
**total = > foreign.session_eval id=`内核会话` code=`total_code`**
|
||||
|
||||
> print text=[result](`total`)
|
||||
> print text=[result](access(`total`, "result"))
|
||||
|
||||
The low-level kernel session is managed entirely by `foreign`; the table crossed the boundary as an explicit JSON copy.
|
||||
|
||||
@@ -69,7 +70,7 @@ sum(value * value for value in values)
|
||||
|
||||
**square_sum = > foreign.session_eval id=`内核会话` code=`square_sum_code`**
|
||||
|
||||
> print text=[result](`square_sum`)
|
||||
> print text=[result](access(`square_sum`, "result"))
|
||||
|
||||
**> foreign.session_close id=`内核会话`**
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: 外联内核 v2 — Python 分析(view 单元)
|
||||
description: 内核态、Marqdo 值传入与 view 单元 —— 不依赖 stdin 的完整示例
|
||||
导入 外联:lib/外联.mq.md
|
||||
@@ -14,8 +15,8 @@ description: 内核态、Marqdo 值传入与 view 单元 —— 不依赖 stdin
|
||||
|
||||
**python = > 外联.探测 语言="python"**
|
||||
|
||||
> 打印 内容=[ok](`python`)
|
||||
> 打印 内容=[version](`python`)
|
||||
> 打印 内容=[ok](access(`python`, "ok"))
|
||||
> 打印 内容=[version](access(`python`, "version"))
|
||||
|
||||
---
|
||||
|
||||
@@ -45,7 +46,7 @@ round(sum(float(row["金额"]) for row in orders), 2)
|
||||
|
||||
**合计 = > 外联.会话求值 标识=`内核会话` 代码=`合计代码`**
|
||||
|
||||
> 打印 内容=[result](`合计`)
|
||||
> 打印 内容=[result](access(`合计`, "result"))
|
||||
|
||||
低层内核会话完全由 `外联` 管理;表格以显式 JSON 拷贝跨过边界。
|
||||
|
||||
@@ -69,7 +70,7 @@ sum(value * value for value in values)
|
||||
|
||||
**平方和 = > 外联.会话求值 标识=`内核会话` 代码=`平方和代码`**
|
||||
|
||||
> 打印 内容=[result](`平方和`)
|
||||
> 打印 内容=[result](access(`平方和`, "result"))
|
||||
|
||||
**> 外联.会话关闭 标识=`内核会话`**
|
||||
|
||||
|
||||
Reference in new issue
Block a user