NEURON
main_c.cpp
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 #include <CLI/CLI.hpp>
9 
10 #include "config/config.h"
11 #include "utils/logger.hpp"
12 
13 #include "parser/c11_driver.hpp"
14 
15 /**
16  * \file
17  * Standalone parser program for C. This demonstrate basic
18  * usage of parser and driver class.
19  */
20 
21 using namespace nmodl;
22 
23 int main(int argc, const char* argv[]) {
24  CLI::App app{fmt::format("C-Parser : Standalone Parser for C Code({})", Version::to_string())};
25 
26  std::vector<std::string> files;
27  app.add_option("file", files, "One or more C files to process")
28  ->required()
29  ->check(CLI::ExistingFile);
30 
31  CLI11_PARSE(app, argc, argv);
32 
33  for (const auto& f: files) {
34  logger->info("Processing {}", f);
35  std::ifstream file(f);
36 
37  /// driver object creates lexer and parser
39  driver.set_verbose(true);
40 
41  /// just call parser method
42  driver.parse_stream(file);
43  }
44  return 0;
45 }
Class that binds all pieces together for parsing C verbatim blocks.
Definition: c11_driver.hpp:37
bool parse_stream(std::istream &in)
parse Units file provided as istream
Definition: unit_driver.cpp:18
static int argc
Definition: inithoc.cpp:45
static char ** argv
Definition: inithoc.cpp:46
int main(int argc, const char *argv[])
Definition: main_c.cpp:46
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
logger_type logger
Definition: logger.cpp:34
static std::string to_string()
return version string (version + git id) as a string
Definition: config.h:39
nmodl::parser::UnitDriver driver
Definition: parser.cpp:28