12 #include "config/config.h"
15 #include "utils/logger.hpp"
35 using namespace nmodl;
36 using namespace visitor;
37 namespace fs = std::filesystem;
53 template <
typename Visitor>
58 visitor.
v->visit_program(ast);
59 const std::string file = fmt::format(
"{}.{}.mod", mod_file, visitor.
id);
61 logger->info(
"NMODL visitor generated {}", file);
66 fmt::format(
"NMODL Visitor : Runs standalone visitor classes({})",
Version::to_string())};
69 std::vector<fs::path> files;
71 app.add_flag(
"-v,--verbose", verbose,
"Enable debug log level");
72 app.add_option(
"-f,--file,file", files,
"One or more MOD files to process")
74 ->check(CLI::ExistingFile);
82 const std::vector<VisitorInfo> visitors = {
83 {std::make_shared<AstVisitor>(),
"astvis",
"AstVisitor"},
84 {std::make_shared<SymtabVisitor>(),
"symtab",
"SymtabVisitor"},
85 {std::make_shared<VerbatimVarRenameVisitor>(),
87 "VerbatimVarRenameVisitor"},
88 {std::make_shared<KineticBlockVisitor>(),
"kinetic-rewrite",
"KineticBlockVisitor"},
89 {std::make_shared<ConstantFolderVisitor>(),
"const-fold",
"ConstantFolderVisitor"},
90 {std::make_shared<InlineVisitor>(),
"inline",
"InlineVisitor"},
91 {std::make_shared<LocalVarRenameVisitor>(),
"local-rename",
"LocalVarRenameVisitor"},
92 {std::make_shared<SymtabVisitor>(),
"symtab",
"SymtabVisitor"},
93 {std::make_shared<SympyConductanceVisitor>(),
95 "SympyConductanceVisitor"},
96 {std::make_shared<SympySolverVisitor>(),
"sympy-solve",
"SympySolverVisitor"},
97 {std::make_shared<NeuronSolveVisitor>(),
"neuron-solve",
"NeuronSolveVisitor"},
101 const std::vector<ConstVisitorInfo> const_visitors = {
102 {std::make_shared<JSONVisitor>(),
"json",
"JSONVisitor"},
103 {std::make_shared<test::CheckParentVisitor>(),
"check-parent",
"CheckParentVisitor"},
104 {std::make_shared<PerfVisitor>(),
"perf",
"PerfVisitor"},
105 {std::make_shared<LocalizeVisitor>(),
"localize",
"LocalizeVisitor"},
106 {std::make_shared<VerbatimVisitor>(),
"verbatim",
"VerbatimVisitor"},
111 for (
const auto& filename: files) {
112 logger->info(
"Processing {}", filename.string());
114 const std::string mod_file = filename.stem().string();
123 for (
const auto& visitor: visitors) {
126 for (
const auto& visitor: const_visitors) {
Concrete visitor for all AST classes.
Visitor for checking parents of ast nodes
Represents top level AST node for whole NMODL input.
Class that binds all pieces together for parsing nmodl file.
static EmbeddedPythonLoader & get_instance()
Construct (if not already done) and get the only instance of this class.
const pybind_wrap_api & api()
Get a pointer to the pybind_wrap_api struct.
Visitor for printing AST back to NMODL
void visit_program(const ast::Program &node) override
visit node of type ast::Program
Perform constant folding of integer/float/double expressions.
bool parse_file(const std::string &filename)
parse Units file
Visitor to inline local procedure and function calls
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
Visitor for kinetic block statements
Visitor to rename local variables conflicting with global scope
Visitor to transform global variable usage to local
encapsulates code generation backend implementations
Visitor that solves ODEs using old solvers of NEURON
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
Visitor for measuring performance related information
Auto generated AST classes declaration.
int main(int argc, const char *argv[])
void visit_program(const std::string &mod_file, const ClassInfo< Visitor > &visitor, ast::Program &ast)
static std::string get_path()
Return path of units database file.
static std::string to_string()
return version string (version + git id) as a string
decltype(&initialize_interpreter_func) initialize_interpreter
decltype(&finalize_interpreter_func) finalize_interpreter
Visitor for generating CONDUCTANCE statements for ions
Visitor for systems of algebraic and differential equations
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::parser::UnitDriver driver
Visitor for Units blocks of AST.
Rename variable in verbatim block.
Visitor for verbatim blocks of AST