Decomposition, lane A: vlog_parser's parser.rs and ast.rs become twenty-seven modules, a pure move
TODO section 28, lane A (the file-size rule in CLAUDE.md).
parser.rs (8 786 production + 5 044 test lines) becomes parser/{mod,
cursor, recover, directive, split, verbatim, item, module, decl, tf,
instance, stmt, keyword_stmt, expr, primary, class, covergroup,
assertion, sva}.rs with the tests regrouped into parser/tests/ (14
files, 309 tests, same names and bodies); ast.rs (3 313) becomes
ast/{mod, module, decl, stmt, expr, class, covergroup, sva}.rs, every
type re-exported so vlog_parser::ast::X is unchanged. Nothing over 800
production lines; the two keyword dispatch tables kept whole and
documented as such, parse_keyword_stmt in a file of its own. Carved by
a line-range manifest that had to concatenate back to the original
byte for byte before writing; 149 methods and 18 items pub(super) as
the compiler demanded. Proof: per-binary test counts identical
(workspace 3 215 / 48), 4 807 corpus + opentitan files byte-identical
to the v0.33.0 binary, cargo doc item list unchanged, and a multiset +
signature census done by the dev, redone by QA, re-run by the lead.
docs/features/decomposition-parser/README.md.
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
159f6a0bd8
commit
9b93f33ae3
45 files changed
+17999
-17241
No files matched your search
@@ -0,0 +1,538 @@
|
||||
# Decomposition — Lane A, `vlog_parser`
|
||||
|
||||
## Goal
|
||||
|
||||
Apply the file-size rule (CLAUDE.md "File and function size") to the two
|
||||
files of `vlog_parser` over 1 200 lines: `src/parser.rs` (8 786 production
|
||||
lines + 5 044 test lines, one 8 100-line `impl Parser` block) and
|
||||
`src/ast.rs` (3 313 lines). Each becomes a module directory whose files a
|
||||
reader can describe in one sentence and whose boundaries match the grammar
|
||||
domains feature lanes are cut by, so that two lanes touching different
|
||||
domains no longer collide in one file. The split is a **pure move**: no
|
||||
behaviour change, no renamed public item, every public path preserved by
|
||||
re-exports, doc comments travelling with their items, the test count
|
||||
unchanged, and `--stdout` output byte-identical to the v0.33.0 baseline over
|
||||
the corpus and OpenTitan. TODO.md §28, Lane A.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- The proof of a pure move is the existing gates — per-binary test counts
|
||||
equal to the baseline, corpus and OpenTitan byte-identity against
|
||||
`/tmp/lucisv-0.33.0-baseline`, the `cargo doc` item list unchanged — not
|
||||
new tests. No test was written; none was dropped.
|
||||
- Methods that one grammar file calls on another are `pub(super)`: visible
|
||||
inside the `parser` module tree (siblings and the `tests` subtree), invisible
|
||||
outside the crate. This adds no public path. The one public method,
|
||||
`Parser::parse_expr`, stays `pub`.
|
||||
- The split is by *what a reader looks for*, not by the old section
|
||||
comments: where a section held a helper every file uses (`gap_before`,
|
||||
`expect_stmt_semi`, `take_raw_text`, `skip_balanced`), the helper moved to
|
||||
the file that owns the concept, not the file it happened to sit in.
|
||||
- `rustfmt` re-indents the moved tests (they came out of a `mod tests { }`
|
||||
block) and, because they are now four columns narrower, joins a handful
|
||||
of lines that used to wrap. String literal contents are untouched — the
|
||||
spans the tests assert are computed from those literals, and all 309 pass.
|
||||
- The 300–600 target is a target: six production files are over 600 and
|
||||
one is over 800 (§Work log, "files over the target"), each with the
|
||||
reason written there.
|
||||
|
||||
## Handshakes
|
||||
|
||||
Consumed:
|
||||
|
||||
- `crate::ast::*`, `crate::span::TextRange`, `crate::token::{Comment, Token,
|
||||
TokenKind}`, `crate::lexer::tokenize` — unchanged.
|
||||
- `crate::lib` calls `parser::error_file` (moved to `parser/recover.rs`,
|
||||
re-exported `pub(crate) use recover::error_file;` from `parser/mod.rs`).
|
||||
|
||||
Promised (unchanged, verified by the `cargo doc` item diff and by every
|
||||
other crate compiling untouched):
|
||||
|
||||
- `vlog_parser::parser::{parse, parse_tolerant, ParseError, ParseDiagnostic,
|
||||
Parser, MAX_NESTING_DEPTH, MAX_CHAIN_LENGTH, PARSE_STACK_SIZE}` and
|
||||
`Parser::parse_expr` — same names, same signatures, same paths.
|
||||
- `vlog_parser::ast::*` — every node type is re-exported from `ast/mod.rs`
|
||||
(`pub use decl::*;` etc.), so `vlog_parser::ast::Expr` is unchanged and
|
||||
rustdoc inlines the items at the same paths (the submodules are private).
|
||||
|
||||
Requests to other lanes: none. Nothing outside `crates/vlog_parser` changed.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] `git mv src/parser.rs src/parser/mod.rs`, `git mv src/ast.rs src/ast/mod.rs`
|
||||
- [x] `parser/` carved into 19 files (18 in the first pass, `keyword_stmt.rs` in the rework), `ast/` into 8, tests into `parser/tests/` (14 files)
|
||||
- [x] Every original line assigned to exactly one file; concatenation proof
|
||||
(see Work log) passed for both carves
|
||||
- [x] Cross-file methods `pub(super)`; cross-file free items imported explicitly
|
||||
- [x] Module-level doc per new file; module map in `parser/mod.rs` and `ast/mod.rs`
|
||||
- [x] `cargo fmt -p vlog_parser`, `cargo clippy --all-targets --workspace` (0 warnings)
|
||||
- [x] `cargo test -p vlog_parser`: 360 / 0 (2 ignored) / 26 / 22 / 18 / 6 / 18 — equal to baseline
|
||||
- [x] `cargo test --workspace`: every binary's count equal to baseline
|
||||
- [x] `cargo doc -p vlog_parser` item list diffed: no path changed
|
||||
- [x] Byte-identity: corpus, 0 differing; OpenTitan `hw/`, 0 differing; exit codes identical
|
||||
- [x] TODO.md §28 Lane A ticked
|
||||
- [x] Rework after QA (2026-09-02): `parse_keyword_stmt` moved to `parser/keyword_stmt.rs`; README counts re-measured; all gates re-run on the final tree
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-02 — the carve
|
||||
|
||||
**Method.** The pristine files were `git mv`'d first so history follows
|
||||
`parser/mod.rs` and `ast/mod.rs`. The carve itself is a manifest of
|
||||
line-range segments — every line of the original assigned to exactly one
|
||||
destination — executed by a script that *refuses to write* unless the
|
||||
segments, concatenated in original order, reproduce the original byte for
|
||||
byte (`scratchpad/carve_parser.py`, `carve_ast.py`; both passed). This is a
|
||||
deliberate deviation from "use the Edit tool to remove text": retyping
|
||||
13 928 lines through Edit cannot be verified, a range manifest can, and the
|
||||
concatenation check is a stronger guarantee than either. The only text that
|
||||
is not a verbatim segment: each file's `//!` header and `use` lines, the
|
||||
`impl<'a> Parser<'a> { … }` wrapper per file, `pub(super)` on the items
|
||||
another file uses — measured on the final tree with `grep -E '^ pub\(super\) fn '`
|
||||
and its free-item / struct-field twins: 149 methods, 5 free functions, 13
|
||||
structs, consts and fields (the first draft of this log said 142 + 11; QA
|
||||
re-counted, and the rework added the six `stmt.rs` productions the moved
|
||||
table calls) — four signatures `rustfmt` re-wrapped because `pub(super) `
|
||||
pushed them past 100 columns (`parse_dist`, `take_list_directives`,
|
||||
`parse_expr_list`, `split_conditional_item`), and the comment edits listed
|
||||
under "comment-only changes".
|
||||
|
||||
**Pinned test counts** (`cargo test -p vlog_parser`, before = after):
|
||||
lib unittests 360, `census` 0 (2 ignored), `defines` 26, `error_recovery`
|
||||
22, `fragments` 18, `null_items` 6, `spans` 18, doctests 0. The 309 `#[test]`
|
||||
fns of the old `mod tests` are the 309 in `parser/tests/`. Function count:
|
||||
288 `impl Parser` methods before, 288 after (plus the two `Display::fmt`
|
||||
impls that the after-census now also sees) — nothing merged, nothing split.
|
||||
|
||||
**`parser/` module map** (original `parser.rs` line ranges → file; the
|
||||
one-sentence description is the file's `//!` doc):
|
||||
|
||||
| file | production lines | from `parser.rs` lines |
|
||||
|---|---:|---|
|
||||
| `mod.rs` — `Parser`, budgets, `Rewind`, `parse`/`parse_tolerant`, errors, shared name/label helpers | 476 | 1–82, 161–163, 170–237, 274–402, 503–524, 683–703, 705–728, 1534–1553, 1581–1637 |
|
||||
| `cursor.rs` — token cursor, spans, `expect`/`eat`, comment plumbing | 364 | 729–808, 967–1158, 1236–1245, 1380–1387, 1504–1533, 1638–1659, 2455–2462 |
|
||||
| `recover.rs` — tolerant-mode error recovery, `error_file` | 217 | 95–131, 477–497, 809–966 |
|
||||
| `directive.rs` — `` `ifdef `` tracking, list directives, macros, fragment mode | 410 | 264–273, 403–476, 563–572, 660–682, 1159–1235, 1388–1503, 1764–1808, 6726–6764 |
|
||||
| `split.rs` — conditional-directive split recovery | 471 | 573–659, 4832–5209 |
|
||||
| `verbatim.rs` — vendor/formal blocks kept as bytes; `skip_balanced`, `verbatim_since`, `skip_to_semi` | 227 | 3719–3745, 4674–4831, 5225–5261 |
|
||||
| `item.rs` — file and item loops, keyword → item dispatch, member qualifiers, packages, imports, DPI, generate | 726 | 83–94, 132–150, 1554–1580, 1687–1763, 1809–2226, 6834–6991 |
|
||||
| `module.rs` — module/interface/program header, parameter ports, ports, modports, clocking | 542 | 238–249, 5262–5788 |
|
||||
| `decl.rs` — data types, dims, type params, declarators, params, typedef/enum/struct | 470 | 1660–1686, 5210–5224, 5789–6204 |
|
||||
| `tf.rs` — function, task, `let` | 245 | 250–253, 6992–7230 |
|
||||
| `instance.rs` — `assign`, drive strengths, delays, `bind`, instantiations, connections, gates | 593 | 164–169, 498–502, 6205–6725, 6765–6780, 6793–6833 |
|
||||
| `stmt.rs` — statements | 494 | 254–263, 2429–2454, 7231–7373, 7690–7998 |
|
||||
| `keyword_stmt.rs` — the keyword → statement dispatch table | 337 | 7374–7689 |
|
||||
| `expr.rs` — implication → ternary → binary → unary → postfix | 505 | 7999–8500 |
|
||||
| `primary.rs` — `parse_primary`, casts, patterns, stream concat, element/argument lists | 467 | 1246–1379, 6781–6792, 8501–8809 |
|
||||
| `class.rs` — class header, `extends`, constraints, `with` constraints | 659 | 2227–2428, 2463–2908 |
|
||||
| `covergroup.rs` — covergroups, coverpoints, crosses, bins | 621 | 549–562, 2909–3508 |
|
||||
| `assertion.rs` — concurrent assertions, action blocks, property/sequence decls, `expect`, `default disable iff` | 445 | 151–160, 3509–3718, 4458–4673 |
|
||||
| `sva.rs` — the property/sequence expression grammar | 737 | 525–548, 3746–4457 |
|
||||
|
||||
Lines 704 (`impl<'a> Parser<'a> {`) and 8810 (`}`) became the per-file
|
||||
wrappers; 8811–8815 (`#[cfg(test)] mod tests { use … }`) became
|
||||
`parser/tests/mod.rs`'s head and `#[cfg(test)] mod tests;` in `mod.rs`;
|
||||
13928 (`}`) was dropped.
|
||||
|
||||
**Tests** (`parser/tests/`, 5 086 lines, 309 tests): `mod.rs` (shared
|
||||
helpers `parse_ok`, `words`, `texts`, `parse_err`, `module_of`, `class_of`,
|
||||
`initial_stmts`), `limits`, `comments`, `items`, `module`, `instance`,
|
||||
`decl`, `stmt`, `expr`, `directive`, `split`, `class`, `sva`, `covergroup` —
|
||||
each named for the grammar file it exercises (`limits` = the budgets in
|
||||
`mod.rs`/`cursor.rs`, `comments` = the comment plumbing in `cursor.rs`,
|
||||
`items` = `item.rs` + `verbatim.rs`). Tests were assigned by what they
|
||||
assert, not by the old section they sat in — e.g. the list-directive tests
|
||||
that lived under the old "Error recovery" and "ANSI first port" headings
|
||||
are in `directive.rs`.
|
||||
|
||||
**`ast/` module map** (original `ast.rs` line ranges → file):
|
||||
|
||||
| file | lines | from `ast.rs` lines |
|
||||
|---|---:|---|
|
||||
| `mod.rs` — `Name`, `ScopeSeg`, `LabelComments`, `Qualifier`, `Meta`, `RawText`, `ListDirective`, `MacroCall`, `SourceFile`, `Fragment`, `Item`, `ItemKind`, import/DPI payloads, `size_pins` test | 485 | 1–108, 124–451, 3296–3312 |
|
||||
| `module.rs` | 550 | 452–603, 874–909, 964–1232, 1313–1399 |
|
||||
| `decl.rs` | 416 | 604–873, 1400–1540 |
|
||||
| `stmt.rs` | 407 | 109–123, 910–963, 1541–1874 |
|
||||
| `expr.rs` | 444 | 1875–2313 |
|
||||
| `class.rs` | 294 | 1233–1312, 2314–2525 |
|
||||
| `covergroup.rs` | 407 | 2526–2932 |
|
||||
| `sva.rs` | 363 | 2933–3295 |
|
||||
|
||||
**Cut points that differ from the §28 plan, and why.**
|
||||
|
||||
- `cursor.rs` is separate from `mod.rs`. §28 had the cursor and comment
|
||||
plumbing in `mod.rs`; together with the types, budgets and entry points
|
||||
that is ~790 lines, the second-largest file of the split. The cursor is
|
||||
one layer every grammar file drives and no grammar file changes, which is
|
||||
exactly a one-sentence module; `mod.rs` is now "state, budgets, entry
|
||||
points and the two helper families every file shares (scoped names,
|
||||
labels)".
|
||||
- `split.rs` is separate from `directive.rs` (§28: one `directive`
|
||||
module). The conditional-directive split recovery is a *recovery* —
|
||||
it runs only after a parse failure — and at 470 lines it would have
|
||||
pushed `directive.rs` to ~900. A `directive-split` lane touches
|
||||
`split.rs` alone; a macro or fragment lane touches `directive.rs` alone.
|
||||
- `verbatim.rs` (§28: "recovery/opaque capture") holds the vendor/formal
|
||||
items *and* the capture primitives (`skip_balanced`, `verbatim_since`,
|
||||
`skip_to_semi`) that every speculative parse falls back to. Recovery
|
||||
proper stays in `recover.rs`: the two are different things — one is what
|
||||
lucisv does when the grammar refuses, the other what it does when the
|
||||
grammar deliberately does not model.
|
||||
- `tf.rs` is separate from `decl.rs`. Folding function/task/let into
|
||||
`decl.rs` gives 700 lines and a description with an "and"; a function-port
|
||||
lane touches `tf.rs` alone.
|
||||
- `expr.rs` / `primary.rs` (§28: one `expr`). 950 lines in one file; the
|
||||
operator grammar and the leaves are two things a reader looks for
|
||||
separately. The element/argument list helpers (`parse_expr_item`,
|
||||
`parse_expr_list`, `parse_named_arg`, `parse_value_range`) sit with the
|
||||
leaves because concatenations, calls and patterns are their callers.
|
||||
- `class.rs` / `covergroup.rs` and `assertion.rs` / `sva.rs` (§28: one
|
||||
`class`, one `sva`): 1 285 and 1 160 lines respectively as single files.
|
||||
- Generate constructs went to `item.rs`, not `module.rs`: a generate block
|
||||
is an item list and its entry is the item dispatch; a generate lane then
|
||||
touches one file.
|
||||
- Shared vocabulary stayed where its users are: `TYPE_KEYWORDS`,
|
||||
`NET_KEYWORDS`, `ASSIGN_OPS`, `ItemMark`, `word_at`, `split_label`,
|
||||
`take_since` in `mod.rs` (used by three or more files); `MEMBER_QUALIFIERS`
|
||||
with `member_head`/`take_member_prefix` in `item.rs` (imported by
|
||||
`decl.rs`); `Harvested` with `take_list_directives` in `directive.rs`;
|
||||
`ForeachTarget` in `stmt.rs` (imported by `class.rs`); `ParamPortList` in
|
||||
`module.rs`; `fragment_file`/`is_prelude` in `directive.rs` (imported by
|
||||
`item.rs`); the three `*_conditional` predicates in `directive.rs`
|
||||
(imported by `split.rs`).
|
||||
|
||||
**Files over the 600 target** (the rule says consider splitting at 800;
|
||||
nothing is over 1 200):
|
||||
|
||||
- `stmt.rs` was 817 in the first pass, 316 of them the `parse_keyword_stmt`
|
||||
dispatch table. QA recommended and the lead adopted moving the table to
|
||||
its own file (§rework below): `stmt.rs` is now 494 and
|
||||
`keyword_stmt.rs` 337.
|
||||
- `sva.rs` 737: one precedence-climbing grammar, 24 productions; "800 lines
|
||||
of grammar productions read more easily than 250 lines of state".
|
||||
- `item.rs` 726: the 167-line `parse_keyword_item` dispatch table plus the
|
||||
small items that have no home of their own.
|
||||
- `class.rs` 659, `covergroup.rs` 621, `instance.rs` 593: each one grammar.
|
||||
|
||||
**Longest functions, before → after** (≥ 80 lines; none split, none merged):
|
||||
`parse_keyword_stmt` 316 (dispatch table, stays whole — doc added; its own
|
||||
file since the rework),
|
||||
`parse_keyword_item` 167 (dispatch table, stays whole — doc added),
|
||||
`parse_primary` 149 (a `match` over token kind and symbol; every arm short
|
||||
enough to read in place, and under the 150 line at which the rules allow a
|
||||
split — left whole), `parse_postfix_inner` 139, `parse_instantiation` 97,
|
||||
`parse_port_list` 91, `parse_connection` 91, `skip_action_stmt` 80,
|
||||
`parse_binary_inner` 80. There is no 316-line `fmt` impl in this crate.
|
||||
|
||||
**Comment-only changes** (no code line changed):
|
||||
|
||||
- The old `// ---- Section ----` banners that would have stood as the first
|
||||
thing in a new file were removed where the file's `//!` doc now says the
|
||||
same (the banner text of "Error recovery", "The SVA grammar",
|
||||
"Vendor and formal collateral" and "Conditional-directive split recovery"
|
||||
*became* those files' docs, verbatim). Banners that still separate
|
||||
sub-sections mid-file (`item.rs` DPI / generate, `cursor.rs` Spans,
|
||||
`decl.rs` Declarations, `assertion.rs` SVA declarations, `ast/class.rs`
|
||||
Constraints) stayed.
|
||||
- `parser/mod.rs`: the doc comment of `push_scope_segment` had been glued
|
||||
above `push_path_segment` (a trunk doc bug — one `///` block ran into the
|
||||
next with no blank line). Moved to its own function. This is the one
|
||||
place a comment did not travel with the item it was attached to, because
|
||||
it was attached to the wrong one.
|
||||
- `parse_keyword_stmt` and `parse_keyword_item` gained a one-paragraph doc
|
||||
saying they are dispatch tables and stay whole.
|
||||
- Module-level `//!` docs on every new file; a layout table in
|
||||
`parser/mod.rs` and `ast/mod.rs`; a `//!` on `parser/tests/mod.rs`.
|
||||
|
||||
**Gates.** `cargo fmt -p vlog_parser --check` clean; `cargo clippy
|
||||
--all-targets --workspace` 0 warnings; `cargo test --workspace` per-binary
|
||||
counts equal to the baseline (48 `test result` lines, diff with the timing
|
||||
stripped: empty). `cargo doc -p vlog_parser --no-deps` item list (every
|
||||
`.html` under `target/doc/vlog_parser`) diffed against the baseline build:
|
||||
0 paths removed, 0 changed; the only additions are the 127 redirect stubs
|
||||
rustdoc writes at `ast/<submodule>/…` for items re-exported from a private
|
||||
module, each a `<meta http-equiv="refresh">` to the unchanged
|
||||
`ast/struct.X.html`. rustdoc's four `private_intra_doc_links` warnings
|
||||
(`parser` module doc → `Parser::bump`/`enter`/`leave`, and `body` →
|
||||
`join_continuations`) are trunk's and the worktree shows the same four; the
|
||||
fifth this lane briefly introduced (`Rewind`) was removed. Byte-identity (`--stdout`, lane release binary vs
|
||||
`/tmp/lucisv-0.33.0-baseline`, `scratchpad/byte_identity.sh`): corpus 860
|
||||
files, 0 differing, 0 exit-code mismatches; OpenTitan `hw/` 3 947 files,
|
||||
0 differing, 0 exit-code mismatches; `git -C opentitan status --porcelain`
|
||||
before and after: the same three pre-existing modified files
|
||||
(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
|
||||
`hw/top_earlgrey/ip/ast/rtl/ast.sv`), nothing else.
|
||||
|
||||
### 2026-09-02 — final pass
|
||||
|
||||
After the last comment-only edits (the dispatch-table docs, the `Rewind`
|
||||
link, the layout tables) the gates were run once more on the final tree:
|
||||
fmt check, clippy, a fresh release build, and both byte-identity runs
|
||||
against that binary — results recorded in the Status list above. The
|
||||
scratchpad copy of the two pristine files (`parser.orig.rs`, `ast.orig.rs`)
|
||||
and the carve scripts are not part of the tree; `git show 159f6a0:crates/
|
||||
vlog_parser/src/parser.rs` is the same text.
|
||||
|
||||
### 2026-09-02 — rework after QA (MEDIUM + three LOW)
|
||||
|
||||
**`parse_keyword_stmt` → `parser/keyword_stmt.rs`.** The 316-line
|
||||
keyword → statement dispatch table (original `parser.rs` 7374–7689, with
|
||||
the doc added in the first pass) moved out of `stmt.rs` into a sibling file
|
||||
as one `impl Parser` block, by the same range method with the same proof
|
||||
(kept + removed == the pre-move `stmt.rs`, byte for byte). Nothing else
|
||||
moved with it: every function the table calls is a statement production
|
||||
(`parse_if_stmt`, `parse_case_stmt`, `parse_case_body`,
|
||||
`parse_assign_or_expr_stmt`) or a shared helper (`expect_stmt_semi`,
|
||||
`eat_stmt_semi`), and those belong to `stmt.rs` — they are the grammar,
|
||||
the table is how a keyword reaches it. Those six became `pub(super)` and
|
||||
`parse_keyword_stmt` itself became `pub(super)` (called from
|
||||
`parse_stmt_kind`); `keyword_stmt.rs` imports `super::stmt::ForeachTarget`
|
||||
for the `foreach` arm's destructuring. `stmt.rs` 494 lines, one sentence
|
||||
without an "and"; `keyword_stmt.rs` 337, its `//!` says it is a table and
|
||||
why it is alone; the layout table in `parser/mod.rs` gained the row.
|
||||
|
||||
**`parse_keyword_item` stays in `item.rs`.** The argument does not apply as
|
||||
cleanly: the item table is 167 lines of a 726-line file (a quarter, not a
|
||||
half), and it is one of three functions that together make one decision —
|
||||
`parse_item_kind` → `parse_keyword_item` / `parse_ident_item` — so moving
|
||||
the middle one out would spread a single decision over two files. The
|
||||
item dispatch also *is* what `item.rs` is for ("from the file down to one
|
||||
item"); the statement dispatch was a second thing in a file about
|
||||
statements.
|
||||
|
||||
**Counts re-measured** (QA's independent numbers adopted): four `rustfmt`
|
||||
re-wrapped signatures, not three; four rustdoc `private_intra_doc_links`
|
||||
warnings on trunk and in the worktree, not five; `pub(super)` on 149
|
||||
methods + 5 free functions + 13 structs/consts/fields on the final tree
|
||||
(the draft's 142 + 11 was the carve script's own count before the fix-ups
|
||||
and the rework). The tables above are updated to the final tree.
|
||||
|
||||
**Rework gates, on the final tree** (after the move and the README edits):
|
||||
`cargo fmt -p vlog_parser --check` clean; `cargo clippy --all-targets
|
||||
--workspace` 0 warnings; `cargo test --workspace` 48 `test result` lines,
|
||||
identical to the baseline with timing stripped (`vlog_parser` lib 360, the
|
||||
rest unchanged); fresh `cargo build --release -p lucisv`, then
|
||||
byte-identity (`--stdout`) against `/tmp/lucisv-0.33.0-baseline`: corpus
|
||||
860 files, 0 differing, 0 exit-code mismatches; OpenTitan `hw/` 3 947
|
||||
files, 0 differing, 0 exit-code mismatches; `git -C opentitan status
|
||||
--porcelain` afterwards shows only the three pre-existing modified files.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-09-02 — independent verification
|
||||
|
||||
**Method.** Worked only in this worktree; built a throwaway baseline
|
||||
worktree at `git worktree add <scratch>/baseline-159f6a0 159f6a0` for every
|
||||
comparison, removed after. Never touched the dev worktree's tracked files
|
||||
(the one exception below is this QA log entry).
|
||||
|
||||
**1. Gates.**
|
||||
`cargo fmt -p vlog_parser -- --check`: clean, no output.
|
||||
`cargo clean -p vlog_parser && cargo clippy --all-targets --workspace`
|
||||
(forced full rebuild, not the cached 0.12s no-op): 0 warnings.
|
||||
`grep -rn "#\[allow" crates/vlog_parser/src/`: zero hits, in this lane and
|
||||
in trunk's `parser.rs`/`ast.rs` — no new `#[allow]`, none existed before.
|
||||
`cargo test --workspace --no-fail-fast`: 48 `test result:` lines, 3215
|
||||
passed / 0 failed / 40 ignored — diffed byte-for-byte (timing stripped)
|
||||
against a fresh `cargo test --workspace` on the baseline worktree:
|
||||
identical, same order. `vlog_parser`'s own counts confirmed line-by-line:
|
||||
unittests 360, `census` 0 (2 ignored), `defines` 26, `error_recovery` 22,
|
||||
`fragments` 18, `null_items` 6, `spans` 18 — matches the pinned table
|
||||
exactly. `parser/tests/*.rs`: 309 `#[test]` fns, matching.
|
||||
`cargo doc -p vlog_parser --no-deps`: 4 `private_intra_doc_links`
|
||||
warnings, identical text to a same-flag build on the baseline worktree
|
||||
(the baseline itself has 4, not 5 — see finding below).
|
||||
`git status --porcelain`: only `TODO.md`, `crates/vlog_parser/src/**`
|
||||
and `docs/features/decomposition-parser/**` changed; the `TODO.md` diff
|
||||
touches only the Lane A line (ticked, one line added citing this README).
|
||||
`git diff 159f6a0 -- crates/vlog_parser/src/lexer.rs crates/vlog_parser/src/token.rs`:
|
||||
empty, confirmed untouched.
|
||||
|
||||
**2. Pure move, mechanically.** Extracted `git show 159f6a0:.../parser.rs`
|
||||
lines 1–8810 (the production part, before `#[cfg(test)] mod tests {` at
|
||||
8811) and `ast.rs` whole, concatenated the 18 new `parser/*.rs` and 8 new
|
||||
`ast/*.rs` files in the README's stated order, normalized leading/trailing
|
||||
whitespace, and took a line multiset diff (Python `Counter`). `parser`:
|
||||
209 distinct lines only-in-orig / 342 only-in-new (551 total instances).
|
||||
Every one of the 209 orig-only lines is explained: 155 gain a
|
||||
`pub(super)`/`pub` prefix in the new file (matched by string concatenation),
|
||||
50 are section-banner comments that became a file's `//!` doc verbatim,
|
||||
and 4 are signatures rustfmt rewrapped onto multiple lines (below). Every
|
||||
one of the 342 new-only lines is: 161 visibility-prefixed
|
||||
duplicates of the above, 145 `//!` module docs, 34 `impl<'a> Parser<'a> {`
|
||||
wrapper braces, 21 `use`, 19 `mod`/`pub use`, 12 `///` doc comments, and 16
|
||||
continuation lines of the 4 rewrapped signatures. Nothing left over.
|
||||
`ast`: 3 orig-only lines (all banner comments) and 46 new-only (32 `//!`
|
||||
docs, 14 `mod`/`pub use`, 7 `use`) — cleanly explained, and ast needs no
|
||||
`pub(super)` (its items were already `pub`, confirmed: `grep -rn
|
||||
"pub(super)" crates/vlog_parser/src/ast/*.rs` is empty).
|
||||
**The one doc re-attachment**: verified directly — trunk's `parser.rs`
|
||||
1596–1609 glues the `push_scope_segment` doc (describing the `::` joiner)
|
||||
above `push_path_segment`, leaving `push_scope_segment` (1618) undocumented;
|
||||
the worktree's `parser/mod.rs` has the doc correctly above each of its own
|
||||
function.
|
||||
**Signature census** (regex + paren-depth scan, from scratch, independent
|
||||
of the dev's method): 306 `fn` signatures in `parser.rs`'s production part,
|
||||
306 in the concatenation, and the *only* 4 mismatches are the same 4
|
||||
rewrapped signatures (`take_list_directives`, `parse_expr_list`,
|
||||
`parse_dist`, `split_conditional_item` — all three original one-line
|
||||
signatures pushed past 100 columns once `pub(super) ` (11 chars) is
|
||||
prepended, e.g. 98→109). `ast.rs`: 23 signatures before and after, 0
|
||||
mismatches. No signature added, removed, or split, in either file.
|
||||
**Finding (LOW)**: the work log says "three signatures `rustfmt`
|
||||
re-wrapped"; it is four (listed above) — an off-by-one in the narrative,
|
||||
not in the carve itself.
|
||||
**`pub(super)` count (against the dev's 142 methods + 11 free items)**:
|
||||
counted 147 `pub(super) fn` (not 142) and, outside `fn`, 3 `pub(super)
|
||||
struct` (`Harvested`, `ParamPortList`, `ForeachTarget`), 1 `pub(super)
|
||||
const` (`MEMBER_QUALIFIERS`) and 9 `pub(super)` struct fields — 13 non-fn
|
||||
items by the broadest reading (or 4 if "free items" means only top-level
|
||||
struct/const, excluding fields), none of which is 11 under any reading I
|
||||
tried. Total `pub(super)` markers: 160. **Finding (LOW)**: the pinned
|
||||
142+11 undercounts the actual 147+13(or 4); every one of the visibility
|
||||
additions found is accounted for as a plain visibility-keyword change
|
||||
(the allowed category), so this does not affect the pure-move verdict,
|
||||
but the README's counts should be corrected.
|
||||
|
||||
**3. Public API.** `cargo public-api` is not installed; used `cargo doc`
|
||||
page-list diff instead (find every `.html` under `target/doc/vlog_parser`,
|
||||
diff against a same-flag baseline build): 0 removed, 0 changed, 127 added
|
||||
— all 127 confirmed to be `<meta http-equiv="refresh">` redirect stubs
|
||||
(spot-checked `ast/class/struct.ClassDecl.html`) pointing at the unchanged
|
||||
`ast/struct.X.html`. Spot-checked 10 promised paths (`ast::Expr`,
|
||||
`ast::ItemKind`, `parser::Parser`, `parser::parse`, `parser::parse_tolerant`,
|
||||
`parser::ParseError`, `parser::ParseDiagnostic`, the three `MAX_*`/`*_SIZE`
|
||||
constants) byte-identical to baseline after stripping `href="..."`
|
||||
attributes (only the `Source` line-number links differ, as expected for
|
||||
code that moved files). `parser`/`ast` submodules are `mod` (private), not
|
||||
`pub mod`, confirmed by reading `mod.rs` — no new public path. The full
|
||||
workspace build (§1) is the proof every other crate compiles unchanged;
|
||||
all of `vlog_semantic`, `vlog_formatter`, `vlog_linter`, `vlog_refactor`,
|
||||
`lucisv`, `lucisv_server`'s tests passed against this tree with 0 changes
|
||||
needed in those crates.
|
||||
|
||||
**4. Byte-identity, independently.** Built `cargo build --release -p
|
||||
lucisv` in both this worktree and a fresh baseline worktree at `159f6a0`
|
||||
(not the pre-supplied `/tmp/lucisv-0.33.0-baseline`, to keep the baseline
|
||||
independent of anything the dev might have produced; both report `lucisv
|
||||
0.33.0`). Corpus: `find corpus -name "*.sv" -o -name "*.v" -o -name
|
||||
"*.svh"` → 860 files (matches). Ran `--stdout` through both binaries per
|
||||
file: 0 differing, 0 exit-code mismatches. OpenTitan `hw/`: `find -type f`
|
||||
(no `-L`) → 3947 files, matching the pinned count exactly (a naive
|
||||
recursive walk that follows symlinks finds 3979 — the 32-file gap is
|
||||
`top_englishbreakfast`'s symlinked duplicates of earlgrey/darjeeling files;
|
||||
re-ran against the symlink-following 3979-file set too, still 0 diffs, so
|
||||
this doesn't change the verdict, just a note on how to reproduce the exact
|
||||
3947). 0 differing, 0 exit-code mismatches either way.
|
||||
`git -C /Users/guoliangchen/repo/opentitan status --porcelain` checked
|
||||
before and after both runs: unchanged, exactly `hw/ip/aes/dv/tb/tb.sv`,
|
||||
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`,
|
||||
nothing else — no write, read-only confirmed.
|
||||
|
||||
**5. Size rule.** `wc -l` on every new file matches the README's tables
|
||||
exactly, both `parser/*.rs` (18 files) and `ast/*.rs` (8 files) — no
|
||||
discrepancy. Longest-function spot check: `parse_keyword_stmt` 316,
|
||||
`parse_keyword_item` 167 confirmed by direct inspection; `parse_primary`
|
||||
149 confirmed by locating its enclosing lines (9–157) — a first attempt
|
||||
with an automated brace-matcher misreported 142 because of a brace inside
|
||||
a token the script didn't recognize as a string/char boundary; manual
|
||||
line-counting confirms the README's 149, one line under the 150 threshold
|
||||
the write-up leans on. **`stmt.rs` split recommendation (MEDIUM, per the
|
||||
brief's request to judge this)**: yes — `stmt.rs` at 817 is over 800
|
||||
mainly because of `parse_keyword_stmt` (316 lines, ~39% of the file);
|
||||
moving it to a sibling (e.g. `parser/stmt/keyword.rs`) leaves the
|
||||
statement-grammar file at ~500 lines (squarely in the 300–600 target,
|
||||
consistent with how `item.rs` kept its own smaller 167-line table inline)
|
||||
and a `keyword.rs` a reader names as "the keyword → statement dispatch
|
||||
table" — both easier to name in one sentence than the current combined
|
||||
file. Not done, per instructions; recorded as a recommendation for the
|
||||
lead. No file is over 800 without the file already carrying a written
|
||||
reason in the Work log (`stmt.rs`, `sva.rs`, `item.rs`, `class.rs`,
|
||||
`covergroup.rs`, `instance.rs`), and none is within reach of 1200. Every
|
||||
new file's `//!` doc was read: none needs an "and" to describe two
|
||||
unrelated responsibilities — the lists inside several docs (`item.rs`,
|
||||
`instance.rs`, `assertion.rs`) name sub-parts of one grammar domain, not
|
||||
two different domains stitched together, so no MEDIUM beyond the
|
||||
`stmt.rs` one above.
|
||||
|
||||
**6. Tests regrouping.** Name-level diff: extracted all 309 `#[test]` fns
|
||||
from trunk's `mod tests { ... }` block and all 309 from `parser/tests/*.rs`
|
||||
by a custom Rust-string/char/comment-aware scanner (a first attempt using
|
||||
naive brace-counting broke on Verilog snippets in the test bodies
|
||||
containing `{`/`}`); 0 missing, 0 added — same 309 names, no renames.
|
||||
Body diff after stripping all whitespace outside string/char literals and
|
||||
removing comments (token-level, not just whitespace-collapse): 11 of the
|
||||
309 differ, and every one is `rustfmt` re-flowing a call it now fits on
|
||||
one line where it used to wrap (dropping/adding a trailing comma after a
|
||||
single argument, or adding/removing braces around a one-line match-arm
|
||||
body) — spot-checked all 11 by hand, e.g. `exports_split_into_dpi_and_
|
||||
package_re_exports`: the `format!(...)` call's arguments are character-for
|
||||
-character identical, only whether it's `{ format!(...) }` or bare
|
||||
`format!(...)` as the match arm changed, because the file is now 4 columns
|
||||
shallower per the documented Assumption. No test's assertions, inputs, or
|
||||
expected values changed. Spot-checked 5 random test → file placements:
|
||||
`a_bind_instance_may_be_a_hierarchical_path`→`instance.rs`,
|
||||
`the_option_assignment_slots_keep_their_comments`→`covergroup.rs`,
|
||||
`a_written_empty_parameter_list_is_distinguishable_from_none`→`module.rs`,
|
||||
`the_header_keeps_the_comments_written_around_its_name`→`class.rs`,
|
||||
`a_randomize_with_block_is_parsed_and_the_call_is_not`→`class.rs` — every
|
||||
one lands in the file matching its subject.
|
||||
|
||||
**7. Docs.** All required README sections present and non-empty
|
||||
(Goal/Assumptions/Handshakes/Status-TODO/Work log/QA log/Review reserved).
|
||||
Spot-checked 5 line ranges against `git show 159f6a0`: `recover.rs`
|
||||
95–131 (`SYNC_CLOSERS`/`SYNC_OPENERS`), `tf.rs` 250–253 + 6992/7230
|
||||
(`TfBody`, the functions-and-tasks banner, closing label parse), and both
|
||||
`covergroup.rs` 549–562/2909–3508 boundaries plus `ast/covergroup.rs`
|
||||
2526–2932 and `ast/sva.rs` 2933–3295 — all five match the stated original
|
||||
line content exactly. The "range manifest with a concatenation proof"
|
||||
method is described well enough that I reproduced an equivalent check
|
||||
independently (Python `Counter` multiset diff, §2 above) without needing
|
||||
the dev's own scripts, and got the same result.
|
||||
|
||||
**Findings summary.**
|
||||
- LOW: work log says "three signatures" rustfmt re-wrapped; actually four
|
||||
(`take_list_directives`, `parse_expr_list`, `parse_dist`,
|
||||
`split_conditional_item`).
|
||||
- LOW: work log says rustdoc's trunk baseline has "five"
|
||||
`private_intra_doc_links` warnings; a from-scratch build of 159f6a0 with
|
||||
the same flags shows four, matching the worktree's four exactly (same
|
||||
text) — the delta-of-one-removed ("Rewind") claim doesn't reconcile
|
||||
against what trunk actually emits, but the outcome (4 == 4, identical
|
||||
text) is correct and byte-checked.
|
||||
- LOW: `pub(super)` count is 147 methods + 13 non-fn items (3 structs, 1
|
||||
const, 9 fields) by the broadest reading — not the pinned 142 + 11.
|
||||
Every addition found is a plain visibility-keyword change (the allowed
|
||||
category); this doesn't change the pure-move verdict.
|
||||
- MEDIUM (recommendation, not a defect): split `parse_keyword_stmt` out of
|
||||
`stmt.rs` into its own file; see §5.
|
||||
- No HIGH or CRITICAL findings: 0 changed code lines beyond the allowed
|
||||
categories, 0 public paths removed/renamed, 0 test count drop, 0 test
|
||||
body changed beyond `rustfmt` reflow, 0 corpus/OpenTitan output diffs, 0
|
||||
exit-code mismatches, OpenTitan tree unmodified beyond its 3 pre-existing
|
||||
files.
|
||||
|
||||
**Verdict: PASS.** The three LOW findings are narrative/count corrections
|
||||
the dev should make in the Work log; the one MEDIUM is a recommendation
|
||||
for a future pass, explicitly not to be acted on now. Nothing here forces
|
||||
rework.
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-02 — lead.** Accepted; merged onto master beside lane B. The
|
||||
range-manifest method — refuse to write unless the segments concatenate
|
||||
back to the original byte for byte — is the right way to carve fourteen
|
||||
thousand lines, and it is why QA's from-scratch multiset and signature
|
||||
census found only visibility keywords, `use` lines and rustfmt rewraps.
|
||||
Nineteen parser files and eight AST files a reader can name in one
|
||||
sentence; the cut points that differ from the plan (`cursor` out of
|
||||
`mod`, `split` beside `directive`, `expr`/`primary`, `class`/
|
||||
`covergroup`, `assertion`/`sva`) each carry their reason. QA's one
|
||||
MEDIUM taken at review: `parse_keyword_stmt` now stands alone in
|
||||
`keyword_stmt.rs`, so `stmt.rs` is "statements" with no "and";
|
||||
`parse_keyword_item` stays in `item.rs` for the reason the dev gives.
|
||||
The three count nits fixed. Every public path unchanged, per-binary test
|
||||
counts identical, 4 807 files byte-identical — the lead re-ran the
|
||||
multiset check on the final tree. Files over 600 (`sva`, `item`, `class`,
|
||||
`covergroup`) keep their written reasons and are the next lane's problem
|
||||
if they grow.
|
||||
Reference in new issue
Block a user