devbisme / kinparse

A Parser for KiCad EESCHEMA netlists.
MIT License
23 stars 11 forks source link

Revision string instead of revision number causes ParseException #2

Closed gnbl closed 6 years ago

gnbl commented 6 years ago

Attempting to parse a netlist like

(export (version D)
  (design
    (source "xxx.sch")
    (date "14/02/2018 11:07:30")
    (tool "Eeschema 4.0.7")
    (sheet (number 1) (name /) (tstamps /)
      (title_block
        (title)
        (company)
        (rev a)

fails with a ParseException and many "Suppress:" messages that seem not very helpful with debugging (could this output be properly formatted or condensed to point out the actual issue a little more direct?).

Removing data from the failing netlist to more resemble a working one (blank sheet) leads to the culprit: the string "a" string in rev, instead of a number as required in: https://github.com/xesscorp/kinparse/blob/master/kinparse/kinparse.py#L80

With that info, the error output [{Suppress:("(") Suppress:("rev") [{W:(0123...) [{"." [W:(0123...)]}]}] Suppress:(")")}] & makes a little more sense as it seems to show what is expected (a number).

Replacing this with rev = _paren_clause('rev', Optional(anystring)) resolves the problem.

xesscorp commented 6 years ago

I made the correction you recommended. New version is 0.0.3 and is available on PyPi. Thanks!

As for the clarity of the debugging output, that's pretty much determined by the pyparsing package. I haven't seen any way of tailoring it to make it easier to spot problems.

gnbl commented 6 years ago

Great, thank you.