feat(lang): implement RFC-LANG-0002 unified semantics (breaking)
One Markdown-to-program mapping, no version selector or legacy mapper. Frontend/runtime: - resolve @exec/@knowledge heading declarations with nearest-ancestor inheritance; only an Exec H2 is callable; add UnitKind::Knowledge and sem.* diagnostics (mode marker, unit name, exec-without-function, payload nesting/empty, syntax, control stack, params position, version directive, inferred-signature lint) - extract Strong/Emph/inline Code as one-statement carriers, refuse nested carriers, and honour heading segment boundaries so an if/while cannot be closed across a heading - lower if/else/while/end to the existing Branch/Loop/Return IR with a compile-time control stack; keep payload-relative source spans through expression parsing and rewrite them onto the file - accept params(...) only as the first direct Exec H2 payload; keep the existing free-variable inference and named-only rule for inferred signatures; fix duplicate-mode/else/end and Knowledge-body inertness - reject marqdo_semantics/syntax front matter directives Data and tests: - migrate stdlib/**/*.mq.md, regenerate stdlib.json digest - migrate examples and the full semantics/negative/runtime corpus to the only current syntax; expected values/runtime codes preserved - migrate Rust-embedded .mq.md fixtures, init template, CLI help and security-lane fixtures Verified: cargo fmt --check, cargo clippy -D warnings and cargo test --workspace --locked (green).
This commit is contained in:
1 parent
49835424ee
commit
e029853e32
375 files changed
+6591
-4790
No files matched your search
+95
-64
@@ -1,22 +1,27 @@
|
||||
|
||||
# @exec path
|
||||
## 是否绝对
|
||||
|
||||
`(路径)`
|
||||
`params(路径)`
|
||||
|
||||
**点 = text.codepoints(路径)**
|
||||
|
||||
1. `长度(点) == 0`
|
||||
`if 长度(点) == 0`
|
||||
|
||||
*false*
|
||||
`return false`
|
||||
|
||||
2. `点[0] == 47`
|
||||
`else`
|
||||
`if 点[0] == 47`
|
||||
|
||||
*true*
|
||||
`return true`
|
||||
|
||||
*false*
|
||||
`end`
|
||||
`end`
|
||||
`return false`
|
||||
|
||||
## 分割
|
||||
|
||||
`(文本, 分隔码点)`
|
||||
`params(文本, 分隔码点)`
|
||||
|
||||
**点 = text.codepoints(文本)**
|
||||
|
||||
@@ -26,65 +31,76 @@
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
- `下标 < 长度(点)`
|
||||
`while 下标 < 长度(点)`
|
||||
|
||||
1. `点[下标] == 分隔码点`
|
||||
`if 点[下标] == 分隔码点`
|
||||
|
||||
**结果 = list.append(结果, 当前)**
|
||||
**结果 = list.append(结果, 当前)**
|
||||
|
||||
**当前 = ""**
|
||||
**当前 = ""**
|
||||
|
||||
2. `true`
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**当前 = 当前 + text.from_codepoint(点[下标])**
|
||||
**当前 = 当前 + text.from_codepoint(点[下标])**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
`end`
|
||||
`end`
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
*list.append(结果, 当前)*
|
||||
`end`
|
||||
`return list.append(结果, 当前)`
|
||||
|
||||
## 连接
|
||||
|
||||
`(片段列表)`
|
||||
`params(片段列表)`
|
||||
|
||||
空片段被跳过,片段之间只插入一个 `/`。
|
||||
空片段被跳过,片段之间只插入一个 /。
|
||||
|
||||
**结果 = ""**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
- `下标 < 长度(片段列表)`
|
||||
`while 下标 < 长度(片段列表)`
|
||||
|
||||
**片段 = 文本(片段列表[下标])**
|
||||
**片段 = 文本(片段列表[下标])**
|
||||
|
||||
1. `片段 != ""`
|
||||
`if 片段 != ""`
|
||||
|
||||
1. `结果 == ""`
|
||||
`if 结果 == ""`
|
||||
|
||||
**结果 = 片段**
|
||||
**结果 = 片段**
|
||||
|
||||
2. `true`
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**结果 = 结果 + "/" + 片段**
|
||||
**结果 = 结果 + "/" + 片段**
|
||||
|
||||
2. `true`
|
||||
`end`
|
||||
`end`
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**忽略 = 0**
|
||||
**忽略 = 0**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
`end`
|
||||
`end`
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
*结果*
|
||||
`end`
|
||||
`return 结果`
|
||||
|
||||
## 文件名
|
||||
|
||||
`(路径)`
|
||||
`params(路径)`
|
||||
|
||||
**片段 = 分割(路径, 47)**
|
||||
|
||||
*片段[长度(片段) - 1]*
|
||||
`return 片段[长度(片段) - 1]`
|
||||
|
||||
## 目录名
|
||||
|
||||
`(路径)`
|
||||
`params(路径)`
|
||||
|
||||
**片段 = 分割(路径, 47)**
|
||||
|
||||
@@ -92,50 +108,53 @@
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
- `下标 < 长度(片段) - 1`
|
||||
`while 下标 < 长度(片段) - 1`
|
||||
|
||||
**结果 = list.append(结果, 片段[下标])**
|
||||
**结果 = list.append(结果, 片段[下标])**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
*连接(结果)*
|
||||
`end`
|
||||
`return 连接(结果)`
|
||||
|
||||
## 扩展名
|
||||
|
||||
`(路径)`
|
||||
`params(路径)`
|
||||
|
||||
**名字 = 文件名(路径)**
|
||||
|
||||
**点列表 = 分割(名字, 46)**
|
||||
|
||||
1. `长度(点列表) <= 1`
|
||||
`if 长度(点列表) <= 1`
|
||||
|
||||
*""*
|
||||
`return ""`
|
||||
|
||||
*点列表[长度(点列表) - 1]*
|
||||
`end`
|
||||
`return 点列表[长度(点列表) - 1]`
|
||||
|
||||
## 去尾
|
||||
|
||||
`(列表)`
|
||||
`params(列表)`
|
||||
|
||||
**结果 = []**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
- `下标 < 长度(列表) - 1`
|
||||
`while 下标 < 长度(列表) - 1`
|
||||
|
||||
**结果 = list.append(结果, 列表[下标])**
|
||||
**结果 = list.append(结果, 列表[下标])**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
*结果*
|
||||
`end`
|
||||
`return 结果`
|
||||
|
||||
## 规范
|
||||
|
||||
`(路径)`
|
||||
`params(路径)`
|
||||
|
||||
词法规范化:折叠 `.`、空片段和重复 `/`,用 `..` 消去前一片段;
|
||||
绝对路径保留前导 `/`。不访问文件系统。
|
||||
词法规范化:折叠 .、空片段和重复 /,用 .. 消去前一片段;
|
||||
绝对路径保留前导 /。不访问文件系统。
|
||||
|
||||
**片段 = 分割(路径, 47)**
|
||||
|
||||
@@ -145,36 +164,48 @@
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
- `下标 < 长度(片段)`
|
||||
`while 下标 < 长度(片段)`
|
||||
|
||||
**段 = 片段[下标]**
|
||||
**段 = 片段[下标]**
|
||||
|
||||
1. `段 == "" or 段 == "."`
|
||||
`if 段 == "" or 段 == "."`
|
||||
|
||||
**忽略 = 0**
|
||||
**忽略 = 0**
|
||||
|
||||
2. `段 == ".."`
|
||||
`else`
|
||||
`if 段 == ".."`
|
||||
|
||||
1. `长度(栈) > 0 and 栈[长度(栈) - 1] != ".."`
|
||||
`if 长度(栈) > 0 and 栈[长度(栈) - 1] != ".."`
|
||||
|
||||
**栈 = 去尾(栈)**
|
||||
**栈 = 去尾(栈)**
|
||||
|
||||
2. `not 绝对`
|
||||
`else`
|
||||
`if not 绝对`
|
||||
|
||||
**栈 = list.append(栈, 段)**
|
||||
**栈 = list.append(栈, 段)**
|
||||
|
||||
3. `true`
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**忽略绝对根 = 0**
|
||||
**忽略绝对根 = 0**
|
||||
|
||||
3. `true`
|
||||
`end`
|
||||
`end`
|
||||
`end`
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**栈 = list.append(栈, 段)**
|
||||
**栈 = list.append(栈, 段)**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
`end`
|
||||
`end`
|
||||
`end`
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
1. `绝对`
|
||||
`end`
|
||||
`if 绝对`
|
||||
|
||||
*"/" + 连接(栈)*
|
||||
`return "/" + 连接(栈)`
|
||||
|
||||
*连接(栈)*
|
||||
`end`
|
||||
`return 连接(栈)`
|
||||
Reference in new issue
Block a user