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§
- Expr
Error - A malformed expression: message and byte range inside the text given to the parser.
- Meas
Syntax Error - A malformed measurement: the message and the byte range of the offending word in the text that was parsed.
- Meas
Warning - A remark on a well-formed measurement (a parameter ngspice accepts but ignores), with its byte range.
- Parse
Outcome
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;
.includeresolves on the file system, relative toname’s directory. - parse_
with_ loader - Parse a deck from a string;
.includeresolves throughloader.