kiutils_sexpr 0.1.1

Lossless S-expression CST parser/printer for KiCad and EDA source files
Documentation
  • Coverage
  • 100%
    27 out of 27 items documented1 out of 1 items with examples
  • Size
  • Source code size: 16.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 23s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Milind220/kiutils-rs
    4 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Milind220

kiutils-sexpr

Lossless S-expression CST parser/printer used by kiutils-kicad.

Design goals

  • Preserve original bytes for exact lossless writes (CstDocument::to_lossless_string)
  • Offer deterministic normalized output (CstDocument::to_canonical_string)
  • Keep explicit byte spans for diagnostics and precise edits
  • Support both single-root and rootless multi-form inputs

Quickstart

use kiutils_sexpr::{parse_one, Node};

let doc = parse_one("(kicad_pcb (version 20260101))").unwrap();
let Node::List { items, .. } = &doc.nodes[0] else { unreachable!() };
assert_eq!(items.len(), 2);
assert_eq!(doc.to_lossless_string(), "(kicad_pcb (version 20260101))");

Rootless mode for multi-form files (for example, .kicad_dru style snippets):

use kiutils_sexpr::parse_rootless;

let doc = parse_rootless("(version 1)\n(rule \"x\")\n").unwrap();
assert_eq!(doc.nodes.len(), 2);