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:
cflmy committed 2026-11-21 12:26:46 +08:00
1 parent 49835424ee
commit e029853e32
375 files changed
+6591 -4790

No files matched your search

@@ -0,0 +1,5 @@
{
"codes": [
"sem.invalid_mode_marker"
]
}
@@ -0,0 +1,5 @@
# @exec 01-invalid-mode-marker-case
## @Exec main
`return 1`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.invalid_mode_marker"
]
}
@@ -0,0 +1,5 @@
# @exec 02-invalid-mode-marker-misspelled
## @knowledg 说明
普通知识文字。
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.invalid_mode_marker"
]
}
@@ -0,0 +1,3 @@
## @exec @knowledge main
`return 1`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.empty_unit_name"
]
}
@@ -0,0 +1 @@
## @exec
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.empty_unit_name"
]
}
@@ -0,0 +1 @@
# @knowledge
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.exec_without_function"
]
}
@@ -0,0 +1,5 @@
## @knowledge 说明
### @exec 过程
`x = 1`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.exec_without_function"
]
}
@@ -0,0 +1,3 @@
# @exec 顶层
`x = 1`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,3 +1,3 @@
## f
## @exec f
**a *b* c**
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,3 +1,3 @@
## f
## @exec f
**a __b__ c**
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,3 +0,0 @@
## f
*`` ``*
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,3 +1,3 @@
## f
## @exec f
**见[链接](https://example.com)**
@@ -1,3 +0,0 @@
## f
**1 +**
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,3 +1,3 @@
## f
## @exec f
**$x + y$**
@@ -1,3 +0,0 @@
## f
*1 +*
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,3 +0,0 @@
## f
1. 没有条件
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,3 +1,3 @@
## f
## @exec f
*a **b** c*
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,3 +0,0 @@
## f
- 没有条件
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,3 +1,3 @@
## f
## @exec f
*a _b_ c*
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,3 +0,0 @@
## f
1. > 引用不是条件
@@ -0,0 +1,5 @@
{
"codes": [
"sem.payload_nested"
]
}
@@ -1,4 +1,4 @@
## f
## @exec f
**a
b**
@@ -0,0 +1,5 @@
{
"codes": [
"sem.empty_payload"
]
}
@@ -1,3 +1,3 @@
## f
## @exec f
**`` ``**
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,3 +0,0 @@
## f
1. 普通文本
@@ -0,0 +1,5 @@
{
"codes": [
"sem.empty_payload"
]
}
@@ -0,0 +1,3 @@
## @exec f
*`` ``*
@@ -1,3 +0,0 @@
## f
1. `n >`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
-3
View File
@@ -1,3 +0,0 @@
## f
> 这不是调用
@@ -1,5 +1,5 @@
{
"codes": [
"expr.parse"
"sem.syntax"
]
}
@@ -0,0 +1,3 @@
## @exec f
`if x >`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,5 +0,0 @@
## f
> 打印(1)
>
> 打印(2)
@@ -1,5 +1,5 @@
{
"codes": [
"expr.parse"
"sem.syntax"
]
}
@@ -0,0 +1,3 @@
## @exec f
`if x > 0:`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
-3
View File
@@ -1,3 +0,0 @@
## f
> > 打印(1)
@@ -1,5 +1,5 @@
{
"codes": [
"expr.parse"
"sem.syntax"
]
}
+3
View File
@@ -0,0 +1,3 @@
## @exec f
`end if`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
-3
View File
@@ -1,3 +0,0 @@
## f
>
@@ -1,5 +1,5 @@
{
"codes": [
"expr.parse"
"sem.syntax"
]
}
@@ -0,0 +1,3 @@
## @exec f
`return`
@@ -1,3 +0,0 @@
## f
> 打印(1) 打印(2)
@@ -0,0 +1,5 @@
{
"codes": [
"sem.syntax"
]
}
@@ -0,0 +1,3 @@
## @exec f
`x = 1; return x`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,3 +0,0 @@
## f
> 1 + 2
@@ -0,0 +1,5 @@
{
"codes": [
"sem.syntax"
]
}
@@ -0,0 +1,5 @@
## @exec f
`params(1x: Int)`
`return 1`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,7 +0,0 @@
## f
*1*
## main
> [f](#f)
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unmatched_else"
]
}
+3
View File
@@ -0,0 +1,3 @@
## @exec f
`else`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.duplicate_else"
]
}
+11
View File
@@ -0,0 +1,11 @@
## @exec f
`params(flag: Bool)`
`if flag`
`else`
`else`
`end`
@@ -1,5 +0,0 @@
{
"codes": [
"ref.unresolved"
]
}
@@ -1,3 +0,0 @@
## main
> [x](https://example.com)()
@@ -1,5 +0,0 @@
{
"codes": [
"module.unresolved"
]
}
@@ -1,3 +0,0 @@
## main
> [f](./other.mq.md#f)()
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unmatched_end"
]
}
+3
View File
@@ -0,0 +1,3 @@
## @exec f
`end`
@@ -1,5 +0,0 @@
{
"codes": [
"ref.unresolved"
]
}
@@ -1,3 +0,0 @@
## main
> [f](#不存在)()
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unclosed_control"
]
}
@@ -0,0 +1,7 @@
## @exec f
`params(flag: Bool)`
`if flag`
`return 1`
@@ -1,5 +0,0 @@
{
"codes": [
"markdown.invalid_construct"
]
}
@@ -1,7 +0,0 @@
## f
*1*
## f
*2*
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unclosed_control"
]
}
@@ -0,0 +1,5 @@
## @exec f
`params(flag: Bool)`
`while flag`
@@ -0,0 +1,6 @@
{
"codes": [
"sem.unclosed_control",
"sem.unmatched_end"
]
}
Loaded 100 of 375 files, more files were not shown because too many files have changed in this diff. Show more