Add dynamic-types and one-parse (round 19)

dynamic-types: queues ($ as an expression primary -- one grammar
addition and [$], [$:N], q[$-1] all fall out of existing machinery),
dynamic [] and wildcard [*] dims (DimKind, the round's one
non-additive AST change: three consumers, all updated), empty {}
literals, named call arguments f(.a(x)) as ExprKind::NamedArg,
case ... inside with range labels, bare @event sensitivities (also
fixing a pre-existing invented-parens refusal), and macro items
before ident-dot statements. Everything structural, nothing
verbatim; verify.rs and fence.rs byte-identical. Corpus 578 ->
636/820 formattable (70.5% -> 77.6%), parse-error 242 -> 184, 58
gained / 0 lost by path, all 636 round-tripped, all 578 previously-
formattable files byte-compared old-vs-new with zero differences.
Two newly-reachable comment drops fixed in-round (one pre-existing,
one this round's own new code -- split documented honestly post-QA).
New top blockers: interface (25), the `else head-swap (13).

one-parse: LintContext::from_parse accepts pre-built parse products
(Backing enum forced by SourceFile: !Clone; new() stays a one-line
wrapper -- all 12 rule files byte-untouched); ParsedSource::parse
lexes once; vfmt check parses once per file; the server lints from
Document's own products, eliminating the per-keystroke second parse.
Behavior identity proven at the byte level (2.4MB corpus JSON, 13
server publishes, corpus-wide --fix); check --threads 1 20% faster,
server didChange latency roughly halved. protected_regions left
alone per its documented anti-drift signature. Lead fixes on
acceptance: the from_parse contract-cost doc sentence, and a stale-
tree guard test in the server (QA's sabotage passed all 773 tests --
nothing pinned text/tree agreement; now one test does, through the
merged diagnostics path where the stale warning actually lives).

791 workspace tests. Dev: 2 Fable agents; QA: 2 Opus agents; reviews
in docs/features/{dynamic-types,one-parse}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-19 20:22:18 -07:00
1 parent e9008b680c
commit da1448ecd0
20 files changed
+2478 -96

No files matched your search

+42 -3
View File
@@ -338,15 +338,27 @@ impl DataType {
}
}
/// A dimension: `[expr]` or `[a:b]`.
/// A dimension: `[expr]`, `[a:b]`, `[]`, or `[*]`.
#[derive(Debug, Clone)]
pub struct Dim {
pub a: Expr,
pub b: Option<Expr>,
pub kind: DimKind,
/// Code extent including the brackets.
pub span: TextRange,
}
/// What stands between a dimension's brackets.
#[derive(Debug, Clone)]
pub enum DimKind {
/// `[expr]` or `[a:b]` — also `[$]`, `[$:N]` (a bare `$` is an ordinary
/// expression) and `[string]` / `[key_t]` (a type or name used as an
/// associative-array key parses as an expression).
Range { a: Expr, b: Option<Expr> },
/// `[]` — a dynamic array.
Dynamic,
/// `[*]` — a wildcard-keyed associative array.
Wildcard,
}
#[derive(Debug)]
pub struct Typedef {
pub name: String,
@@ -482,6 +494,10 @@ pub enum SensList {
after: Vec<Comment>,
},
List(Vec<SensItem>),
/// `@name` or `@a.b` written without parens; printed back without them —
/// inventing a `( ... )` would be a token-stream change the safety net
/// refuses.
Bare(Expr),
}
#[derive(Debug)]
@@ -834,6 +850,9 @@ pub enum StmtKind {
qualifier: Option<String>,
kw: String,
expr: Expr,
/// True for `case (expr) inside`, whose labels may be `[lo:hi]`
/// value ranges.
inside: bool,
items: Vec<CaseItem>,
dangling: Vec<Comment>,
},
@@ -867,6 +886,13 @@ pub enum StmtKind {
Assign {
lhs: Expr,
op: String,
/// Comments written between the left-hand side and the operator
/// (`instr[6:0] /* opcode */ = ...;`). Kept here so they print on
/// the operator's left instead of being lost.
op_comments: Vec<Comment>,
/// Comments written between the operator and the right-hand side,
/// kept on the operator's line as a continuous assignment's are.
rhs_comments: Vec<Comment>,
/// Intra-assignment timing control (e.g. `#1`, `@(posedge clk)`).
timing: Option<TimingControl>,
rhs: Expr,
@@ -1052,6 +1078,19 @@ pub enum ExprKind {
lhs: Box<Expr>,
ranges: Vec<ExprItem>,
},
/// A named call argument: the `.ptr(ral.ovrd)` of
/// `csr_wr(.ptr(ral.ovrd), .value(x))`. `value` is [`ExprKind::Empty`]
/// for `.name()`, exactly as an empty connection is.
NamedArg {
name: String,
/// Byte range of `name`.
name_span: TextRange,
value: Box<Expr>,
/// Comments written between the value and the closing `)`
/// (`.src(5'd0 /* x0 */)`), printed back inside the parens — the
/// same slot a connection has.
close_comments: Vec<Comment>,
},
/// `[a:b]` inside an `inside` range list or value range.
ValueRange {
lo: Box<Expr>,