User Guide
diffeq_driver.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #pragma once
9 
10 #include <string>
11 
13 
14 
15 namespace nmodl {
16 namespace parser {
17 
18 /// flex generated scanner class (extends base lexer class of flex)
19 class DiffeqlLexer;
20 
21 /// parser class generated by bison
22 class DiffeqParser;
23 
24 /**
25  * @addtogroup parser
26  * @{
27  */
28 
29 /**
30  * \class DiffeqDriver
31  * \brief Class that binds all pieces together for parsing differential equations
32  *
33  * Driver class bind components required for lexing, parsing and ast
34  * generation for differential equations.
35  */
36 class DiffeqDriver {
37  private:
38  static std::string solve_equation(std::string& state,
39  int order,
40  std::string& rhs,
41  std::string& method,
42  bool& cnexp_possible,
43  bool debug = false);
44 
45  /// parse given equation into lhs, rhs and find it's order and state variable
46  static void parse_equation(const std::string& equation,
47  std::string& state,
48  std::string& rhs,
49  int& order);
50 
51  public:
52  DiffeqDriver() = default;
53 
54  /// solve equation using provided method
55  static std::string solve(const std::string& equation, std::string method, bool debug = false);
56 
57  /// check if given equation can be solved using cnexp method
58  static bool cnexp_possible(const std::string& equation, std::string& solution);
59 };
60 
61 /** @} */ // end of parser
62 
63 } // namespace parser
64 } // namespace nmodl
nmodl::parser::DiffeqDriver::cnexp_possible
static bool cnexp_possible(const std::string &equation, std::string &solution)
check if given equation can be solved using cnexp method
Definition: diffeq_driver.cpp:64
nmodl
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
nmodl::parser::DiffeqDriver::solve_equation
static std::string solve_equation(std::string &state, int order, std::string &rhs, std::string &method, bool &cnexp_possible, bool debug=false)
Definition: diffeq_driver.cpp:46
nmodl::parser::DiffeqDriver::parse_equation
static void parse_equation(const std::string &equation, std::string &state, std::string &rhs, int &order)
parse given equation into lhs, rhs and find it's order and state variable
Definition: diffeq_driver.cpp:18
diffeq_context.hpp
nmodl::parser::DiffeqDriver
Class that binds all pieces together for parsing differential equations.
Definition: diffeq_driver.hpp:36
nmodl::parser::DiffeqDriver::solve
static std::string solve(const std::string &equation, std::string method, bool debug=false)
solve equation using provided method
Definition: diffeq_driver.cpp:38
nmodl::parser::DiffeqDriver::DiffeqDriver
DiffeqDriver()=default