PandA-2024.02
c_initialization_parser.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (c) 2018-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
43 
45 #include "Parameter.hpp"
46 
49 #define YYSTYPE CInitializationParserNode
51 
54 
56 #include "dbgPrintHelper.hpp"
57 #include "fileIO.hpp"
58 #include "utility.hpp"
59 
61 {
62  debug_level = parameters->get_class_debug_level(GET_CLASS(*this));
63 }
64 
66  const std::string& initialization_string) const
67 {
69  "-->Analyzing initialization string " + initialization_string);
70  if(initialization_string.size() > DATA_SIZE_THRESHOLD)
71  {
72  std::string seed_name = "_cip";
73  auto output_parameter_initialization_filename =
74  parameters->getOption<std::string>(OPT_output_directory) + "/simulation/";
75  unsigned int progressive = 0;
76  std::string candidate_out_file_name;
77  do
78  {
79  candidate_out_file_name =
80  output_parameter_initialization_filename + seed_name + "_" + std::to_string(progressive++) + ".data";
81  } while(std::filesystem::exists(candidate_out_file_name));
82  c_initialization_parser_functor->ActivateFileInit(candidate_out_file_name);
83  }
84  const auto parsed_stream = fileIO_istream_open_from_string(initialization_string);
85  const CInitializationFlexLexerRef lexer(new CInitializationFlexLexer(parameters, parsed_stream.get(), nullptr));
86  YYParse(c_initialization_parser_functor, lexer);
87  if(initialization_string.size() > DATA_SIZE_THRESHOLD)
88  {
89  c_initialization_parser_functor->FinalizeFileInit();
90  }
91  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Analyzed initialization string " + initialization_string);
92 }
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
File containing functions and utilities to support the printing of debug messagges.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
const ParameterConstRef parameters
The set of input parameters.
Interface to parse the initialization of c variable.
fileIO_istreamRef fileIO_istream_open_from_string(const std::string &input)
Create a fileIO_istreamRef starting from a string.
Definition: fileIO.hpp:87
void Parse(CInitializationParserFunctorRef c_initialization_parser_functor, const std::string &initialization_string) const
Parse a string to generate the corresponding memory initialization.
int debug_level
The debug level.
#define DATA_SIZE_THRESHOLD
threshold used to switch from data directly printed to data written to a file and then copied ...
header file for LEX based lexer for C initialization string.
Specification of the data structure associated with a node during c initialization parsing...
utility function used to read files.
This file collects some utility functions and macros.
Specification of the abstract functor used during parsing of C initialization string.
constants used in testbench generation
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
T * get() const
Definition: refcount.hpp:169
void YYParse(const CInitializationParserFunctorRef c_initialization_parser_functor, const CInitializationFlexLexerRef lexer) const
Wrapper to yyparse.
this class is used to manage the command-line or XML options.
CInitializationParser(const ParameterConstRef parameters)
Constructor.

Generated on Mon Feb 12 2024 13:02:54 for PandA-2024.02 by doxygen 1.8.13