User Guide
units.cpp File Reference
#include "utils/fmt.h"
#include <catch2/catch_test_macros.hpp>
#include "ast/double.hpp"
#include "ast/factor_def.hpp"
#include "ast/program.hpp"
#include "parser/nmodl_driver.hpp"
#include "src/config/config.h"
#include "test/unit/utils/nmodl_constructs.hpp"
#include "test/unit/utils/test_utils.hpp"
#include "visitors/checkparent_visitor.hpp"
#include "visitors/units_visitor.hpp"

Go to the source code of this file.

Functions

std::tuple< std::shared_ptr< ast::Program >, std::shared_ptr< units::UnitTable > > run_units_visitor (const std::string &text)
 
std::string get_unit_definitions (const ast::Program &ast, const units::UnitTable &unit_table)
 Returns all the UnitDef s of the ast::Program. More...
 
std::string get_factor_definitions (const ast::Program &ast)
 Returns all the FactorDef s of the ast::Program. More...
 
 SCENARIO ("Parse UNITS block of mod files using Units Visitor", "[visitor][units]")
 

Function Documentation

◆ get_factor_definitions()

std::string get_factor_definitions ( const ast::Program ast)

Returns all the FactorDef s of the ast::Program.

Visit AST to find all the ast::FactorDef nodes to print their unit names and factors as they are calculated to be printed to the generated .cpp file The FactorDef s are printed in the format:

<unit_name> <unit_value>
  • ast ast::Program to look for FactorDef s
Returns
std::string Factor definitions

Definition at line 117 of file units.cpp.

◆ get_unit_definitions()

std::string get_unit_definitions ( const ast::Program ast,
const units::UnitTable unit_table 
)

Returns all the UnitDef s of the ast::Program.

Visit AST to find all the ast::UnitDef nodes to print their unit names, factors and dimensions as they are calculated in the units::UnitTable The UnitDef s are printed in the format:

<unit_name> <unit_value>: <dimensions>

If the unit is constant then instead of the dimensions we print constant

  • ast ast::Program to look for UnitDef s
  • unit_table units::UnitTable to look for the definitions of the units
Returns
std::string Unit definitions

Definition at line 74 of file units.cpp.

◆ run_units_visitor()

std::tuple<std::shared_ptr<ast::Program>, std::shared_ptr<units::UnitTable> > run_units_visitor ( const std::string &  text)

Definition at line 32 of file units.cpp.

◆ SCENARIO()

SCENARIO ( "Parse UNITS block of mod files using Units Visitor"  ,
""  [visitor][units] 
)

Definition at line 129 of file units.cpp.