kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #10989
About the sexp format
I'm writing some lisp tooling for working with modules; obviously the
sexp files are pretty much lisp favourite food:P
However I have some questions (if there is some documentation on the
syntax it would be great) to make the support more robust as possible.
- Case sensitivity. It appears it is case sensitive, am I right?
- Numbers seems the usual stuff at least for integers. Floating point
could have some peculiar syntax? For example E notation or other
things different than n.nnnn
- Strings are somewhat bothering me, because these are easily confused
as a symbol or number... in a 'conventional' sexp strings are always
in quotes and symbol aren't (symbols have their own syntactic quirks,
too...)
For example:
(fp_text value 470p (at 0 0 270) (layer F.SilkS) hide
(effects (font (size 1 1) (thickness 0.1))))
Is a problematic sexp because 470p is a string for kicad, but in fact
it's a possible-number (a strange thing due to lisp extensibility...).
One of the advantages of sexp is to be self describing i.e. just doing
(read) slurps the thing whole without needing a schema. Needing to
give a schema lose most of the advantages of using sexps...
I think that making strings self evident always using quotes would
solve the problem without breaking compatibility. So making an
emission like:
(fp_text value "470p" (at 0 0 270) (layer F.SilkS) hide
(effects (font (size 1 1) (thickness 0.1))))
would a) make the sexp self-parsing and b) better shows that 470p is
some text and not some special symbol or keyword (like F.Silk, for
example). I suppose it shouldn't be a big modification to do.
- What about special characters inside strings? for example, is
a " represented as \" ? Other special character that could be found?
IIRC you could put newline in texts, is that stored as \n or other?
(lisp standards vary about this, everyone has it's own escape rule but
AFAIK the \" is universal)
- File encoding? is it UTF-8 or something else?
--
Lorenzo Marcantonio
Logos Srl
Follow ups