Skip to main content

Crate dune_netlist

Crate dune_netlist 

Source
Expand description

SPICE3f5 netlist lexer, parser, and intermediate representation.

The grammar contract is the SPICE3f5 user’s manual (corpus/spice3f5/lib/helpdir/spice.txt) and the C parser in corpus/spice3f5/src/lib/inp. Malformed input must always produce a structured diagnostic with a span — never a panic, never a hang.

Porting notes live in docs/dune-netlist.md.

Re-exports§

pub use deck::Deck;
pub use deck::IncludeLoader;
pub use diag::Diagnostic;
pub use diag::Severity;
pub use span::FileId;
pub use span::Location;
pub use span::SourceMap;
pub use span::Span;

Modules§

deck
Physical deck reading: files → logical cards.
diag
Structured diagnostics (the rpic philosophy, CLAUDE.md §Princípios 4): malformed input produces an error or warning with a span, never a panic. The parser keeps going after errors so one pass reports as much as possible; callers decide whether errors are fatal.
ir
Intermediate representation of a parsed deck (PLAN.md §2.1).
span
Source positions for diagnostics.

Structs§

ExprError
A malformed expression: message and byte range inside the text given to the parser.
MeasSyntaxError
A malformed measurement: the message and the byte range of the offending word in the text that was parsed.
MeasWarning
A remark on a well-formed measurement (a parameter ngspice accepts but ignores), with its byte range.
ParseOutcome

Enums§

Error
Hard failures outside the deck itself (the root file is unreadable). Everything found inside a deck is a Diagnostic, not an error.

Constants§

EXPR_MAX_DEPTH
Deepest tree accepted (operands nested inside operators).
EXPR_MAX_NODES
Largest tree accepted, in nodes.

Functions§

parse_expr
Parse a whole B-source expression (v(1)*2, exp(i(vin)/1m)). Names are lowercased, as the 3f5 lowercases the whole deck; text left after a complete expression is an error.
parse_file
Parse a deck from the file system.
parse_measure_body
Parse a measurement body — the function keyword and what follows it, as in .meas tran NAME <body> — e.g. "trig v(1) val=0.5 rise=1 targ v(2) val=0.5 rise=1" or "max v(out) from=1n". This is what the language bindings’ direct measurement API takes.
parse_str
Parse a deck from a string; .include resolves on the file system, relative to name’s directory.
parse_with_loader
Parse a deck from a string; .include resolves through loader.