예제 #1
0
void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd )
    throw( IO_ERROR, PARSE_ERROR )
{
    wxString text;
    while( ( token = NextTok() ) != T_EOF )
    {
        if( token == T_LEFT )
            token = NextTok();
        if( token == T_components )
        {
            // The section comp starts here.
            while( ( token = NextTok() ) != T_RIGHT )
            {
                if( token == T_LEFT )
                    token = NextTok();
                if( token == T_comp )
                {
                    // A comp section if found. Read it
                    COMPONENT_INFO* cmp_info = ParseComp();
                    netlist_reader->AddModuleInfo( cmp_info );
                }
            }
            if( netlist_reader->BuildModuleListOnlyOpt() )
                return; // at this point, the module list is read and built.
            // Load new footprints
            netlist_reader->InitializeModules();
            netlist_reader->TestFootprintsMatchingAndExchange();
        }

        if( token == T_nets )
        {
            // The section nets starts here.
            while( ( token = NextTok() ) != T_RIGHT )
            {
                if( token == T_LEFT )
                    token = NextTok();
                if( token == T_net )
                {
                    // A net section if found. Read it
                    ParseNet( aBrd );
                }
            }
        }

        if( token == T_libparts && netlist_reader->ReadLibpartSectionOpt() )
        {
            // The section libparts starts here.
            while( ( token = NextTok() ) != T_RIGHT )
            {
                if( token == T_LEFT )
                    token = NextTok();
                if( token == T_libpart )
                {
                    // A libpart section if found. Read it
                    ParseKicadLibpartList();
                }
            }
        }
    }
}