Skip to main content

dune_netlist/
lib.rs

1//! SPICE3f5 netlist lexer, parser, and intermediate representation.
2//!
3//! The grammar contract is the SPICE3f5 user's manual
4//! (`corpus/spice3f5/lib/helpdir/spice.txt`) and the C parser in
5//! `corpus/spice3f5/src/lib/inp`. Malformed input must always produce a
6//! structured diagnostic with a span — never a panic, never a hang.
7//!
8//! Porting notes live in `docs/dune-netlist.md`.
9
10#![forbid(unsafe_code)]
11
12pub mod deck;
13pub mod diag;
14pub mod ir;
15pub mod span;
16
17mod dot;
18mod elem;
19mod expr;
20mod meas;
21mod param;
22mod parse;
23mod scan;
24mod subckt;
25
26pub use deck::{Deck, IncludeLoader};
27pub use diag::{Diagnostic, Severity};
28pub use expr::{ExprError, MAX_DEPTH as EXPR_MAX_DEPTH, MAX_NODES as EXPR_MAX_NODES, parse_expr};
29pub use meas::{MeasSyntaxError, MeasWarning, parse_measure_body};
30pub use parse::{ParseOutcome, parse_file, parse_str, parse_with_loader};
31pub use span::{FileId, Location, SourceMap, Span};
32
33/// Hard failures outside the deck itself (the root file is unreadable).
34/// Everything found *inside* a deck is a [`Diagnostic`], not an error.
35#[derive(Debug, thiserror::Error)]
36pub enum Error {
37    #[error("cannot read {path}: {message}")]
38    Io {
39        path: std::path::PathBuf,
40        message: String,
41    },
42}