Rename the tool to lucisv (Language Utility for Coding In SystemVerilog)
This commit is contained in:
1 parent
a284e33110
commit
eeaffafd56
188 files changed
+2825
-2802
No files matched your search
@@ -126,7 +126,7 @@ pub struct RawText {
|
||||
/// It is kept in a vector *beside* the elements rather than folded into one
|
||||
/// enum with them: the element vectors are read by `vlog_semantic` and
|
||||
/// `vlog_linter`, and a directive is not a port. `before` is what puts the
|
||||
/// two back into source order. vfmt does not evaluate the condition — both
|
||||
/// two back into source order. lucisv does not evaluate the condition — both
|
||||
/// arms' elements are ordinary elements of the one list, exactly as an
|
||||
/// `` `ifdef`` at item position already works.
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -240,7 +240,7 @@ pub enum ItemKind {
|
||||
/// `clocking cb @(posedge clk); ... endclocking` and the `default`
|
||||
/// spellings of it (IEEE 1800 §14).
|
||||
Clocking(ClockingDecl),
|
||||
/// A block vfmt deliberately does not model, kept byte-for-byte:
|
||||
/// A block lucisv deliberately does not model, kept byte-for-byte:
|
||||
/// `constraint c { ... }`, `covergroup ... endgroup`, a concurrent
|
||||
/// assertion (`assert property ( ... );`) and a `property`/`sequence`
|
||||
/// declaration. See `docs/features/classes/README.md` and
|
||||
@@ -446,7 +446,7 @@ impl DataType {
|
||||
pub enum TypeExtra {
|
||||
/// The `#( ... )` of a parameterized type reference, verbatim:
|
||||
/// `uvm_analysis_port #(bit [31:0]) port;`. Its arguments are types as
|
||||
/// often as expressions (`#(virtual bus_if)`, `#(item #(A, B))`), so vfmt
|
||||
/// often as expressions (`#(virtual bus_if)`, `#(item #(A, B))`), so lucisv
|
||||
/// reproduces them as written instead of modelling a second grammar.
|
||||
Params(RawText),
|
||||
/// An anonymous enum standing where a type name would:
|
||||
@@ -619,7 +619,7 @@ pub struct ContAssign {
|
||||
|
||||
/// The `( strength0 , strength1 )` pair of a continuous assignment. The two
|
||||
/// strengths are stored in the order the source wrote them — the language
|
||||
/// allows either order and vfmt is not a legality checker.
|
||||
/// allows either order and lucisv is not a legality checker.
|
||||
#[derive(Debug)]
|
||||
pub struct DriveStrength {
|
||||
pub first: String,
|
||||
|
||||
@@ -636,7 +636,7 @@ impl<'a> RawLexer<'a> {
|
||||
text.push(self.bump() as char);
|
||||
// A based number whose digits come from a macro: `` 32'h`DM_ADDR ``
|
||||
// (corpus `ibex/dv/uvm/core_ibex/tb/core_ibex_tb_top.sv:75`). The
|
||||
// digits are preprocessor output vfmt does not expand, so the number
|
||||
// digits are preprocessor output lucisv does not expand, so the number
|
||||
// token ends here, with no digits, and the invocation lexes as the
|
||||
// macro token it is; the parser rejoins the pair into one primary
|
||||
// expression and the formatter prints them adjacent, as written.
|
||||
|
||||
@@ -228,7 +228,7 @@ pub struct Parser<'a> {
|
||||
/// Parse a token stream, stopping at the first error.
|
||||
///
|
||||
/// `source` must be the exact text `tokens` were lexed from: the constructs
|
||||
/// vfmt keeps verbatim (`constraint`, `covergroup` — see
|
||||
/// lucisv keeps verbatim (`constraint`, `covergroup` — see
|
||||
/// `docs/features/classes/README.md`) copy their bytes out of it by span.
|
||||
pub fn parse(tokens: Vec<Token>, source: &str) -> PResult<SourceFile> {
|
||||
Parser::new(tokens, source, false).parse_source_file()
|
||||
@@ -720,7 +720,7 @@ impl<'a> Parser<'a> {
|
||||
// argument (`.value(x)`, `.name()`) and a `[lo:hi]` value range (a
|
||||
// `case ... inside` label). Both are recognized here, in the shared
|
||||
// element parse, because rejecting them in the lists that cannot
|
||||
// legally hold them would gain nothing — vfmt checks legality
|
||||
// legally hold them would gain nothing — lucisv checks legality
|
||||
// nowhere else either, and a wrong guess emits the same tokens.
|
||||
let expr = if self.cur().is_sym(".") && self.nth(1).kind == TokenKind::Ident {
|
||||
self.parse_named_arg()?
|
||||
@@ -902,7 +902,7 @@ impl<'a> Parser<'a> {
|
||||
/// expression or a port/parameter list. In an expression `` `A (b) `` may
|
||||
/// well be `` `A `` applied to the parenthesized value `(b)` — the answer
|
||||
/// depends on whether the macro was defined with formals, which lives in
|
||||
/// a file vfmt does not read (IEEE 1800 §22.5.1, and the analysis in
|
||||
/// a file lucisv does not read (IEEE 1800 §22.5.1, and the analysis in
|
||||
/// `docs/features/lexer-cleanup/README.md`). At item position there is no
|
||||
/// such ambiguity: neither reading is an item on its own.
|
||||
///
|
||||
@@ -925,7 +925,7 @@ impl<'a> Parser<'a> {
|
||||
self.bump(); // (
|
||||
self.skip_balanced("(", ")")?;
|
||||
// Verbatim, space included: the argument text is preprocessor
|
||||
// input vfmt does not model, and closing the gap would make the
|
||||
// input lucisv does not model, and closing the gap would make the
|
||||
// output's token text differ from the input's (`` `A (b) `` and
|
||||
// `` `A(b) `` are one token each, of different text) — which the
|
||||
// safety net rightly refuses.
|
||||
@@ -1156,7 +1156,7 @@ 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 vfmt does not model, so it
|
||||
// §8.26): a different construct that lucisv does not model, so it
|
||||
// falls through to the unsupported-construct error below.
|
||||
"interface" if !self.nth(1).is_kw("class") => {
|
||||
self.parse_module("endinterface").map(ItemKind::Module)
|
||||
@@ -1574,7 +1574,7 @@ impl<'a> Parser<'a> {
|
||||
/// `constraint name { ... }`, kept as verbatim source.
|
||||
///
|
||||
/// The constraint language is a grammar of its own (`dist`, `->`,
|
||||
/// `solve ... before`, `inside`, `foreach`, `if`/`else`) that vfmt models
|
||||
/// `solve ... before`, `inside`, `foreach`, `if`/`else`) that lucisv models
|
||||
/// none of, and reflowing it has no payoff, so the block is copied out of
|
||||
/// the source by span. A prototype (`constraint c;`) has no braces.
|
||||
fn parse_constraint(&mut self) -> PResult<RawText> {
|
||||
@@ -1654,7 +1654,7 @@ impl<'a> Parser<'a> {
|
||||
///
|
||||
/// `assert property (@(posedge clk) a |-> ##[1:3] b) else $error("...");`
|
||||
/// — the property expression is a grammar of its own (`|->`, `##[1:3]`,
|
||||
/// `throughout`, `disable iff`, `$rose`) that vfmt models none of, and
|
||||
/// `throughout`, `disable iff`, `$rose`) that lucisv models none of, and
|
||||
/// there is no layout convention worth inventing for it, so the whole
|
||||
/// item is copied out of the source by span exactly as a `constraint` is.
|
||||
fn parse_concurrent_assertion(&mut self) -> PResult<RawText> {
|
||||
@@ -2024,7 +2024,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
/// A clocking skew, as written: `#2`, `#1step`, `negedge`. Kept as text —
|
||||
/// it is a delay or an edge, never something vfmt re-lays out — so the
|
||||
/// it is a delay or an edge, never something lucisv re-lays out — so the
|
||||
/// printer writes back exactly what the source said. The `#(min:typ:max)`
|
||||
/// spelling is not supported; see the feature README's Assumptions.
|
||||
fn parse_clocking_skew(&mut self) -> PResult<String> {
|
||||
@@ -2643,7 +2643,7 @@ impl<'a> Parser<'a> {
|
||||
/// True when the cursor opens a `bind` directive (IEEE 1800 §23.11).
|
||||
///
|
||||
/// `bind` is deliberately *not* in the lexer's keyword table — the same
|
||||
/// call vfmt makes for `new`/`this`/`super` — so that `obj.bind()` keeps
|
||||
/// call lucisv makes for `new`/`this`/`super` — so that `obj.bind()` keeps
|
||||
/// parsing as the ordinary method call it is in existing testbenches.
|
||||
/// A directive is recognized from its shape instead: the word `bind`,
|
||||
/// then a target scope (a name, possibly a `.`-separated hierarchical
|
||||
@@ -4154,7 +4154,7 @@ impl<'a> Parser<'a> {
|
||||
// `with { ... }` (a `randomize` constraint block) are the two
|
||||
// postfix spellings of `with`; the delimiter tells them apart and
|
||||
// demanding one keeps the `with [range]` of a stream expression,
|
||||
// which vfmt does not model, out of this path.
|
||||
// which lucisv does not model, out of this path.
|
||||
|| (t.is_kw("with") && (self.nth(1).is_sym("(") || self.nth(1).is_sym("{")))
|
||||
}
|
||||
|
||||
@@ -4463,7 +4463,7 @@ impl<'a> Parser<'a> {
|
||||
// A bare `$` — the upper bound of a queue (`q[$]`,
|
||||
// `q[$-1]`, `int q[$]`). Kept an ordinary name, like
|
||||
// `new`/`this`/`super`: one leaf makes every position
|
||||
// work through the existing expression grammar, and vfmt
|
||||
// work through the existing expression grammar, and lucisv
|
||||
// checks legality nowhere else either.
|
||||
"$" => {
|
||||
self.bump();
|
||||
@@ -4508,7 +4508,7 @@ impl<'a> Parser<'a> {
|
||||
if self.cur().is_sym("}") {
|
||||
// `{}` — the empty queue/dynamic-array literal
|
||||
// (`q = {};`). Illegal as a Verilog concatenation,
|
||||
// but vfmt is not a legality checker.
|
||||
// but lucisv is not a legality checker.
|
||||
self.bump();
|
||||
return Ok(self.expr_at(start, ExprKind::Concat(Vec::new())));
|
||||
}
|
||||
@@ -5018,7 +5018,7 @@ mod tests {
|
||||
|
||||
/// The spaced reading is offered at item and statement position only. In
|
||||
/// an expression `` `A (b) `` may be `` `A `` applied to `(b)`, which
|
||||
/// depends on a `` `define`` vfmt never sees.
|
||||
/// depends on a `` `define`` lucisv never sees.
|
||||
#[test]
|
||||
fn a_spaced_macro_in_expression_position_is_still_a_call() {
|
||||
let file = parse_ok("module m;\nassign x = `A (b);\nendmodule");
|
||||
@@ -5327,11 +5327,14 @@ mod tests {
|
||||
// The handshake `docs/features/format-fences/README.md` asked for: a
|
||||
// same-line comment now has a byte offset, so a fence written there
|
||||
// can be located in the source.
|
||||
let src = "module m;\n wire a; // vfmt: off\nendmodule\n";
|
||||
let src = "module m;\n wire a; // lucisv: off\nendmodule\n";
|
||||
let file = parse_ok(src);
|
||||
let ItemKind::Module(m) = &file.items[0].kind else { panic!("expected a module") };
|
||||
let trailing = m.items[0].meta.trailing.as_ref().expect("a trailing comment");
|
||||
assert_eq!(&src[trailing.span.start as usize..trailing.span.end as usize], "// vfmt: off");
|
||||
assert_eq!(
|
||||
&src[trailing.span.start as usize..trailing.span.end as usize],
|
||||
"// lucisv: off"
|
||||
);
|
||||
assert_eq!((trailing.line, trailing.col), (2, 11));
|
||||
}
|
||||
|
||||
@@ -5479,7 +5482,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn both_arms_of_an_else_are_ordinary_elements_of_one_list() {
|
||||
// vfmt does not evaluate the condition: an `ifdef/`else pair simply
|
||||
// lucisv does not evaluate the condition: an `ifdef/`else pair simply
|
||||
// contributes every element of both arms, in source order.
|
||||
let src = "module m (\n`ifdef X\n input a\n`else\n input b\n`endif\n);\nendmodule\n";
|
||||
let file = parse_ok(src);
|
||||
|
||||
Reference in new issue
Block a user