v4 preprocessor: minor improvement related to debugging of scanning & parsing
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1751 ac1d8469-bf42-47a9-8791-bf33cf982152issue#70
parent
32bf5c7525
commit
76da313b98
|
@ -32,8 +32,7 @@ using namespace std;
|
|||
Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be
|
||||
included simultaneously (because of Bison limitations).
|
||||
*/
|
||||
void main2(stringstream &in, string &basename, bool trace_scanning, bool trace_parsing,
|
||||
bool clear_all);
|
||||
void main2(stringstream &in, string &basename, bool debug, bool clear_all);
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
|
@ -47,17 +46,13 @@ main(int argc, char** argv)
|
|||
|
||||
bool clear_all = true;
|
||||
bool save_macro = false;
|
||||
bool trace_scanning = false;
|
||||
bool trace_parsing = false;
|
||||
bool debug = false;
|
||||
|
||||
// Parse options
|
||||
for (int arg = 2; arg < argc; arg++)
|
||||
{
|
||||
if (string(argv[arg]) == string("debug"))
|
||||
{
|
||||
trace_scanning = true;
|
||||
trace_parsing = true;
|
||||
}
|
||||
debug = true;
|
||||
else if (string(argv[arg]) == string("noclearall"))
|
||||
clear_all = false;
|
||||
else if (string(argv[arg]) == string("savemacro"))
|
||||
|
@ -79,9 +74,8 @@ main(int argc, char** argv)
|
|||
basename.erase(basename.size() - 4, 4);
|
||||
|
||||
// Do macro processing
|
||||
MacroDriver m;
|
||||
m.trace_scanning = trace_scanning;
|
||||
m.trace_parsing = trace_parsing;
|
||||
MacroDriver m(debug);
|
||||
|
||||
stringstream macro_output;
|
||||
m.parse(argv[1], macro_output);
|
||||
if (save_macro)
|
||||
|
@ -92,7 +86,7 @@ main(int argc, char** argv)
|
|||
}
|
||||
|
||||
// Do the rest
|
||||
main2(macro_output, basename, trace_scanning, trace_parsing, clear_all);
|
||||
main2(macro_output, basename, debug, clear_all);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,11 +25,9 @@ using namespace std;
|
|||
#include "ModFile.hh"
|
||||
|
||||
void
|
||||
main2(stringstream &in, string &basename, bool trace_scanning, bool trace_parsing, bool clear_all)
|
||||
main2(stringstream &in, string &basename, bool debug, bool clear_all)
|
||||
{
|
||||
ParsingDriver p;
|
||||
p.trace_scanning = trace_scanning;
|
||||
p.trace_parsing = trace_parsing;
|
||||
ParsingDriver p(debug);
|
||||
|
||||
// Do parsing and construct internal representation of mod file
|
||||
ModFile *mod_file = p.parse(in);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "ParsingDriver.hh"
|
||||
#include "Statement.hh"
|
||||
|
||||
ParsingDriver::ParsingDriver() : trace_scanning(false), trace_parsing(false)
|
||||
ParsingDriver::ParsingDriver(bool debug_arg) : debug(debug_arg)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -70,9 +70,10 @@ ParsingDriver::parse(istream &in)
|
|||
reset_data_tree();
|
||||
|
||||
lexer = new DynareFlex(&in);
|
||||
lexer->set_debug(trace_scanning);
|
||||
lexer->set_debug(debug);
|
||||
|
||||
Dynare::parser parser(*this);
|
||||
parser.set_debug_level(debug);
|
||||
parser.parse();
|
||||
|
||||
delete lexer;
|
||||
|
|
|
@ -137,9 +137,12 @@ private:
|
|||
//! The mod file representation constructed by this ParsingDriver
|
||||
ModFile *mod_file;
|
||||
|
||||
//! Output debugging info during scanning and parsing ?
|
||||
const bool debug;
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
ParsingDriver();
|
||||
ParsingDriver(bool debug_arg);
|
||||
//! Destructor
|
||||
virtual ~ParsingDriver();
|
||||
|
||||
|
@ -153,15 +156,6 @@ public:
|
|||
//! Copy of parsing location, maintained by YYLLOC_DEFAULT macro in DynareBison.yy
|
||||
Dynare::parser::location_type location;
|
||||
|
||||
//! Trace scanning ?
|
||||
/*! If set to true before calling parse(), the flex scanner will dump a lot of debugging information. Defaults to false.
|
||||
*/
|
||||
bool trace_scanning;
|
||||
|
||||
//! Trace parsing ?
|
||||
/*! If set to true before calling parse(), the bison parser will dump debugging information. Defaults to false. */
|
||||
bool trace_parsing;
|
||||
|
||||
//! Estimation parameters
|
||||
EstimationParams estim_params;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "MacroDriver.hh"
|
||||
|
||||
MacroDriver::MacroDriver() : trace_scanning(false), trace_parsing(false)
|
||||
MacroDriver::MacroDriver(bool debug_arg) : debug(debug_arg)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,10 @@ MacroDriver::parse(const string &f, ostream &out)
|
|||
}
|
||||
|
||||
lexer = new MacroFlex(&in, &out);
|
||||
lexer->set_debug(trace_scanning);
|
||||
lexer->set_debug(debug);
|
||||
|
||||
Macro::parser parser(*this, out);
|
||||
parser.set_debug_level(debug);
|
||||
parser.parse();
|
||||
|
||||
delete lexer;
|
||||
|
|
|
@ -138,6 +138,9 @@ class MacroDriver
|
|||
{
|
||||
friend class MacroValue;
|
||||
private:
|
||||
//! Output debugging info during scanning and parsing ?
|
||||
const bool debug;
|
||||
|
||||
//! Stores all created macro values
|
||||
set<const MacroValue *> values;
|
||||
|
||||
|
@ -157,7 +160,7 @@ public:
|
|||
};
|
||||
|
||||
//! Constructor
|
||||
MacroDriver();
|
||||
MacroDriver(bool debug_arg);
|
||||
//! Destructor
|
||||
virtual ~MacroDriver();
|
||||
|
||||
|
@ -176,15 +179,6 @@ public:
|
|||
//! Used to store the value of the last @if condition
|
||||
bool last_if;
|
||||
|
||||
//! Trace scanning ?
|
||||
/*! If set to true before calling parse(), the flex scanner will dump a lot of debugging information. Defaults to false.
|
||||
*/
|
||||
bool trace_scanning;
|
||||
|
||||
//! Trace parsing ?
|
||||
/*! If set to true before calling parse(), the bison parser will dump debugging information. Defaults to false. */
|
||||
bool trace_parsing;
|
||||
|
||||
//! Error handler
|
||||
void error(const Macro::parser::location_type &l, const string &m) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue