jdthorpe / kicad-module-parser

A PegJS parser for Kicad Modules
3 stars 3 forks source link

Parser error #3

Open ToastyStoemp opened 2 years ago

ToastyStoemp commented 2 years ago

Hey, running into this error:

Error ```kicad-to-json\src\module-parser.js:15205 throw peg$buildStructuredError( ^ peg$SyntaxError: Expected "at", "attr", "autoplace_cost180", "autoplace_cost90", "clearance", "descr", "fp_arc", "fp_circle", " "solder_mask_margin", "solder_paste_margin", "solder_paste_margin_ratio", "solder_paste_ratio", "tags", "tedit", "thermal_gap" at peg$buildStructuredError (G:\Other computers\Desktop\Keyboard\_Extra\KiCad\Kicad Parser\node_modules\kicad-to-json\src\m at Object.peg$parse [as parse] (G:\Other computers\Desktop\Keyboard\_Extra\KiCad\Kicad Parser\node_modules\kicad-to-json\sr at Object.parse (G:\Other computers\Desktop\Keyboard\_Extra\KiCad\Kicad Parser\node_modules\kicad-to-json\src\parse.js:11:3 at Object.board (G:\Other computers\Desktop\Keyboard\_Extra\KiCad\Kicad Parser\node_modules\kicad-to-json\index.js:19:61) at Object. (G:\Other computers\Desktop\Keyboard\_Extra\KiCad\Kicad Parser\main.js:10:24) at Module._compile (node:internal/modules/cjs/loader:1108:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10) at Module.load (node:internal/modules/cjs/loader:973:32) at Function.Module._load (node:internal/modules/cjs/loader:813:14) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) { expected: [ { type: 'literal', text: 'version', ignoreCase: false }, { type: 'literal', text: 'layer', ignoreCase: false }, { type: 'literal', text: 'tedit', ignoreCase: false }, { type: 'literal', text: 'tstamp', ignoreCase: false }, { type: 'literal', text: 'at', ignoreCase: false }, { type: 'literal', text: 'descr', ignoreCase: false }, { type: 'literal', text: 'tags', ignoreCase: false }, { type: 'literal', text: 'path', ignoreCase: false }, { type: 'literal', text: 'solder_paste_margin_ratio', ignoreCase: false }, { type: 'literal', text: 'solder_mask_margin', ignoreCase: false }, { type: 'literal', text: 'solder_paste_margin', ignoreCase: false }, { type: 'literal', text: 'solder_paste_ratio', ignoreCase: false }, { type: 'literal', text: 'thermal_width', ignoreCase: false }, { type: 'literal', text: 'clearance', ignoreCase: false }, { type: 'literal', text: 'thermal_gap', ignoreCase: false }, { type: 'literal', text: 'zone_connect', ignoreCase: false }, { type: 'literal', text: 'autoplace_cost90', ignoreCase: false }, { type: 'literal', text: 'autoplace_cost180', ignoreCase: false }, { type: 'literal', text: 'attr', ignoreCase: false }, { type: 'literal', text: 'fp_text', ignoreCase: false }, { type: 'literal', text: 'fp_arc', ignoreCase: false }, { type: 'literal', text: 'fp_circle', ignoreCase: false }, { type: 'literal', text: 'fp_curve', ignoreCase: false }, { type: 'literal', text: 'fp_line', ignoreCase: false }, { type: 'literal', text: 'fp_rect', ignoreCase: false }, { type: 'literal', text: 'fp_poly', ignoreCase: false }, { type: 'literal', text: 'pad', ignoreCase: false }, { type: 'literal', text: 'model', ignoreCase: false }, { type: 'literal', text: 'zone', ignoreCase: false } ], found: 'p', location: { start: { offset: 6154, line: 227, column: 6 }, end: { offset: 6155, line: 227, column: 7 } } } ```

This is using KiCad 6

would appreciate some help

jdthorpe commented 1 year ago

Looks like Kicad 6 introduced some new syntax / options. Since Kicad uses a hand-written parser, it won't be obvious what changes they made that introduced the new schema -- so I would need an example file that raises this error. Would, you be able to share a the file or a link to a file that raises this error? (The smaller the better).

If you're not able to share the whole file, can you open the kicad file in a text editor and copy the relevent section? I can see from the error that the new / invalid syntax is on line 227 of your kicad file, so possibly just the first 227 lines would be sufficient...

ToastyStoemp commented 1 year ago

Sure no problem, here is a sample project: https://drive.google.com/file/d/194fkAp9rbQRIXtIBTpL2YjYbg2UKKU7W/view?usp=share_link