30#include <pegtl/contrib/parse_tree.hpp>
61 std::vector<std::string> currentNames;
65 currentNames.push_back( fmt::format(
"I({})",
ItemName( aItem ) ) );
70 currentNames.push_back( fmt::format(
"I({}:{})",
ItemName( aItem ),
pin.modelPinName ) );
78 const std::string& aSpiceCode )
80 tao::pegtl::string_input<> in( aSpiceCode,
"from_content" );
81 std::unique_ptr<tao::pegtl::parse_tree::node> root;
90 catch(
const tao::pegtl::parse_error& e )
97 for(
const auto& node : root->children )
101 for(
const auto& subnode : node->children )
108 model.AddPin( { subnode->string(), fmt::format(
"{}",
model.GetPinCount() + 1 ) } );
112 for(
const auto& subsubnode : subnode->children )
116 model.m_paramInfos.push_back( std::make_unique<SIM_MODEL::PARAM::INFO>() );
117 model.m_paramInfos.back()->name = subsubnode->string();
118 model.m_paramInfos.back()->isInstanceParam =
true;
119 model.m_paramInfos.back()->isSpiceInstanceParam =
true;
125 wxASSERT(
model.m_paramInfos.size() > 0 );
126 model.m_paramInfos.back()->defaultValue = subsubnode->string();
130 wxFAIL_MSG(
"Unhandled parse tree subsubnode" );
138 wxFAIL_MSG(
"Unhandled parse tree node" );
142 model.m_spiceCode = aSpiceCode;
173 return baseModel->GetSpiceCode();
SIM_MODEL_SPICE(TYPE aType, std::unique_ptr< SPICE_GENERATOR > aSpiceGenerator)
friend class SPICE_MODEL_PARSER_SUBCKT
std::string GetSpiceCode() const
void SetBaseModel(const SIM_MODEL &aBaseModel) override
const SIM_MODEL * GetBaseModel() const
void AddParam(const PARAM::INFO &aInfo)
void AddPin(const SIM_MODEL_PIN &aPin)
virtual const PARAM & GetParam(unsigned aParamIndex) const
virtual void SetBaseModel(const SIM_MODEL &aBaseModel)
int GetParamCount() const
std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
const SIM_MODEL * m_baseModel
std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const override
std::string ModelLine(const SPICE_ITEM &aItem) const override
virtual std::string ItemName(const SPICE_ITEM &aItem) const
virtual std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
void ReadModel(const SIM_LIBRARY_SPICE &aLibrary, const std::string &aSpiceCode) override
SIM_MODEL_SPICE & m_model
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
must_if< error >::control< Rule > control