← Back to team overview

kicad-developers team mailing list archive

Re: [rfc] actual sexpression parsing

 

On 18.12.2015 13:55, Mark Roszko wrote:
> Writing a new state machine for every single list and every single
> file over and over again is the part I have problems with. There
> should be a single state machine that takes the tokens and gives you a
> list. Not 500 over the whole codebase.

Hi Mark,

May I add my 5 cents to this discussion...

- My only big concern with the current parser so far is the lexer code
generation done by CMake. I'm not a big fan of making scripts that
produce code which then gets compiled...

Anyway, since we got here, I have a devilish idea: why a text format at
all? Of course we are not going to change the format again (we have a
lot of more exciting things to do ;-), but to point out a few reasons:

- PCB files (as opposed to netlists) represent graphical objects. For
someone looking at a PCB file with a text editor, it's just meaningless
numbers. Diffs look equally horrible (just look at a diff between two
.kicad_pcb files after moving a couple of traces in P&S mode).

- binary formats are generally easier to parse (unless someone made it
deliberately difficult - but it's not our case). We could just serialize
objects directly to a binary file, along with some version info (think
of Google's protobuf). This would also let us implement introspection
(e.g. a property editor tool) for no extra cost.

- Our s-expr format needs a custom parser (correct me if I'm wrong),
which contradicts the idea that generic text formats (e.g. json/lisp
s-expr, even lua/python arrays) need no dedicated parsers.

- Last but not least (and surely not least controversial): file format
that is easy to hand-edit enables people to hack scripts that do stuff
that Kicad is currently missing. This is an advantage for some (perhaps
more advanced) users who can work around missing features this way, but
is it really beneficial for Kicad as a complete PCB design tool? If the
easiest way is to hack a PCB file with a perl script/text editor, what
motivation is left to implement the missing feature in Kicad?

Cheers,
Tom




Follow ups

References