← Back to team overview

kicad-developers team mailing list archive

Re: 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.

John


Follow ups

References