|
User Guide
|
Go to the documentation of this file.
33 if (!suffix_node.empty()) {
34 const auto& suffix = std::dynamic_pointer_cast<const ast::Suffix>(suffix_node[0]);
35 const auto& type = suffix->get_type()->get_node_name();
41 using namespace symtab::syminfo;
42 const auto& with_prop = NmodlType::read_ion_var | NmodlType::write_ion_var;
45 assert(sym_table !=
nullptr);
48 const auto& ion_variables = sym_table->get_variables_with_properties(with_prop,
false);
51 for (
const auto& var: ion_variables) {
52 if (var->has_any_property(NmodlType::constant_var)) {
54 fmt::format(
"SemanticAnalysisVisitor :: ion variable {} from the USEION statement "
55 "can not be re-declared in a CONSTANT block",
69 if (derivative_block_nodes.size() > 1) {
70 logger->critical(
"It is not supported to have several DERIVATIVE blocks");
114 if (parent && parent->is_random_var()) {
118 if (parent && parent->is_var_name()) {
120 if (parent && parent->is_function_call()) {
127 if (!arguments.empty() && arguments.front()->is_var_name() &&
128 arguments.front()->get_node_name() == name) {
141 fmt::format(
"SemanticAnalysisVisitor :: RANDOM variable {} at {}"
142 " can be used only as the first arg of a random function",
158 if (!arguments.empty()) {
159 auto arg0 = arguments.front();
160 if (arg0->is_var_name()) {
161 auto name = arg0->get_node_name();
169 auto position = node.
get_name()->get_token()->position();
171 fmt::format(
"SemanticAnalysisVisitor :: random function {} at {} :: The first arg must "
172 "be a random variable",
185 "SemanticAnalysisVisitor :: The procedure or function containing the TABLE statement "
186 "should contains exactly one argument.");
194 "SemanticAnalysisVisitor :: TABLE statement in FUNCTION cannot have a table name "
199 "SemanticAnalysisVisitor :: TABLE statement in PROCEDURE must have a table name list.");
208 "SemanticAnalysisVisitor :: This mod file is not point process but contains a "
218 if (n->get_value()->get_value() !=
"t") {
220 "SemanticAnalysisVisitor :: '{}' cannot be used as an independent variable, only "
222 n->get_value()->get_value());
232 "SemanticAnalysisVisitor :: Function table '{}' must have one or more arguments.",
242 logger->error(
"PROTECT statement is not supported with GPU execution");
245 logger->warn(
"SemanticAnalysisVisitor :: Find a PROTECT inside a already locked part.");
253 logger->error(
"MUTEXLOCK statement is not supported with GPU execution");
256 logger->warn(
"SemanticAnalysisVisitor :: Found a MUTEXLOCK inside an already locked part.");
265 logger->error(
"MUTEXUNLOCK statement is not supported with GPU execution");
268 logger->warn(
"SemanticAnalysisVisitor :: Found a MUTEXUNLOCK outside a locked part.");
std::string get_node_name() const override
Return name of the node.
@ DERIVATIVE_BLOCK
type of ast::DerivativeBlock
const ArgumentVector & get_parameters() const noexcept override
Getter for member variable ProcedureBlock::parameters.
void visit_children(visitor::Visitor &v) override
visit children i.e.
const ArgumentVector & get_parameters() const noexcept override
Getter for member variable FunctionTableBlock::parameters.
bool in_mutex
true if we are inside a mutex locked part
bool in_function
true if we are in a function block
bool accel_backend
true if accelerator backend is used for code generation
std::shared_ptr< Name > get_name() const noexcept
Getter for member variable FunctionCall::name.
encapsulates code generation backend implementations
Auto generated AST classes declaration.
void visit_procedure_block(const ast::ProcedureBlock &node) override
Store if we are in a procedure and if the arity of this is 1.
Represent MUTEXLOCK statement in NMODL.
Represents TABLE statement in NMODL.
Implement various classes to represent various Symbol properties.
void visit_children(visitor::Visitor &v) override
visit children i.e.
void visit_children(visitor::Visitor &v) override
visit children i.e.
bool is_random_construct_function(const std::string &name)
Is given name a one of the function for RANDOM construct.
Auto generated AST classes declaration.
void visit_name(const ast::Name &node) override
Only use of random_var is as first arg in random function.
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
void visit_table_statement(const ast::TableStatement &node) override
Visit a table statement and check that the arity of the block were 1.
symtab::SymbolTable * program_symtab
std::string position() const
Return position of the token as string.
std::string get_node_name() const override
Return name of the node.
void visit_function_call(const ast::FunctionCall &node) override
random function first arg must be random_var
Auto generated AST classes declaration.
Utility functions for visitors implementation.
Auto generated AST classes declaration.
Auto generated AST classes declaration.
Auto generated AST classes declaration.
const ArgumentVector & get_parameters() const noexcept override
Getter for member variable FunctionBlock::parameters.
bool check(const ast::Program &node)
const NameVector & get_variables() const noexcept
Getter for member variable IndependentBlock::variables.
bool in_procedure
true if we are in a procedure block
Represents a DESTRUCTOR block in the NMODL.
Auto generated AST classes declaration.
void visit_function_block(const ast::FunctionBlock &node) override
Store if we are in a function and if the arity of this is 1.
Represent MUTEXUNLOCK statement in NMODL.
void visit_independent_block(const ast::IndependentBlock &node) override
Visit independent block and check if one of the variable is not t.
@ SUFFIX
type of ast::Suffix
void visit_children(visitor::Visitor &v) override
visit children i.e.
Auto generated AST classes declaration.
void visit_mutex_unlock(const ast::MutexUnlock &node) override
Look if MUTEXUNLOCK is outside a locked block.
const ExpressionVector & get_arguments() const noexcept
Getter for member variable FunctionCall::arguments.
void visit_program(const ast::Program &node) override
Check number of DERIVATIVE blocks.
std::vector< std::shared_ptr< const ast::Ast > > collect_nodes(const ast::Ast &node, const std::vector< ast::AstNodeType > &types)
traverse node recursively and collect nodes of given types
void visit_protect_statement(const ast::ProtectStatement &node) override
Look if protect is inside a locked block.
Auto generated AST classes declaration.
Auto generated AST classes declaration.
void visit_function_table_block(const ast::FunctionTableBlock &node) override
Visit function table to check that number of args > 0.
const NameVector & get_table_vars() const noexcept
Getter for member variable TableStatement::table_vars.
void visit_children(visitor::Visitor &v) override
visit children i.e.
std::string get_node_name() const override
Return name of the node.
Implement logger based on spdlog library.
bool one_arg_in_procedure_function
true if the procedure or the function contains only one argument
bool is_point_process
true if the mod file is of type point process
symtab::SymbolTable * get_symbol_table() const override
Return associated symbol table for the current ast node.
Represents a INDEPENDENT block in the NMODL.
void visit_destructor_block(const ast::DestructorBlock &node) override
Visit destructor and check that the file is of type POINT_PROCESS or ARTIFICIAL_CELL.
Represents top level AST node for whole NMODL input.
@ random_var
Randomvar Type.
Auto generated AST classes declaration.
std::shared_ptr< Symbol > lookup(const std::string &name) const
check if symbol with given name exist in the current table (but not in parents)
void visit_mutex_lock(const ast::MutexLock &node) override
Look if MUTEXLOCK is inside a locked block.
virtual Ast * get_parent() const
Parent getter.
virtual std::string get_node_name() const
Return name of of the node.