24 node.visit_children(*
this);
39 std::ostringstream ss;
44 if (
node.get_unit2()->get_node_name() ==
"1") {
45 ss <<
node.get_unit1()->get_node_name() <<
'\t';
48 ss <<
node.get_unit1()->get_node_name() <<
'\t' <<
node.get_unit2()->get_node_name();
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;
128 auto node_unit_name =
node.get_node_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));
Auto generated AST classes declaration.
Represents a double variable.
Represents top level AST node for whole NMODL input.
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...
parser::UnitDriver units_driver
Units Driver needed to parse the units file and the string produces by mod files' units.
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::string units_dir
Directory of units lib file that defines all the basic units.
void visit_program(ast::Program &node) override
Override visit_program function to parse the nrnunits.lib unit file before starting visiting the AST ...
const std::string UNIT_FUZZ
Declaration of fuzz constant unit, which is the equivilant of 1 in mod files UNITS definitions.
std::shared_ptr< nmodl::units::UnitTable > table
shared pointer to the UnitTable that stores all the unit definitions
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
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.
void move(Item *q1, Item *q2, Item *q3)
encapsulates code generation backend implementations
static Node * node(Object *)
Implement string manipulation functions.
Visitor for Units blocks of AST.