Commit Graph
19 Commits
Author SHA1 Message Date
lucioandClaude Fable 5 a4f8476894 Fix round-1 QA findings: Inline width in fits(), action-block nesting, comment gaps
printer::fits() now measures from a multi-line Doc::Inline's last line and
keeps measuring the rest of the group (a with {...} block no longer hides
an overflow). skip_action_stmt tracks begin/end, fork/join, case/endcase
nesting so a concurrent assertion's action block is captured whole.
Comments between bind/target/module and around randomize(...) with are
attached and reprinted instead of being refused by the safety net.
All 800 passing corpus files format byte-identically before and after.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 02:11:59 -07:00
lucioandClaude Fable 5 e35da292bd Add mop-up-2: macro items ending their line, new shallow copy, 32'h`MACRO
A macro invocation that ends its line is a complete item whatever opens
the next line; new <expr> shallow-copy constructor; a based number whose
digits come from a macro (32'h`BOOT_ADDR) lexes as a base-only number
joined with the macro in the parser. verify.rs untouched, attack tests added.

Coverage loop round 2: 796 -> 800 / 820 (97.1% -> 97.6%).
Feature README: docs/features/mop-up-2/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 01:42:53 -07:00
lucioandClaude Fable 5 f1db1e5746 Add dv-statements: with clauses, foreach targets, randcase, let, labels
randomize()/std::randomize() with { ... } (block verbatim), array-method
with (expr), foreach over scoped/hierarchical/indexed arrays, randcase,
wait fork, import as a statement, let declarations, empty call arguments,
general statement labels, and endtask: name; (stray semicolon kept).
Also fixes a pre-existing verification failure for a comment between a
then-branch and its else.

Coverage loop round 1, cluster 8: 772 -> 796 / 820 (94.1% -> 97.1%).
Feature README: docs/features/dv-statements/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 01:19:49 -07:00
lucioandClaude Fable 5 c2ea1656e1 Add expressions-2: casts, streaming, ->, drive strengths, pattern replication
Casts with parenthesized/keyword/scoped bases, streaming operators, -> and <-> implication, assign (weak0, pull1) drive strengths, (* attr *) on named connections, '{N{x}} replication in assignment patterns, x inside `MACRO, const ref tf arguments.

Coverage loop round 1, cluster 7: 751 -> 772 / 820 (91.6% -> 94.1%).
Feature README: docs/features/expressions-2/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 00:46:39 -07:00
lucioandClaude Fable 5 2a63faf9a2 Add interfaces, modport, clocking blocks and virtual interface types
interface...endinterface shares the module header/body machinery (ItemKind::Module with kw == "interface"); modport and clocking are structural items; virtual <iface>[#(...)] is accepted in every type position. module-filename now applies to interfaces.

Coverage loop round 1, cluster 5: 712 -> 740 / 820 (86.8% -> 90.2%).
Feature README: docs/features/interfaces/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-21 00:01:53 -07:00
lucioandClaude Fable 5 e24d33afab Add concurrent assertions, sequence and property as verbatim items
assert/assume/cover/restrict property (...) [action block], optionally labeled, at item and statement position; sequence...endsequence and property...endproperty declarations. Verbatim pass-through like constraint/covergroup; verify.rs untouched, attack tests added.

Coverage loop round 1, cluster 4: 699 -> 712 / 820 (85.2% -> 86.8%).
Feature README: docs/features/assertions/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 23:38:22 -07:00
lucioandClaude Fable 5 f7c66c79bf Add bind directives
bind <target> [: inst, ...] <module> [#(...)] <inst> (...); reusing the instantiation AST and layout wholesale.

Coverage loop round 1, cluster 3: 671 -> 699 / 820 (81.8% -> 85.2%).
Feature README: docs/features/bind/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 23:23:41 -07:00
lucioandClaude Fable 5 8007a71932 Add dpi-export: DPI-C import/export and package export
import "DPI-C" [context|pure] function/task prototypes, export "DPI-C" function/task, and export pkg::*; / pkg::item.

Coverage loop round 1, cluster 2: 661 -> 671 / 820 (80.6% -> 81.8%).
Feature README: docs/features/dpi-export/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 23:09:49 -07:00
lucioandClaude Fable 5 f52beff48f Add item-misc: spaced macro calls, line-aware macro items, `error, elab tasks
Macro invocations with whitespace before the argument list, a bare macro on its own line followed by a declaration, `error/`warning directives, and $error/$fatal/$warning/$info as module/generate items.

Coverage loop round 1, cluster 1: 636 -> 661 / 820 (77.6% -> 80.6%).
Feature README: docs/features/item-misc/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 22:54:47 -07:00
lucioandClaude Fable 5 54b0ca3896 Add class-semantics and lexer-cleanup (round 20)
class-semantics: classes are first-class in vlog_semantic -- class
scopes and symbols, member/method/prototype binding, this.x
(nearest-class-only), super.x, cls::x with lexical unit heads,
out-of-body cls::method bound into the class's scope with the extern
prototype as the definition (rule 10), and the honest
InheritedCandidate{base, paths} shape: a member miss in an extending
class records what the unknown base might supply (import paths
included) and is never chased, not even in-file -- the future
inheritance round's worklist, measured at 1303 candidates. Unit-name
misses stay ExternalCandidate (QA-found, lead-ruled: bases supply
members, not package names; +170 recovered navigations, pinned).
Workspace index gains classes as units (246) and their members
(11399). scan.rs migrated to parser name-spans: 26 call sites down
to the 2 documented consumers. 114044 spans, 0 unplaced, 0 panics;
UVM code now has hover/definition/references/outline.

lexer-cleanup: the three filed gaps -- @(* ) lexes via a
starts_attribute backoff (an attribute cannot begin with `)`; real
attributes pinned, no misfire on legal expressions), a leading BOM
is accepted as a named losslessness exception (mid-file BOM errors
clearly; 20k-case position fuzz clean), and non-ASCII lex errors now
decode the full character AND surface through vfmt check's error
slot (exit 2, matching format, text-rule findings still reported --
the silent-pass hole closed). The macro space-before-paren item is
parked with a QA-hardened analysis: the reading depends on a
definition vfmt cannot see, any fixed answer is provably wrong for
one population, and today's behavior fails safe.

827 workspace tests. Dev: 2 Fable agents; QA: 2 Opus agents; reviews
in docs/features/{class-semantics,lexer-cleanup}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-20 00:56:32 -07:00
lucioandClaude Fable 5 da1448ecd0 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]>
2026-08-19 20:22:18 -07:00
lucioandClaude Fable 5 7f2e78fc1c Add classes: SystemVerilog class support, corpus 58.0% -> 70.5%
The top corpus blocker (142 extends-blocked UVM/DV files) falls.
Structural support: class/virtual class with parameter ports,
extends (named/ordered params), implements, property qualifiers
(rand/randc/local/protected/static/const), virtual interface
properties, parameterized types, method qualifiers with extern and
pure-virtual prototypes plus out-of-body cls::method definitions,
typedef class, scoped parameterized calls, disable fork. Class
bodies reuse the existing item loop, so Meta, directives, macros and
nesting work with no per-site code. Constraint blocks, covergroups
and parameterized-type #() arguments are span-sliced verbatim leaves
-- their internals are a distinct sub-language where formatting has
no payoff and corruption risk is highest, so 9 masked-corruption
rejection tests ship although verify.rs is byte-identical
(invariant-4 discipline, voluntarily; QA's sabotage recreated the
historical in-string corruption and exactly one pin turned red).

Corpus: 476 -> 578/820 formattable (70.5%), parse-error 344 -> 242,
zero regressions by path, all 578 formattable files round-tripped
individually. 72 of the 142 extends files format; 70 advance to
named next blockers -- queues/dynamic arrays are now the top corpus
blocker (41 files). Two verification failures fixed en route: a
pre-existing lexer blank-line-after-continuation bug (proven
pre-existing on a HEAD worktree) and raw_inline convergence for
mid-line verbatim starts.

Handshakes filed: fences inactive inside class bodies; the four
AST-walking lint rules skip class members (line-based rules still
fire); vlog_semantic treats class bodies as opaque -- the LSP
navigation gap is that crate's natural next round. parse() now takes
the source (verbatim capture in strict mode); single caller updated.

612 workspace tests (397 cases). Dev: Opus agent; QA: Sonnet agent
(pre-feature worktree diff, full 578-file round-trip, UVM torture,
two reverted sabotages); review in docs/features/classes/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 13:45:18 -07:00
lucioandClaude Fable 5 692496fb89 Add directives-in-instances and shared-fence-filter (round 15)
directives-in-instances: `ifdef/`else/`elsif/`endif/`define/`include
now parse between elements of instantiation #() override lists and
connection lists (param_directives on Instantiation, conn_directives
on Instance -- an all-in-arm list is Connections::Ordered(vec![]),
so the vector cannot live inside it; commas stored on Connection and
OrderedConn, never derived). All six named corpus targets format and
converge; no corpus file is blocked on a compiler directive any more
(backtick parse errors 6 -> 0); corpus 476/820 formattable (58.0%),
clean-file external resolution 94.0%. One bug found en route and
fixed: directive_entry overwrote before_sep, dropping a comment
(net-caught; pinned by directives_in_lists.cases:780, sabotage-
verified).

shared-fence-filter: one definition of "which bytes are fenced" --
protected_regions/is_protected in vlog_formatter::fence (the CLI's
scan MOVED in, not copied; grep finds one owner). The CLI filter is
byte-identical (isolated-diff worktrees, 8 shapes, 48 CLI tests
diff-empty); the server's quickfix and fixAll paths now drop fixes
touching protected bytes -- off means hands-off in the editor too.
Sabotage: removing the scan union fails six tests across three
crates. Lead fix: the good-tree test now genuinely pins the collect
path (QA found it only exercised the scan).

(The stale corpus-check-results.tsv two QAs flagged turned out to be
an untracked ignored working file, not a committed one -- deleted
from disk after this commit; it regenerates on every corpus run.)

589 workspace tests. Dev: 2 Opus agents; QA: 2 Sonnet agents;
reviews in docs/features/{directives-in-instances,
shared-fence-filter}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 12:09:51 -07:00
lucioandClaude Fable 5 6e6aacb392 Add directives-in-lists: ifdef/define/`include between list elements
Roadmap item 6: conditional-compilation directives are now accepted
between elements of port lists, parameter-port lists and enum member
lists, carried as parallel ListDirective vectors (source order via a
before-index; additive AST so vlog_semantic and vlog_linter compile
unmodified) and emitted verbatim. Commas are STORED, never derived:
two real corpus shapes (comma inside the `ifdef arm; no comma at all
in `else alternatives) kill any derivation rule in opposite
directions. A comma printed on a directive's line would be swallowed
into the condition on re-parse -- prevented by a forced break,
sabotage-verified against the safety net.

Corpus: parse-error 352 -> 350 (ibex_core.sv formats), six more
files advance to later blockers -- picorv32.v parses 1986 lines
further but still refuses on restrict property (item 7). The real
payoff is the workspace index: picorv32/_axi/_wb now index
(530 modules, 9174 members), cross-file external resolution
87.0% -> 93.6% on clean files, unresolved externals 2.6% -> 1.3%.
0 verification errors, 0 crashes, verify.rs byte-identical.

563 workspace tests (20 new cases, 9 verification, 7 parser units).
Dev: Opus agent; QA: Sonnet agent (both semantic baselines
reproduced from a detached worktree); review in
docs/features/directives-in-lists/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 11:31:14 -07:00
lucioandClaude Fable 5 1ac9746c45 Add workspace-index and name-spans (jointly: round 10)
workspace-index (vlog_semantic): cross-file resolution -- the
owner's `import pkg::*;`-anywhere requirement delivered.
WorkspaceIndex maps modules/packages/file-scope typedefs, package
exports, module ports/params and per-file define tables; built
tolerantly (broken files still contribute), deterministic by
construction (FileIds assigned after path sort). resolve_external
answers ExternalCandidates in a two-layer overlay keyed by
ReferenceId -- Semantics stays a pure single-file fact; local
declarations outrank imports. Corpus: 87% of external candidates
answered (external rate 19.6% -> 2.6% on clean files), ambiguity
kept honest (OpenTitan prim_generic/prim_xilinx), 0.7s build,
workspace_symbols substring search.

name-spans (vlog_parser): the approved vlog-semantic handshake --
the parser records every declared name's span at parse time (28
fields across 21 node kinds; Name/ImportPath bundles where parallel
Vecs could desync; ImportPath splits p::x for the index). Content-
pinned by the exhaustive walker on every source, mutation-tested
three ways, zero behavior change (corpus md5 exact, QA byte-compared
formatter output against a HEAD worktree). scan.rs is now one
consumer away from deletion (DataType span, handshake item 2).

TODO §6 foundations complete: spans, error recovery, define table,
single-file semantics, workspace index. Next: vfmt_server.

Dev: 2 Opus agents; QA: 2 Sonnet agents; reviews in
docs/features/{workspace-index,name-spans}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 07:09:04 -07:00
lucioandClaude Fable 5 982e37063b Add comments-round: close the comment-attachment gaps
Meta.trailing is now Option<Comment> (line/col/span — delivers the
format-fences handshake; same-line fences stay deliberately inert),
and Meta::before_sep keeps a comment on its element's side of the
separator across every list kind, including the closing-bracket
buckets. take_before_sep is a no-op unless the cursor is on the
separator, which is why all 299 pre-existing cases stayed
byte-identical. Also fixes: EnumType::dangling comments parsed but
never printed (a latent invariant-#3 violation), the double-blank
between leading comments (six corpus files became fixed points), and
five documented expression refusals (replication interior,
compact-bracket operator position, assign-value, concat brace,
header imports via HeaderImport).

Reproducible acceptance metrics (HEAD-worktree control): line-
position comment injection refusals 2.3% -> 0.4%; exhaustive gap
probe 90 -> 22 refused; delimiter-position 61% -> 36%. Remaining
parked positions documented. verify.rs byte-identical; +7 rejection
tests; corpus 0 verification errors, 0 crashes, parse 468/820.

229 workspace tests, clippy silent. Dev: Opus agent; QA: Sonnet
agent (sabotage-verified pins, independent probes); review in
docs/features/comments-round/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 06:11:53 -07:00
lucioandClaude Fable 5 0ba29d4635 Add define-table: record every `define for LSP hover expansion
collect_defines() is a post-lex pass over Directive tokens (zero
lexer changes) building an ordered DefineTable: name, params (as
written, defaults included), body normalized exactly as a
preprocessor joins continuations (backslash-newline removed, every
other byte preserved -- string values survive), span and name_span.
Redefinitions and `undef events are all recorded in source order
(latest()/all()); position-aware resolution is deliberately left to
the future hover implementation, which needs the history.

Pure data feature: no behavior change anywhere. 24 tests including
mutation-testing of the normalization rule against alternatives that
would rewrite string values. QA swept 502 defines from the corpus
with zero span/name mismatches and hand-verified prim_assert.sv
macros; CRLF continuations confirmed at lexer and table layers.

TODO §6 data foundations now complete (spans, error recovery,
define table).

Dev: Opus agent; QA: Sonnet agent; review in
docs/features/define-table/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 05:39:56 -07:00
lucioandClaude Fable 5 02f68655b5 Add error-recovery and format-fences (jointly: entangled in format.rs)
error-recovery (vlog_parser): parse_source_tolerant never fails —
errors become positioned ParseDiagnostics and ItemKind::Error /
StmtKind::Error leaves (raw text + span, nesting invariant intact),
with recovery at documented sync tokens, bracket-balanced skipping,
and stray-closer collapse. Strict parse_source is byte-identical in
behavior (shared grammar, tolerant flag). Guarantees tested:
tolerant==strict on 500 valid sources; depth/links budgets neither
reset nor leak across recovery (mutation-tested); no panic across
27k+ truncation cuts, every single-char fixture deletion, 1MB of
semicolons (500k recoveries, 344ms). The future LSP parses mid-edit
code; the formatter still refuses on the first error.

format-fences (vlog_formatter): // verilog_format: off|on and
// vfmt: off|on emit fenced item ranges as exact source bytes via
spans (Doc::Verbatim), Verible-style item-level regions per scope,
unmatched off to end of scope, byte-exact including indentation and
idempotent at every join (24 adversarial probes). ~2000 corpus fence
injections: zero region byte changes, zero new verification
failures. verify.rs untouched; with no fences output is
byte-identical (corpus TSV md5 unchanged).

Also surfaced and queued in TODO: comment-in-list refusals
(112/1868 injection trials) and the double-blank leading-comment
nit — the next comments round.

Dev: 2 Opus agents; QA: 2 Sonnet agents; reviews in
docs/features/{error-recovery,format-fences}/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 05:23:05 -07:00
lucioandClaude Fable 5 901a78ccb2 Add spans: byte ranges on every token and AST node, plus LineIndex
The LSP cornerstone (TODO §6) and the prerequisite for format-off
fences and range formatting. Convention: node span = code extent
(first to last token; attributes included, comments excluded and
carrying their own spans) — chosen because it makes child-nests-in-
parent a total, assertable invariant. Expr became {kind, span};
element structs carry spans; payload structs whose extent equals
their wrapper's deliberately don't (one fact, one place). LineIndex
maps offset <-> 1-based line:col in UTF-8 bytes, with clamping.

A token-level losslessness test asserts every source byte is covered
by token/trivia spans (whitespace aside) and concatenation
reconstructs the input — it immediately surfaced and documented two
pre-existing lexer normalizations (sized-literal tick spacing,
merged same-line trailing comments), both whitespace-only.

Zero behavior change, proven: corpus TSV md5-identical, and QA
diffed formatter output on all 820 corpus files against a pre-spans
worktree binary — no differences. Mutation-tested by dev and QA;
one unpinned span QA found (GenIf content) is now pinned by a
lead-added slice test. 161 workspace tests.

Dev: Opus agent; QA: Sonnet agent; review in
docs/features/spans/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-19 04:44:51 -07:00