Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Fix footprint parser for KiCad 10: add duplicate_pad_numbers_are_jumpers + lenient unknown_sexp#18

Merged
natarius merged 3 commits into
masterfrom
devin/1772862902-fix-footprint-kicad10
Mar 7, 2026
Merged

Fix footprint parser for KiCad 10: add duplicate_pad_numbers_are_jumpers + lenient unknown_sexp#18
natarius merged 3 commits into
masterfrom
devin/1772862902-fix-footprint-kicad10

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Mar 7, 2026

Copy link
Copy Markdown

Fix footprint parser for KiCad 10: add missing token + lenient catch-all

Summary

KiCad 10 footprint files (.kicad_mod, version 20260206) fail to parse because the module grammar doesn't recognize the duplicate_pad_numbers_are_jumpers token. This causes the parser to error out entirely, resulting in all pads appearing stacked at the origin when imported into Flux.

Changes to module.pegjs:

  1. Added duplicate_pad_numbers_are_jumpers as a new boolean rule in module_contents
  2. Added an unknown_sexp catch-all rule (matching the pattern already used in symbol.pegjs) to 10 grammar rules: board, module_contents, pad_attr, fp_generics, gr_generics, module_property, fp_text, fp_text_box, effects, and font
  3. Added .filter(function(v) { return v !== null; }) to all .map() calls in rules that now include unknown_sexp, since the catch-all returns null

The compiled dist/ files are regenerated from the grammar — the meaningful diff is entirely in src/module.pegjs (~40 lines changed).

Updates since last revision

  • Fixed balanced_content quote bug — changed [^()]+ to [^()"']+ so quote characters are always handled by the string alternative. Without this, a value like (new_field "value with )") would have the " consumed by the catch-all character class, causing the ) inside the string to be treated as a structural paren and breaking the parse.
  • Added KiCad 10 test fixtures from Thea:
    • Footprints: MSOP-10_3x3mm_P0.5mm.kicad_mod (10 pads) and QSOP-28_3.9x9.9mm_P0.635mm.kicad_mod (28 pads)
    • Symbols: ch334u.kicad_sym and ch340x.kicad_sym
  • Updated .gitignore — changed data/module to data/module/* with !data/module/custom so custom footprint test files are tracked in git (matching the pattern used for data/symbols/custom/)

All test fixtures parse successfully with pnpm test.

Review & Testing Checklist for Human

  • Verify unknown_sexp is always the last alternative in every rule it was added to — PEG grammars are ordered, so placing it last ensures known tokens are always tried first. If it appeared earlier, it could swallow valid tokens silently.
  • Verify the null-filtering doesn't mask real issues.filter(v => v !== null) was added to ~10 .map() calls. Confirm no existing grammar rule relied on returning null for a meaningful purpose.
  • Test with real KiCad 10 footprint files — import MSOP-10_3x3mm_P0.5mm.kicad_mod and QSOP-28_3.9x9.9mm_P0.635mm.kicad_mod in Flux and verify pads are positioned correctly (not stacked at origin). MSOP-10 should have 10 pads spanning x={-2.1, 2.1}; QSOP-28 should have 28 pads spanning x={-2.6375, 2.6375}.
  • Regression test with existing KiCad 5/6/7/8/9 footprints — the existing test suite passes, but spot-check a few older footprints to make sure the catch-all doesn't break anything.

Notes


Open with Devin

…ers + lenient unknown_sexp catch-all

- Add duplicate_pad_numbers_are_jumpers rule to module_contents
- Add unknown_sexp catch-all to module_contents, pad_attr, fp_generics,
  gr_generics, board rule, module_property, fp_text, fp_text_box, effects,
  and font rules so future KiCad versions don't break the parser
- Rebuild compiled parser (module-parser.js) and dist/

Co-Authored-By: Matthias <matthias.chills@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author
Original prompt from Matthias
SYSTEM:
=== BEGIN THREAD HISTORY (in #dogfooding) ===
Thea (U0AFH6R3D8D): Given the speed the EAGLE, EasyEDA and other imports (seem) to have been implemented. Could we get a KiCad Import that works with the newest filetype?  No KiCad file that was created in the last 5 year works. The last supported version seems to be KiCad 5 and soon KiCad 10 will be launching.

Giulio (U091GFANVAT): Mmm weird since we are using kicad 9 internally 

Giulio (U091GFANVAT): I think it’s a matter of correctly mapping the kicad features into flux 

Thea (U0AFH6R3D8D): Its a biig Painpoint.

Thea (U0AFH6R3D8D): CC @matthias (U0852RD7LMP)

matthias (U0852RD7LMP): What exactly doesn't work?

Thea (U0AFH6R3D8D): Import of symbols and footprints created in a recent KiCad version just fail

matthias (U0852RD7LMP): Can you put together a folder of test files please

matthias (U0852RD7LMP): This is the first time I hear about this issue

matthias (U0852RD7LMP): @Jharwin (U091GF9SA5V) @Nicolas Tzovanis (U084Q3S45U3) is this a regressions?

Nicolas Tzovanis (U084Q3S45U3): Afaik we supported up to kicad v6

Nicolas Tzovanis (U084Q3S45U3): And kicad 9 uses the same format as kicad v6 for parts. Not sure what the deal is with Kicad 10 though.

Thea (U0AFH6R3D8D): 

ATTACHMENT:"https://app.devin.ai/attachments/a644df82-7cda-43c6-b42e-26affadf9653/image.png"

Thea (U0AFH6R3D8D): Currently making a Test folder.

Nicolas Tzovanis (U084Q3S45U3): Did the format change on Kicad 10?

matthias (U0852RD7LMP): @Devin please investigate
=== END THREAD HISTORY ===

Thread URL: https://fluxaigroup.slack.com/archives/C09286X4F7Y/p1772466774920479?thread_ts=1772466774.920479&cid=C09286X4F7Y

The latest message is the one right above that tagged you.

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

Address Devin Review findings: add .filter(v => v !== null) to
module rule (line 684) and pad rule (line 1104) where unknown_sexp
null values were not being filtered out.

Co-Authored-By: Matthias <matthias.chills@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

- Add MSOP-10 and QSOP-28 footprint test fixtures (KiCad 10 v20260206)
- Add CH334U and CH340X symbol test fixtures (KiCad 10)
- Fix balanced_content rule: exclude quote chars from [^()] catch-all
- Update .gitignore to allow data/module/custom/ test files

Co-Authored-By: Matthias <matthias.chills@gmail.com>
@natarius
natarius merged commit 83842fb into master Mar 7, 2026
3 of 4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant