kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #10990
Re: About the sexp format
On 08/14/2013 12:51 PM, Lorenzo Marcantonio wrote:
> 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?
>
I like our format and it works. I am unwilling to change it for a single user of lisp.
Here is some more info
a) see OUTPUT_FORMATTER::Quote{s,w}
b) see <kisrc>/Documentation/s-expressions.txt
c) keywords are always lowercase ASCII. The rest of the file is UTF8 with no restrictions
on case.
d) multiline strings in the datatree are single line strings in the file, with a separator
of "slash n", visible.
Dick
Follow ups
References