Skip to content

Add etchy-kicad S-expression parser - #396

Merged
Cimos merged 1 commit into
mainfrom
native-kicad-parser
Oct 3, 2026
Merged

Cimos merged 1 commit into
mainfrom
native-kicad-parser

Conversation

@Cimos

@Cimos Cimos commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Phase 1, PR 3 of the native KiCad plan.

  • New crate crates/etchy-kicad, no external dependencies, builds for wasm32.
  • Byte-level lexer and node tree: lists, atoms, quoted strings with KiCad escapes, numbers kept as source text, byte/line/column positions on every node.
  • Every node keeps an id; Consumption lets later decoders mark what they used and list unconsumed nodes by path, for the record inventory in PR 4.
  • Limits for native and wasm (input bytes, nesting depth, node count, atom/string length), each a typed error with its position.
  • Typed errors for invalid UTF-8, unterminated strings, bad escapes, unbalanced parens, empty input, trailing data and numeric traps; checked helpers for integers and millimetre-to-nanometre conversion.
  • Reads the root and header (version, generator, generator_version) only.

Tested: 14 unit tests including mutation/truncation never panicking. The public Mad_RP2040 board (KiCad 9, 4 MB, 599,750 nodes) parses in about 90 ms in release; an optional smoke test runs it when ETCHY_KICAD_SMOKE_FILE is set at build time. The first version re-checked the rest of the file for every string character (17.5 s on that board); fixed, with a linear-time regression test.

Refs #122

Bounded byte-level parser for .kicad_pcb files: nodes with source positions, consumption tracking for unknown-node reports, native and wasm limits, typed errors and header extraction. No geometry yet, no new dependencies. Parses the 4 MB Mad_RP2040 board (600k nodes) in about 90 ms. Refs #122
@Cimos
Cimos merged commit 02ea580 into main Oct 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant