From 2bcfe5e42cfc5e061ab41e003579776bd66c35f4 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 30 Aug 2022 11:58:20 +0200 Subject: [PATCH] Fix Spice subcircuit parsing When parsing a subcircuit, the parser was incorrectly identifying parameters of models inside it as belonging to the subcircuit. --- eeschema/sim/sim_model_subckt.cpp | 9 ++------- eeschema/sim/spice_grammar.h | 7 ++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/eeschema/sim/sim_model_subckt.cpp b/eeschema/sim/sim_model_subckt.cpp index 753c4f16ac..d3446d0ff9 100644 --- a/eeschema/sim/sim_model_subckt.cpp +++ b/eeschema/sim/sim_model_subckt.cpp @@ -37,7 +37,7 @@ namespace SIM_MODEL_SUBCKT_SPICE_PARSER template <> struct spiceUnitSelector : std::true_type {}; template <> struct spiceUnitSelector : std::true_type {}; template <> struct spiceUnitSelector : std::true_type {}; - template <> struct spiceUnitSelector : std::true_type {}; + template <> struct spiceUnitSelector : std::true_type {}; template <> struct spiceUnitSelector : std::true_type {}; template <> struct spiceUnitSelector> : std::true_type {}; @@ -72,8 +72,6 @@ void SIM_MODEL_SUBCKT::ReadSpiceCode( const wxString& aSpiceCode ) { if( node->is_type() ) { - bool hadParamValuePairs = false; - for( const auto& subnode : node->children ) { if( subnode->is_type() ) @@ -83,8 +81,7 @@ void SIM_MODEL_SUBCKT::ReadSpiceCode( const wxString& aSpiceCode ) { AddPin( { subnode->string(), wxString::FromCDouble( GetPinCount() + 1 ) } ); } - else if( !hadParamValuePairs - && subnode->is_type() ) + else if( subnode->is_type() ) { for( const auto& subsubnode : subnode->children ) { @@ -102,8 +99,6 @@ void SIM_MODEL_SUBCKT::ReadSpiceCode( const wxString& aSpiceCode ) wxFAIL_MSG( "Unhandled parse tree subsubnode" ); } } - - hadParamValuePairs = true; } else if( subnode->is_type< SIM_MODEL_SUBCKT_SPICE_PARSER::number>> {}; + struct dotSubcktParams : seq {}; struct dotSubcktEnd : seq> {}; struct spiceUnit; @@ -169,9 +172,7 @@ namespace SPICE_GRAMMAR sep, dotSubcktPinSequence, opt, + dotSubcktParams>, opt, newline, until> {};