Accept empty "(fp)" statements.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20002
This commit is contained in:
Jeff Young 2025-06-08 16:32:14 +01:00
parent f3050bd7ed
commit 70dfc9215d
3 changed files with 19 additions and 3 deletions

View File

@ -333,6 +333,12 @@ bool DSNLEXER::IsSymbol( int aTok )
}
bool DSNLEXER::IsNumber( int aTok )
{
return aTok == DSN_NUMBER;
}
void DSNLEXER::Expecting( int aTok ) const
{
wxString errText = wxString::Format( _( "Expecting %s" ), GetTokenString( aTok ) );
@ -410,7 +416,7 @@ int DSNLEXER::NeedSYMBOLorNUMBER()
{
int tok = NextTok();
if( !IsSymbol( tok ) && tok!=DSN_NUMBER )
if( !IsSymbol( tok ) && !IsNumber( tok ) )
Expecting( "a symbol or number" );
return tok;
@ -421,7 +427,7 @@ int DSNLEXER::NeedNUMBER( const char* aExpectation )
{
int tok = NextTok();
if( tok != DSN_NUMBER )
if( !IsNumber( tok ) )
{
wxString errText = wxString::Format( _( "need a number for '%s'" ),
wxString::FromUTF8( aExpectation ).GetData() );

View File

@ -332,6 +332,8 @@ public:
*/
static bool IsSymbol( int aTok );
static bool IsNumber( int aTok );
/**
* Throw an #IO_ERROR exception with an input file specific error message.
*

View File

@ -743,7 +743,15 @@ void KICAD_NETLIST_PARSER::parseLibPartList()
if( token != T_fp )
Expecting( T_fp );
NeedSYMBOLorNUMBER();
token = NextTok();
// Accept an empty (fp) sexpr. We do write them out.
if( token == T_RIGHT )
continue;
if( !IsSymbol( token ) && !IsNumber( token ) )
Expecting( "footprint ID" );
footprintFilters.Add( From_UTF8( CurText() ) );
NeedRIGHT();
}