This repository was archived by the owner on Apr 22, 2026. It is now read-only.
Fix boolean parsing, add lenient unknown-field handling, include dist/#17
Merged
Merged
Conversation
… repo - Fix embedded_fonts, in_pos_files, duplicate_pin_numbers_are_jumpers, show_name, do_not_autoplace rules to pass bool value through directly instead of double-wrapping (value === 'yes' on an object always yields false) - Remove dist/ from .gitignore so pnpm git dependencies resolve correctly (dist/ contains the built package needed by consumers) Co-Authored-By: Matthias <matthias.chills@gmail.com>
Author
Original prompt from Matthias |
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Same class of bug as the 5 rules fixed earlier: bool rule returns
{type, value} object but these rules compared it to string 'yes',
always evaluating to false. Now pass through the bool value directly.
Co-Authored-By: Matthias <matthias.chills@gmail.com>
natarius
approved these changes
Mar 2, 2026
Add unknown_sexp catch-all rule that matches any balanced parenthesised form and returns null. This rule is added as the last alternative in all choice lists (kicad_symbol_lib, kicad_symbol_element, property, pin, stroke, effects, font) so known fields parse normally but unknown future fields are silently skipped instead of causing parse failures. This ensures KiCad 11+ format changes won't break the parser. Co-Authored-By: Matthias <matthias.chills@gmail.com>
Merged
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three sets of changes to the KiCad symbol parser:
1. Fix boolean double-wrapping (8 rules)
The
boolrule already returns{ type: "boolean", value: true/false }, but 8 action blocks were re-wrapping it by comparing the object to the string"yes"(always evaluating tofalse). Changed all 8 to pass through theboolresult directly withreturn { type, value }.Affected rules:
embedded_fonts,in_pos_files,duplicate_pin_numbers_are_jumpers,show_name,do_not_autoplace,exclude_from_sim,in_bom,on_board2. Make parser lenient: skip unknown fields gracefully
Added an
unknown_sexpcatch-all rule that matches any balanced parenthesised S-expression and returnsnull. This rule is appended as the last alternative in all choice lists so known fields still parse normally, but unknown future fields (e.g. from KiCad 11+) are silently skipped instead of causing parse failures.Updated alternation lists:
kicad_symbol_lib,kicad_symbol_element,property,pin,stroke_definition,effects,fontAll collection rules now filter out
nullvalues returned byunknown_sexp.3. Track
dist/in gitRemoves
dist/from.gitignoreso built artifacts are committed. This is needed because pnpm git dependencies fetch tarballs containing only tracked files — withoutdist/, consumers (like flux-app) get an empty package.Review & Testing Checklist for Human
unknown_sexpcatch-all doesn't silently swallow valid fields. Since it's always last in alternation, known rules should match first. However, if a known rule fails mid-match (e.g. a property has a new inner structure),unknown_sexpwould consume and discard it. This is the intended trade-off for leniency — but worth verifying with a complex real-world file.balanced_contenthandles edge cases. The rule depends on the existingstringrule for quoted strings inside unknown S-expressions. Confirm it doesn't choke on strings containing escaped parens or unusual characters.dist/in git is acceptable for this project's workflow. It meansdist/must be rebuilt and committed whenever source changes.pnpm testto confirm all tests pass with both the boolean fixes and lenient parsing..kicad_symfile with an invented field like(some_future_field 42)inside a symbol and confirm it parses without error.Notes
symbol-parser.jsanddist/is entirely machine-generated from the grammar changes insymbol.pegjs