![Logo](logo.png) |
User Guide
|
Go to the documentation of this file.
39 std::ostringstream ss;
44 if (node.
get_unit2()->get_node_name() ==
"1") {
45 ss << node.
get_unit1()->get_node_name() <<
'\t';
84 const auto node_has_value_defined_in_modfile = node.
get_value() !=
nullptr;
85 if (!node_has_value_defined_in_modfile) {
86 std::ostringstream ss_unit1, ss_unit2;
87 std::string unit1_name, unit2_name;
92 if (node.
get_unit1()->get_node_name() ==
"1") {
95 unit1_name = node.
get_unit1()->get_node_name();
97 if (node.
get_unit2()->get_node_name() ==
"1") {
100 unit2_name = node.
get_unit2()->get_node_name();
106 ss_unit1 << node.
get_node_name() <<
"_unit1\t" << unit1_name;
112 ss_unit2 << node.
get_node_name() <<
"_unit2\t" << unit2_name;
129 auto unit1_factor =
units_driver.
table->get_unit(node_unit_name +
"_unit1")->get_factor();
130 auto unit2_factor =
units_driver.
table->get_unit(node_unit_name +
"_unit2")->get_factor();
132 auto double_value_ptr = std::make_shared<ast::Double>(
ast::Double(unit_factor));
133 node.
set_value(std::move(double_value_ptr));
std::shared_ptr< nmodl::units::UnitTable > table
shared pointer to the UnitTable that stores all the unit definitions
const std::string UNIT_FUZZ
Declaration of fuzz constant unit, which is the equivilant of 1 in mod files UNITS definitions.
std::string get_node_name() const override
Return name of the node.
Represents a double variable.
void visit_program(ast::Program &node) override
Override visit_program function to parse the nrnunits.lib unit file before starting visiting the AST ...
encapsulates code generation backend implementations
Implement string manipulation functions.
parser::UnitDriver units_driver
Units Driver needed to parse the units file and the string produces by mod files' units.
std::shared_ptr< Unit > get_unit1() const noexcept
Getter for member variable UnitDef::unit1.
std::shared_ptr< Double > get_value() const noexcept
Getter for member variable FactorDef::value.
void visit_factor_def(ast::FactorDef &node) override
Function to visit all the ast::FactorDef nodes and parse the units defined as ast::FactorDef in the U...
void visit_children(visitor::Visitor &v) override
visit children i.e.
std::shared_ptr< Unit > get_unit2() const noexcept
Getter for member variable FactorDef::unit2.
std::string units_dir
Directory of units lib file that defines all the basic units.
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
Visitor for Units blocks of AST.
void visit_unit_def(ast::UnitDef &node) override
Function to visit all the ast::UnitDef nodes and parse the units defined as ast::UnitDef in the UNITS...
std::shared_ptr< Unit > get_unit1() const noexcept
Getter for member variable FactorDef::unit1.
std::shared_ptr< Unit > get_unit2() const noexcept
Getter for member variable UnitDef::unit2.
Represents top level AST node for whole NMODL input.
void set_value(std::shared_ptr< Double > &&value)
Setter for member variable FactorDef::value (rvalue reference)
bool parse_file(const std::string &filename)
parse Units file
std::string to_string(double value, const std::string &format_spec)
Convert double value to string without trailing zeros.
Auto generated AST classes declaration.