Sim: Allow .subckt parameter lists without "params:"
And fix .subckt parameter list parsing, because it was broken. Fixes https://gitlab.com/kicad/code/kicad/issues/12779
This commit is contained in:
parent
709ad14e74
commit
0b5814f98f
|
@ -41,6 +41,7 @@ namespace SIM_MODEL_SUBCKT_SPICE_PARSER
|
||||||
template <> struct spiceUnitSelector<dotSubcktPinName> : std::true_type {};
|
template <> struct spiceUnitSelector<dotSubcktPinName> : std::true_type {};
|
||||||
template <> struct spiceUnitSelector<dotSubcktParams> : std::true_type {};
|
template <> struct spiceUnitSelector<dotSubcktParams> : std::true_type {};
|
||||||
template <> struct spiceUnitSelector<param> : std::true_type {};
|
template <> struct spiceUnitSelector<param> : std::true_type {};
|
||||||
|
template <> struct spiceUnitSelector<paramValue> : std::true_type {};
|
||||||
template <> struct spiceUnitSelector<number<SIM_VALUE::TYPE_INT, NOTATION::SPICE>>
|
template <> struct spiceUnitSelector<number<SIM_VALUE::TYPE_INT, NOTATION::SPICE>>
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
template <> struct spiceUnitSelector<number<SIM_VALUE::TYPE_FLOAT, NOTATION::SPICE>>
|
template <> struct spiceUnitSelector<number<SIM_VALUE::TYPE_FLOAT, NOTATION::SPICE>>
|
||||||
|
@ -111,22 +112,17 @@ void SPICE_MODEL_PARSER_SUBCKT::ReadModel( const SIM_LIBRARY_SPICE& aLibrary,
|
||||||
|
|
||||||
model.AddParam( *model.m_paramInfos.back() );
|
model.AddParam( *model.m_paramInfos.back() );
|
||||||
}
|
}
|
||||||
|
else if( subsubnode->is_type<SIM_MODEL_SUBCKT_SPICE_PARSER::paramValue>() )
|
||||||
|
{
|
||||||
|
wxASSERT( model.m_paramInfos.size() > 0 );
|
||||||
|
model.m_paramInfos.back()->defaultValue = subsubnode->string();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "Unhandled parse tree subsubnode" );
|
wxFAIL_MSG( "Unhandled parse tree subsubnode" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( subnode->is_type<
|
|
||||||
SIM_MODEL_SUBCKT_SPICE_PARSER::number<SIM_VALUE::TYPE_INT,
|
|
||||||
SIM_MODEL_SUBCKT_SPICE_PARSER::NOTATION::SPICE>>()
|
|
||||||
|| subnode->is_type<
|
|
||||||
SIM_MODEL_SUBCKT_SPICE_PARSER::number<SIM_VALUE::TYPE_FLOAT,
|
|
||||||
SIM_MODEL_SUBCKT_SPICE_PARSER::NOTATION::SPICE>>() )
|
|
||||||
{
|
|
||||||
wxASSERT( model.m_paramInfos.size() > 0 );
|
|
||||||
model.m_paramInfos.back()->defaultValue = subnode->string();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -110,7 +110,6 @@ namespace SPICE_GRAMMAR
|
||||||
// Param names cannot be `token` because LTspice models contain spurious values without
|
// Param names cannot be `token` because LTspice models contain spurious values without
|
||||||
// parameter names, which we need to skip.
|
// parameter names, which we need to skip.
|
||||||
struct param : identifier {};
|
struct param : identifier {};
|
||||||
|
|
||||||
struct paramValue : token {};
|
struct paramValue : token {};
|
||||||
|
|
||||||
struct paramValuePair : seq<param,
|
struct paramValuePair : seq<param,
|
||||||
|
@ -145,12 +144,20 @@ namespace SPICE_GRAMMAR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct dotSubcktPinName : seq<not_at<TAO_PEGTL_ISTRING( "params:" )>,
|
struct dotSubcktParamValuePair : seq<param,
|
||||||
|
// TODO: Check if these `star<space>`s match Ngspice's
|
||||||
|
// behavior.
|
||||||
|
star<space>,
|
||||||
|
one<'='>,
|
||||||
|
star<space>,
|
||||||
|
paramValue> {};
|
||||||
|
struct dotSubcktParamValuePairs : list<dotSubcktParamValuePair, sep> {};
|
||||||
|
struct dotSubcktParams : seq<opt<TAO_PEGTL_ISTRING( "params:" ),
|
||||||
|
opt<sep>>,
|
||||||
|
dotSubcktParamValuePairs> {};
|
||||||
|
struct dotSubcktPinName : seq<not_at<dotSubcktParams>,
|
||||||
plus<not_at<space>, any>> {};
|
plus<not_at<space>, any>> {};
|
||||||
struct dotSubcktPinSequence : list<dotSubcktPinName, sep> {};
|
struct dotSubcktPinSequence : list<dotSubcktPinName, sep> {};
|
||||||
struct dotSubcktParams : seq<TAO_PEGTL_ISTRING( "params:" ),
|
|
||||||
sep,
|
|
||||||
paramValuePairs> {};
|
|
||||||
struct dotSubcktEnd : seq<TAO_PEGTL_ISTRING( ".ends" ),
|
struct dotSubcktEnd : seq<TAO_PEGTL_ISTRING( ".ends" ),
|
||||||
until<newline>> {};
|
until<newline>> {};
|
||||||
struct spiceUnit;
|
struct spiceUnit;
|
||||||
|
|
Loading…
Reference in New Issue