refactor(expression): own the v2 payload statement grammar
Move keyword recognition out of the Markdown mapper and into the single expression/statement parser: - add parse_payload_statement + PayloadStatement for if/else/while/end/ return/params/ordinary; keyword matching uses complete tokens, requires whitespace before a control expression, rejects trailing tokens/colons and reserves the statement words in expression positions - keep expression spans payload-relative so the frontend can rewrite them onto the file; malformed params(...) interiors stay owned by the signature parser (one sem.syntax diagnostic, not a duplicate) - simplify the frontend mapper to control-stack lowering and mapped semantic diagnostics only - emit sem.no_entry_function from run when no Exec H2 main exists - add else-under-while, params-in-quote, Knowledge-inertness and no-entry tests; update the corpus counts - make the EBNF parameter type annotation optional (params(n) is valid) Verified: cargo fmt --check, cargo clippy -D warnings and cargo test --workspace --locked: 501 passed, 0 failed, 2 ignored.
This commit is contained in:
1 parent
e029853e32
commit
ffd1cc9862
14 files changed
+334
-145
No files matched your search
+3
-3
@@ -31,7 +31,7 @@ tests/
|
||||
│ ├── ast/ 160 × *.mq.md + sibling *.ast.json goldens
|
||||
│ └── semantics/ 73 × *.mq.md + sibling *.expected.json goldens
|
||||
├── negative/
|
||||
│ ├── *.mq.md 45 × compile-time hard-error fixtures + *.expected.json
|
||||
│ ├── *.mq.md 47 × compile-time hard-error fixtures + *.expected.json
|
||||
│ ├── warnings/ 2 × warning-model/control fixtures + *.expected.json
|
||||
│ └── runtime/ 21 × runtime-error fixtures + *.expected.json
|
||||
└── README.md this file
|
||||
@@ -79,9 +79,9 @@ The power/control-flow slice is pinned by:
|
||||
loop and inert prose;
|
||||
* negative fixtures 18–23: malformed payload statements (missing condition,
|
||||
trailing colon, `end if`, empty `return`, multi-statement payload, bad
|
||||
`params` syntax); fixtures 24–29 pin control-stack pairing, including the
|
||||
`params` syntax); fixtures 24–29 and 46 pin control-stack pairing, including the
|
||||
heading boundary that reports `sem.unclosed_control` and `sem.unmatched_end`
|
||||
independently;
|
||||
independently and `else` under an open `while`;
|
||||
* runtime negatives 11–12: negative integer exponent and exponent budget;
|
||||
* `crates/marqdo-frontend/src/payload.rs` span tests and
|
||||
`crates/cli/tests/integration_cli.rs` CLI span/E2E assertions.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"codes": [
|
||||
"sem.unmatched_else"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## @exec f
|
||||
|
||||
`params(flag: Bool)`
|
||||
|
||||
`while flag`
|
||||
|
||||
`else`
|
||||
|
||||
`end`
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"codes": [
|
||||
"sem.signature_position"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
## @exec f
|
||||
|
||||
> `params(n: Int)`
|
||||
|
||||
`return n`
|
||||
@@ -19,3 +19,7 @@
|
||||
`params(a: Int, b: Int)`
|
||||
|
||||
`return a + b`
|
||||
|
||||
## @knowledge 补充说明
|
||||
|
||||
这里的 `if x > 0` 与 **重点** 都只是文档。
|
||||
Reference in new issue
Block a user