![]() |
User Guide
|
encapsulates code generation backend implementations More...
encapsulates code generation backend implementations
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
encapsulates everything related to NMODL code generation framework
Namespaces | |
ast | |
Abstract Syntax Tree (AST) related implementations. | |
codegen | |
crout | |
details | |
details of lexer tokens | |
docstring | |
docstring of Python exposed API | |
newton | |
newton solver implementations | |
parser | |
encapsulate lexer and parsers implementations | |
printer | |
implementation of various printers | |
pybind_wrappers | |
stringutils | |
string utility functions | |
symtab | |
Symbol table related implementations | |
test_utils | |
custom type to represent nmodl construct for testing | |
units | |
encapsulates unit database and tables implementation | |
utils | |
file/string manipulation functions | |
visitor | |
Implementation of different AST visitors. | |
Classes | |
struct | CMakeInfo |
class | CodegenTransformVisitor |
Visitor to make last transformation to AST before codegen. More... | |
class | FileLibrary |
Manage search path. More... | |
struct | Logger |
Logger implementation based on spdlog. More... | |
class | ModToken |
Represent token returned by scanner. More... | |
struct | NrnUnitsLib |
Information of units database i.e. More... | |
class | PyNmodlDriver |
Class to bridge C++ NmodlDriver with Python world using pybind11. More... | |
struct | Version |
Project version information. More... | |
Typedefs | |
using | SymbolType = parser::NmodlParser::symbol_type |
using | Token = parser::NmodlParser::token |
using | TokenType = parser::NmodlParser::token_type |
using | LocationType = nmodl::parser::location |
using | Parser = parser::NmodlParser |
using | PositionType = parser::location |
using | logger_type = std::shared_ptr< spdlog::logger > |
Functions | |
void | tokenize (const std::string &mod_text) |
std::ostream & | operator<< (std::ostream &stream, const ModToken &mt) |
ModToken | operator+ (ModToken const &adder1, ModToken const &adder2) |
SymbolType | double_symbol (const std::string &value, PositionType &pos) |
Create a symbol for ast::Double AST class. More... | |
SymbolType | integer_symbol (int value, PositionType &pos, const char *text) |
Create a symbol for ast::Integer AST. More... | |
SymbolType | name_symbol (const std::string &text, PositionType &pos, TokenType type) |
Create symbol for ast::Name AST class. More... | |
SymbolType | prime_symbol (std::string text, PositionType &pos) |
Create symbol for ast::Prime AST class. More... | |
SymbolType | string_symbol (const std::string &text, PositionType &pos) |
Create symbol for ast::String AST class. More... | |
SymbolType | token_symbol (const std::string &key, PositionType &pos, TokenType type) |
Create symbol for AST class. More... | |
bool | is_keyword (const std::string &name) |
Check if given name is a keyword in NMODL. More... | |
bool | is_method (const std::string &name) |
Check if given name is an integration method in NMODL. More... | |
TokenType | token_type (const std::string &name) |
Return token type for given token name. More... | |
std::vector< std::string > | get_external_variables () |
Return variables declared in NEURON that are available to NMODL. More... | |
std::vector< std::string > | get_external_functions () |
Return functions that can be used in the NMODL. More... | |
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 More... | |
std::vector< std::shared_ptr< ast::Ast > > | collect_nodes (ast::Ast &node, const std::vector< ast::AstNodeType > &types={}) |
traverse node recursively and collect nodes of given types More... | |
bool | node_exists (const ast::Ast &node, ast::AstNodeType ast_type) |
Whether a node of type ast_type exists as a subnode of node . More... | |
bool | solver_exists (const ast::Ast &node, const std::string &name) |
Whether or not a solver of type name exists in the AST. More... | |
std::string | to_nmodl (const ast::Ast &node, const std::set< ast::AstNodeType > &exclude_types={}) |
Given AST node, return the NMODL string representation. More... | |
std::string | to_json (const ast::Ast &node, bool compact=false, bool expand=false, bool add_nmodl=false) |
Given AST node, return the JSON string representation. More... | |
std::string | statement_dependencies_key (const std::shared_ptr< ast::Expression > &lhs) |
The result.first of statement_dependencies . More... | |
std::pair< std::string, std::unordered_set< std::string > > | statement_dependencies (const std::shared_ptr< ast::Expression > &lhs, const std::shared_ptr< ast::Expression > &rhs) |
If lhs and rhs combined represent an assignment (we assume to have an "=" in between them) we extract the variables on which the assigned variable depends on. More... | |
std::string | get_indexed_name (const ast::IndexedName &node) |
Given a Indexed node, return the name with index. More... | |
std::string | get_full_var_name (const ast::VarName &node) |
Given a VarName node, return the full var name including index. More... | |
bool | is_random_construct_function (const std::string &name) |
Is given name a one of the function for RANDOM construct. More... | |
bool | is_nrn_pointing (const std::string &name) |
Is given name nrn_pointing . More... | |
template<typename T > | |
std::enable_if< std::is_base_of< ast::Ast, T >::value, std::string >::type | to_nmodl (const std::shared_ptr< T > &node, const std::set< ast::AstNodeType > &exclude_types={}) |
Given a shared pointer to an AST node, return the NMODL string representation. More... | |
Variables | |
Logger | nmodl_logger ("NMODL", "[%n] [%^%l%$] :: %v") |
logger_type | logger = nmodl_logger.logger |
using nmodl::LocationType = typedef nmodl::parser::location |
Definition at line 12 of file modtoken.cpp.
typedef std::shared_ptr< spdlog::logger > nmodl::logger_type |
Definition at line 19 of file logger.cpp.
using nmodl::Parser = typedef parser::NmodlParser |
Definition at line 19 of file nmodl_utils.cpp.
using nmodl::PositionType = typedef parser::location |
Definition at line 25 of file nmodl_utils.hpp.
Definition at line 33 of file main_nmodl.cpp.
typedef parser::NmodlParser::token nmodl::Token |
Definition at line 34 of file main_nmodl.cpp.
typedef parser::NmodlParser::token_type nmodl::TokenType |
Definition at line 35 of file main_nmodl.cpp.
std::vector< std::shared_ptr< ast::Ast > > nmodl::collect_nodes | ( | ast::Ast & | node, |
const std::vector< ast::AstNodeType > & | types | ||
) |
traverse node recursively and collect nodes of given types
Definition at line 213 of file visitor_utils.cpp.
std::vector< std::shared_ptr< const ast::Ast > > nmodl::collect_nodes | ( | const ast::Ast & | node, |
const std::vector< ast::AstNodeType > & | types | ||
) |
traverse node recursively and collect nodes of given types
Definition at line 206 of file visitor_utils.cpp.
SymbolType nmodl::double_symbol | ( | const std::string & | value, |
PositionType & | pos | ||
) |
Create a symbol for ast::Double AST class.
value | Double value parsed by lexer |
pos | Position of value in the mod file |
Definition at line 28 of file nmodl_utils.cpp.
std::vector< std::string > nmodl::get_external_functions | ( | ) |
Return functions that can be used in the NMODL.
Definition at line 308 of file token_mapping.cpp.
std::vector< std::string > nmodl::get_external_variables | ( | ) |
Return variables declared in NEURON that are available to NMODL.
Definition at line 299 of file token_mapping.cpp.
std::string nmodl::get_full_var_name | ( | const ast::VarName & | node | ) |
Given a VarName node, return the full var name including index.
Definition at line 286 of file visitor_utils.cpp.
std::string nmodl::get_indexed_name | ( | const ast::IndexedName & | node | ) |
Given a Indexed node, return the name with index.
Definition at line 282 of file visitor_utils.cpp.
SymbolType nmodl::integer_symbol | ( | int | value, |
PositionType & | pos, | ||
const char * | text | ||
) |
Create a symbol for ast::Integer AST.
ast::Integer class also represent macro definition and hence could have associated text.
value | Integer value parsed by lexer |
pos | Position of value in the mod file |
text | associated macro for the value |
Definition at line 47 of file nmodl_utils.cpp.
bool nmodl::is_keyword | ( | const std::string & | name | ) |
Check if given name is a keyword in NMODL.
name | token name |
Definition at line 264 of file token_mapping.cpp.
bool nmodl::is_method | ( | const std::string & | name | ) |
Check if given name is an integration method in NMODL.
name | Name of the integration method |
Definition at line 274 of file token_mapping.cpp.
bool nmodl::is_nrn_pointing | ( | const std::string & | name | ) |
Is given name nrn_pointing
.
Definition at line 301 of file visitor_utils.cpp.
bool nmodl::is_random_construct_function | ( | const std::string & | name | ) |
Is given name a one of the function for RANDOM construct.
Definition at line 297 of file visitor_utils.cpp.
SymbolType nmodl::name_symbol | ( | const std::string & | text, |
PositionType & | pos, | ||
TokenType | type | ||
) |
Create symbol for ast::Name AST class.
text | Text value parsed by lexer |
pos | Position of value in the mod file |
type | Token type returned by lexer (see parser::NmodlParser::token::yytokentype) |
Definition at line 75 of file nmodl_utils.cpp.
bool nmodl::node_exists | ( | const ast::Ast & | node, |
ast::AstNodeType | ast_type | ||
) |
Whether a node of type ast_type
exists as a subnode of node
.
Definition at line 219 of file visitor_utils.cpp.
For example:
Output:
Definition at line 32 of file modtoken.cpp.
std::ostream& nmodl::operator<< | ( | std::ostream & | stream, |
const ModToken & | mt | ||
) |
Overload ostream operator to print token in the form :
For example:
Definition at line 26 of file modtoken.cpp.
SymbolType nmodl::prime_symbol | ( | std::string | text, |
PositionType & | pos | ||
) |
Create symbol for ast::Prime AST class.
ast::Prime has name as well as order. Text returned by lexer has single quote (‘’`) as an order. We count the order and remove quote from the text.
text | Prime variable name parsed by lexer |
pos | Position of text in the mod file |
Definition at line 93 of file nmodl_utils.cpp.
bool nmodl::solver_exists | ( | const ast::Ast & | node, |
const std::string & | name | ||
) |
Whether or not a solver of type name exists in the AST.
Definition at line 224 of file visitor_utils.cpp.
std::pair< std::string, std::unordered_set< std::string > > nmodl::statement_dependencies | ( | const std::shared_ptr< ast::Expression > & | lhs, |
const std::shared_ptr< ast::Expression > & | rhs | ||
) |
If lhs
and rhs
combined represent an assignment (we assume to have an "=" in between them) we extract the variables on which the assigned variable depends on.
We provide the input with lhs and rhs because there are a few nodes that have this similar structure but slightly different naming (binaryExpression, diff_eq_expression, linExpression)
Definition at line 262 of file visitor_utils.cpp.
std::string nmodl::statement_dependencies_key | ( | const std::shared_ptr< ast::Expression > & | lhs | ) |
The result.first
of statement_dependencies
.
Definition at line 253 of file visitor_utils.cpp.
SymbolType nmodl::string_symbol | ( | const std::string & | text, |
PositionType & | pos | ||
) |
Create symbol for ast::String AST class.
text | Text value parsed by lexer |
pos | Position of value in the mod file |
Definition at line 113 of file nmodl_utils.cpp.
std::string nmodl::to_json | ( | const ast::Ast & | node, |
bool | compact, | ||
bool | expand, | ||
bool | add_nmodl | ||
) |
Given AST node, return the JSON string representation.
Definition at line 242 of file visitor_utils.cpp.
std::string nmodl::to_nmodl | ( | const ast::Ast & | node, |
const std::set< ast::AstNodeType > & | exclude_types | ||
) |
Given AST node, return the NMODL string representation.
Definition at line 234 of file visitor_utils.cpp.
std::enable_if<std::is_base_of<ast::Ast, T>::value, std::string>::type nmodl::to_nmodl | ( | const std::shared_ptr< T > & | node, |
const std::set< ast::AstNodeType > & | exclude_types = {} |
||
) |
Given a shared pointer to an AST node, return the NMODL string representation.
Definition at line 115 of file visitor_utils.hpp.
SymbolType nmodl::token_symbol | ( | const std::string & | key, |
PositionType & | pos, | ||
TokenType | type | ||
) |
Create symbol for AST class.
These tokens doesn't have specific value to pass to the parser. They are more part of grammar. Depending on the type of toke, we create appropriate symbol. From lexer we pass token type (which is optional). This is required for reaction parsing where we have "lexical context". Hence, if token type is passed then we don't check/search for the token type.
key | Text parsed by lexer |
pos | Position of value in the mod file |
type | Token type returned by lexer (see parser::NmodlParser::token::yytokentype) |
if token type is not passed, check if it is keyword or method
we hit default case for missing token type. This is more likely a bug in the implementation where we forgot to handle token type.
Definition at line 135 of file nmodl_utils.cpp.
parser::NmodlParser::token_type nmodl::token_type | ( | const std::string & | name | ) |
Return token type for given token name.
name | Token name from lexer |
Definition at line 284 of file token_mapping.cpp.
void nmodl::tokenize | ( | const std::string & | mod_text | ) |
lexer instance use driver object for error reporting
lexer instance with stream to read-in tokens
parse nmodl text and print token until EOF
Lexer returns different ast types base on token type. We retrieve token object from each instance and print it. Note that value is of ast type i.e. ast::Name* etc.
token with name ast class
token with prime ast class
token with integer ast class
token with double/float ast class
token with string ast class
token with string data type
all remaining tokens has ModToken* as a vaue
Definition at line 38 of file main_nmodl.cpp.
logger_type nmodl::logger = nmodl_logger.logger |
Definition at line 34 of file logger.cpp.
Logger nmodl::nmodl_logger("NMODL", "[%n] [%^%l%$] :: %v") |