17 #include "utils/logger.hpp"
36 if (is_root_with_null_parent &&
node.get_parent()) {
37 const auto& parent_type = parent->get_node_type_name();
38 throw std::runtime_error(
39 fmt::format(
"root->parent: {} is set when it should be nullptr", parent_type));
42 if (parent !=
node.get_parent()) {
43 const std::string parent_type = (parent ==
nullptr) ?
"nullptr" : parent->get_node_type_name();
44 const std::string node_parent_type = (
node.get_parent() ==
nullptr) ?
"nullptr" :
node.get_parent()->get_node_type_name();
45 throw std::runtime_error(fmt::format(
"parent: {} and child->parent: {} missmatch",
61 node.visit_children(*
this);
64 parent =
node.get_parent();
75 node.visit_children(*
this);
78 parent =
node.get_parent();
89 node.visit_children(*
this);
92 parent =
node.get_parent();
103 node.visit_children(*
this);
106 parent =
node.get_parent();
117 node.visit_children(*
this);
120 parent =
node.get_parent();
131 node.visit_children(*
this);
134 parent =
node.get_parent();
145 node.visit_children(*
this);
148 parent =
node.get_parent();
159 node.visit_children(*
this);
162 parent =
node.get_parent();
173 node.visit_children(*
this);
176 parent =
node.get_parent();
187 node.visit_children(*
this);
190 parent =
node.get_parent();
201 node.visit_children(*
this);
204 parent =
node.get_parent();
215 node.visit_children(*
this);
218 parent =
node.get_parent();
229 node.visit_children(*
this);
232 parent =
node.get_parent();
243 node.visit_children(*
this);
246 parent =
node.get_parent();
257 node.visit_children(*
this);
260 parent =
node.get_parent();
271 node.visit_children(*
this);
274 parent =
node.get_parent();
285 node.visit_children(*
this);
288 parent =
node.get_parent();
299 node.visit_children(*
this);
302 parent =
node.get_parent();
313 node.visit_children(*
this);
316 parent =
node.get_parent();
327 node.visit_children(*
this);
330 parent =
node.get_parent();
341 node.visit_children(*
this);
344 parent =
node.get_parent();
355 node.visit_children(*
this);
358 parent =
node.get_parent();
369 node.visit_children(*
this);
372 parent =
node.get_parent();
383 node.visit_children(*
this);
386 parent =
node.get_parent();
397 node.visit_children(*
this);
400 parent =
node.get_parent();
411 node.visit_children(*
this);
414 parent =
node.get_parent();
425 node.visit_children(*
this);
428 parent =
node.get_parent();
439 node.visit_children(*
this);
442 parent =
node.get_parent();
453 node.visit_children(*
this);
456 parent =
node.get_parent();
467 node.visit_children(*
this);
470 parent =
node.get_parent();
481 node.visit_children(*
this);
484 parent =
node.get_parent();
495 node.visit_children(*
this);
498 parent =
node.get_parent();
509 node.visit_children(*
this);
512 parent =
node.get_parent();
523 node.visit_children(*
this);
526 parent =
node.get_parent();
537 node.visit_children(*
this);
540 parent =
node.get_parent();
551 node.visit_children(*
this);
554 parent =
node.get_parent();
565 node.visit_children(*
this);
568 parent =
node.get_parent();
579 node.visit_children(*
this);
582 parent =
node.get_parent();
593 node.visit_children(*
this);
596 parent =
node.get_parent();
607 node.visit_children(*
this);
610 parent =
node.get_parent();
621 node.visit_children(*
this);
624 parent =
node.get_parent();
635 node.visit_children(*
this);
638 parent =
node.get_parent();
649 node.visit_children(*
this);
652 parent =
node.get_parent();
663 node.visit_children(*
this);
666 parent =
node.get_parent();
677 node.visit_children(*
this);
680 parent =
node.get_parent();
691 node.visit_children(*
this);
694 parent =
node.get_parent();
705 node.visit_children(*
this);
708 parent =
node.get_parent();
719 node.visit_children(*
this);
722 parent =
node.get_parent();
733 node.visit_children(*
this);
736 parent =
node.get_parent();
747 node.visit_children(*
this);
750 parent =
node.get_parent();
761 node.visit_children(*
this);
764 parent =
node.get_parent();
775 node.visit_children(*
this);
778 parent =
node.get_parent();
789 node.visit_children(*
this);
792 parent =
node.get_parent();
803 node.visit_children(*
this);
806 parent =
node.get_parent();
817 node.visit_children(*
this);
820 parent =
node.get_parent();
831 node.visit_children(*
this);
834 parent =
node.get_parent();
845 node.visit_children(*
this);
848 parent =
node.get_parent();
859 node.visit_children(*
this);
862 parent =
node.get_parent();
873 node.visit_children(*
this);
876 parent =
node.get_parent();
887 node.visit_children(*
this);
890 parent =
node.get_parent();
901 node.visit_children(*
this);
904 parent =
node.get_parent();
915 node.visit_children(*
this);
918 parent =
node.get_parent();
929 node.visit_children(*
this);
932 parent =
node.get_parent();
943 node.visit_children(*
this);
946 parent =
node.get_parent();
957 node.visit_children(*
this);
960 parent =
node.get_parent();
971 node.visit_children(*
this);
974 parent =
node.get_parent();
985 node.visit_children(*
this);
988 parent =
node.get_parent();
999 node.visit_children(*
this);
1002 parent =
node.get_parent();
1013 node.visit_children(*
this);
1016 parent =
node.get_parent();
1027 node.visit_children(*
this);
1030 parent =
node.get_parent();
1041 node.visit_children(*
this);
1044 parent =
node.get_parent();
1055 node.visit_children(*
this);
1058 parent =
node.get_parent();
1069 node.visit_children(*
this);
1072 parent =
node.get_parent();
1083 node.visit_children(*
this);
1086 parent =
node.get_parent();
1097 node.visit_children(*
this);
1100 parent =
node.get_parent();
1111 node.visit_children(*
this);
1114 parent =
node.get_parent();
1125 node.visit_children(*
this);
1128 parent =
node.get_parent();
1139 node.visit_children(*
this);
1142 parent =
node.get_parent();
1153 node.visit_children(*
this);
1156 parent =
node.get_parent();
1167 node.visit_children(*
this);
1170 parent =
node.get_parent();
1181 node.visit_children(*
this);
1184 parent =
node.get_parent();
1195 node.visit_children(*
this);
1198 parent =
node.get_parent();
1209 node.visit_children(*
this);
1212 parent =
node.get_parent();
1223 node.visit_children(*
this);
1226 parent =
node.get_parent();
1237 node.visit_children(*
this);
1240 parent =
node.get_parent();
1251 node.visit_children(*
this);
1254 parent =
node.get_parent();
1265 node.visit_children(*
this);
1268 parent =
node.get_parent();
1279 node.visit_children(*
this);
1282 parent =
node.get_parent();
1293 node.visit_children(*
this);
1296 parent =
node.get_parent();
1307 node.visit_children(*
this);
1310 parent =
node.get_parent();
1321 node.visit_children(*
this);
1324 parent =
node.get_parent();
1335 node.visit_children(*
this);
1338 parent =
node.get_parent();
1349 node.visit_children(*
this);
1352 parent =
node.get_parent();
1363 node.visit_children(*
this);
1366 parent =
node.get_parent();
1377 node.visit_children(*
this);
1380 parent =
node.get_parent();
1391 node.visit_children(*
this);
1394 parent =
node.get_parent();
1405 node.visit_children(*
this);
1408 parent =
node.get_parent();
1419 node.visit_children(*
this);
1422 parent =
node.get_parent();
1433 node.visit_children(*
this);
1436 parent =
node.get_parent();
1447 node.visit_children(*
this);
1450 parent =
node.get_parent();
1461 node.visit_children(*
this);
1464 parent =
node.get_parent();
1475 node.visit_children(*
this);
1478 parent =
node.get_parent();
1489 node.visit_children(*
this);
1492 parent =
node.get_parent();
1503 node.visit_children(*
this);
1506 parent =
node.get_parent();
1517 node.visit_children(*
this);
1520 parent =
node.get_parent();
1531 node.visit_children(*
this);
1534 parent =
node.get_parent();
1545 node.visit_children(*
this);
1548 parent =
node.get_parent();
1559 node.visit_children(*
this);
1562 parent =
node.get_parent();
1573 node.visit_children(*
this);
1576 parent =
node.get_parent();
1587 node.visit_children(*
this);
1590 parent =
node.get_parent();
1601 node.visit_children(*
this);
1604 parent =
node.get_parent();
1615 node.visit_children(*
this);
1618 parent =
node.get_parent();
1629 node.visit_children(*
this);
1632 parent =
node.get_parent();
1643 node.visit_children(*
this);
1646 parent =
node.get_parent();
1657 node.visit_children(*
this);
1660 parent =
node.get_parent();
1671 node.visit_children(*
this);
1674 parent =
node.get_parent();
1685 node.visit_children(*
this);
1688 parent =
node.get_parent();
1699 node.visit_children(*
this);
1702 parent =
node.get_parent();
1713 node.visit_children(*
this);
1716 parent =
node.get_parent();
1727 node.visit_children(*
this);
1730 parent =
node.get_parent();
1741 node.visit_children(*
this);
1744 parent =
node.get_parent();
1755 node.visit_children(*
this);
1758 parent =
node.get_parent();
1769 node.visit_children(*
this);
1772 parent =
node.get_parent();
1783 node.visit_children(*
this);
1786 parent =
node.get_parent();
Auto generated AST classes declaration.
Visitor for checking parents of ast nodes
Represents a AFTER block in NMODL.
Represents an argument to functions and procedures.
Represents a ASSIGNED block in the NMODL.
Represents a statement in ASSIGNED or STATE block.
Represents a block to be executed before or after another block.
Type to represent different block types for before/after block.
Represents BBCOREPOINTER statement in NMODL.
Represent a single variable of type BBCOREPOINTER.
Represents a BEFORE block in NMODL.
Represents binary expression in the NMODL.
Operator used in ast::BinaryExpression.
Base class for all block scoped nodes.
Represents a boolean variable.
Represents a BREAKPOINT block in NMODL.
Represent COMPARTMENT statement in NMODL.
Represents CONDUCTANCE statement in NMODL.
Represent CONSERVE statement in NMODL.
Represent CONSTANT block in the mod file.
Represent statement in CONSTANT block of NMODL.
Represents a variable in the ast::ConstantBlock.
Represents a CONSTRUCTOR block in the NMODL.
Represents a block used for variable timestep integration (CVODE) of DERIVATIVE blocks.
Represents a DEFINE statement in NMODL.
Represents DERIVATIVE block in the NMODL.
Represent a callback to NEURON's derivimplicit solver.
Represents a DESTRUCTOR block in the NMODL.
Represents differential equation in DERIVATIVE block.
Represents a double variable.
Represent linear solver solution block based on Eigen.
Represent newton solver solution block based on Eigen.
Represents ELECTRODE_CURRENT variables statement in NMODL.
Base class for all expressions in the NMODL.
This construct is deprecated and no longer supported in the NMODL.
Represents a float variable.
Represents GLOBAL statement in NMODL.
Base class for all identifiers.
Represents an INCLUDE statement in NMODL.
Represents a INDEPENDENT block in the NMODL.
Represents specific element of an array variable.
Represents a INITIAL block in the NMODL.
Represents an integer variable.
Represents a LAG statement in the mod file.
One equation in a system of equations tha collectively form a LINEAR block.
Represents LINEAR block in the NMODL.
Represent LONGITUDINAL_DIFFUSION statement in NMODL.
Extracts information required for LONGITUDINAL_DIFFUSION for each KINETIC block.
Represent MUTEXLOCK statement in NMODL.
Represent MUTEXUNLOCK statement in NMODL.
Represent NEURON block in the mod file.
Base class for all AST node.
One equation in a system of equations that collectively make a NONLINEAR block.
Represents NONLINEAR block in the NMODL.
Represents NONSPECIFIC_CURRENT variables statement in NMODL.
Represents the coreneuron nrn_state callback function.
Base class for all numbers.
Represents CURIE information in NMODL.
Represents a PARAMETER block in the NMODL.
Represents POINTER statement in NMODL.
Represents a prime variable (for ODE)
Represents top level AST node for whole NMODL input.
Single variable of type RANDOM.
Represents RANDOM statement in NMODL.
Represents RANGE variables statement in NMODL.
Represent solution of a block in the AST.
Represents a STATE block in the NMODL.
Represents block encapsulating list of statements.
Represents SUFFIX statement in NMODL.
Represents TABLE statement in NMODL.
Represents THREADSAFE statement in NMODL.
Statement to indicate a change in timestep in a given block.
Represents USEION statement in NMODL.
Represents a C code block.
Represent WATCH statement in NMODL.
Wrap any other expression type.
void visit_prime_name(const ast::PrimeName &node) override
Go through the tree while checking the parents.
void visit_write_ion_var(const ast::WriteIonVar &node) override
Go through the tree while checking the parents.
void visit_kinetic_block(const ast::KineticBlock &node) override
Go through the tree while checking the parents.
void visit_solution_expression(const ast::SolutionExpression &node) override
Go through the tree while checking the parents.
void visit_bbcore_pointer(const ast::BbcorePointer &node) override
Go through the tree while checking the parents.
void visit_local_var(const ast::LocalVar &node) override
Go through the tree while checking the parents.
void visit_conductance_hint(const ast::ConductanceHint &node) override
Go through the tree while checking the parents.
void visit_random_var(const ast::RandomVar &node) override
Go through the tree while checking the parents.
void visit_eigen_linear_solver_block(const ast::EigenLinearSolverBlock &node) override
Go through the tree while checking the parents.
void visit_for_netcon(const ast::ForNetcon &node) override
Go through the tree while checking the parents.
void visit_unit(const ast::Unit &node) override
Go through the tree while checking the parents.
void visit_factor_def(const ast::FactorDef &node) override
Go through the tree while checking the parents.
void visit_non_lin_equation(const ast::NonLinEquation &node) override
Go through the tree while checking the parents.
void visit_nonspecific(const ast::Nonspecific &node) override
Go through the tree while checking the parents.
void visit_bbcore_pointer_var(const ast::BbcorePointerVar &node) override
Go through the tree while checking the parents.
void visit_unit_def(const ast::UnitDef &node) override
Go through the tree while checking the parents.
void visit_after_block(const ast::AfterBlock &node) override
Go through the tree while checking the parents.
void visit_state_block(const ast::StateBlock &node) override
Go through the tree while checking the parents.
void visit_range(const ast::Range &node) override
Go through the tree while checking the parents.
void visit_reaction_statement(const ast::ReactionStatement &node) override
Go through the tree while checking the parents.
void visit_argument(const ast::Argument &node) override
Go through the tree while checking the parents.
void visit_binary_operator(const ast::BinaryOperator &node) override
Go through the tree while checking the parents.
void visit_unit_block(const ast::UnitBlock &node) override
Go through the tree while checking the parents.
void visit_lag_statement(const ast::LagStatement &node) override
Go through the tree while checking the parents.
void visit_suffix(const ast::Suffix &node) override
Go through the tree while checking the parents.
void visit_non_linear_block(const ast::NonLinearBlock &node) override
Go through the tree while checking the parents.
void visit_mutex_lock(const ast::MutexLock &node) override
Go through the tree while checking the parents.
void visit_define(const ast::Define &node) override
Go through the tree while checking the parents.
void visit_range_var(const ast::RangeVar &node) override
Go through the tree while checking the parents.
void visit_electrode_cur_var(const ast::ElectrodeCurVar &node) override
Go through the tree while checking the parents.
void visit_constructor_block(const ast::ConstructorBlock &node) override
Go through the tree while checking the parents.
void visit_program(const ast::Program &node) override
Go through the tree while checking the parents.
void visit_local_list_statement(const ast::LocalListStatement &node) override
Go through the tree while checking the parents.
void visit_discrete_block(const ast::DiscreteBlock &node) override
Go through the tree while checking the parents.
void visit_pointer(const ast::Pointer &node) override
Go through the tree while checking the parents.
void visit_lon_diffuse(const ast::LonDiffuse &node) override
Go through the tree while checking the parents.
void visit_ba_block(const ast::BABlock &node) override
Go through the tree while checking the parents.
void visit_global(const ast::Global &node) override
Go through the tree while checking the parents.
void visit_float(const ast::Float &node) override
Go through the tree while checking the parents.
void visit_external(const ast::External &node) override
Go through the tree while checking the parents.
void visit_wrapped_expression(const ast::WrappedExpression &node) override
Go through the tree while checking the parents.
void visit_conserve(const ast::Conserve &node) override
Go through the tree while checking the parents.
void visit_electrode_current(const ast::ElectrodeCurrent &node) override
Go through the tree while checking the parents.
void visit_watch(const ast::Watch &node) override
Go through the tree while checking the parents.
void visit_var_name(const ast::VarName &node) override
Go through the tree while checking the parents.
void visit_eigen_newton_solver_block(const ast::EigenNewtonSolverBlock &node) override
Go through the tree while checking the parents.
void visit_compartment(const ast::Compartment &node) override
Go through the tree while checking the parents.
void visit_independent_block(const ast::IndependentBlock &node) override
Go through the tree while checking the parents.
void visit_expression_statement(const ast::ExpressionStatement &node) override
Go through the tree while checking the parents.
void visit_extern_var(const ast::ExternVar &node) override
Go through the tree while checking the parents.
void visit_double_unit(const ast::DoubleUnit &node) override
Go through the tree while checking the parents.
void visit_from_statement(const ast::FromStatement &node) override
Go through the tree while checking the parents.
void visit_number(const ast::Number &node) override
Go through the tree while checking the parents.
void visit_include(const ast::Include &node) override
Go through the tree while checking the parents.
void visit_watch_statement(const ast::WatchStatement &node) override
Go through the tree while checking the parents.
void visit_constant_block(const ast::ConstantBlock &node) override
Go through the tree while checking the parents.
void visit_name(const ast::Name &node) override
Go through the tree while checking the parents.
void visit_ontology_statement(const ast::OntologyStatement &node) override
Go through the tree while checking the parents.
void visit_nrn_state_block(const ast::NrnStateBlock &node) override
Go through the tree while checking the parents.
void visit_random_var_list(const ast::RandomVarList &node) override
Go through the tree while checking the parents.
void visit_number_range(const ast::NumberRange &node) override
Go through the tree while checking the parents.
void visit_neuron_block(const ast::NeuronBlock &node) override
Go through the tree while checking the parents.
void visit_table_statement(const ast::TableStatement &node) override
Go through the tree while checking the parents.
void visit_linear_block(const ast::LinearBlock &node) override
Go through the tree while checking the parents.
void visit_unit_state(const ast::UnitState &node) override
Go through the tree while checking the parents.
void visit_block_comment(const ast::BlockComment &node) override
Go through the tree while checking the parents.
void visit_read_ion_var(const ast::ReadIonVar &node) override
Go through the tree while checking the parents.
void visit_net_receive_block(const ast::NetReceiveBlock &node) override
Go through the tree while checking the parents.
void visit_function_call(const ast::FunctionCall &node) override
Go through the tree while checking the parents.
void visit_cvode_block(const ast::CvodeBlock &node) override
Go through the tree while checking the parents.
void visit_thread_safe(const ast::ThreadSafe &node) override
Go through the tree while checking the parents.
void visit_nonspecific_cur_var(const ast::NonspecificCurVar &node) override
Go through the tree while checking the parents.
void visit_model(const ast::Model &node) override
Go through the tree while checking the parents.
void visit_unary_expression(const ast::UnaryExpression &node) override
Go through the tree while checking the parents.
void visit_assigned_block(const ast::AssignedBlock &node) override
Go through the tree while checking the parents.
void visit_param_block(const ast::ParamBlock &node) override
Go through the tree while checking the parents.
void visit_pointer_var(const ast::PointerVar &node) override
Go through the tree while checking the parents.
void visit_derivimplicit_callback(const ast::DerivimplicitCallback &node) override
Go through the tree while checking the parents.
void visit_while_statement(const ast::WhileStatement &node) override
Go through the tree while checking the parents.
void visit_mutex_unlock(const ast::MutexUnlock &node) override
Go through the tree while checking the parents.
void visit_react_var_name(const ast::ReactVarName &node) override
Go through the tree while checking the parents.
void visit_protect_statement(const ast::ProtectStatement &node) override
Go through the tree while checking the parents.
void visit_assigned_definition(const ast::AssignedDefinition &node) override
Go through the tree while checking the parents.
void visit_breakpoint_block(const ast::BreakpointBlock &node) override
Go through the tree while checking the parents.
void visit_indexed_name(const ast::IndexedName &node) override
Go through the tree while checking the parents.
void visit_verbatim(const ast::Verbatim &node) override
Go through the tree while checking the parents.
void visit_derivative_block(const ast::DerivativeBlock &node) override
Go through the tree while checking the parents.
void check_parent(const ast::Ast &node) const
Check the parent, throw an error if not.
void visit_limits(const ast::Limits &node) override
Go through the tree while checking the parents.
void visit_lin_equation(const ast::LinEquation &node) override
Go through the tree while checking the parents.
void visit_initial_block(const ast::InitialBlock &node) override
Go through the tree while checking the parents.
int check_ast(const ast::Ast &node)
A small wrapper to have a nicer call in parser.cpp.
void visit_global_var(const ast::GlobalVar &node) override
Go through the tree while checking the parents.
void visit_binary_expression(const ast::BinaryExpression &node) override
Go through the tree while checking the parents.
void visit_else_if_statement(const ast::ElseIfStatement &node) override
Go through the tree while checking the parents.
void visit_destructor_block(const ast::DestructorBlock &node) override
Go through the tree while checking the parents.
void visit_ba_block_type(const ast::BABlockType &node) override
Go through the tree while checking the parents.
void visit_param_assign(const ast::ParamAssign &node) override
Go through the tree while checking the parents.
void visit_constant_var(const ast::ConstantVar &node) override
Go through the tree while checking the parents.
void visit_before_block(const ast::BeforeBlock &node) override
Go through the tree while checking the parents.
void visit_block(const ast::Block &node) override
Go through the tree while checking the parents.
void visit_boolean(const ast::Boolean &node) override
Go through the tree while checking the parents.
void visit_string(const ast::String &node) override
Go through the tree while checking the parents.
void visit_statement(const ast::Statement &node) override
Go through the tree while checking the parents.
void visit_useion(const ast::Useion &node) override
Go through the tree while checking the parents.
void visit_constant_statement(const ast::ConstantStatement &node) override
Go through the tree while checking the parents.
void visit_if_statement(const ast::IfStatement &node) override
Go through the tree while checking the parents.
void visit_line_comment(const ast::LineComment &node) override
Go through the tree while checking the parents.
void visit_integer(const ast::Integer &node) override
Go through the tree while checking the parents.
void visit_identifier(const ast::Identifier &node) override
Go through the tree while checking the parents.
void visit_longitudinal_diffusion_block(const ast::LongitudinalDiffusionBlock &node) override
Go through the tree while checking the parents.
void visit_solve_block(const ast::SolveBlock &node) override
Go through the tree while checking the parents.
void visit_paren_expression(const ast::ParenExpression &node) override
Go through the tree while checking the parents.
void visit_double(const ast::Double &node) override
Go through the tree while checking the parents.
void visit_expression(const ast::Expression &node) override
Go through the tree while checking the parents.
void visit_update_dt(const ast::UpdateDt &node) override
Go through the tree while checking the parents.
void visit_node(const ast::Node &node) override
Go through the tree while checking the parents.
void visit_valence(const ast::Valence &node) override
Go through the tree while checking the parents.
void visit_diff_eq_expression(const ast::DiffEqExpression &node) override
Go through the tree while checking the parents.
void visit_unary_operator(const ast::UnaryOperator &node) override
Go through the tree while checking the parents.
void visit_else_statement(const ast::ElseStatement &node) override
Go through the tree while checking the parents.
void visit_statement_block(const ast::StatementBlock &node) override
Go through the tree while checking the parents.
void visit_procedure_block(const ast::ProcedureBlock &node) override
Go through the tree while checking the parents.
void visit_function_table_block(const ast::FunctionTableBlock &node) override
Go through the tree while checking the parents.
void visit_function_block(const ast::FunctionBlock &node) override
Go through the tree while checking the parents.
void visit_reaction_operator(const ast::ReactionOperator &node) override
Go through the tree while checking the parents.
encapsulates code generation backend implementations
static Node * node(Object *)
Base class for all Abstract Syntax Tree node types.