Vendor and formal collateral: specify, UDPs, checkers, configs, interface classes, alias, union tagged - proven output-neutral
TODO section 23, coverage_gaps M1-M3 with the evidence corrected: every construct here has zero declarations in the corpus and in opentitan (the analysis's '13 checker files' were UVM protocol-checker filenames), so this is a completeness round for vendored cell/IO/memory models and formal collateral, and the formatted output of all 860 corpus and all 3975 opentitan files is byte-identical to v0.29.0. Five keywords reserved on a measured zero-collision census (checker, endchecker, config, endconfig, library); five deliberately not - expect has 41 real task-call sites, so the statement form is recognised only when its parentheses hold a sequence operator. One parse_opaque_block (counts its own opener, keeps the label, leaves a trailing ';' as the null item empty-item sees) serves specify, primitive with table, checker and config; library lines parse; specparam is a real declaration with a rewind for PATHPULSE$; alias a = b = c binds every term; union tagged formats; interface class routes through the class prefix with no new kind and no FACTS bump - deliberately, so it cannot collide with the parallel lane's bump - and implements now contributes type-hierarchy supertypes. pairs.rs pairs table, checker and config. docs/features/vendor-formal-grammar/README.md. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
c40e720518
commit
29096cbbac
22 files changed
+1793
-100
No files matched your search
@@ -2549,25 +2549,40 @@ docs/features/vendor-formal-grammar/README.md (new), amendments in
|
||||
interfaces / type-hierarchy / editor-scopes / corpus-check READMEs,
|
||||
docs/coverage_gaps.md (M2 evidence corrected), TODO.md §23.
|
||||
|
||||
- [ ] Opaque scans via one `parse_opaque_block(open, close)` (the
|
||||
- [x] Opaque scans via one `parse_opaque_block(open, close)` (the
|
||||
`parse_covergroup_verbatim` template): `specify…endspecify`,
|
||||
`primitive…endprimitive` (swallows `table…endtable`),
|
||||
`checker…endchecker`, `config…endconfig`; `SYNC_CLOSERS` gains
|
||||
their closers; `specparam` outside specify as a param-like item.
|
||||
- [ ] `interface class … endclass` routed to `parse_class` with a kind
|
||||
- [x] `interface class … endclass` routed to `parse_class` with a kind
|
||||
marker; `ClassDecl.implements` already parsed — type hierarchy
|
||||
adds `implements` to `supertypes` (the two blocking pins flip);
|
||||
classes.rs collects it; `SymbolKind::Class` with an
|
||||
interface-class flag or a new kind (argue; FACTS bump if new).
|
||||
- [ ] `alias a = b = c;` as `ItemKind::Alias(Vec<Expr>)`; statement
|
||||
- [x] `alias a = b = c;` as `ItemKind::Alias(Vec<Expr>)`; statement
|
||||
`expect (…) action;` text-matched into the concurrent-assertion
|
||||
verbatim path; `union tagged` flag on StructType (formatted);
|
||||
`tagged Valid 5` / `case … matches` left filed (pattern grammar).
|
||||
- [ ] Pins: each construct formats + round-trips (opaque byte-exact),
|
||||
- [x] Pins: each construct formats + round-trips (opaque byte-exact),
|
||||
pairs/folding for the new pairs, grammar lock green, `expect(x);`
|
||||
as a task call unchanged (the 40-site regression guard), a
|
||||
module named `checker_x` unaffected; corpus 813/820 unchanged;
|
||||
opentitan sweep unchanged.
|
||||
- [x] **QA (2026-09-02)**: verdict **SHIP**. Gates reproduced exactly
|
||||
(fmt/clippy clean, tests 3 092/0/39, grammar lock green, corpus
|
||||
814/820, release build + smoke.js OK, `verify.rs` untouched).
|
||||
Census re-derived independently (0/0/0 for
|
||||
config/library/checker across corpus + opentitan hw). Keyword-
|
||||
boundary, `expect`-disambiguation, opaque-block and
|
||||
unclosed-block attacks all landed as documented; gap-parity pin
|
||||
reproduced directly against `defparam`. Regression net
|
||||
(spiflash_tb.v, otbn tb.sv, rom_ctrl scoreboard) and a 30-file
|
||||
opentitan sample byte-identical against a trunk `c40e720` build;
|
||||
opentitan tree held only its 3 pre-existing owner files. One
|
||||
informational, non-blocking finding (pre-existing, confirmed on
|
||||
trunk too): an unquoted library wildcard path containing `/*`
|
||||
lexes as an unterminated block comment. Full log in the feature
|
||||
README's QA log.
|
||||
|
||||
## 24. Semantic lints on by default (planned 2026-09-02) — coverage_gaps M7 via topo §2.9-6 + §2.9-4
|
||||
|
||||
@@ -2626,3 +2641,61 @@ completion-core READMEs, docs/site rules.md regenerated, TODO.md §24.
|
||||
finding is a suspect FP: hand-verify a sample of ≥30, report the
|
||||
FP rate by mode; server diagnostics on 10 RTL files; settings
|
||||
round trip over the wire; store/scan deltas.
|
||||
|
||||
## 25. Small-correctness residue (planned 2026-09-02) — §2.9-22, H5, M11, §2.9-20, §2.9-21
|
||||
|
||||
Mapped: comment "loss" is re-attachment — `bump` queues every comment
|
||||
and `take_meta` hands it to the NEXT node, so a slot with no field
|
||||
prints the comment one node later and the safety net (which compares
|
||||
comments too) refuses the file. Six fix families cover every filed
|
||||
slot: **G1** postfix segments (`.`/`::`/`[` branches of
|
||||
`parse_postfix_inner` — three bare `bump()`s beside a `(` branch that
|
||||
already keeps `CallComments`; `parse_foreach_target_inner` is a
|
||||
hand-copied duplicate of the same loop) → one `SegmentComments
|
||||
{before_open, after_open, before_close}` on Member/Scope/Index/Range
|
||||
and one shared loop; **G2** the `[a:b]` range grammar written three
|
||||
times (`parse_value_range`, the inlined `inside` copy, `parse_dims`)
|
||||
→ one function with `RangeComments`, and `ExprKind::Inside` gets the
|
||||
`BinaryComments` its operator peers carry; **G3** `keyword (` headers
|
||||
(statement `if`/`case`/`foreach`, `@`, `#`) → the existing boxed
|
||||
`HeaderComments`; **G4** the gap before a statement's `;` →
|
||||
`Stmt.before_semi` + `StmtKind::takes_semi()` (constraint-bodies'
|
||||
"one owner of the `;`", widest blast radius); **G5** segment-preserving
|
||||
scoped names (`parse_scoped_name` joins a `String`) → `Vec<Name>` with
|
||||
per-`::` comments — closes §2.9-21 too (the escaped segment's space);
|
||||
**G6** per-construct fields: enum member `=`, sens-item edge keyword,
|
||||
`take_member_prefix`, `parse_label`, class/module header gaps,
|
||||
`parse_tf_ports` (the bulk of the covergroup count, 38 of 52). Plus
|
||||
three small fixes: **H5** `nav::definition` gains the macro branch hover
|
||||
already has (`DefineTable::latest` / `WorkspaceIndex::find_define`
|
||||
return file+`name_span`; the include-graph narrowing is factored);
|
||||
**M11** the cast's type binds (`bind_expr`'s `Cast { expr, .. }` drops
|
||||
`ty`; a `bind_type_expr` mirroring `bind_data_type`'s three shapes —
|
||||
type_def.rs's own doc claim about casts becomes true); **§2.9-20** the
|
||||
rename warning for a candidate reference that stayed
|
||||
`StillUnresolved` through the overlay ("`sig` after `.` could not be
|
||||
resolved — module `unknown_mod` not indexed"), `unaccounted_warnings`
|
||||
run over all files that mention the name (as `macro_use_warnings`
|
||||
does), the premise pin inverted in the same commit. Files:
|
||||
crates/vlog_parser/src/{ast.rs, parser.rs}, tests/spans.rs,
|
||||
crates/vlog_formatter/src/format.rs, tests/verification.rs (drive
|
||||
`EXPECTED_FAILING_GAPS` and `EXPECTED_FAILING_FRAGMENT_GAPS` to 0, delete
|
||||
the two analogue tests in the same commit, commit the constraint
|
||||
fuzzer that was never committed), cases/comment_slots.cases (new),
|
||||
crates/vlog_semantic/src/bind.rs (+ tests), crates/lucisv_server/src/
|
||||
{nav.rs, hover.rs shared narrowing, type_def.rs test}, tests/e2e.rs,
|
||||
crates/vlog_refactor/src/rename.rs + tests/rename.rs, docs/features/
|
||||
comment-slots/README.md (new), amendments in escaped-identifiers /
|
||||
overlay-promotion / type-definition / refactor-rename / the three
|
||||
fuzzer READMEs, docs/topo.md rows 20/21/22 struck (lead), TODO §25.
|
||||
Runs AFTER §23 (parser/format/bind collide), in parallel with §24.
|
||||
- [ ] G1 · [ ] G2 · [ ] G3 · [ ] G4 · [ ] G5 (+§2.9-21) · [ ] G6
|
||||
- [ ] fuzzers to zero; the analogue tests deleted; constraint fuzzer
|
||||
committed; corpus 814/820 unchanged; opentitan sweep unchanged
|
||||
- [ ] H5 define definition (in-file + cross-file + include-narrowed)
|
||||
- [ ] M11 cast type reference (hover/definition/rename/typeDefinition)
|
||||
- [ ] §2.9-20 rename warning + pin inverted
|
||||
- [ ] QA: fuzz 5 fresh fixtures to zero failures; comment-stream
|
||||
equality over 48 opentitan DV files + 20 RTL files; rename of a
|
||||
typedef used in casts; `define` definition on opentitan macros
|
||||
(`uvm_*` absent → nothing, project macros → the define site).
|
||||
@@ -141,7 +141,12 @@ fn indent_edit(doc: &Document, position: Position, indent_width: usize) -> Optio
|
||||
/// are laid out from a real tree now, at one indent from the header, which is
|
||||
/// exactly what an ordinary block frame computes. Its bins bodies are behind a
|
||||
/// `{`, so they need no entry either, for the reason a constraint's do not.
|
||||
const OPAQUE: &[&str] = &["property", "sequence"];
|
||||
/// The five vendor/formal blocks joined the list in `vendor-formal-grammar`
|
||||
/// (2026-09-02): a specify path, a UDP truth table, a checker body and a
|
||||
/// config's library clauses are all emitted byte-for-byte, so this model has
|
||||
/// no opinion inside any of them either.
|
||||
const OPAQUE: &[&str] =
|
||||
&["property", "sequence", "specify", "primitive", "table", "checker", "config"];
|
||||
|
||||
/// Keywords whose statement body follows them directly, after an optional
|
||||
/// `@(...)` event control or `#delay`.
|
||||
|
||||
@@ -48,6 +48,13 @@ const RULES: &[Rule] = &[
|
||||
Rule { open: "covergroup", close: &["endgroup"] },
|
||||
Rule { open: "specify", close: &["endspecify"] },
|
||||
Rule { open: "primitive", close: &["endprimitive"] },
|
||||
// `vendor-formal-grammar`, 2026-09-02. `table`/`endtable` could not be a
|
||||
// rule before this round for a reason worth writing down: a rule only
|
||||
// fires on a `TokenKind::Keyword`, and `checker`/`config` were not
|
||||
// keywords — `table` was, so its row is simply the one nobody had added.
|
||||
Rule { open: "table", close: &["endtable"] },
|
||||
Rule { open: "checker", close: &["endchecker"] },
|
||||
Rule { open: "config", close: &["endconfig"] },
|
||||
];
|
||||
|
||||
/// Keywords that turn the rest of their statement into a declaration without a
|
||||
@@ -599,6 +606,34 @@ mod tests {
|
||||
scopes(text).unmatched_open.iter().map(|u| u.keyword).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_vendor_and_formal_blocks_are_scopes() {
|
||||
// `vendor-formal-grammar`, 2026-09-02. A rule only fires on a
|
||||
// `TokenKind::Keyword`, so `checker` and `config` became matchable
|
||||
// the moment the lexer reserved them; `table` was a keyword all along
|
||||
// and simply had no row.
|
||||
assert_eq!(
|
||||
matched("primitive p (q, a);\n table\n 0 : 1;\n endtable\nendprimitive\n"),
|
||||
["primitive..endprimitive", "table..endtable"]
|
||||
);
|
||||
assert_eq!(
|
||||
matched("checker c (logic a);\n checker d (logic b);\n endchecker\nendchecker\n"),
|
||||
["checker..endchecker", "checker..endchecker"]
|
||||
);
|
||||
assert_eq!(matched("config cfg;\n design work.top;\nendconfig\n"), ["config..endconfig"]);
|
||||
assert_eq!(
|
||||
matched("module m;\n specify\n endspecify\nendmodule\n"),
|
||||
["module..endmodule", "specify..endspecify"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unclosed_vendor_block_is_reported_against_its_own_keyword() {
|
||||
assert_eq!(unclosed("checker c (logic a);\n"), ["checker"]);
|
||||
assert_eq!(unclosed("config cfg;\n"), ["config"]);
|
||||
assert_eq!(orphan_closers("endchecker\n"), ["endchecker"]);
|
||||
}
|
||||
|
||||
/// The keyword of every closer that closed nothing.
|
||||
fn orphan_closers(text: &str) -> Vec<&'static str> {
|
||||
scopes(text).unmatched_close.iter().map(|u| u.keyword).collect()
|
||||
|
||||
@@ -125,7 +125,15 @@ pub fn subtypes(ws: &Workspace, item: &TypeHierarchyItem) -> Vec<TypeHierarchyIt
|
||||
found
|
||||
}
|
||||
|
||||
/// The base classes of the class an item names, in the file it names.
|
||||
/// The supertypes of the class an item names, in the file it names: the one
|
||||
/// it `extends`, and every interface class it `implements`.
|
||||
///
|
||||
/// Both clauses are edges of the same graph — a class's method set comes from
|
||||
/// its base *and* from every interface it promises to implement — and both
|
||||
/// resolve through the same hop, so they are read together here. `implements`
|
||||
/// joined in `vendor-formal-grammar` (2026-09-02), when `interface class`
|
||||
/// became an ordinary class declaration and there was finally something to
|
||||
/// point at.
|
||||
fn bases_of(
|
||||
ws: &Workspace,
|
||||
doc: &Document,
|
||||
@@ -135,16 +143,24 @@ fn bases_of(
|
||||
let positions = doc.positions();
|
||||
let at = span(&positions, item.selection_range);
|
||||
let Some(decl) = find_class(&doc.tree.items, &item.name, Some(at)) else { return Vec::new() };
|
||||
let Some(extends) = decl.class.extends.as_ref() else { return Vec::new() };
|
||||
if extends.name_span.is_empty() {
|
||||
return Vec::new();
|
||||
let mut out = Vec::new();
|
||||
// The last byte of a supertype's name span. For `pkg::base` that is inside
|
||||
// the *tail's* own reference, which is the one that names a class — the
|
||||
// head names the package. For a bare `base` it is that one reference.
|
||||
// Either way the answer comes from the same two layers
|
||||
// `textDocument/definition` uses, so a supertype in another file needs no
|
||||
// lookup of this feature's own.
|
||||
if let Some(extends) = decl.class.extends.as_ref() {
|
||||
if !extends.name_span.is_empty() {
|
||||
out.extend(classes_at(ws, doc, uri, extends.name_span.end - 1));
|
||||
}
|
||||
}
|
||||
// The last byte of the base-name span. For `pkg::base` that is inside the
|
||||
// *tail's* own reference, which is the one that names a class — the head
|
||||
// names the package. For a bare `base` it is that one reference. Either
|
||||
// way the answer comes from the same two layers `textDocument/definition`
|
||||
// uses, so a base in another file needs no lookup of this feature's own.
|
||||
classes_at(ws, doc, uri, extends.name_span.end - 1)
|
||||
for name in &decl.class.implements {
|
||||
if !name.span.is_empty() {
|
||||
out.extend(classes_at(ws, doc, uri, name.span.end - 1));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Every class declaration the name at `offset` resolves to, through both
|
||||
@@ -451,14 +467,18 @@ endmodule
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_interface_class_is_not_a_node_because_the_parser_does_not_model_one() {
|
||||
// `interface class` is a different construct (IEEE 1800 §8.26) that
|
||||
// `vlog_parser` rejects, so it never becomes a `ClassDecl` and there is
|
||||
// no item — and no `SymbolKind::INTERFACE` case — to build. Pinned so a
|
||||
// future parser round that models it is forced past this test.
|
||||
fn an_interface_class_is_a_node() {
|
||||
// Was `..._is_not_a_node_because_the_parser_does_not_model_one` until
|
||||
// `vendor-formal-grammar` (2026-09-02) made `interface class` an
|
||||
// ordinary `ClassDecl` carrying the word in its prefix. It declares a
|
||||
// class symbol, so it prepares like any other class — which is what
|
||||
// gives the `implements` edge below something to point at.
|
||||
let text = "interface class ic;\n pure virtual function void f();\nendclass\n";
|
||||
let (_tree, ws, uri) = workspace("ifaceclass", &[("ic.sv", text)]);
|
||||
assert!(prepare(&ws, &uri, at(text, "ic")).is_none());
|
||||
let items = prepare(&ws, &uri, at(text, "ic")).expect("the interface class");
|
||||
assert_eq!(items.len(), 1);
|
||||
assert_eq!(items[0].name, "ic");
|
||||
assert!(supertypes(&ws, &items[0]).is_empty(), "and it implements nothing");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -555,16 +575,30 @@ endclass
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_implements_clause_names_no_supertype() {
|
||||
// `implements` names an *interface* class, which `vlog_parser` does not
|
||||
// model — so there is never a declaration to point at, and matching one
|
||||
// by name would claim an unrelated ordinary class. Only `extends` is an
|
||||
// edge here.
|
||||
let base = "class base;\nendclass\n";
|
||||
let child = "class child implements base;\nendclass\n";
|
||||
let (_tree, ws, uri) = workspace("implements", &[("child.sv", child), ("base.sv", base)]);
|
||||
fn an_implements_clause_names_a_supertype() {
|
||||
// Was `..._names_no_supertype` until `vendor-formal-grammar`
|
||||
// (2026-09-02): `implements` names an interface class, and now that one
|
||||
// is a `ClassDecl` there is a declaration to point at. The hop is the
|
||||
// same one `extends` takes, so a supertype in another file works with
|
||||
// no lookup of this feature's own.
|
||||
let base = "interface class api;\n pure virtual function void f();\nendclass\n";
|
||||
let child = "class child implements api;\nendclass\n";
|
||||
let (_tree, ws, uri) = workspace("implements", &[("child.sv", child), ("api.sv", base)]);
|
||||
let root = prepare(&ws, &uri, at(child, "child")).expect("child")[0].clone();
|
||||
assert!(supertypes(&ws, &root).is_empty(), "pinning today's answer and its reason");
|
||||
let bases = supertypes(&ws, &root);
|
||||
assert_eq!(shape(&bases[0]), ("api".to_string(), "api.sv".to_string(), 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extends_and_implements_are_both_edges_of_the_same_answer() {
|
||||
let api = "interface class api;\nendclass\n";
|
||||
let base = "class base;\nendclass\n";
|
||||
let child = "class child extends base implements api;\nendclass\n";
|
||||
let (_tree, ws, uri) =
|
||||
workspace("both", &[("child.sv", child), ("base.sv", base), ("api.sv", api)]);
|
||||
let root = prepare(&ws, &uri, at(child, "child")).expect("child")[0].clone();
|
||||
let names: Vec<String> = supertypes(&ws, &root).iter().map(|i| i.name.clone()).collect();
|
||||
assert_eq!(names, ["base", "api"], "the base first, then the interfaces, in source order");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1201,6 +1201,14 @@ impl<'a> Fmt<'a> {
|
||||
docs.push(text(";"));
|
||||
concat(docs)
|
||||
}
|
||||
// `alias a = b = c;` — one line, one space around every `=`, the
|
||||
// spacing every other assignment-shaped item already uses.
|
||||
ItemKind::Alias(nets) => {
|
||||
let mut docs = vec![text("alias ")];
|
||||
docs.extend(join(nets.iter().map(|n| self.expr(n)).collect(), text(" = ")));
|
||||
docs.push(text(";"));
|
||||
concat(docs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1716,6 +1724,10 @@ impl<'a> Fmt<'a> {
|
||||
/// struct — the recursion is what indents a nested body one more level.
|
||||
fn struct_type(&self, s: &StructType) -> Doc {
|
||||
let mut header = s.kw.clone();
|
||||
// `union tagged packed`, in the LRM's order.
|
||||
if s.tagged {
|
||||
header.push_str(" tagged");
|
||||
}
|
||||
if s.packed {
|
||||
header.push_str(" packed");
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# a bind directive is a module instantiation with a target scope in front
|
||||
module m;
|
||||
bind target_mod checker u_chk(.a(x),.b(y));
|
||||
bind target_mod chk_mod u_chk(.a(x),.b(y));
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
bind target_mod checker u_chk (.a(x), .b(y));
|
||||
bind target_mod chk_mod u_chk (.a(x), .b(y));
|
||||
endmodule
|
||||
====
|
||||
# implicit named connections, target on its own line
|
||||
@@ -171,11 +171,11 @@ endmodule
|
||||
====
|
||||
# a hierarchical target path
|
||||
module m;
|
||||
bind top.u_dut.u_core checker u_chk(.*);
|
||||
bind top.u_dut.u_core chk_mod u_chk(.*);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
bind top.u_dut.u_core checker u_chk (.*);
|
||||
bind top.u_dut.u_core chk_mod u_chk (.*);
|
||||
endmodule
|
||||
====
|
||||
# a bind directive at top level, outside any module
|
||||
@@ -187,7 +187,7 @@ bind cpu cpu_assert u_cpu_assert (.clk_i, .rst_ni);
|
||||
module m;
|
||||
generate
|
||||
if (Enable) begin : g_chk
|
||||
bind sub checker u_chk(.*);
|
||||
bind sub chk_mod u_chk(.*);
|
||||
end
|
||||
endgenerate
|
||||
endmodule
|
||||
@@ -195,7 +195,7 @@ endmodule
|
||||
module m;
|
||||
generate
|
||||
if (Enable) begin : g_chk
|
||||
bind sub checker u_chk (.*);
|
||||
bind sub chk_mod u_chk (.*);
|
||||
end
|
||||
endgenerate
|
||||
endmodule
|
||||
@@ -203,7 +203,7 @@ endmodule
|
||||
# comments attached to a bind directive are kept
|
||||
module m;
|
||||
// bind the checker in
|
||||
bind dut checker u_chk (
|
||||
bind dut chk_mod u_chk (
|
||||
// clock and reset come in implicitly
|
||||
.clk_i,
|
||||
.rst_ni // active low
|
||||
@@ -212,7 +212,7 @@ endmodule
|
||||
----
|
||||
module m;
|
||||
// bind the checker in
|
||||
bind dut checker u_chk (
|
||||
bind dut chk_mod u_chk (
|
||||
// clock and reset come in implicitly
|
||||
.clk_i,
|
||||
.rst_ni // active low
|
||||
@@ -221,7 +221,7 @@ endmodule
|
||||
====
|
||||
# an `ifdef inside the connection list of a bind
|
||||
module m;
|
||||
bind dut checker u_chk (
|
||||
bind dut chk_mod u_chk (
|
||||
.clk_i,
|
||||
`ifdef FPV
|
||||
.fpv_only_i,
|
||||
@@ -231,7 +231,7 @@ module m;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
bind dut checker u_chk (
|
||||
bind dut chk_mod u_chk (
|
||||
.clk_i,
|
||||
`ifdef FPV
|
||||
.fpv_only_i,
|
||||
@@ -243,16 +243,16 @@ endmodule
|
||||
# a bind directive inside a `verilog_format: off` fence is untouched
|
||||
module m;
|
||||
// verilog_format: off
|
||||
bind dut checker u_chk ( .clk_i ,.rst_ni );
|
||||
bind dut chk_mod u_chk ( .clk_i ,.rst_ni );
|
||||
// verilog_format: on
|
||||
bind dut2 checker u_chk2 ( .clk_i ,.rst_ni );
|
||||
bind dut2 chk_mod u_chk2 ( .clk_i ,.rst_ni );
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
// verilog_format: off
|
||||
bind dut checker u_chk ( .clk_i ,.rst_ni );
|
||||
bind dut chk_mod u_chk ( .clk_i ,.rst_ni );
|
||||
// verilog_format: on
|
||||
bind dut2 checker u_chk2 (.clk_i, .rst_ni);
|
||||
bind dut2 chk_mod u_chk2 (.clk_i, .rst_ni);
|
||||
endmodule
|
||||
====
|
||||
# at the line-length boundary: exactly 100 columns stays on one line
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
# a specify block is re-indented as a unit and kept byte-for-byte inside
|
||||
# The block moves from column 1 to column 3, so every line inside it moves
|
||||
# by the same two columns — the `col` contract every verbatim leaf keeps.
|
||||
module m;
|
||||
input a; output b;
|
||||
specify
|
||||
(a => b) = (1.0, 1.2);
|
||||
$setuphold(posedge a, b, 0.1, 0.2);
|
||||
endspecify
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
input a;
|
||||
output b;
|
||||
specify
|
||||
(a => b) = (1.0, 1.2);
|
||||
$setuphold(posedge a, b, 0.1, 0.2);
|
||||
endspecify
|
||||
endmodule
|
||||
====
|
||||
# a specify block's inner alignment is the user's, not ours
|
||||
module m;
|
||||
specify
|
||||
(A => Z) = (1,2);
|
||||
if (S) (A => Z) = 1.5;
|
||||
endspecify
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
specify
|
||||
(A => Z) = (1,2);
|
||||
if (S) (A => Z) = 1.5;
|
||||
endspecify
|
||||
endmodule
|
||||
====
|
||||
# a UDP declaration, its truth table swallowed whole
|
||||
primitive udp_mux (q, sel, a, b);
|
||||
output q;
|
||||
input sel, a, b;
|
||||
table
|
||||
// sel a b : q
|
||||
0 1 ? : 1;
|
||||
1 ? 0 : 0;
|
||||
x 0 0 : 0;
|
||||
endtable
|
||||
endprimitive
|
||||
----
|
||||
primitive udp_mux (q, sel, a, b);
|
||||
output q;
|
||||
input sel, a, b;
|
||||
table
|
||||
// sel a b : q
|
||||
0 1 ? : 1;
|
||||
1 ? 0 : 0;
|
||||
x 0 0 : 0;
|
||||
endtable
|
||||
endprimitive
|
||||
====
|
||||
# a UDP with a label after endprimitive, and the null item after it
|
||||
primitive p (q, a);
|
||||
table
|
||||
0 : 1;
|
||||
endtable
|
||||
endprimitive : p
|
||||
;
|
||||
----
|
||||
primitive p (q, a);
|
||||
table
|
||||
0 : 1;
|
||||
endtable
|
||||
endprimitive : p
|
||||
;
|
||||
====
|
||||
# a checker declaration at file scope, and one nested inside it
|
||||
checker outer (logic clk);
|
||||
checker inner (logic a);
|
||||
a1: assert property (@(posedge clk) a);
|
||||
endchecker : inner
|
||||
inner u_inner (x);
|
||||
endchecker : outer
|
||||
----
|
||||
checker outer (logic clk);
|
||||
checker inner (logic a);
|
||||
a1: assert property (@(posedge clk) a);
|
||||
endchecker : inner
|
||||
inner u_inner (x);
|
||||
endchecker : outer
|
||||
====
|
||||
# a config block
|
||||
config cfg;
|
||||
design work.top;
|
||||
default liblist libA libB;
|
||||
instance top.u1 use work.impl;
|
||||
endconfig : cfg
|
||||
----
|
||||
config cfg;
|
||||
design work.top;
|
||||
default liblist libA libB;
|
||||
instance top.u1 use work.impl;
|
||||
endconfig : cfg
|
||||
====
|
||||
# a library map line
|
||||
library rtlLib "/proj/rtl/*.v", "/proj/rtl/*.sv" -incdir "/proj/inc";
|
||||
----
|
||||
library rtlLib "/proj/rtl/*.v", "/proj/rtl/*.sv" -incdir "/proj/inc";
|
||||
====
|
||||
# specparam outside a specify block is a declaration, laid out like a localparam
|
||||
module m;
|
||||
specparam tSETUP=0.12 ,tHOLD = 0.08;
|
||||
specparam [3:0] tRANGE = 4'd3;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
specparam tSETUP = 0.12, tHOLD = 0.08;
|
||||
specparam [3:0] tRANGE = 4'd3;
|
||||
endmodule
|
||||
====
|
||||
# a specparam spelling the declaration grammar cannot read stays verbatim
|
||||
module m;
|
||||
specparam PATHPULSE$a$b = (1.0, 1.2);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
specparam PATHPULSE$a$b = (1.0, 1.2);
|
||||
endmodule
|
||||
====
|
||||
# an alias item
|
||||
module m;
|
||||
wire a,b,c;
|
||||
alias a =b = c ;
|
||||
alias {x, y} = z;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
wire a, b, c;
|
||||
alias a = b = c;
|
||||
alias {x, y} = z;
|
||||
endmodule
|
||||
====
|
||||
# an interface class is a class, printed with its keyword in front
|
||||
interface class api #(int W = 8) ;
|
||||
pure virtual function void run(int x) ;
|
||||
endclass : api
|
||||
----
|
||||
interface class api #(int W = 8);
|
||||
pure virtual function void run(int x);
|
||||
endclass : api
|
||||
====
|
||||
# an interface class extends another, and a class implements two
|
||||
interface class b extends a;
|
||||
endclass
|
||||
class impl extends base implements a, b;
|
||||
endclass
|
||||
----
|
||||
interface class b extends a;
|
||||
endclass
|
||||
class impl extends base implements a, b;
|
||||
endclass
|
||||
====
|
||||
# a tagged union keeps its keyword, in the LRM's order
|
||||
typedef union tagged packed {
|
||||
logic [7:0] v;
|
||||
} u_t;
|
||||
----
|
||||
typedef union tagged packed {
|
||||
logic [7:0] v;
|
||||
} u_t;
|
||||
====
|
||||
# a plain union is untouched by the tagged flag
|
||||
typedef union packed {
|
||||
logic [7:0] v;
|
||||
} u_t;
|
||||
----
|
||||
typedef union packed {
|
||||
logic [7:0] v;
|
||||
} u_t;
|
||||
====
|
||||
# `expect` with a sequence operator is an assertion, kept byte-for-byte
|
||||
module m;
|
||||
initial begin
|
||||
expect (@(posedge clk) a ##1 b) else $error("no");
|
||||
end
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
initial begin
|
||||
expect (@(posedge clk) a ##1 b) else $error("no");
|
||||
end
|
||||
endmodule
|
||||
====
|
||||
# `expect(x);` is a task call and is laid out like one — the 41-site guard
|
||||
module m;
|
||||
initial begin
|
||||
expect(word1[7:0]);
|
||||
expect ( x , y ) ;
|
||||
end
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
initial begin
|
||||
expect(word1[7:0]);
|
||||
expect(x, y);
|
||||
end
|
||||
endmodule
|
||||
====
|
||||
# a name that merely contains a new keyword is still a name
|
||||
module checker_x;
|
||||
wire config_reg;
|
||||
logic library_sel;
|
||||
assign config_reg = library_sel;
|
||||
endmodule
|
||||
----
|
||||
module checker_x;
|
||||
wire config_reg;
|
||||
logic library_sel;
|
||||
assign config_reg = library_sel;
|
||||
endmodule
|
||||
====
|
||||
# a whole vendored cell: UDP, specify, specparam, alias, in one file
|
||||
`timescale 1ns / 1ps
|
||||
|
||||
primitive udp_buf (q, a);
|
||||
output q;
|
||||
input a;
|
||||
table
|
||||
0 : 0;
|
||||
1 : 1;
|
||||
endtable
|
||||
endprimitive
|
||||
|
||||
module DFFQX1 (D, CK, Q);
|
||||
input D, CK;
|
||||
output Q;
|
||||
reg Q;
|
||||
specparam tSETUP = 0.12, tHOLD = 0.08;
|
||||
wire n1;
|
||||
alias n1 = D;
|
||||
always @(posedge CK) Q <= D;
|
||||
specify
|
||||
specparam tRISE = 1.0;
|
||||
(CK => Q) = (tRISE, 1.2);
|
||||
$setuphold(posedge CK, D, tSETUP, tHOLD);
|
||||
endspecify
|
||||
endmodule
|
||||
----
|
||||
`timescale 1ns / 1ps
|
||||
|
||||
primitive udp_buf (q, a);
|
||||
output q;
|
||||
input a;
|
||||
table
|
||||
0 : 0;
|
||||
1 : 1;
|
||||
endtable
|
||||
endprimitive
|
||||
|
||||
module DFFQX1 (D, CK, Q);
|
||||
input D, CK;
|
||||
output Q;
|
||||
reg Q;
|
||||
specparam tSETUP = 0.12, tHOLD = 0.08;
|
||||
wire n1;
|
||||
alias n1 = D;
|
||||
always @(posedge CK) Q <= D;
|
||||
specify
|
||||
specparam tRISE = 1.0;
|
||||
(CK => Q) = (tRISE, 1.2);
|
||||
$setuphold(posedge CK, D, tSETUP, tHOLD);
|
||||
endspecify
|
||||
endmodule
|
||||
@@ -2382,3 +2382,140 @@ fn the_gaps_the_fragment_fuzzer_fails_fail_outside_a_fragment_too() {
|
||||
fuzzer's expected count above is stale: {working:?}"
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Vendor and formal collateral — `vendor-formal-grammar`
|
||||
//
|
||||
// The five new blocks are emitted byte-for-byte, so the safety net is the
|
||||
// *only* thing standing between a mis-scanned opaque leaf and silently
|
||||
// changed timing. `verify.rs` was not touched by this round and no
|
||||
// normalization was widened; these are the attack pairs that say so out loud —
|
||||
// crafted (input, corrupted output) pairs the net must reject.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_changed_timing_path_inside_a_specify_block_is_rejected() {
|
||||
let input = "module m;\n specify\n (a => b) = (1.0, 1.2);\n endspecify\nendmodule\n";
|
||||
let output = "module m;\n specify\n (a => b) = (1.0, 2.1);\n endspecify\nendmodule\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_specify_item_is_rejected() {
|
||||
let input =
|
||||
"module m;\n specify\n (a => b) = 1;\n (c => d) = 2;\n endspecify\nendmodule\n";
|
||||
let output = "module m;\n specify\n (a => b) = 1;\n endspecify\nendmodule\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_flipped_udp_table_row_is_rejected() {
|
||||
let input = "primitive p (q, a);\n table\n 0 : 1;\n 1 : 0;\n endtable\nendprimitive\n";
|
||||
let output = "primitive p (q, a);\n table\n 0 : 1;\n 1 : 1;\n endtable\nendprimitive\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_comment_inside_a_udp_table_is_not_droppable() {
|
||||
let input =
|
||||
"primitive p (q, a);\n table\n // a b : q\n 0 : 1;\n endtable\nendprimitive\n";
|
||||
let output = "primitive p (q, a);\n table\n 0 : 1;\n endtable\nendprimitive\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_endchecker_label_is_rejected() {
|
||||
let input = "checker c (logic a);\nendchecker : c\n";
|
||||
let output = "checker c (logic a);\nendchecker\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_config_clause_is_rejected() {
|
||||
let input = "config cfg;\n design work.top;\n default liblist a b;\nendconfig\n";
|
||||
let output = "config cfg;\n design work.top;\nendconfig\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_tagged_keyword_is_rejected() {
|
||||
let input = "typedef union tagged packed {\n logic v;\n} u_t;\n";
|
||||
let output = "typedef union packed {\n logic v;\n} u_t;\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_alias_term_is_rejected() {
|
||||
let input = "module m;\n alias a = b = c;\nendmodule\n";
|
||||
let output = "module m;\n alias a = c;\nendmodule\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_interface_keyword_before_class_is_rejected() {
|
||||
let input = "interface class api;\nendclass\n";
|
||||
let output = "class api;\nendclass\n";
|
||||
assert!(matches!(expect_divergence(input, output), VerificationError::Divergence { .. }));
|
||||
}
|
||||
|
||||
/// Every construct this round added formats and reaches a fixed point.
|
||||
#[test]
|
||||
fn every_vendor_construct_round_trips() {
|
||||
let sources = [
|
||||
"module m;\n specify\n (a => b) = (1.0, 1.2);\n endspecify\nendmodule\n",
|
||||
"primitive p (q, a);\n table\n 0 : 1;\n endtable\nendprimitive : p\n",
|
||||
"checker c (logic clk);\n a1: assert property (@(posedge clk) x);\nendchecker : c\n",
|
||||
"config cfg;\n design work.top;\nendconfig : cfg\n",
|
||||
"library rtlLib \"/proj/*.v\";\n",
|
||||
"module m;\n specparam tS = 0.12, tH = 0.08;\nendmodule\n",
|
||||
"module m;\n specparam PATHPULSE$a$b = (1.0, 1.2);\nendmodule\n",
|
||||
"module m;\n alias a = b = c;\nendmodule\n",
|
||||
"interface class api;\n pure virtual function void f();\nendclass\n",
|
||||
"class k implements api;\nendclass\n",
|
||||
"typedef union tagged packed {\n logic v;\n} u_t;\n",
|
||||
"module m;\n initial expect (@(posedge clk) a ##1 b) else $error(\"no\");\nendmodule\n",
|
||||
"module m;\n initial expect(word1[7:0]);\nendmodule\n",
|
||||
];
|
||||
for src in sources {
|
||||
let once = format_source(src, &Config::default())
|
||||
.unwrap_or_else(|e| panic!("format failed for {src:?}: {e}"));
|
||||
let twice = format_source(&once, &Config::default())
|
||||
.unwrap_or_else(|e| panic!("reformat failed for {src:?}: {e}"));
|
||||
assert_eq!(once, twice, "not idempotent: {src:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The gap slots this round's items *do* drop a comment in are exactly the
|
||||
/// ones their shared machinery already dropped it in before the round — the
|
||||
/// `§2.9-22` shared-machinery gap, not a new class of loss.
|
||||
///
|
||||
/// Each pair is `(new construct, its pre-existing twin)`, and the test demands
|
||||
/// they agree. When somebody fixes the twin, this test fails and points at the
|
||||
/// construct that must be fixed with it.
|
||||
#[test]
|
||||
fn the_new_items_lose_a_gap_comment_exactly_where_their_twins_do() {
|
||||
let pairs = [
|
||||
(
|
||||
"module m;\n alias a /*C*/ = b;\nendmodule\n",
|
||||
"module m;\n defparam u.p /*C*/ = 1;\nendmodule\n",
|
||||
),
|
||||
(
|
||||
"module m;\n specparam tS /*C*/ = 1;\nendmodule\n",
|
||||
"module m;\n localparam tS /*C*/ = 1;\nendmodule\n",
|
||||
),
|
||||
("interface /*C*/ class api;\nendclass\n", "virtual /*C*/ class api;\nendclass\n"),
|
||||
(
|
||||
"typedef union /*C*/ tagged packed {\n logic v;\n} u_t;\n",
|
||||
"typedef union /*C*/ packed {\n logic v;\n} u_t;\n",
|
||||
),
|
||||
];
|
||||
for (new, twin) in pairs {
|
||||
let new_ok = format_source(new, &Config::default()).is_ok();
|
||||
let twin_ok = format_source(twin, &Config::default()).is_ok();
|
||||
assert_eq!(new_ok, twin_ok, "{new:?} and its twin {twin:?} must agree");
|
||||
}
|
||||
// And the one slot the new items *do* keep, because a declarator's own
|
||||
// comment bucket harvests it.
|
||||
format_source("module m;\n specparam /*C*/ tS = 1;\nendmodule\n", &Config::default())
|
||||
.expect("a comment before a specparam's name survives");
|
||||
}
|
||||
@@ -308,6 +308,10 @@ pub enum ItemKind {
|
||||
/// verbatim.
|
||||
Verbatim(RawText),
|
||||
Defparam(Vec<(Expr, Expr)>),
|
||||
/// `alias a = b = c;` (IEEE 1800 §10.11): one bidirectional connection
|
||||
/// between two or more net lvalues. The `=`s are separators — no term is
|
||||
/// the value of any other — so the terms are a flat list.
|
||||
Alias(Vec<Expr>),
|
||||
/// A **null item**: a lone `;` standing where an item belongs
|
||||
/// (IEEE 1800-2017 A.1.4 `package_or_generate_item_declaration ::= … | ;`
|
||||
/// and `class_item ::= … | ;`). Legal and meaningless in every item
|
||||
@@ -624,6 +628,11 @@ pub struct EnumMember {
|
||||
pub struct StructType {
|
||||
/// "struct" or "union"
|
||||
pub kw: String,
|
||||
/// The `tagged` of `union tagged { ... }` (IEEE 1800 §7.3.2) — a
|
||||
/// discriminated union. Carried and printed; lucisv models no tag
|
||||
/// semantics, and the `tagged Valid 5` expression form that goes with it
|
||||
/// is a pattern grammar the parser still rejects.
|
||||
pub tagged: bool,
|
||||
pub packed: bool,
|
||||
pub signing: Option<String>,
|
||||
pub members: Vec<StructMember>,
|
||||
@@ -970,8 +979,10 @@ pub struct GenBlock {
|
||||
/// — works inside a class without any per-site code.
|
||||
#[derive(Debug)]
|
||||
pub struct ClassDecl {
|
||||
/// Keywords written before `class`; `virtual` is the only one real code
|
||||
/// uses. Kept as a list so the source order is reproduced verbatim.
|
||||
/// Keywords written before `class`: `virtual`, the class-member
|
||||
/// qualifiers, and the `interface` of an `interface class` (IEEE 1800
|
||||
/// §8.26). Kept as a list so the source order is reproduced verbatim —
|
||||
/// see [`ClassDecl::is_interface_class`].
|
||||
pub prefix: Vec<String>,
|
||||
/// `static`/`automatic` lifetime written after `class`, if any.
|
||||
pub lifetime: Option<String>,
|
||||
@@ -1000,6 +1011,17 @@ pub struct ClassDecl {
|
||||
pub end_label_span: Option<TextRange>,
|
||||
}
|
||||
|
||||
impl ClassDecl {
|
||||
/// True for an `interface class` (IEEE 1800 §8.26) — a class whose body
|
||||
/// may hold only pure virtual prototypes, parameters and typedefs, and
|
||||
/// which other classes name in an `implements` clause rather than
|
||||
/// `extends`. It is an ordinary [`ClassDecl`] everywhere else: same
|
||||
/// header, same `endclass`, same symbol.
|
||||
pub fn is_interface_class(&self) -> bool {
|
||||
self.prefix.iter().any(|word| word == "interface")
|
||||
}
|
||||
}
|
||||
|
||||
/// The `extends Base #( ... )` clause of a class header. The overrides are
|
||||
/// [`Connection`]s — the same node an instantiation's `#( ... )` uses, because
|
||||
/// both spell named (`.CFG_T(cfg_t)`) and ordered (`cfg_t`) overrides the same
|
||||
|
||||
@@ -111,6 +111,15 @@ const SYNC_CLOSERS: &[&str] = &[
|
||||
"join",
|
||||
"join_any",
|
||||
"join_none",
|
||||
// The vendor/formal closers (`vendor-formal-grammar`, 2026-09-02). Each
|
||||
// one closes a block the parser keeps as an opaque leaf, so recovery that
|
||||
// runs past a broken item inside a module must stop before them for the
|
||||
// same reason it stops before `endgenerate`.
|
||||
"endspecify",
|
||||
"endprimitive",
|
||||
"endtable",
|
||||
"endchecker",
|
||||
"endconfig",
|
||||
];
|
||||
|
||||
/// Keywords that can only *begin* a construct at file scope. Recovery stops
|
||||
@@ -1715,11 +1724,15 @@ impl<'a> Parser<'a> {
|
||||
match kw.as_str() {
|
||||
"module" | "macromodule" => self.parse_module("endmodule").map(ItemKind::Module),
|
||||
// `interface class` is a class, not an interface (IEEE 1800
|
||||
// §8.26): a different construct that lucisv does not model, so it
|
||||
// falls through to the unsupported-construct error below.
|
||||
// §8.26): its body is a subset of a class body (pure virtual
|
||||
// method prototypes, parameters, typedefs) and it closes with
|
||||
// `endclass`, so it *is* a [`ClassDecl`] — the word `interface`
|
||||
// rides along in [`ClassDecl::prefix`] beside `virtual`, which is
|
||||
// where every keyword written in front of `class` already lives.
|
||||
"interface" if !self.nth(1).is_kw("class") => {
|
||||
self.parse_module("endinterface").map(ItemKind::Module)
|
||||
}
|
||||
"interface" => self.parse_class().map(ItemKind::Class),
|
||||
// A `program` block is a module header over a module body with a
|
||||
// different closer (IEEE 1800 §24.3) — the same node, the way an
|
||||
// `interface` already is. Its stricter *legality* rules (no
|
||||
@@ -1810,6 +1823,26 @@ impl<'a> Parser<'a> {
|
||||
self.parse_concurrent_assertion().map(ItemKind::Verbatim)
|
||||
}
|
||||
"property" | "sequence" => self.parse_property_decl().map(ItemKind::Verbatim),
|
||||
// Vendor and formal collateral, each one an opaque leaf. The
|
||||
// bodies are grammars of their own — a specify path with its
|
||||
// `=>`/`*>` connections, a UDP truth table, a checker's assertion
|
||||
// vocabulary, a config's `design`/`instance`/`liblist` clauses —
|
||||
// that lucisv models none of, and there is no layout convention
|
||||
// worth inventing for any of them, so the whole block is copied
|
||||
// out of the source by span the way a `property` declaration is.
|
||||
// See `docs/features/vendor-formal-grammar/README.md`.
|
||||
"specify" => self.parse_opaque_block("endspecify").map(ItemKind::Verbatim),
|
||||
"primitive" => self.parse_opaque_block("endprimitive").map(ItemKind::Verbatim),
|
||||
"checker" => self.parse_opaque_block("endchecker").map(ItemKind::Verbatim),
|
||||
"config" => self.parse_opaque_block("endconfig").map(ItemKind::Verbatim),
|
||||
// A `table ... endtable` only ever stands inside a `primitive`,
|
||||
// whose scan already swallows it; this arm is what a stray one —
|
||||
// or a UDP whose `primitive` line is behind an `` `ifdef `` — gets
|
||||
// instead of an unsupported-construct error.
|
||||
"table" => self.parse_opaque_block("endtable").map(ItemKind::Verbatim),
|
||||
"library" => self.parse_opaque_line().map(ItemKind::Verbatim),
|
||||
"specparam" => self.parse_specparam(),
|
||||
"alias" => self.parse_alias(),
|
||||
// A run of member qualifiers (`virtual`, `local rand`, `static`,
|
||||
// `pure virtual`, ...) does not say what it qualifies; the first
|
||||
// keyword past the run does. Nothing is consumed here, so each
|
||||
@@ -2039,7 +2072,16 @@ impl<'a> Parser<'a> {
|
||||
/// `import`, directives, macro invocations — works inside a class for
|
||||
/// free, and nesting is charged against the item budget by `parse_item`.
|
||||
fn parse_class(&mut self) -> PResult<ClassDecl> {
|
||||
let prefix = self.take_member_prefix();
|
||||
let mut prefix = self.take_member_prefix();
|
||||
// `interface class ic; ... endclass` (IEEE 1800 §8.26). The word rides
|
||||
// in the prefix beside `virtual`, because that is what it is: a
|
||||
// keyword written in front of `class`, printed back in source order.
|
||||
// What it changes is the body's *legality* — only pure virtual method
|
||||
// prototypes, parameters and typedefs may stand in one — and legality
|
||||
// is a checker's business, not a formatter's.
|
||||
if self.cur().is_kw("interface") && self.nth(1).is_kw("class") {
|
||||
prefix.push(self.bump().text);
|
||||
}
|
||||
self.expect_kw("class")?;
|
||||
let lifetime = if self.cur().is_kw("static") || self.cur().is_kw("automatic") {
|
||||
Some(self.bump().text)
|
||||
@@ -3460,8 +3502,16 @@ impl<'a> Parser<'a> {
|
||||
self.bump(); // default
|
||||
self.expect_kw("disable")?;
|
||||
self.expect_kw("iff")?;
|
||||
// Scan to the terminating `;`, skipping bracketed runs whole so a `;`
|
||||
// written inside a `dist { ... }` set does not end the item early.
|
||||
self.skip_to_semi()?;
|
||||
Ok(self.verbatim_since(start, col))
|
||||
}
|
||||
|
||||
/// Consume everything through the next `;` at bracket depth zero.
|
||||
///
|
||||
/// Bracketed runs are skipped whole, so a `;` written inside a
|
||||
/// `dist { ... }` set — or inside a library map's `-incdir` list — does
|
||||
/// not end the scan early.
|
||||
fn skip_to_semi(&mut self) -> PResult<()> {
|
||||
loop {
|
||||
if self.at_eof() {
|
||||
return self.error("expected `;`");
|
||||
@@ -3476,11 +3526,167 @@ impl<'a> Parser<'a> {
|
||||
self.bump();
|
||||
self.skip_balanced(open, close)?;
|
||||
} else if self.eat_sym(";") {
|
||||
break;
|
||||
return Ok(());
|
||||
} else {
|
||||
self.bump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Vendor and formal collateral
|
||||
//
|
||||
// Five blocks and two lines that lucisv deliberately does not model. Each
|
||||
// one is copied out of the source by span for the reason a `property`
|
||||
// declaration is: the body is a second grammar — a specify path's
|
||||
// `=>`/`*>` connections, a UDP truth table, a checker's assertion
|
||||
// vocabulary, a config's `design`/`instance`/`liblist` clauses — with no
|
||||
// layout convention worth inventing. See
|
||||
// `docs/features/vendor-formal-grammar/README.md`.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// A block kept byte-for-byte: the keyword at the cursor through the
|
||||
/// matching `close`, its `: label` included.
|
||||
///
|
||||
/// The scan counts its own opener, so a `checker` written inside a
|
||||
/// `checker` — the only one of the five that may nest (IEEE 1800 §17.1) —
|
||||
/// closes on the right keyword. A `;` after the closer is left where it
|
||||
/// is: none of the five takes one, so it is the null item it looks like
|
||||
/// and the `empty-item` lint gets to say so.
|
||||
fn parse_opaque_block(&mut self, close: &str) -> PResult<RawText> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
let open = self.bump().text;
|
||||
let mut depth = 1usize;
|
||||
while !self.at_eof() {
|
||||
let t = self.cur();
|
||||
if t.is_kw(close) {
|
||||
depth -= 1;
|
||||
if depth == 0 {
|
||||
break;
|
||||
}
|
||||
} else if t.is_kw(&open) {
|
||||
depth += 1;
|
||||
}
|
||||
self.bump();
|
||||
}
|
||||
self.expect_closer(close)?;
|
||||
self.parse_label()?;
|
||||
Ok(self.verbatim_since(start, col))
|
||||
}
|
||||
|
||||
/// An item kept byte-for-byte that ends at its own `;`: the `library
|
||||
/// lib_name file_path, ...;` line a library map file is made of (IEEE
|
||||
/// 1800 §33.3), and the `specparam` spelling
|
||||
/// [`Parser::parse_specparam`] could not read.
|
||||
fn parse_opaque_line(&mut self) -> PResult<RawText> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
self.bump();
|
||||
self.skip_to_semi()?;
|
||||
Ok(self.verbatim_since(start, col))
|
||||
}
|
||||
|
||||
/// `specparam [range] name = constant_expression {, ...};` (IEEE 1800
|
||||
/// §3.12).
|
||||
///
|
||||
/// A specify parameter is a declaration with a `localparam`'s shape, so it
|
||||
/// becomes the same [`ParamDecl`] node — which is what makes the `tRISE`
|
||||
/// of a vendored cell model hover, resolve and complete. The one spelling
|
||||
/// that does not fit is the `PATHPULSE$a$b = (reject, error);` form, whose
|
||||
/// value is a pair rather than an expression; that one rewinds and is kept
|
||||
/// verbatim, the way a constraint body the grammar does not know is.
|
||||
fn parse_specparam(&mut self) -> PResult<ItemKind> {
|
||||
let mark = self.rewind_mark();
|
||||
match self.parse_specparam_decl() {
|
||||
Ok(decl) => Ok(ItemKind::ParamDecl(decl)),
|
||||
Err(_) => {
|
||||
self.rewind_to(mark);
|
||||
self.parse_opaque_line().map(ItemKind::Verbatim)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_specparam_decl(&mut self) -> PResult<ParamDecl> {
|
||||
let kw = self.bump().text;
|
||||
let ty = self.parse_opt_data_type()?;
|
||||
let declarators = self.parse_declarators()?;
|
||||
self.expect_sym(";")?;
|
||||
Ok(ParamDecl { kw, is_type: false, ty, declarators })
|
||||
}
|
||||
|
||||
/// `alias a = b = c;` (IEEE 1800 §10.11) — one bidirectional connection
|
||||
/// between two or more net lvalues.
|
||||
///
|
||||
/// The `=` between the terms is a *separator*, not an operator: no term is
|
||||
/// the value of any other, which is why they are kept as a list rather
|
||||
/// than as a nested assignment. How many there are, and whether they are
|
||||
/// legal lvalues, is a checker's business.
|
||||
fn parse_alias(&mut self) -> PResult<ItemKind> {
|
||||
self.bump(); // alias
|
||||
let mut nets = vec![self.parse_expr()?];
|
||||
while self.eat_sym("=") {
|
||||
nets.push(self.parse_expr()?);
|
||||
}
|
||||
self.expect_sym(";")?;
|
||||
Ok(ItemKind::Alias(nets))
|
||||
}
|
||||
|
||||
/// True when `expect` at the cursor opens a concurrent `expect` statement
|
||||
/// (IEEE 1800 §16.17) rather than calling a task named `expect`.
|
||||
///
|
||||
/// The two spellings are `expect (property_spec) action_block` and
|
||||
/// `expect(args);`, and only what stands *between* the parentheses tells
|
||||
/// them apart. The corpus has 41 of the second — `expect(word1[7:0]);` in
|
||||
/// picorv32's spiflash testbench — and none of the first, so the word is
|
||||
/// never reserved and the assertion reading is taken only when the
|
||||
/// parenthesised run holds something no argument list can: a `##` delay, a
|
||||
/// `|->` or `|=>` implication, `throughout`, `disable iff`, or a clocking
|
||||
/// event `@(`. Anything else stays the call it has always been.
|
||||
///
|
||||
/// The list is deliberately narrow and its misses are safe: an
|
||||
/// `expect (done) else $error;` written with a purely boolean property is
|
||||
/// read as a call, which is the parse error it already was.
|
||||
fn at_expect_statement(&self) -> bool {
|
||||
if !word_at(self.cur(), "expect") || !self.nth(1).is_sym("(") {
|
||||
return false;
|
||||
}
|
||||
// `scan_matching` answers one past the `)`, and the closer itself can
|
||||
// hold no operator, so the scan stops before it either way.
|
||||
let end = self.scan_matching(self.pos + 1, "(", ")");
|
||||
for i in (self.pos + 2)..end {
|
||||
let Some(t) = self.tokens.get(i) else { return false };
|
||||
let next = self.tokens.get(i + 1);
|
||||
let sequence = match t.kind {
|
||||
// `|->` and `|=>` are two tokens each: the lexer's operator
|
||||
// table has no entry for either, deliberately, and adding one
|
||||
// would buy nothing outside a property.
|
||||
TokenKind::Symbol => {
|
||||
t.text == "##"
|
||||
|| (t.text == "|" && next.is_some_and(|n| n.is_sym("->")))
|
||||
|| (t.text == "|=" && next.is_some_and(|n| n.is_sym(">")))
|
||||
|| (t.text == "@" && next.is_some_and(|n| n.is_sym("(")))
|
||||
}
|
||||
TokenKind::Ident => t.text == "throughout",
|
||||
TokenKind::Keyword => t.text == "disable" && next.is_some_and(|n| n.is_kw("iff")),
|
||||
_ => false,
|
||||
};
|
||||
if sequence {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// `expect (property_spec) action_block`, kept as verbatim source for the
|
||||
/// reason [`Parser::parse_concurrent_assertion`] gives.
|
||||
fn parse_expect_statement(&mut self) -> PResult<RawText> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
self.bump(); // expect
|
||||
self.expect_sym("(")?;
|
||||
self.skip_balanced("(", ")")?;
|
||||
self.skip_action_block()?;
|
||||
Ok(self.verbatim_since(start, col))
|
||||
}
|
||||
|
||||
@@ -4678,6 +4884,15 @@ impl<'a> Parser<'a> {
|
||||
/// a struct member whose own type is an inline struct (uart_reg_pkg.sv:30).
|
||||
fn parse_struct_type(&mut self) -> PResult<StructType> {
|
||||
let kw = self.bump().text;
|
||||
// `union tagged [packed] { ... }` (IEEE 1800 §7.3.2): the discriminated
|
||||
// union. `tagged` is matched by text rather than reserved, for the
|
||||
// reason [`word_at`] gives, and only the *flag* is modelled — the
|
||||
// `tagged Valid 5` expression and `case (x) matches` are a pattern
|
||||
// grammar of their own and are still a clean parse error.
|
||||
let tagged = word_at(self.cur(), "tagged");
|
||||
if tagged {
|
||||
self.bump();
|
||||
}
|
||||
let packed = self.eat_kw("packed");
|
||||
let signing = if self.cur().is_kw("signed") || self.cur().is_kw("unsigned") {
|
||||
Some(self.bump().text)
|
||||
@@ -4702,7 +4917,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
let dangling = self.take_dangling();
|
||||
self.expect_sym("}")?;
|
||||
Ok(StructType { kw, packed, signing, members, dangling })
|
||||
Ok(StructType { kw, tagged, packed, signing, members, dangling })
|
||||
}
|
||||
|
||||
/// A data type in a position where one is *required* — an enum base type,
|
||||
@@ -5625,6 +5840,12 @@ impl<'a> Parser<'a> {
|
||||
if self.at_concurrent_assertion() {
|
||||
return Ok(StmtKind::Verbatim(self.parse_concurrent_assertion()?));
|
||||
}
|
||||
// `expect (a ##1 b) else $error;` — the one assertion whose keyword is
|
||||
// not reserved, so what is inside the parentheses is what tells it
|
||||
// from a task call. See [`Parser::at_expect_statement`].
|
||||
if self.at_expect_statement() {
|
||||
return Ok(StmtKind::Verbatim(self.parse_expect_statement()?));
|
||||
}
|
||||
// A statement label (IEEE 1800 §9.3.5): `check_decode: assert (...)`.
|
||||
// It is read only here, where a statement is expected — a case item's
|
||||
// `LABEL:` is read by `parse_case_body`, which never reaches this
|
||||
@@ -7276,9 +7497,9 @@ mod tests {
|
||||
fn bind_directive_forms() {
|
||||
parse_ok(
|
||||
"module top;
|
||||
bind target_mod checker u_chk (.a(x), .b(y));
|
||||
bind i_inst checker #(.W(8)) u_chk2 (.*);
|
||||
bind top.u_dut.u_core checker u_chk3 (.clk_i, .rst_ni);
|
||||
bind target_mod chk_mod u_chk (.a(x), .b(y));
|
||||
bind i_inst chk_mod #(.W(8)) u_chk2 (.*);
|
||||
bind top.u_dut.u_core chk_mod u_chk3 (.clk_i, .rst_ni);
|
||||
bind fifo_v3 : i_a, i_b fifo_props u_props (.*);
|
||||
endmodule",
|
||||
);
|
||||
@@ -7287,7 +7508,7 @@ mod tests {
|
||||
parse_ok(
|
||||
"module m;
|
||||
generate if (E) begin : g
|
||||
bind sub checker u (.*);
|
||||
bind sub chk_mod u (.*);
|
||||
end endgenerate
|
||||
endmodule",
|
||||
);
|
||||
@@ -9398,8 +9619,196 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn interface_class_is_not_an_interface() {
|
||||
// IEEE 1800-2017 8.26: a different construct, deliberately unsupported.
|
||||
assert!(parse_err("interface class ic;\nendclass\n").contains("`interface`"));
|
||||
// IEEE 1800-2017 §8.26: a different construct — and since
|
||||
// `vendor-formal-grammar` a supported one. It is a *class*: the word
|
||||
// rides in the prefix, the closer is `endclass`, and nothing reads it
|
||||
// as an `interface ... endinterface`.
|
||||
let f = parse_ok("interface class ic;\n pure virtual function void f();\nendclass\n");
|
||||
let ItemKind::Class(c) = &f.items[0].kind else { panic!("expected a class") };
|
||||
assert_eq!(c.prefix, ["interface"]);
|
||||
assert!(c.is_interface_class());
|
||||
assert_eq!(c.name, "ic");
|
||||
assert_eq!(c.items.len(), 1, "the pure virtual prototype is an ordinary class item");
|
||||
// And an ordinary interface is still an interface.
|
||||
let f = parse_ok("interface i;\nendinterface\n");
|
||||
assert!(matches!(&f.items[0].kind, ItemKind::Module(m) if m.kw == "interface"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_interface_class_may_extend_another_one() {
|
||||
// IEEE 1800-2017 §8.26.4: interface classes inherit with `extends`,
|
||||
// and a plain class promises them with `implements`.
|
||||
let f = parse_ok("interface class b extends a;\nendclass\n");
|
||||
let ItemKind::Class(c) = &f.items[0].kind else { panic!("expected a class") };
|
||||
assert!(c.is_interface_class());
|
||||
assert_eq!(c.extends.as_ref().map(|e| e.name.as_str()), Some("a"));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Vendor and formal collateral — `vendor-formal-grammar`
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// The verbatim leaf `src`'s single item must be, with its text.
|
||||
fn verbatim_item(src: &str) -> String {
|
||||
let f = parse_ok(src);
|
||||
let ItemKind::Verbatim(raw) = &f.items[0].kind else {
|
||||
panic!("expected a verbatim item, got {:?}", f.items[0].kind)
|
||||
};
|
||||
raw.text.clone()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_specify_block_is_one_opaque_item() {
|
||||
let src = "module m;\n specify\n (a => b) = (1.0, 1.2);\n endspecify\nendmodule\n";
|
||||
let f = parse_ok(src);
|
||||
let m = module_of(&f);
|
||||
let ItemKind::Verbatim(raw) = &m.items[0].kind else { panic!("expected a verbatim item") };
|
||||
assert!(raw.text.starts_with("specify"));
|
||||
assert!(raw.text.ends_with("endspecify"), "the closer is inside the leaf: {:?}", raw.text);
|
||||
assert_eq!(raw.col, 3, "the block's own column, for the re-indent contract");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_primitive_swallows_its_own_table() {
|
||||
let text = verbatim_item(
|
||||
"primitive p (q, a);\n output q;\n input a;\n table\n 0 : 1;\n 1 : 0;\n endtable\nendprimitive : p\n",
|
||||
);
|
||||
assert!(text.starts_with("primitive p"));
|
||||
assert!(text.ends_with("endprimitive : p"), "the end label is inside: {text:?}");
|
||||
assert!(text.contains("endtable"), "the truth table never became an item of its own");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_semicolon_after_an_opaque_closer_is_a_null_item() {
|
||||
// None of the five closers takes a `;` in the LRM, so the scan leaves
|
||||
// it where it is and the `empty-item` lint gets to say so — unlike
|
||||
// `endgroup`, whose scan eats one.
|
||||
let f = parse_ok("primitive p (q, a);\n table\n 0 : 1;\n endtable\nendprimitive\n;\n");
|
||||
assert_eq!(f.items.len(), 2);
|
||||
assert!(matches!(f.items[1].kind, ItemKind::Empty));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_checker_nested_in_a_checker_closes_on_the_right_keyword() {
|
||||
let text = verbatim_item(
|
||||
"checker outer (logic clk);\n checker inner (logic a);\n endchecker : inner\nendchecker : outer\n",
|
||||
);
|
||||
assert!(text.ends_with("endchecker : outer"), "the outer closer, not the inner: {text:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_config_block_and_a_library_line_are_opaque() {
|
||||
let text = verbatim_item(
|
||||
"config cfg;\n design work.top;\n default liblist a b;\n instance top.u1 use work.impl;\nendconfig : cfg\n",
|
||||
);
|
||||
assert!(text.ends_with("endconfig : cfg"));
|
||||
let line = verbatim_item("library rtlLib \"/proj/*.v\" -incdir \"/inc\";\n");
|
||||
assert_eq!(line, "library rtlLib \"/proj/*.v\" -incdir \"/inc\";");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_specparam_is_a_declaration() {
|
||||
let f = parse_ok("module m;\n specparam tS = 0.12, tH = 0.08;\nendmodule\n");
|
||||
let m = module_of(&f);
|
||||
let ItemKind::ParamDecl(d) = &m.items[0].kind else { panic!("expected a param decl") };
|
||||
assert_eq!(d.kw, "specparam");
|
||||
let names: Vec<&str> = d.declarators.iter().map(|x| x.name.as_str()).collect();
|
||||
assert_eq!(names, ["tS", "tH"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_specparam_the_grammar_cannot_read_rewinds_to_verbatim() {
|
||||
// `PATHPULSE$a$b = (reject, error);` — the value is a pair, not an
|
||||
// expression, so the declaration parse fails and the item is the
|
||||
// opaque line instead. Nothing is lost and nothing is guessed.
|
||||
let f = parse_ok("module m;\n specparam PATHPULSE$a$b = (1.0, 1.2);\nendmodule\n");
|
||||
let m = module_of(&f);
|
||||
let ItemKind::Verbatim(raw) = &m.items[0].kind else { panic!("expected a verbatim item") };
|
||||
assert_eq!(raw.text, "specparam PATHPULSE$a$b = (1.0, 1.2);");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_alias_is_a_flat_list_of_nets() {
|
||||
let f = parse_ok("module m;\n alias a = b[3:0] = {c, d};\nendmodule\n");
|
||||
let m = module_of(&f);
|
||||
let ItemKind::Alias(nets) = &m.items[0].kind else { panic!("expected an alias") };
|
||||
assert_eq!(nets.len(), 3, "three terms, none of them the value of another");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_union_may_be_tagged() {
|
||||
let f = parse_ok("typedef union tagged packed {\n logic [7:0] v;\n} u_t;\n");
|
||||
let ItemKind::Typedef(t) = &f.items[0].kind else { panic!("expected a typedef") };
|
||||
let TypedefKind::Struct(s) = &t.kind else { panic!("expected a union") };
|
||||
assert!(s.tagged);
|
||||
assert!(s.packed);
|
||||
// And a plain one is not.
|
||||
let f = parse_ok("typedef union packed {\n logic [7:0] v;\n} u_t;\n");
|
||||
let ItemKind::Typedef(t) = &f.items[0].kind else { panic!("expected a typedef") };
|
||||
let TypedefKind::Struct(s) = &t.kind else { panic!("expected a union") };
|
||||
assert!(!s.tagged);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expect_with_a_sequence_operator_is_an_assertion() {
|
||||
for body in [
|
||||
"expect (@(posedge clk) a ##1 b) else $error(\"no\");",
|
||||
"expect (a |-> b);",
|
||||
"expect (a |=> b);",
|
||||
"expect (a throughout b);",
|
||||
"expect (disable iff (rst) a ##1 b);",
|
||||
] {
|
||||
let f =
|
||||
parse_ok(&format!("module m;\n initial begin\n {body}\n end\nendmodule\n"));
|
||||
let m = module_of(&f);
|
||||
let ItemKind::Initial(stmt) = &m.items[0].kind else { panic!("expected an initial") };
|
||||
let StmtKind::Block { stmts, .. } = &stmt.kind else { panic!("expected a block") };
|
||||
assert!(
|
||||
matches!(stmts[0].kind, StmtKind::Verbatim(_)),
|
||||
"{body} should be an assertion, got {:?}",
|
||||
stmts[0].kind
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expect_of_an_argument_list_is_still_a_task_call() {
|
||||
// The 41-site regression guard: `expect(word1[7:0]);` in picorv32's
|
||||
// spiflash testbench is a task, and nothing this round did may change
|
||||
// that. An argument list cannot hold `##`, `|->`, `|=>`, `throughout`,
|
||||
// `disable iff` or `@(`, which is the whole reason the rule is safe.
|
||||
for body in ["expect(word1[7:0]);", "expect(x, y);", "expect(a[i] + 1);", "expect();"] {
|
||||
let f =
|
||||
parse_ok(&format!("module m;\n initial begin\n {body}\n end\nendmodule\n"));
|
||||
let m = module_of(&f);
|
||||
let ItemKind::Initial(stmt) = &m.items[0].kind else { panic!("expected an initial") };
|
||||
let StmtKind::Block { stmts, .. } = &stmt.kind else { panic!("expected a block") };
|
||||
assert!(
|
||||
!matches!(stmts[0].kind, StmtKind::Verbatim(_)),
|
||||
"{body} must stay a call, got {:?}",
|
||||
stmts[0].kind
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_name_that_contains_a_new_keyword_is_still_a_name() {
|
||||
// The keyword/identifier boundary: only the whole word is reserved.
|
||||
let f = parse_ok(
|
||||
"module checker_x;\n wire config_reg;\n logic library_sel;\n assign config_reg = library_sel;\nendmodule\n",
|
||||
);
|
||||
assert_eq!(module_of(&f).name, "checker_x");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unclosed_opaque_block_stops_at_the_next_construct() {
|
||||
// Tolerant mode only: `SYNC_CLOSERS` gained the five new closers, so a
|
||||
// broken item inside a module cannot eat the `endspecify` the module's
|
||||
// own loop is waiting behind.
|
||||
let src = "module m;\n specify\nendmodule\n";
|
||||
let (f, diags) = parse_tolerant(tokenize(src).expect("lex error"), src);
|
||||
assert!(!diags.is_empty(), "the missing `endspecify` is reported");
|
||||
assert_eq!(f.items.len(), 1, "and the module still closed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -293,6 +293,21 @@ keywords![
|
||||
"endspecify",
|
||||
"table",
|
||||
"endtable",
|
||||
// Vendor and formal collateral (`vendor-formal-grammar`, 2026-09-02).
|
||||
// All five are reserved words in IEEE 1800 Table B.1, so a file that
|
||||
// spells one as an identifier is already illegal SystemVerilog — and a
|
||||
// census of 4 839 corpus + opentitan files found **zero** code-shaped
|
||||
// uses of any of them. The rest of the vendor/config vocabulary
|
||||
// (`expect`, `tagged`, `design`, `instance`, `cell`, `liblist`, `use`,
|
||||
// `showcancelled`, `ifnone`) is deliberately *not* here: real code does
|
||||
// spell those as identifiers — `expect(word1[7:0]);` is a task call in 41
|
||||
// corpus sites — so they are matched by text where they are needed at
|
||||
// all. See `docs/features/vendor-formal-grammar/README.md`.
|
||||
"checker",
|
||||
"endchecker",
|
||||
"config",
|
||||
"endconfig",
|
||||
"library",
|
||||
"small",
|
||||
"medium",
|
||||
"large",
|
||||
|
||||
@@ -667,6 +667,11 @@ fn check_item(src: &str, item: &Item, parent: TextRange) {
|
||||
// above. A null item is a leaf too — its span is the `;`, which the
|
||||
// caller has already asserted sits inside its parent.
|
||||
ItemKind::Verbatim(_) | ItemKind::Empty => {}
|
||||
ItemKind::Alias(nets) => {
|
||||
for net in nets {
|
||||
check_expr(src, net, here);
|
||||
}
|
||||
}
|
||||
ItemKind::Function(f) => {
|
||||
check_name(src, "function name", &f.name, f.name_span, here);
|
||||
check_dpi_import(src, f.dpi.as_ref(), here);
|
||||
|
||||
@@ -470,6 +470,13 @@ impl<'a> Binder<'a> {
|
||||
self.bind_expr(rhs, scope);
|
||||
}
|
||||
}
|
||||
// Every term of an `alias` names an existing net — the item
|
||||
// declares nothing — so all of them are references.
|
||||
ItemKind::Alias(nets) => {
|
||||
for net in nets {
|
||||
self.bind_expr(net, scope);
|
||||
}
|
||||
}
|
||||
// Opaque leaves: verbatim text this crate makes no claims about.
|
||||
// `Verbatim` is a constraint or covergroup body — no symbol is
|
||||
// bound for its name and nothing inside it is scanned, the same
|
||||
@@ -2067,7 +2074,10 @@ fn spine(base: &Expr) -> Option<(String, Vec<String>)> {
|
||||
/// been written at all — is a [`SymbolKind::Param`].
|
||||
fn param_kind(kw: &str) -> SymbolKind {
|
||||
match kw {
|
||||
"localparam" => SymbolKind::LocalParam,
|
||||
// A `specparam` is not overridable from a `#( ... )` list — only an
|
||||
// SDF annotator may change one — so it travels with `localparam`,
|
||||
// whose kind exists to keep exactly that promise.
|
||||
"localparam" | "specparam" => SymbolKind::LocalParam,
|
||||
_ => SymbolKind::Param,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
//! What the vendor and formal constructs bind — and, mostly, what they
|
||||
//! deliberately do not. See `docs/features/vendor-formal-grammar/README.md`.
|
||||
|
||||
use vlog_parser::parse_source;
|
||||
use vlog_semantic::{analyze, Resolution, Semantics, SymbolKind};
|
||||
|
||||
fn sem(src: &str) -> Semantics {
|
||||
let file = parse_source(src).expect("fixture must parse");
|
||||
analyze(&file, src)
|
||||
}
|
||||
|
||||
fn symbol_named<'a>(s: &'a Semantics, name: &str) -> &'a vlog_semantic::Symbol {
|
||||
s.symbols().iter().find(|sym| sym.name == name).unwrap_or_else(|| panic!("no symbol {name}"))
|
||||
}
|
||||
|
||||
/// Offset of the `n`th (0-based) occurrence of `needle`.
|
||||
fn nth(src: &str, needle: &str, n: usize) -> u32 {
|
||||
src.match_indices(needle).nth(n).expect("occurrence must exist").0 as u32
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_specparam_is_a_local_parameter() {
|
||||
// Not a `Param`: a specparam cannot be overridden from a `#( ... )` list,
|
||||
// and `SymbolKind::LocalParam` is the kind that keeps exactly that
|
||||
// promise — a header `localparam` offered as an override was the bug that
|
||||
// parted the two kinds.
|
||||
let src =
|
||||
"module m;\n specparam tSETUP = 0.12, tHOLD = 0.08;\n wire w = tSETUP;\nendmodule\n";
|
||||
let s = sem(src);
|
||||
assert_eq!(symbol_named(&s, "tSETUP").kind, SymbolKind::LocalParam);
|
||||
assert_eq!(symbol_named(&s, "tHOLD").kind, SymbolKind::LocalParam);
|
||||
// And it resolves where it is read.
|
||||
let at = nth(src, "tSETUP", 1);
|
||||
let reference = s.reference_at(at).expect("a reference to the specparam");
|
||||
assert!(matches!(reference.resolution, Resolution::Resolved(_)), "the specparam resolves");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_term_of_an_alias_is_a_reference_and_none_is_a_declaration() {
|
||||
let src = "module m;\n wire n1, n2;\n alias n1 = n2;\nendmodule\n";
|
||||
let s = sem(src);
|
||||
// Two nets, and no third symbol invented by the alias.
|
||||
assert_eq!(s.symbols().iter().filter(|x| x.kind == SymbolKind::Net).count(), 2);
|
||||
for name in ["n1", "n2"] {
|
||||
let at = nth(src, name, 1);
|
||||
let reference = s.reference_at(at).unwrap_or_else(|| panic!("a reference to {name}"));
|
||||
assert!(matches!(reference.resolution, Resolution::Resolved(_)), "{name} resolves");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_interface_class_declares_a_class() {
|
||||
let src = "\
|
||||
interface class api;
|
||||
pure virtual function void run();
|
||||
endclass
|
||||
|
||||
class impl implements api;
|
||||
virtual function void run();
|
||||
endfunction
|
||||
endclass
|
||||
";
|
||||
let s = sem(src);
|
||||
assert_eq!(symbol_named(&s, "api").kind, SymbolKind::Class);
|
||||
assert_eq!(symbol_named(&s, "impl").kind, SymbolKind::Class);
|
||||
// And the `implements` clause is a reference to it, which is what the
|
||||
// type hierarchy's supertype hop reads.
|
||||
let at = nth(src, "api", 1);
|
||||
let reference = s.reference_at(at).expect("a reference from `implements`");
|
||||
assert!(matches!(reference.resolution, Resolution::Resolved(_)), "`implements api` resolves");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_interface_class_is_collected_like_any_other_class() {
|
||||
let src = "interface class api;\nendclass\nclass k;\nendclass\n";
|
||||
let file = parse_source(src).expect("fixture must parse");
|
||||
let names: Vec<&str> = vlog_semantic::classes::declarations(&file.items)
|
||||
.iter()
|
||||
.map(|d| d.class.name.as_str())
|
||||
.collect();
|
||||
assert_eq!(names, ["api", "k"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_opaque_blocks_bind_nothing_and_break_nothing_around_them() {
|
||||
// A `specify`, a UDP and a `checker` are verbatim leaves: no symbol, no
|
||||
// reference, and — the part that matters — the declarations written
|
||||
// beside them are bound exactly as if the blocks were not there.
|
||||
let src = "\
|
||||
primitive udp (q, a);
|
||||
table
|
||||
0 : 1;
|
||||
endtable
|
||||
endprimitive
|
||||
|
||||
module m;
|
||||
wire clk;
|
||||
specify
|
||||
(clk => q) = 1;
|
||||
endspecify
|
||||
wire done;
|
||||
endmodule
|
||||
|
||||
checker chk (logic a);
|
||||
endchecker
|
||||
";
|
||||
let s = sem(src);
|
||||
assert_eq!(symbol_named(&s, "m").kind, SymbolKind::Module);
|
||||
assert_eq!(symbol_named(&s, "clk").kind, SymbolKind::Net);
|
||||
assert_eq!(symbol_named(&s, "done").kind, SymbolKind::Net);
|
||||
// Nothing inside a leaf became a symbol.
|
||||
for name in ["udp", "chk", "q"] {
|
||||
assert!(
|
||||
!s.symbols().iter().any(|x| x.name == name),
|
||||
"an opaque leaf declares nothing, but `{name}` appeared"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ request.
|
||||
| # | Gap | Evidence | Why |
|
||||
|---|---|---|---|
|
||||
| M1 | `specify … endspecify` / `specparam` and UDP `primitive … endprimitive` — hard parse errors. | Probe (3 files); README "still open". Corpus count 0, opentitan 0. | Absent from hand-written RTL, present in every std-cell / IO / memory simulation model a project vendors. Exclude patterns cover most; parsing (opaque-verbatim capture is enough) would stop the errors. |
|
||||
| M2 | `checker … endchecker` — parse error on the checker's port list; `checker` not even a keyword. | Probe; corpus has **13** files with it. | Formal-verification collateral; 13 corpus hits says it is real. |
|
||||
| M2 | `checker … endchecker` — parse error on the checker's port list; `checker` not even a keyword. | **Evidence corrected 2026-09-02:** the "13 corpus files" were UVM protocol-*checker* filenames and identifiers, not declarations. A token-level census over 4 839 corpus + opentitan files finds **0** `checker` declarations — and 0 code-shaped uses of the word at all. | Formal-verification collateral. The 13-hit number was wrong, so this is a completeness item, not a measured pain: the value is that a formal harness opens without an error node. Delivered by TODO §23. |
|
||||
| M3 | `interface class` + `implements` — parse error. | Probe; interfaces/type-hierarchy READMEs. | UVM-style DV uses it occasionally; also blocks type-hierarchy's `implements` edges. |
|
||||
| M4 | Macro call with a space before `(` — `` `uvm_field_int (x, y) `` — clean parse error at item position. | macro-items/lexer-cleanup READMEs; measured 11 opentitan files. | A UVM spelling people actually type. Deliberately deferred because the lexer fix could break expression position; needs a careful round. |
|
||||
| M5 | Directives inside a list *element* or between an instance name and its `(`. | directives-in-instances README; measured 13 files. | The `.a(` ⏎ `` `ifdef `` ⏎ … ⏎ `)` shape in real port maps. |
|
||||
@@ -99,7 +99,7 @@ LSP: hover + definition for package-imported parameters, enum members, class par
|
||||
4. **H3**: the escaped-identifier space — a one-line formatter fix with attack tests; ship it in any adjacent round.
|
||||
5. **C1**: constraint and covergroup bodies as real nodes — the biggest single DV win and the one correctness risk; SVA expressions can follow.
|
||||
6. **H4**: fragment mode for `.svh` pieces. *(Done by TODO §22 — and the row itself was wrong; see the correction in the High table.)*
|
||||
7. **M1–M3** grammar arms (specify/UDP/checker/interface class) as one "vendor and formal collateral" round, verbatim capture acceptable.
|
||||
7. **M1–M3** grammar arms (specify/UDP/checker/interface class) as one "vendor and formal collateral" round, verbatim capture acceptable. *(Done by TODO §23 — and the M2 row's evidence was wrong; see the correction in the Medium table.)*
|
||||
8. **M7** semantic lints on by default via §2.9-6.
|
||||
|
||||
Two stale READMEs found by the inventory, to fix on the next docs pass:
|
||||
@@ -128,7 +128,7 @@ Delivered since this analysis was written at 0.21.0, in the recommended order:
|
||||
| **C1** covergroup bodies | done; 544/544 opentitan covergroups structured | 0.28.0 |
|
||||
| H5 `` `define`` go-to-definition | **open** | — |
|
||||
| H4 fragment mode — statement / enum-member / covergroup-item files, plus the `` `define`` formal-argument continuation (the H4 row above is corrected: class-body and module-item fragments already parsed) | done; opentitan 12 → 10, corpus 813 → 814 | 0.29.0 |
|
||||
| M1–M3 specify/UDP/checker/interface class | queued | — |
|
||||
| M1–M3 specify/UDP/checker/interface class, plus L1/L2/L4/L5 (`alias`, statement `expect`, `config`/`library`, `union tagged`) | done; corpus 814/820 and the opentitan 3 975-file sweep byte-identical | pending release |
|
||||
| M7 semantic lints on by default (§2.9-6) | queued | — |
|
||||
|
||||
New gaps filed along the way: §2.9-20 (rename loses its warning for an
|
||||
|
||||
@@ -434,6 +434,27 @@ aborts. Two caveats for the recursion-limit work in TODO.md §1:
|
||||
with the tool.
|
||||
- Did not run `git commit`/`git push`; did not touch `cargo` or any test.
|
||||
|
||||
### 2026-09-02 — `vendor-formal-grammar` (amendment)
|
||||
|
||||
A note for whoever reads this tracker next, because the headline number
|
||||
did not move and that is the point. This round added five keywords and
|
||||
seven constructs to the grammar; over the pinned 820-file corpus the
|
||||
result is **814/820 parsed & formattable, 0 verification errors,
|
||||
0 crashes — unchanged**, and stronger than the script measures: the
|
||||
formatted output of all 860 `.v`/`.sv`/`.svh`/`.vh` files was hashed
|
||||
against a release build of trunk (`c40e720`) and is **byte-identical**,
|
||||
file for file. The same comparison over opentitan's 3 975 `hw` files is
|
||||
also byte-identical, with the same 10 failures carrying the same
|
||||
messages.
|
||||
|
||||
That is the shape of a completeness round: nothing in the corpus spells
|
||||
`specify`, `primitive`, `checker`, `config`, `interface class`, `alias`
|
||||
or a `tagged` union, so the corpus *cannot* move. The measurement that
|
||||
matters for this round is the collision census — which words could be
|
||||
reserved without breaking a file that already parsed — and it lives in
|
||||
`docs/features/vendor-formal-grammar/README.md`, not here. The four
|
||||
corpus working trees were verified clean before and after, as always.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-08-19 — QA agent
|
||||
|
||||
@@ -35,13 +35,18 @@ keyword in an error red.
|
||||
outer` matches on the two keywords; the label is tokens the matcher skips.
|
||||
Nothing checks that the two labels agree — that is a linter's job, not this
|
||||
one's.
|
||||
- **`checker`/`endchecker` and `config`/`endconfig` are not in the pair set**
|
||||
because `vlog_parser::token::is_keyword` does not list them: they lex as
|
||||
plain identifiers, and matching identifiers named `checker` would be a
|
||||
false-positive machine. `table`/`endtable` *are* keywords but are left out
|
||||
too — they only occur inside a `primitive`, which is matched, and the plan
|
||||
did not ask for them. All three are one line each in `RULES` the day the
|
||||
lexer or the need arrives.
|
||||
- **`checker`/`endchecker`, `config`/`endconfig` and `table`/`endtable` are in
|
||||
the pair set** — *amended 2026-09-02 by `vendor-formal-grammar`*, which is
|
||||
the day this assumption predicted. It read, until then: the first two are not
|
||||
in the set because `vlog_parser::token::is_keyword` does not list them, so
|
||||
they lex as plain identifiers and matching identifiers named `checker` would
|
||||
be a false-positive machine; `table`/`endtable` *are* keywords but were left
|
||||
out because they only occur inside a `primitive`, which is matched. The
|
||||
lexer now reserves all five words (a census found 0 code-shaped uses of them
|
||||
in 4 839 corpus + opentitan files), so the three rows cost one line each
|
||||
exactly as predicted, and a UDP truth table now folds. Pinned by
|
||||
`the_vendor_and_formal_blocks_are_scopes` and
|
||||
`an_unclosed_vendor_block_is_reported_against_its_own_keyword`.
|
||||
- **A prototype ends at the next `;`.** The flag `extern`, `pure`, `import`,
|
||||
`export` and `typedef` raise is dropped at the next semicolon, wherever it
|
||||
falls. A `typedef struct { logic a; } t;` therefore drops the flag at the
|
||||
@@ -400,6 +405,8 @@ reading the LRM would not have caught it, running the corpus did. One guard
|
||||
|
||||
- `checker`/`endchecker` **dropped** from the pair set: `vlog_parser` does not
|
||||
lex them as keywords, so matching them would mean matching identifiers.
|
||||
*(Reversed 2026-09-02: the lexer reserves them now — see the amended
|
||||
assumption above.)*
|
||||
- Four guards added beyond the plan's list, three of them for constructs the
|
||||
plan did not mention: `assert property (` / `cover sequence (` (an assertion
|
||||
is not a declaration — this one is unavoidable, SV assertions are everywhere),
|
||||
|
||||
@@ -26,9 +26,15 @@ At the start of this round `interface` was the corpus's top blocker at
|
||||
is that a consumer that wants to tell the two apart must read `kw`;
|
||||
that is the same thing it already had to do for `macromodule`.
|
||||
- **`interface class` is not an interface** (IEEE 1800-2017 §8.26). It
|
||||
is a class-like construct with a different body grammar and is
|
||||
deliberately left as an "unsupported construct" parse error. No corpus
|
||||
file uses it (0 of 820).
|
||||
is a class-like construct with a different body grammar. This round
|
||||
left it as an "unsupported construct" parse error; *amended 2026-09-02
|
||||
by `vendor-formal-grammar`*, it now parses — as an `ItemKind::Class`
|
||||
whose `prefix` holds the word `interface`, never as a `Module`. The
|
||||
guard this round wrote in `parse_keyword_item`
|
||||
(`"interface" if !self.nth(1).is_kw("class")`) is what routes it, and
|
||||
it is unchanged: an `interface` followed by `class` has always been
|
||||
something else, and now there is somewhere for it to go. Still 0 of
|
||||
820 corpus files.
|
||||
- **`program … endprogram` is out of scope** for this round even though
|
||||
it shares the same header/body grammar and would be a one-line
|
||||
addition here. No corpus file uses it (0 of 820), so it buys nothing
|
||||
@@ -145,9 +151,11 @@ Requests to other owners (not done here):
|
||||
plus 8 parser unit tests, covering every corpus shape cited above,
|
||||
comments in every position, a `verilog_format: off` fence and the
|
||||
line-length boundary
|
||||
- [ ] Not done, and not planned here: `interface class`, `program`,
|
||||
explicit modport ports, modport method prototypes, clocking
|
||||
`= expr` items, `#(min:typ:max)` skews (see Assumptions)
|
||||
- [ ] Not done, and not planned here: explicit modport ports, modport
|
||||
method prototypes, `#(min:typ:max)` skews (see Assumptions).
|
||||
`program` and clocking `= expr` items landed in §11 round 2;
|
||||
`interface class` landed 2026-09-02 in `vendor-formal-grammar` —
|
||||
as a class, which is what it is
|
||||
|
||||
## Work log
|
||||
|
||||
|
||||
@@ -30,22 +30,28 @@ reader — to tell them apart. One item kind, done well.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **`extends` is the edge, and nothing else is.** `implements` names an
|
||||
**interface class**, which is a different construct (IEEE 1800 §8.26) that
|
||||
`vlog_parser` does not model at all — `interface class ic; ... endclass` is
|
||||
rejected as an unsupported construct
|
||||
(`vlog_parser::parser::parse_keyword_item`, and its own
|
||||
`interface_class_is_not_an_interface` test). So an `implements` target can
|
||||
never be a class declaration this server holds, and matching one by name would
|
||||
claim an unrelated ordinary class of that name. `implements` therefore
|
||||
contributes no supertype. Pinned by
|
||||
`an_implements_clause_names_no_supertype` and
|
||||
`an_interface_class_is_not_a_node_because_the_parser_does_not_model_one`,
|
||||
the second named so a future parser round that models interface classes is
|
||||
forced past it.
|
||||
- **Every item is `SymbolKind::CLASS`.** Following from the above: there is no
|
||||
node in this feature that could carry `INTERFACE`, because there is no AST
|
||||
node for an interface class to build one from.
|
||||
- **`extends` and `implements` are both edges.** *(Amended 2026-09-02 by
|
||||
`vendor-formal-grammar`; the original assumption is kept below because it
|
||||
explains the shape of the code.)* `vlog_parser` now models
|
||||
`interface class ic; ... endclass` as an ordinary `ClassDecl` carrying the
|
||||
word `interface` in its `prefix`, so an `implements` target **is** a class
|
||||
declaration this server holds, and `bases_of` follows it through the same
|
||||
`classes_at` hop `extends` takes — base first, then the interfaces, in source
|
||||
order. Pinned by `an_implements_clause_names_a_supertype`,
|
||||
`an_interface_class_is_a_node` and
|
||||
`extends_and_implements_are_both_edges_of_the_same_answer`.
|
||||
|
||||
*Superseded:* until 2026-09-02, `implements` contributed no supertype,
|
||||
because `interface class` was rejected as an unsupported construct and
|
||||
matching an `implements` target by name would have claimed an unrelated
|
||||
ordinary class of that name. The two tests that pinned that answer were
|
||||
named so this round would be forced past them, and it was.
|
||||
- **Every item is still `SymbolKind::CLASS`.** An interface class declares a
|
||||
`SymbolKind::Class` like any other — deliberately, and argued in
|
||||
`docs/features/vendor-formal-grammar/README.md`: a distinct kind would have
|
||||
to round-trip through the on-disk index (a `FACTS_FORMAT` bump) and nothing
|
||||
downstream asks the question. `ClassDecl::is_interface_class()` is there for
|
||||
the first consumer that ever does.
|
||||
- **A class has exactly one base**, which is what the AST gives
|
||||
(`ClassDecl::extends` is an `Option<ClassExtends>`) and what the LRM says for
|
||||
ordinary classes. `supertypes` is therefore a list of at most one — except
|
||||
@@ -263,10 +269,17 @@ UVM class names are long and specific, and no such name exists in the corpus.
|
||||
- [ ] Not done, backlog: the **inheritance edge table in `WorkspaceIndex`**,
|
||||
filed with the instantiation-edge table it should ship beside (Handshakes
|
||||
above).
|
||||
- [ ] Not done, blocked: **interface classes**. `vlog_parser` rejects
|
||||
`interface class`, so `implements` can never resolve and no item can carry
|
||||
`SymbolKind::INTERFACE`. When the parser models them, this feature needs
|
||||
one arm in the walk, one kind, and `implements` added to `supertypes`.
|
||||
- [x] **Interface classes** — unblocked and done 2026-09-02 by
|
||||
`vendor-formal-grammar`: the parser models them, `classes::declarations`
|
||||
collects them unchanged, and `implements` joined `supertypes`. No new
|
||||
kind and no walk arm were needed; see the amended assumption above.
|
||||
- [ ] Not done, filed: `subtypes` does **not** answer the reverse
|
||||
`implements` edge. The forward hop reads the parse tree, but the reverse
|
||||
one is `WorkspaceIndex::subclasses_of`, whose edge table records
|
||||
`extends` only. "Who implements this interface class?" therefore returns
|
||||
nothing. Filed against the index rather than worked around here, because
|
||||
a name match would be exactly the wrong answer the original assumption
|
||||
warned about.
|
||||
- [ ] Not done, deliberately: chasing a chain server-side (the client drives
|
||||
it), a whole-tree "show me every class" view, and typedef/struct
|
||||
hierarchies — SystemVerilog has no inheritance for them.
|
||||
|
||||
@@ -0,0 +1,497 @@
|
||||
# vendor-formal-grammar
|
||||
|
||||
## Goal
|
||||
|
||||
Close the last block-shaped holes in lucisv's item grammar: the constructs a
|
||||
**vendored** cell/IO/memory model and a **formal** collateral file are made of.
|
||||
`specify`/`endspecify`, `specparam`, `primitive`/`endprimitive` with its
|
||||
`table`/`endtable`, `checker`/`endchecker`, `config`/`endconfig`, a library
|
||||
map's `library ...;` line, `interface class`, `alias`, the concurrent `expect`
|
||||
statement and `union tagged`. Every one of them is a *completeness* item, not a
|
||||
measured pain: a census of the four corpus repos plus opentitan's `hw` tree
|
||||
(4 839 files) finds **zero** declarations of any of them. The value is that a
|
||||
user who opens a foundry cell library, a UDP, or a formal harness gets a file
|
||||
lucisv can read instead of one error node — so scope is kept to opaque leaves
|
||||
except where a real node is exactly one arm of work (`specparam`, `alias`,
|
||||
`interface class`, the `tagged` flag).
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **A reserved word in IEEE 1800 Table B.1 that no real file spells as an
|
||||
identifier may be reserved here.** That is the whole test applied to the
|
||||
five new keywords (`checker`, `endchecker`, `config`, `endconfig`,
|
||||
`library`): they are reserved by the LRM, so a file using one as a name is
|
||||
already illegal SystemVerilog, *and* the census below found none. The
|
||||
converse assumption is the load-bearing one: a Table B.1 word that real code
|
||||
does spell as an identifier is **not** reserved here, which is why `expect`,
|
||||
`tagged`, `design`, `instance`, `cell`, `liblist`, `use`, `showcancelled`
|
||||
and `ifnone` stay ordinary identifiers matched by text where needed at all.
|
||||
- **A specify block's own vocabulary needs nothing.** `pulsestyle_onevent`,
|
||||
`pulsestyle_ondetect`, `showcancelled`, `noshowcancelled` and `ifnone` only
|
||||
ever stand *inside* a `specify`, which is one opaque leaf — so none of them
|
||||
is reserved, matched, or modelled, and none ever will need to be unless the
|
||||
block itself stops being opaque.
|
||||
- **The five blocks have no layout worth inventing.** A specify path
|
||||
(`(a => b) = (1.0, 1.2);`), a UDP truth table row, a checker's assertion
|
||||
vocabulary and a config's `design`/`instance`/`liblist` clauses are each a
|
||||
second grammar. Copying them out of the source by span is the same bargain
|
||||
`property`/`sequence` and a concurrent assertion already take.
|
||||
- **An `interface class` is a class.** Its header is a class header, its body
|
||||
is a subset of a class body, and it closes with `endclass`. The subset — only
|
||||
pure virtual prototypes, parameters and typedefs may stand in one — is a
|
||||
legality rule, and legality is a checker's business, not a formatter's.
|
||||
- **Only what is between an `expect`'s parentheses can tell the assertion from
|
||||
the task call.** No token before or after them differs. See the rule under
|
||||
Handshakes.
|
||||
- **A `;` after one of the new closers is a null item.** None of
|
||||
`endspecify`/`endprimitive`/`endtable`/`endchecker`/`endconfig` takes a
|
||||
terminating `;` in the LRM, so the opaque scan leaves it where it is and the
|
||||
`empty-item` lint gets to say so — unlike `endgroup`, whose scan eats one.
|
||||
|
||||
### The collision census
|
||||
|
||||
Run over `corpus/{common_cells,ibex,opentitan,picorv32}` (860 files) and
|
||||
`~/repo/opentitan/hw` (3 979 files), with comments and string literals removed
|
||||
and each word matched only where it stands as a whole token:
|
||||
|
||||
| word | corpus | opentitan `hw` | reserved by this round? |
|
||||
| --- | --- | --- | --- |
|
||||
| `checker` / `endchecker` | 0 | 0 | yes |
|
||||
| `config` / `endconfig` | 0 | 0 | yes |
|
||||
| `library` | 0 | 0 | yes |
|
||||
| `expect` | **41** | 0 | **no** — `expect(word1[7:0]);` is a task call in `picorv32/picosoc/spiflash_tb.v` |
|
||||
| `tagged`, `design`, `instance`, `cell`, `liblist`, `use` | 0 | 0 | no — no construct in this round needs them reserved |
|
||||
|
||||
The one in-repo collision the census could not see was our own:
|
||||
`crates/vlog_formatter/tests/cases/bind.cases` and one `vlog_parser` test
|
||||
bound a module *named* `checker`, which is illegal SV. Both were renamed to
|
||||
`chk_mod` (same length, so no fixture re-alignment). See the work log.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**Consumed from `vlog_parser` (this round's own):**
|
||||
|
||||
- `parse_opaque_block(close)` — the flat scan `parse_covergroup_verbatim`
|
||||
established, plus an opener count so a nested `checker` closes on the right
|
||||
keyword. Produces an `ItemKind::Verbatim` whose `col` re-indent contract the
|
||||
formatter already honours.
|
||||
- `parse_opaque_line()` — the same leaf, ending at its own `;`. Used by
|
||||
`library` and by the `specparam` fallback.
|
||||
- `skip_to_semi()` — lifted out of `parse_default_disable` unchanged, now
|
||||
shared by three callers.
|
||||
|
||||
**Promised to `vlog_formatter`:**
|
||||
|
||||
- `ItemKind::Alias(Vec<Expr>)` — a new exhaustive-match arm. Printed
|
||||
`alias a = b = c;`.
|
||||
- `StructType.tagged: bool` — printed between the keyword and `packed`, in the
|
||||
LRM's order (`union tagged packed { ... }`).
|
||||
- `ClassDecl.prefix` may now contain `"interface"`. The formatter's `class`
|
||||
already prints the prefix in source order, so `interface class` needed no
|
||||
formatter change at all.
|
||||
|
||||
**Promised to `vlog_semantic`:**
|
||||
|
||||
- `ItemKind::Alias` binds every term as a *reference*; the item declares
|
||||
nothing.
|
||||
- `specparam` arrives as an `ItemKind::ParamDecl` whose `kw` is `"specparam"`.
|
||||
`param_kind` maps it to `SymbolKind::LocalParam`, because a specparam is not
|
||||
overridable from a `#( ... )` list — which is the exact promise that kind
|
||||
exists to keep.
|
||||
- An `interface class` arrives as an ordinary `ItemKind::Class`, so
|
||||
`bind_class` declares a `SymbolKind::Class` and `classes::declarations`
|
||||
collects it with no change to either. **No `FACTS_FORMAT` bump** — see the
|
||||
decision below.
|
||||
|
||||
**Promised to `lucisv_server`:**
|
||||
|
||||
- `pairs.rs` `RULES` gains `table`/`endtable`, `checker`/`endchecker` and
|
||||
`config`/`endconfig`. A rule can only fire on a `TokenKind::Keyword`, so the
|
||||
latter two were impossible before the lexer change and `table` was simply a
|
||||
row nobody had added. `folding.rs` reads `pairs::analyze` directly, so a UDP
|
||||
truth table and a checker body fold with no change of its own.
|
||||
- `on_type.rs` `OPAQUE` gains all five block openers: their bodies are emitted
|
||||
byte-for-byte, so the indent model must have no opinion inside them.
|
||||
- `type_hierarchy.rs` `supertypes` now follows `implements` as well as
|
||||
`extends`, through the same `classes_at` hop. `subtypes` is unchanged: the
|
||||
reverse edge lives in the workspace index (`subclasses_of`), which records
|
||||
`extends` only — filed below.
|
||||
|
||||
**Requested of nobody.** `verify.rs` is untouched: this round adds no
|
||||
normalization to the safety net, and every new block is byte-for-byte output,
|
||||
which the net already checks the strongest way it knows.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] Five keywords in `token.rs` + the hand-edited tmLanguage alternation
|
||||
(`tests/grammar.rs` green) + `pairs.rs` re-checked
|
||||
- [x] `SYNC_CLOSERS` gains `endspecify`, `endprimitive`, `endtable`,
|
||||
`endchecker`, `endconfig`
|
||||
- [x] `parse_opaque_block` for `specify`, `primitive`, `table`, `checker`,
|
||||
`config`; `parse_opaque_line` for `library`
|
||||
- [x] `specparam` as a `ParamDecl`, with a verbatim rewind for the
|
||||
`PATHPULSE$` form
|
||||
- [x] `interface class` routed to `parse_class` through `ClassDecl::prefix`
|
||||
- [x] `implements` as a type-hierarchy supertype; the two blocking pins flipped
|
||||
- [x] `ItemKind::Alias`, `StructType.tagged`, the concurrent `expect` statement
|
||||
- [x] `pairs.rs` rows, `on_type.rs` OPAQUE
|
||||
- [x] Pins: format + round-trip per construct, folding/pairs, grammar lock,
|
||||
the 41-site `expect(x);` regression guard, identifier-boundary tests
|
||||
- [x] Gates: fmt, clippy, `cargo test --workspace`, corpus, opentitan sweep
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-02 — dev
|
||||
|
||||
**Keywords.** `checker`, `endchecker`, `config`, `endconfig`, `library` added
|
||||
to `token.rs`'s `keywords!` list, with the census above written into the
|
||||
comment beside them so the next reader does not have to re-derive why those
|
||||
five and not the other nine. The tmLanguage alternation was hand-edited in the
|
||||
same place in the list (`tests/grammar.rs` sorts both sides, so position is
|
||||
cosmetic; keeping the order parallel is for the human diff). `pairs.rs` was
|
||||
re-checked per `docs/topo.md` §3.3 and gained three rows.
|
||||
|
||||
**One opaque helper.** `parse_opaque_block(close)` reads the opener from the
|
||||
cursor so one function serves five constructs. It counts its own opener, which
|
||||
matters for exactly one of them: a `checker` may nest inside a `checker`
|
||||
(IEEE 1800 §17.1). `primitive` swallows its `table ... endtable` in the flat
|
||||
scan, so the `table` arm exists only for the stray case (a UDP whose
|
||||
`primitive` line is behind an `` `ifdef ``) and for the `pairs.rs` row, which
|
||||
is what actually pays for it: folding and rainbow highlight inside a UDP body.
|
||||
|
||||
**Deviation — no `include` item.** The plan mentioned an `include ...;` line
|
||||
inside a library map file as a second opaque item. Not done, deliberately:
|
||||
`include` is not a keyword and reserving it would break every `` `include ``
|
||||
adjacent identifier for no measured gain, while text-matching `include` at
|
||||
file scope would claim a declaration of a type named `include`. A library map
|
||||
is not a `.sv` file and lucisv is never pointed at one. Filed.
|
||||
|
||||
**Deviation — `specparam` is a real node, with a rewind.** The plan allowed
|
||||
either a `ParamDecl` or an opaque line. Both, in the end: the declaration is
|
||||
read as a `ParamDecl` (so `tRISE` hovers, resolves and completes), and the one
|
||||
LRM spelling that cannot be an expression — `PATHPULSE$a$b = (reject, error);`
|
||||
— rewinds to the opaque line. That is the `constraint-bodies` pattern, and it
|
||||
means an unreadable specparam *is* the old behaviour rather than an
|
||||
approximation of it.
|
||||
|
||||
**Decision — `interface class` is `ClassDecl.prefix`, not a new kind.** Three
|
||||
representations were on the table: a new `SymbolKind::InterfaceClass`, a flag
|
||||
on the symbol, or nothing downstream at all. The first two both force a
|
||||
`FACTS_FORMAT` bump (a new kind must round-trip through the on-disk index, and
|
||||
so must a new `Def` field), and the §24 lane is bumping 12 → 13 for its own
|
||||
words census in the same wave — two lanes bumping one format is a merge
|
||||
conflict by construction. More to the point, **nothing downstream needs the
|
||||
distinction**: an interface class declares a class symbol, is collected by
|
||||
`classes::declarations`, resolves by name, and is reached by `implements` the
|
||||
same way a base is reached by `extends`. So the word rides in
|
||||
`ClassDecl.prefix` beside `virtual` — which is what it literally is, a keyword
|
||||
written in front of `class` — and `ClassDecl::is_interface_class()` is there
|
||||
for the first consumer that ever needs to ask. Zero FACTS impact, zero new
|
||||
arms, and the formatter needed no change because it already prints the prefix
|
||||
in source order.
|
||||
|
||||
**Decision — no binder change for `checker`/`primitive` names.** The plan
|
||||
offered a second half: declare a checker's and a UDP's name as instantiable
|
||||
symbols so their instances resolve. Not done. Both bodies are opaque leaves
|
||||
that bind nothing, so the name would be a symbol with no scope behind it; and
|
||||
`SymbolKind::is_instantiable` is `Module | Interface`, so admitting them means
|
||||
either a new kind (FACTS bump — see above) or calling a UDP a `Module`, which
|
||||
is a lie the hover card would repeat. Today an instance of either stays an
|
||||
`ExternalCandidate`: no answer, rather than a wrong one. Filed for the round
|
||||
that has a FACTS bump of its own to spend.
|
||||
|
||||
**The `expect` rule.** `expect` is never reserved — 41 corpus sites call a
|
||||
task by that name. The assertion reading is taken only when the parenthesised
|
||||
run holds a token an argument list cannot: `##`, `|` `->`, `|=` `>`
|
||||
(both implications are *two* tokens each — the lexer's operator table has no
|
||||
entry for either), `throughout`, `disable iff`, or `@(`. The rule's misses are
|
||||
all in the safe direction: `expect (done) else $error;` with a purely boolean
|
||||
property reads as a call, which is the parse error it already was. Its false
|
||||
*positives* would be the dangerous direction, and an argument list cannot hold
|
||||
any of those six shapes.
|
||||
|
||||
**`union tagged`.** A `tagged: bool` on `StructType`, eaten by text right
|
||||
after the keyword and before `packed`, per the LRM's order. Only the flag: the
|
||||
`tagged Valid 5` expression and `case (x) matches` are a pattern grammar of
|
||||
their own and stay a clean parse error. Filed.
|
||||
|
||||
**Fixture fallout, flagged.** Reserving `checker` broke six `bind.cases` cases
|
||||
and one `vlog_parser` test that bound a module *named* `checker` — illegal SV,
|
||||
and the only such site in the repo. Renamed to `chk_mod` (identical length, so
|
||||
no case re-alignment). `crates/vlog_formatter/tests/cases/bind.cases` is
|
||||
**outside this lane's stated file-ownership list**; the edit is a
|
||||
mechanical consequence of the keyword reservation and touches nothing the §24
|
||||
lane owns, but it is recorded here and in the lane report rather than made
|
||||
silently.
|
||||
|
||||
**Measurements.**
|
||||
|
||||
*Gates.* `cargo fmt -p vlog_parser -p vlog_formatter -p vlog_semantic
|
||||
-p lucisv_server -- --check` clean; `cargo clippy --all-targets --workspace`
|
||||
zero warnings; `cargo test --workspace` **3 092 passed, 0 failed, 39 ignored**
|
||||
(the 39 are the suite's standing ignores). `cargo doc` grew no new warning.
|
||||
`cargo build -p lucisv_server` + `node editors/vscode/smoke.js` OK
|
||||
(initialize/didOpen/shutdown/exit, 16 messages).
|
||||
|
||||
*Corpus, 820 files, `tools/corpus_check.sh`:*
|
||||
|
||||
| | trunk `c40e720` | this tree |
|
||||
|---|---|---|
|
||||
| parsed & formattable | 814/820 (99.3%) | **814/820 (99.3%)** |
|
||||
| verification errors | 0 | **0** |
|
||||
| crashes | 0 | **0** |
|
||||
|
||||
*OpenTitan `hw`, 3 975 `.sv`/`.svh`, read-only `--no-cache`, against a release
|
||||
build of trunk (`c40e720`) unpacked with `git archive` into a scratch tree:*
|
||||
|
||||
| | trunk | this tree |
|
||||
|---|---|---|
|
||||
| files that fail to format | 10 | **10** |
|
||||
| newly failing / newly fixed | — | **0 / 0** |
|
||||
| exit codes, file for file | — | **identical (10 error, 3 888 would-reformat, 77 clean)** |
|
||||
| formatted output, hashed file for file | — | **byte-identical, all 3 975** |
|
||||
|
||||
The same hash comparison over the corpus's 860 files is byte-identical too.
|
||||
That is the strongest form of "unchanged" available: `--stdout` runs
|
||||
`format_source`, which runs both halves of the safety net, so 4 835 real files
|
||||
produce the same bytes they did before the round. `git -C .../opentitan status
|
||||
--porcelain` held its three pre-existing modified files before and after; the
|
||||
four corpus trees hold only their `.vfmt-corpus-rev` markers.
|
||||
|
||||
*Gap comments.* Every slot where a new item drops a gap comment is a slot its
|
||||
pre-existing twin already drops one in — `alias a /*C*/ = b` behaves as
|
||||
`defparam u.p /*C*/ = 1`, `specparam tS /*C*/ = 1` as `localparam tS /*C*/ =
|
||||
1`, `interface /*C*/ class` as `virtual /*C*/ class`, `union /*C*/ tagged
|
||||
packed` as `union /*C*/ packed`. That is §2.9-22, the shared-machinery gap, not
|
||||
a new class of loss, and the pairing is pinned by
|
||||
`the_new_items_lose_a_gap_comment_exactly_where_their_twins_do` so that fixing
|
||||
a twin fails the test until the new item is fixed with it. The one slot the new
|
||||
items *do* keep is a comment before a `specparam`'s name, which a declarator's
|
||||
own bucket harvests.
|
||||
|
||||
**Filed requests.**
|
||||
|
||||
1. **`subtypes` does not answer the reverse `implements` edge.**
|
||||
`WorkspaceIndex::subclasses_of`'s table records `extends` only, and the
|
||||
index is `vlog_semantic`'s (and, this wave, the §24 lane's file). "Who
|
||||
implements this interface class?" therefore returns nothing. Amended into
|
||||
`docs/features/type-hierarchy/README.md`'s Status.
|
||||
2. **A checker's and a UDP's name are not instantiable symbols.** An instance
|
||||
of either stays an `ExternalCandidate` — no answer, rather than a wrong
|
||||
one. Needs a `SymbolKind` and therefore a `FACTS_FORMAT` bump; see the
|
||||
decision above.
|
||||
3. **The `tagged` pattern grammar.** `tagged Valid 5` in expression position
|
||||
and `case (x) matches` are still clean parse errors. Only the type-side
|
||||
flag landed.
|
||||
4. **No `include ...;` item for library map files**, and no `.map` file type.
|
||||
Reasoning in the work log.
|
||||
5. **`alias` carries no gap comments** — the `defparam` shape, filed with it
|
||||
under §2.9-22 rather than solved for one item.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-09-02 — QA agent
|
||||
|
||||
**Verdict: SHIP.**
|
||||
|
||||
*Gates, reproduced independently.* `cargo fmt -p vlog_parser -p vlog_formatter
|
||||
-p vlog_semantic -p lucisv_server -- --check` clean. `cargo clippy
|
||||
--all-targets --workspace` zero warnings. `cargo test --workspace`: summed
|
||||
every `test result:` line myself — **3 092 passed, 0 failed, 39 ignored**,
|
||||
matching the dev's count exactly. `cargo test -p lucisv_server --test grammar`
|
||||
green (`the_grammars_keywords_are_exactly_the_lexers` — nothing missing or
|
||||
extra). `cargo build --release -p lucisv` + `tools/corpus_check.sh`:
|
||||
**814/820 parsed & formattable, 0 verification errors, 0 crashes** — matches.
|
||||
`node editors/vscode/smoke.js target/debug/lucisv-server` → OK
|
||||
(initialize/didOpen/shutdown/exit; this run framed 20 messages against the
|
||||
dev's 16 — message-count is session/content-dependent in this harness, not a
|
||||
regression signal; the pass/fail contract is what matters and it passed).
|
||||
`git diff -- crates/vlog_formatter/src/verify.rs` empty — confirmed untouched,
|
||||
as promised.
|
||||
|
||||
**Scope.** Diffed file list matches the README's Handshakes plus the
|
||||
disclosed `bind.cases`/parser-test rename exactly: `chk_mod` appears in
|
||||
exactly 6 case blocks in `bind.cases` (confirmed by block count) and one
|
||||
parser-test source string. No unwrap/expect/panic! introduced outside
|
||||
`#[cfg(test)]` modules (checked every touched library file's added lines).
|
||||
The §24 lane's file list (`vlog_semantic` facts/workspace/lib, `vlog_linter`,
|
||||
`lucisv` CLI, `lucisv_core::config`, `lucisv_server` lint/settings/candidates/
|
||||
state, `package.json`) is untouched in the main tree — confirmed via `git
|
||||
status`. Its worktree at `.claude/worktrees/lints` was never touched by this
|
||||
QA pass. Note: `docs/topo.md` in the main tree carries a pending, unstaged
|
||||
edit that includes both this feature's row (accurate, matches the README) and
|
||||
a `semantic-lints-on` (§24) row — that file is lead-owned by convention
|
||||
(`docs/topo.md` is updated "after merging" per CLAUDE.md) and outside this
|
||||
lane's stated ownership either way; not this lane's concern, flagged only so
|
||||
the lead knows it wasn't this QA pass's edit.
|
||||
|
||||
**Independent census re-derivation.** Re-ran the corpus/opentitan-hw census
|
||||
myself with a fresh comment/string-stripping script (not the dev's), matching
|
||||
whole-token `\bconfig\b`, `\blibrary\b`, `\bchecker\b`: **0/0/0** in both
|
||||
corpus (860 files) and `~/repo/opentitan/hw` (3 979 files) — confirms the
|
||||
README's table independently. Spot-checked the raw (non-stripped) grep hits
|
||||
by hand to confirm every one is a comment, a quoted path, or a `` `include ``
|
||||
string, never a declaration.
|
||||
|
||||
**Keyword-boundary attacks.**
|
||||
|
||||
| position | word | result |
|
||||
|---|---|---|
|
||||
| module name | `checker` | parse error, expected identifier — correct |
|
||||
| module name | `library` | parse error, expected identifier — correct |
|
||||
| signal decl | `checker` | parse error, expected identifier — correct |
|
||||
| port name | `checker` | parse error, expected identifier — correct |
|
||||
| instance name | `checker` (`foo checker();`) | parse error — correct (bare `foo bar();` parses fine, confirming the reservation, not an unrelated defect) |
|
||||
| function name | `config` | parse error, expected identifier — correct |
|
||||
| class member | `config` | parse error, expected identifier — correct |
|
||||
| `pkg::config` | `config` | parse error, expected identifier — correct |
|
||||
| macro name/use, `` `config `` | `config` | unaffected, formats unchanged — correct |
|
||||
| string literal `"config"` | `config` | unaffected — correct |
|
||||
| comment `// config` | `config` | unaffected — correct |
|
||||
| substring identifiers `config_reg`, `checker_x`, `my_library`, `library_reg` | — | all unaffected — correct |
|
||||
| signal decl | `endconfig` | parse error, expected identifier — correct |
|
||||
|
||||
**`expect` disambiguation attacks.**
|
||||
|
||||
| input | reading | result |
|
||||
|---|---|---|
|
||||
| `expect(x);` | call | formats `expect(x);`, no space — correct |
|
||||
| `expect (word1[7:0]);` | call | formats as call — correct (the real corpus shape) |
|
||||
| `expect(a, b);` | call | correct |
|
||||
| `expect (a \|-> b);` | assertion | formats with space, `\|->` recognized — correct |
|
||||
| `expect (@(posedge clk) a ##1 b) else $error("x");` | assertion | correct |
|
||||
| `expect (a throughout b);` | assertion | correct |
|
||||
| `expect (a disable iff (rst) b);` | assertion | correct |
|
||||
| `expect (done) else $error;` | call (documented miss) | parse error at `else` — same failure shape as before, not a corruption — correct, matches the documented miss exactly |
|
||||
| `int expect; expect = 1;` | identifier | unaffected — correct |
|
||||
| `task expect(input int x); ... endtask` | identifier | unaffected — correct |
|
||||
|
||||
**Opaque blocks.** `specify` with timing paths, `specparam` (declaration and
|
||||
`PATHPULSE$a$b = (reject, error);` rewind form), `ifnone`, `showcancelled`/
|
||||
`noshowcancelled` inside one block: byte-identical output, idempotent. UDP
|
||||
`primitive`/`table`/`endtable` (sequential and combinational rows, `?`/`-`
|
||||
symbols, a comment on a row): byte-identical, and confirmed `primitive`
|
||||
swallows its own `table...endtable` in the flat scan (an unterminated `table`
|
||||
without `primitive` closing reports `expected endprimitive`, not
|
||||
`endtable` — matches the work log's claim). `checker` with ports, a nested
|
||||
`checker`, and `: label` on `endchecker`: correct. `config` with `design`,
|
||||
`default liblist`, `instance ... use`, `cell ... liblist`: correct, both at
|
||||
module scope substitute and at file scope. `library` line with quoted
|
||||
wildcard paths (the shape the shipped `vendor_formal.cases` test uses):
|
||||
byte-identical, idempotent. `;` after `endspecify` fires `empty-item`
|
||||
(confirmed via `lucisv check`). Three deliberately unclosed blocks (`specify`,
|
||||
`table`-in-`primitive`, `checker`) at EOF: each a clean, fast parse error
|
||||
naming the expected closer — no hang.
|
||||
|
||||
*One informational, non-blocking observation:* an **unquoted** wildcard
|
||||
library path containing `/*` (e.g. `library fast_lib fast/*.v;`) triggers
|
||||
`lex error: unterminated block comment`, consuming the rest of the file — the
|
||||
lexer treats `/*` as a comment opener in every context, library lines
|
||||
included. I confirmed this is **pre-existing, not a regression**: I built a
|
||||
detached worktree at trunk `c40e720` and got the byte-identical error message
|
||||
on the same input. It cannot be fixed inside this round's opaque-line
|
||||
strategy (lexing happens as a pass before the parser ever sees the `library`
|
||||
keyword) and the dev's own shipped test/case only uses the quoted form
|
||||
(`"/proj/rtl/*.v"`), which works correctly. Filed here rather than against
|
||||
this feature; not a reason to rework it.
|
||||
|
||||
**`interface class`.** `interface class ic; pure virtual function int f();
|
||||
endclass` parses; `class c implements ic;` and `class d extends b implements
|
||||
ic, ic2;` resolve `supertypes` correctly — verified via the shipped unit
|
||||
tests `an_interface_class_is_a_node`, `an_implements_clause_names_a_
|
||||
supertype`, and `extends_and_implements_are_both_edges_of_the_same_answer`
|
||||
(the last is exactly the "both edges" test the checklist asked for: base
|
||||
first, then interfaces, in source order). `interface class` declares an
|
||||
ordinary `SymbolKind::Class`, so hover reports "class" as promised — no
|
||||
`SymbolKind::InterfaceClass` exists to say otherwise, matching the
|
||||
zero-FACTS-bump decision. `union tagged { ... }` formats; `tagged Valid 5` in
|
||||
expression position is a clean parse error (unchanged pre-existing shape).
|
||||
|
||||
**`alias`.** `alias a = b = c;` and hierarchical terms (`alias top.a.b =
|
||||
bottom.x.y;`) format correctly. Comment-inside-alias
|
||||
(`alias a /*C*/ = b;`) is refused by the safety net
|
||||
(`verification failed: token stream diverges ... input has comment ...`); ran
|
||||
the identical shape against `defparam u.p /*C*/ = 1;` and got the
|
||||
byte-identical error message and divergence index shape — the gap-parity pin
|
||||
claim is exactly true, confirmed by direct reproduction, not just by reading
|
||||
the pinned test.
|
||||
|
||||
**Regression net.** The three named files' `--check` results are unchanged
|
||||
between this tree and trunk `c40e720`, confirmed by direct comparison of full
|
||||
stdout+exit code (not just spot inspection): `corpus/picorv32/picosoc/
|
||||
spiflash_tb.v`, `~/repo/opentitan/hw/ip/otbn/dv/uvm/tb.sv`, `~/repo/opentitan/
|
||||
hw/ip/rom_ctrl/dv/env/rom_ctrl_scoreboard.sv`. Independently recounted the
|
||||
"41" sites: 40 `expect(...)` call sites plus one `task expect;`
|
||||
*declaration* itself (old-style ANSI-free task header, `task expect;` on its
|
||||
own line) — 41 total, all in `spiflash_tb.v`; the count is exactly right, my
|
||||
first naive grep for `expect(` alone found 40 and missed the declaration.
|
||||
30 opentitan `hw` files sampled by seeded random choice (`random.seed(42)`,
|
||||
independent of the dev's own sweep): `--stdout` byte-identical to a
|
||||
freshly-built trunk `c40e720` release binary for all 30. `git -C
|
||||
~/repo/opentitan status --porcelain -uall` after every run: only the same 3
|
||||
pre-existing owner-modified files (`aes/dv/tb/tb.sv`,
|
||||
`top_darjeeling/.../ast.sv`, `top_earlgrey/.../ast.sv`) — untouched by this
|
||||
QA pass.
|
||||
|
||||
**Doc/test-count nits (trivial, non-blocking).** The assignment brief quoted
|
||||
"19" formatter cases in `vendor_formal.cases`; the file's own case-splitting
|
||||
convention (a `====`-or-EOF-terminated block, per `cases.rs`'s doc comment)
|
||||
yields **18**. Likewise "10 attack pairs" in `verification.rs`; I count **9**
|
||||
`expect_divergence(...)` calls, plus a separate (and valuable) gap-parity
|
||||
consistency test that isn't itself a masked-corruption attack pair. Neither
|
||||
miscount reflects a gap in coverage — the 9 pairs already hit every new
|
||||
construct's corruption shape (timing path edit, dropped specify item,
|
||||
flipped UDP row, dropped table comment, dropped `endchecker` label, dropped
|
||||
config clause, dropped `tagged`, dropped alias term, dropped `interface`) —
|
||||
and since `verify.rs` was not touched at all, CLAUDE.md's invariant 4 (attack
|
||||
tests required for a *widened* normalization) does not even apply here; the
|
||||
9 pairs are the dev going beyond what was required. Recording the exact
|
||||
numbers for whoever reconciles the brief against the shipped file.
|
||||
|
||||
**Findings summary.** No blocking findings. One informational note (unquoted
|
||||
`/*`-in-library-path lexing, pre-existing, not this round's regression) and
|
||||
two trivial doc-count nits (18 vs 19 cases, 9 vs 10 attack pairs), neither
|
||||
affecting correctness, idempotency, or the corpus/opentitan byte-identity
|
||||
claims. All nine checklist items verified, all reproduced numbers match the
|
||||
dev's claims exactly except the two noted trivial counts.
|
||||
|
||||
## Review
|
||||
|
||||
*(reserved for the lead)*
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-02 — lead.** Approved and committed; ran in parallel with
|
||||
semantic-lints-on (§24) in its worktree under the CLAUDE.md lane rule.
|
||||
|
||||
- The round's most valuable output is the evidence correction it began
|
||||
with: every construct here has zero declarations in the corpus and in
|
||||
opentitan, and the analysis's "13 checker files" were UVM
|
||||
protocol-checker filenames. That reframed a Medium item into a
|
||||
completeness round, sized accordingly, and the dev proved it neutral in
|
||||
the strongest way available — formatted output byte-identical for all
|
||||
860 corpus and all 3 975 opentitan files against the previous release.
|
||||
- Decisions the lead endorses: five keywords reserved on a measured
|
||||
zero-collision census and five deliberately not (`expect`'s 41 real
|
||||
task-call sites settle that one; the statement form is recognised only
|
||||
when its parentheses hold a sequence operator, and the documented miss
|
||||
is the same error it already was); one opaque-block helper that counts
|
||||
its own opener and leaves a trailing `;` as the null item `empty-item`
|
||||
sees; `specparam` as a real declaration with a rewind for `PATHPULSE$`;
|
||||
and `interface class` through the existing class prefix with **no new
|
||||
kind and no FACTS bump** — chosen because §24 was spending that bump in
|
||||
parallel, so two lanes could not both mint format 13. That is the lane
|
||||
discipline working as written.
|
||||
- The one out-of-list edit — six `bind.cases` and a parser test that
|
||||
bound a module *named* `checker`, illegal now that it is reserved —
|
||||
was disclosed and is correct.
|
||||
- QA re-derived the census independently, attacked every keyword position
|
||||
and every `expect` shape, and found one pre-existing informational nit
|
||||
(an unquoted library path containing `/*` lexes as a block comment on
|
||||
trunk too). Filed items carried: the reverse `implements` edge (index is
|
||||
§24's this wave), checker/UDP names as instantiable symbols, the
|
||||
`tagged` pattern grammar, `include …;` in library maps; and `alias`
|
||||
loses a gap comment exactly where `defparam` does — §2.9-22, next round.
|
||||
- Gates re-run by the lead: fmt clean, clippy zero warnings, 3 092 passed
|
||||
/ 0 failed over 46 binaries, corpus 814/820, smoke OK. Ships in 0.30.0
|
||||
with semantic-lints-on.
|
||||
+5
-3
@@ -363,6 +363,7 @@ recursion-limit, whose edges sit in §2.1). Code edges:
|
||||
| `constraint-bodies ──▶ classes / out-of-class-constraints / dv-statements / safety-net` | depends | (2026-09-02, round 1 of coverage_gaps C1) `ItemKind::Constraint(ConstraintDecl)` with a structured `ConstraintSet` (`Expr{soft}`, `Implication`, `If`, `Foreach`, `SolveBefore`, `Unique`, `DisableSoft`, `Directive`, `Empty`), `ExprKind::Dist`, and `WithConstraint.block` as `ConstraintBody::{Items, Verbatim}`. The parser takes a `Rewind` snapshot (cursor, **both pending-comment buckets**, depth, links, `open_conds`, diagnostics length), attempts the structured body, and on any error restores it and re-runs v0.26.0's verbatim capture character for character — so an unknown shape *is* the old behavior, not an approximation (pinned on text, slice and `col`). **No keywords reserved**: `soft`/`dist`/`solve`/`before` are matched by text like `restrict`, so `token.rs`, `pairs.rs`, the editor grammar and `tests/grammar.rs` are untouched and `logic before;` keeps working; `:=`/`:/` stay two tokens with a span-adjacency check (a `:/` token would swallow `:/* c */`). Canonical layout: one item per line, `}` at the header column, dist weights as a braced list; a `with` block keeps the source's one-line-or-not shape. `verify.rs` untouched; the constraint attack pairs re-derived plus new ones. Exhaustive arms paid in `format.rs`, `bind.rs`, `tests/spans.rs`; `visit.rs` gets an explicit no-op arm (no items/statements inside). **QA rework**: comments after the round's own text-matched words were dropped; the dev answered with an exhaustive gap fuzzer (a `/*C*/` in every inter-token gap of 15 fixtures, 358 gaps, format + idempotency demanded) and 14 named comment fields plus `ConstraintItemKind::takes_semi()` (one owner of the `;`) and `Parser::gap_before` (the closer-side twin of `take_before_open`); 96 regressions vs v0.26.0 became 40, all in shared machinery outside this lane — §2.9-22. Opentitan: 1 993 of 2 009 bodies structured (fallbacks: 10 macro-item bodies, 6 non-LRM shapes), failure set unchanged, per-file tolerant diagnostics identical, 48 DV files idempotent with comment streams byte-identical. |
|
||||
| `covergroup-bodies ──▶ constraint-bodies / classes / safety-net` | depends | (2026-09-02, round 2 of coverage_gaps C1) `ItemKind::Covergroup(Box<CovergroupDecl>)` with `CoverItemKind::{Coverpoint, Cross, Option, Directive, Empty}`, `BinDecl { wildcard, kind, name, array, spec: BinSpec::{Values, Transitions, Default, DefaultSequence, Select}, with_expr, iff }`, `SelectExpr` for `binsof … intersect … && !binsof`, one `CoverageEvent` enum. Same `Rewind` fallback as constraints — v0.27.0's flat scan re-run character for character on any failure — and no keywords reserved (`coverpoint`, `bins`, `cross`, `binsof`, `intersect`, `wildcard`, `ignore_bins`, `illegal_bins`, `option`, `type_option` by text). **Two guards in shared expression machinery, the round's one risk**: `at_postfix_segment` refuses `[` followed by `*`/`->`/`=` (no index can start with those — it is what lets `1'b1[*5]` be a transition repeat), and a `no_with` flag while a bin spec operand is read (so the bin's own `with (…)` filter is not eaten as an array-method iterator argument); `(`-disambiguation is by position, the LRM's own rule. `plain_expr_list` → `plain_list` and `constraint_parens` → `guard_parens`, shared with `iff`/`with`. `verify.rs` untouched, twelve attack pairs. The gap fuzzer was built in from day one (329 gaps, 52 fail, all §2.9-22 shared machinery — *asserted* by running each shape outside a covergroup). Opentitan: 544 of 544 covergroups structured, 87/87 DV covergroup files idempotent, failure set and per-file diagnostics identical. `on_type.rs` keeps `covergroup` OPAQUE by argument. |
|
||||
| `fragment-mode ──▶ error-recovery / define-table / lexer-cleanup / covergroup-bodies` | depends | (2026-09-02, coverage_gaps H4 corrected) Class-body and module-item `.svh` fragments already parsed — the file-scope item loop *is* the class-item loop; the three shapes that did not (statement lists, enum-member lists, cover-item lists) become `SourceFile::fragment: Option<Fragment>` (`items` empty iff `fragment` is `Some`). Detection is a whole-file rule, not an error-message match: the FIRST STRUCTURAL item failed (directives, macro items and null items are legal in every body and do not count; a tolerant `Ok` that recorded a diagnostic counts as failed — the `if … else` generate-vs-statement parity bug), the file does not open with a design-unit keyword, and a shape consumes the file to EOF, tried narrowest-first (cover items → enum members → statements: the wider grammars mis-read the narrower). Each shape re-lexes a fresh token stream — `Rewind` deliberately does not restore the tokens' comment buckets, right for verbatim captures and fatal here. Shared loops lifted (`parse_enum_members`, `parse_cover_items`); formatter prints a fragment at indent 0 through existing printers; binder gives statements a file `Block` scope and enum variants file scope; **no census change** (a fragment's variants are not exported — `pkg::CUSTOM_1` must not resolve to a name that does not exist), FACTS stays 12. Separately, the lexer continues a `` `define `` whose formal-argument `(` touches the name and is still open at end of line, no backslash needed until the list closes — `cip_base_vseq__tl_errors.svh`'s real blocker. Corpus 813 → 814/820; opentitan 12 → 10, exactly the two predicted files. |
|
||||
| `vendor-formal-grammar ──▶ corpus-check / classes / type-hierarchy / editor-scopes` | depends | (2026-09-02, coverage_gaps M1–M3 + L1/L2/L4/L5, with the evidence corrected: every construct here has 0 declarations in the corpus and in opentitan — the analysis's "13 checker files" were UVM protocol-checker filenames — so this is a completeness round, proven output-neutral: formatted output byte-identical for all 860 corpus and all 3 975 opentitan files against a v0.29.0 build.) Five keywords reserved on a measured 0-collision census (`checker`, `endchecker`, `config`, `endconfig`, `library`) — the tmLanguage alternation hand-edited under `tests/grammar.rs`'s lock — and five deliberately NOT (`expect` has 41 real task-call sites; `tagged`, `design`, `instance`, `cell`, `use` only stand inside blocks that are opaque). One `parse_opaque_block(close)` (the covergroup-verbatim template; counts its own opener; keeps `: label`; leaves a trailing `;` as the null item `empty-item` sees) serves `specify`/`primitive`/`table`/`checker`/`config`; `parse_opaque_line` serves `library …;`; `SYNC_CLOSERS` gains the five closers. `specparam` is a real `ParamDecl` (`LocalParam` kind) with a rewind to the opaque line for `PATHPULSE$`. `alias` is `ItemKind::Alias(Vec<Expr>)`; `union tagged` a flag on `StructType`; statement `expect` is read as an assertion only when its parenthesised run holds a sequence operator, else it stays the call it always was. `interface class` routes to `parse_class` via the existing `prefix` — **no new kind, no FACTS bump** (deliberately, so it cannot collide with §24's bump) — and type-hierarchy's `bases_of` follows `implements` through the same `classes_at` hop as `extends` (the two blocking pins flipped). pairs.rs gains `table`/`checker`/`config` rows; on_type's OPAQUE gains the five openers. Filed: the reverse `implements` edge in `subtypes`, checker/UDP names as instantiable symbols, the `tagged` pattern grammar, `include …;` in library maps; `alias` loses a gap comment exactly where `defparam` does (§2.9-22 parity, pinned). |
|
||||
| `formatter-bug-fixes (round 2) ──▶ safety-net` | depends | Three comment-shape bugs fixed in `format.rs` (`then_is_block` trailing-line-comment cuddle guard, `Fmt::header_parens`, `default_has_colon`); `verify.rs` untouched, four masked-corruption rejection pairs added per the standing template, plus three more for the directive capture at merge (2026-08-29 testbench wave, Lane B + lead). |
|
||||
| `lexer-cleanup ──▶ error-recovery / lint-rules-2` (QA logs) | depends | Fixes three lexer gaps: `@(* )` (TODO §1) plus the BOM and non-ASCII-honesty findings those two QA rounds filed; adds `ParsedSource::lex_error()` so `lucisv check` stops silently passing unlexable files. |
|
||||
| `error-recovery ─▶ lucisv-server / linter-core` | depends (downstream) | `parse_source_tolerant` is the entry point the whole LSP and the linter stand on; the strict/tolerant split (shared grammar, no second parser) is the contract. |
|
||||
@@ -442,6 +443,7 @@ promise:
|
||||
| `struct-members ◀──▶ workspace-index / index-persistence / class-member-access / type-definition` | handshake | **`FACTS_FORMAT` 8 → 9** (2026-09-01): struct members exported (`is_exported(Typedef \| StructMember, StructMember)`), fields declared with `declare_typed` so `s.hdr.addr` hops through a member's own type, and `collect_members` recursing into package-nested struct typedefs (bare-name key, the nested-class convention — two packages with a same-named struct typedef collide by name and answer `Ambiguous`/nothing, never a guess) and into **inline nested fields under a synthesized key `owner.field` joined with `.`** carried as the field's `Def::type_name` — `.` not `::` because `member_type` runs `last_segment` on it and `::` would collapse to the bare field name; the key is unwritable as a type name and passes `units()`'s ambiguity guard for free. This is what makes opentitan's generated register packages resolve (`hw2reg.status.txfull.d` picks `txfull`'s `d`, not `rxfull`'s). `resolve::member_scope` accepts any symbol whose child scope is `ScopeKind::Struct` — typedef, anonymous declarator or inline field, one rule. `type_def.rs::alias_site` descends into `typedef struct` bodies. Corpus unresolved 1 203 → 1 162; store shrank 1.14 % (resolved anonymous-enum variants encode smaller than the external candidates they replaced). |
|
||||
| `constraint-bodies ◀──▶ class-semantics / class-member-access / index-persistence / semantic-lints` | handshake | **`FACTS_FORMAT` 10 → 11** (2026-09-02): `SymbolKind::Constraint` declared in the class scope (a stand-in `Class` scope for `constraint C::c`, the out-of-body-method mechanism reused); the body opens a scope under the class so every operand binds to the class's properties — rename from a `rand` field's declaration now rewrites its constraint uses, in-file and cross-file; `foreach` vars nest; `Target::InlineConstraint` resolves a `randomize() with { … }` operand against the randomized object's class first and the writing scope second. `Constraint` exported from `Class`. `signals.rs` reads constraint operands instead of routing the body to `opaque_spans` (a constraint reads, never drives). Corpus references +1 646, 84 % answered. Filed: a rename issued *from inside* an out-of-block constraint body whose class is elsewhere is refused by `vlog_refactor` (pre-existing — the same refusal `task C::m` bodies get). |
|
||||
| `covergroup-bodies ◀──▶ class-semantics / class-member-access / index-persistence / semantic-lints` | handshake | **`FACTS_FORMAT` 11 → 12** (2026-09-02): `SymbolKind::{Covergroup, Coverpoint, Cross}` and `ScopeKind::Covergroup`; the covergroup opens a scope whose labelled coverpoints and crosses are symbols (an unlabelled coverpoint declares nothing), `sample()`/`(args)` parameters are visible in the body and nowhere else, every sampled expression, bin value and `iff` binds to the enclosing class's properties. `collect_members` recurses into a covergroup so `cg_inst.cp` resolves cross-file; `member_scope` accepts a `Covergroup` symbol. `signals.rs` reads coverpoint operands (a covergroup samples, never drives). Corpus references +1 139 with 1 135 answered. |
|
||||
| `semantic-lints-on ◀──▶ workspace-index / index-persistence / linter-core / semantic-lints / completion-core / editor-settings` | handshake | **`FACTS_FORMAT` 12 → 13** (2026-09-02): `FileFacts::words`, a per-file sorted dedup'd identifier census from the token stream (macro/directive words included, comments and strings excluded by construction) — the one harvest `vlog_semantic::words` provides, which the server's completion word table is now built from instead of re-lexing every file at startup (scan −28 %). No inverted index: `files_mentioning`/`mentioned_outside` are a linear walk with a binary search per file, `files_spelling`'s own shape. `vlog_linter` gains `MentionOracle` (`LintContext::with_oracle`) and `Rule::needs_workspace()` + `workspace_rules()` beside an unchanged `default_rules()`: `unused-signal` and `undriven-net` say nothing when the oracle says the name is mentioned in another indexed file (the false-negative-safe direction), `multiply-driven` shares the gate but never reads it; the three are on whenever an oracle exists — the server always, the CLI when a multi-file job set is walked (a harvest pre-pass, +36 ms on the corpus over 10 cores, zero when the rules are ignored) — and off for a single file or stdin. The off switch shipped with it (§2.9-4). Store +14 % measured on both corpora; opentitan with the rules on reports 14 findings, spot-checked true. Filed: quick fixes ignore `lucisv.lint.*` (`code_action.rs`). |
|
||||
| `define-table ◀──▶ macro-expansion` | handshake | What began as free-to-change became contract at M14: params stored **as written**, `NAME()` = `Some(vec![])` — `expand.rs` counts arguments against them and declines on mismatch. |
|
||||
|
||||
### 2.6 Refactor lane (the M-plan)
|
||||
@@ -533,9 +535,9 @@ update the filing README(s) and this file.
|
||||
| 1 | `lucisv_core::path::normalize` — one `.`/`..` folding instead of three private copies (`filelist::Reader::normalize`, `config::Discovery::absolute`, `includes::normalize`, the last now `pub`) | include-nav; restated by file-operations | lucisv_core |
|
||||
| 2 | A span for `DataType` (and `ExprKind::Cast::ty` tails) — the last thing keeping `vlog_semantic/src/scan.rs` alive | vlog-semantic (item 2); restated by class-semantics | vlog_parser |
|
||||
| 3 | `fence::scan_nested` has no `ItemKind::Class` arm — formatter fences are inert inside class bodies (the `--fix` backstop still holds; asymmetry errs hands-off) | classes | vlog_formatter (fence.rs) |
|
||||
| 4 | A `lint` key in `lucisv.toml` (`[lint.<rule>]` config; selected-rules list) with CLI>config precedence | linter-core; restated by lint-rules-2, semantic-lints, server-lint | config-discovery / lucisv_core |
|
||||
| ~~4~~ | ~~A `lint` key in `lucisv.toml` (`[lint.<rule>]` config; selected-rules list) with CLI>config precedence~~ — **delivered 2026-09-02 by semantic-lints-on**: `[lint] select = […] / ignore = […]` in `lucisv.toml` (CLI over config, key by key; unknown rule names fail the run naming the file; `[lint.<rule>]` tables rejected by name — per-rule config stays filed) and `lucisv.lint.select/ignore` settings (registry-validated, republish on change). | linter-core; restated by lint-rules-2, semantic-lints, server-lint | ~~config-discovery / lucisv_core~~ done |
|
||||
| 5 | `lucisv check --rules-doc` printing `rules_markdown()` | lint-rules-2 | crates/lucisv |
|
||||
| 6 | Workspace-wide "does any file mention this name" query — the precondition for the semantic lints defaulting on (cross-file hierarchical use is their one false-positive mode) | semantic-lints | vlog_semantic (index) |
|
||||
| ~~6~~ | ~~Workspace-wide "does any file mention this name" query — the precondition for the semantic lints defaulting on~~ — **delivered 2026-09-02 by semantic-lints-on**: `FileFacts::words` (one identifier harvest, `vlog_semantic::words`, lifted from the server's candidates) and `WorkspaceIndex::files_mentioning` / `mentioned_outside(name, own_file)`; `FACTS_FORMAT` 12 → 13. The three rules consult a `MentionOracle` and are on by default whenever one exists. | semantic-lints | ~~vlog_semantic (index)~~ done |
|
||||
| ~~7~~ | ~~`SymbolKind::Interface` (interfaces currently indexed as `Module`; modport/clocking names unbound)~~ — **delivered 2026-09-01 by interface-semantics**: `SymbolKind::{Interface, Modport, Clocking}`, `is_instantiable()` threaded through every Module-exact filter, an interface export rule that treats its signals as its surface, modport/clocking-internal names bound as scope-local references, the modport half of a glued type name bound as `Target::TypeMember`. `program` still indexes as `Module`. Corpus unresolved fell 1 256 → 1 203 | interfaces | ~~vlog_semantic~~ done |
|
||||
| 8 | Symlink-cycle detection in the shared walk (both front ends exposed; wants its own round — it changes CLI behavior) | lucisv-core-lift | lucisv_core |
|
||||
| ~~9~~ | ~~Chasing `InheritedCandidate` through the member tables (in-file and cross-file) + hover for `extends`~~ — **delivered 2026-09-01 by class-member-access**: `resolve::member_in_chain` walks the in-file `extends` chain, `WorkspaceIndex::base_of` + `member_chain` walk it across files (inside `follow_one`, so hover and cross-file references agree), both cycle-guarded; `this.x`/`super.x` misses ride the same loop. `extends` hover/definition on the base name was already answered by overlay-promotion's type-position promotion. Residue filed in TODO §15 round 2: a `base` field on `ReferenceFact` so `this.x` misses get index postings too | class-semantics | ~~vlog_semantic~~ done |
|
||||
@@ -547,7 +549,7 @@ update the filing README(s) and this file.
|
||||
| 15 | Bind semantics: whether a `bind`'s target scope and connections should resolve through the workspace index (today only the instantiated module name is recorded) | bind | vlog_semantic |
|
||||
| 16 | DPI/package re-export halves as real references (`export pkg::item` doesn't resolve; `*::*` has `"*"` as its package name, which nothing expects) | dpi-export | vlog_semantic |
|
||||
| 17 | Inline aggregate as a parameter-override *argument* (`m #(.T(struct packed { logic a; })) u ();`) is rejected in expression position; M4's `instantiation_plan` drops such a `parameter type` default rather than emit unparseable text | refactor-instantiate (gap 1; its gap 2 was delivered by ansi-first-port) | vlog_parser |
|
||||
| 18 | A macro-invocation census in `FileFacts`: per-file macro names plus identifier-shaped words in their arguments. Rename's index-bounded fan-out currently preserves every edit/refusal but can lose informational macro-argument warnings in files that have no other relationship to the renamed name; the same table would serve the port refactorings' identical scan. This changes the record shape and therefore requires a `FACTS_FORMAT` bump. | refactor-rename (performance-wave residue, accepted and filed) | vlog_semantic |
|
||||
| 18 | *(substrate delivered 2026-09-02: `FileFacts::words` includes the identifier-shaped words inside macro invocations and directives — rename's lost warnings can now be answered from it; the wiring into `macro_use_warnings` is what remains)* A macro-invocation census in `FileFacts`: per-file macro names plus identifier-shaped words in their arguments. Rename's index-bounded fan-out currently preserves every edit/refusal but can lose informational macro-argument warnings in files that have no other relationship to the renamed name; the same table would serve the port refactorings' identical scan. This changes the record shape and therefore requires a `FACTS_FORMAT` bump. | refactor-rename (performance-wave residue, accepted and filed) | vlog_semantic |
|
||||
| 19 | An execute-command spelling of the instantiation skeleton (plain-text `render` through the same `plan_for`), for clients without `textDocument/inlineCompletion` — since the 2026-08-30 names-only popup, such a client (Neovim's built-in LSP, today) has no path to the full skeleton at all. Filed at lead review after correcting the dev's assumption that a `lucisv/instantiate` command already existed (it never did). | inline-instantiation (lead) | lucisv_server |
|
||||
| 20 | Rename loses its heads-up for an **unresolvable member/hierarchical tail** spelling the renamed name (`unknown_mod u_x (); … u_x.sig` when `unknown_mod` is indexed nowhere): before class-member-access the tail had no reference and `rename.rs::stray_reason` warned "a hierarchical or member tail, which lucisv does not resolve"; since round 2 it carries an `ExternalCandidate` the workspace cannot answer, which the engine neither edits (correct) nor mentions. Wanted: a warning for candidate references that spell the old name and stayed unresolved through the overlay — one message per file. Pinned as a premise by `a_hierarchical_tail_that_cannot_resolve_is_left_alone_and_named_as_such`. Same class as item 18. | class-member-access round 2 (lead) | vlog_refactor (`rename.rs`) |
|
||||
| 21 | `Parser::parse_scoped_name` joins a `pkg::name` chain into one `String`, erasing the segment boundary, so an escaped segment (`\my-pkg ::\state-t` as a type, an instantiated module or a `bind` target) is reprinted without its terminating space and **refused by the safety net** — an error, never a corruption. Wanted: the AST keeps the segments (as `parse_method_name` already does for `FunctionDecl::scope`). Pinned by `escaped_identifiers.cases`'s one `#SKIP` and `verification::an_escaped_name_in_a_scoped_type_is_rejected_rather_than_corrupted`, both of which must keep failing-to-format until delivered | escaped-identifiers | vlog_parser |
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
},
|
||||
"keywords": {
|
||||
"name": "keyword.other.systemverilog",
|
||||
"match": "\\b(module|macromodule|endmodule|interface|endinterface|package|endpackage|program|endprogram|modport|clocking|endclocking|input|output|inout|ref|wire|tri|tri0|tri1|wand|wor|trireg|supply0|supply1|uwire|reg|logic|bit|byte|shortint|int|longint|integer|time|realtime|real|shortreal|string|chandle|event|var|void|signed|unsigned|packed|parameter|localparam|defparam|specparam|type|typedef|enum|struct|union|assign|alias|always|always_comb|always_ff|always_latch|initial|final|begin|end|if|else|case|casex|casez|randcase|let|endcase|default|unique|unique0|priority|for|while|repeat|forever|do|foreach|break|continue|return|fork|join|join_any|join_none|disable|wait|posedge|negedge|edge|or|and|nand|nor|xor|xnor|not|buf|bufif0|bufif1|notif0|notif1|pullup|pulldown|generate|endgenerate|genvar|class|endclass|extends|implements|virtual|pure|extern|rand|randc|local|protected|constraint|covergroup|endgroup|function|endfunction|task|endtask|automatic|static|const|import|export|timeunit|timeprecision|assert|assume|cover|property|endproperty|sequence|endsequence|inside|with|iff|release|force|deassign|primitive|endprimitive|specify|endspecify|table|endtable|small|medium|large|scalared|vectored|highz0|highz1|strong0|strong1|pull0|pull1|weak0|weak1|cmos|rcmos|nmos|pmos|rnmos|rpmos|tran|rtran|tranif0|tranif1|rtranif0|rtranif1)\\b"
|
||||
"match": "\\b(module|macromodule|endmodule|interface|endinterface|package|endpackage|program|endprogram|modport|clocking|endclocking|input|output|inout|ref|wire|tri|tri0|tri1|wand|wor|trireg|supply0|supply1|uwire|reg|logic|bit|byte|shortint|int|longint|integer|time|realtime|real|shortreal|string|chandle|event|var|void|signed|unsigned|packed|parameter|localparam|defparam|specparam|type|typedef|enum|struct|union|assign|alias|always|always_comb|always_ff|always_latch|initial|final|begin|end|if|else|case|casex|casez|randcase|let|endcase|default|unique|unique0|priority|for|while|repeat|forever|do|foreach|break|continue|return|fork|join|join_any|join_none|disable|wait|posedge|negedge|edge|or|and|nand|nor|xor|xnor|not|buf|bufif0|bufif1|notif0|notif1|pullup|pulldown|generate|endgenerate|genvar|class|endclass|extends|implements|virtual|pure|extern|rand|randc|local|protected|constraint|covergroup|endgroup|function|endfunction|task|endtask|automatic|static|const|import|export|timeunit|timeprecision|assert|assume|cover|property|endproperty|sequence|endsequence|inside|with|iff|release|force|deassign|primitive|endprimitive|specify|endspecify|table|endtable|checker|endchecker|config|endconfig|library|small|medium|large|scalared|vectored|highz0|highz1|strong0|strong1|pull0|pull1|weak0|weak1|cmos|rcmos|nmos|pmos|rnmos|rpmos|tran|rtran|tranif0|tranif1|rtranif0|rtranif1)\\b"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user