17 #include <unordered_map>
82 std::shared_ptr<ast::Program>
astRoot =
nullptr;
89 std::unordered_map<std::string, const location*>
open_files;
110 std::shared_ptr<ast::Program>
parse_stream(std::istream& in);
113 std::shared_ptr<ast::Program>
parse_string(
const std::string& input);
121 std::shared_ptr<ast::Program>
parse_file(
const std::filesystem::path& filename,
124 std::shared_ptr<ast::Include>
parse_include(
const std::filesystem::path& filename,
136 const std::shared_ptr<ast::Program>&
get_ast() const noexcept {
157 const std::string& message);
static FileLibrary default_instance()
Initialize the library with the following path:
Represents top level AST node for whole NMODL input.
Class that binds all pieces together for parsing nmodl file.
std::shared_ptr< ast::Include > parse_include(const std::filesystem::path &filename, const location &loc)
void parse_error(const location &location, const std::string &message)
Emit a parsing error.
std::shared_ptr< ast::Program > astRoot
root of the ast
std::shared_ptr< ast::Program > parse_file(const std::filesystem::path &filename, const location *loc=nullptr)
parse NMODL file
FileLibrary library
The file library for IMPORT directives.
std::shared_ptr< ast::Program > parse_string(const std::string &input)
parser nmodl provided as string (used for testing)
bool trace_scanner
enable debug output in the flex scanner
int get_defined_var_value(const std::string &name) const
return variable's value defined as macro (always an integer)
void add_defined_var(const std::string &name, int value)
add macro definition and it's value (DEFINE keyword of nmodl)
std::string stream_name
file or input stream name (used by scanner for position), see todo
std::unordered_map< std::string, const location * > open_files
The list of open files, and the location of the request.
bool is_defined_var(const std::string &name) const
check if particular text is defined as macro
std::string check_include_argument(const location &location, const std::string &filename)
Ensure file argument given to the INCLUDE directive is valid:
std::unordered_map< std::string, int > defined_var
all macro defined in the mod file
void set_ast(ast::Program *node) noexcept
set new ast root
bool trace_parser
enable debug output in the bison parser
const std::shared_ptr< ast::Program > & get_ast() const noexcept
return previously parsed AST otherwise nullptr
std::ostringstream parser_stream
The stream where Bison will dump its logs.
std::shared_ptr< ast::Program > parse_stream(std::istream &in)
parse nmodl file provided as istream
bool verbose
print messages from lexer/parser
bool is_verbose() const noexcept
Represent Lexer/Scanner class for NMODL language parsing.
static double location(void *v)
Auto generated AST classes declaration.
encapsulates code generation backend implementations
static Node * node(Object *)