← Back to team overview

kicad-developers team mailing list archive

Re: Forward-compatibility in s-expression formats

 

----- Original Message -----

> From: John Beard <john.j.beard@xxxxxxxxx>
> To: kicad-developers@xxxxxxxxxxxxxxxxxxx
> Cc: 
> Sent: Friday, May 9, 2014 5:42 AM
> Subject: Re: [Kicad-developers] Forward-compatibility in s-expression formats
> 
> On 07/05/14 07:19, Lorenzo Marcantonio wrote:
>>  On Wed, May 07, 2014 at 12:48:22AM +0100, John Beard wrote:
>>>  I would have thought this would exactly be done at the end of 
> tokenisation
>> 
>>  More or less, that's the idea :D
>> 
>>  There are various ways to do this but all depends on the flexibility
>>  required and the current architecture of the parser.
> 
> I've had a quick look, and basically what you'd need to do (for a
> module) is when you get an unknown symbol, replace the Expected() call
> with a call to some new function parseUnknown(). In there, you
> basically do:
> 
>     int depth = 1; // we just passed a (
>     T token = T_SYMBOL;
> 
>     while (depth > 0)
>     {
>         // we have token and CurText() here, can save them
> 
>         token = NextTok();
> 
>         if (token == T_LEFT)
>             depth ++;
>         else if (token == T_RIGHT)
>             depth --;
>     }
> 
> This consumes the unknown element and continues as normal. I have tested
> it on (unknown abc) and (unknown (abc 3 3)) in a .kicad_mod, and the
> footprint is now readable.
> 
> More work to do on keeping the structured data around, even though we
> don't know what it means in KiCad, which means we can still potentially
> provide it to whoever (Python?) wants it, as well as save it back
> non-destructively.
> 


I'd given it a bit more thought. Simply ignoring the information is trivial, but storing it and rewriting it when the board is changed is a nuisance. At the very least that would introduce a list of strings into many types of object and no one wants that. A more detailed proposal would be required as to which objects might accept such data and why this is a Good Thing(tm). Then at least if a particular object accepts the data then it can be rewritten as well and if the object does not accept this foreign data it simply makes it disappear forever.

The question is: what is really needed and how can it be implemented?

- Cirilo


Follow ups

References