From 2a7ee3d05658d8f88b0752b951d051f309ec7db0 Mon Sep 17 00:00:00 2001 From: sebastien Date: Mon, 25 Aug 2008 16:45:39 +0000 Subject: [PATCH] v4 preprocessor: * DynareBison.yy: added missing declaration of MODEL_INFO as a token * various cosmetic changes git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1995 ac1d8469-bf42-47a9-8791-bf33cf982152 --- preprocessor/ComputingTasks.cc | 8 +++----- preprocessor/DynareBison.yy | 4 ++-- preprocessor/DynareMain.cc | 1 - preprocessor/DynareMain2.cc | 4 ++-- preprocessor/ParsingDriver.cc | 4 +--- preprocessor/include/ComputingTasks.hh | 4 ++-- preprocessor/include/ParsingDriver.hh | 4 ++-- preprocessor/macro/MacroDriver.hh | 8 ++++---- 8 files changed, 16 insertions(+), 21 deletions(-) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 26f8fff99..8de0bcc0c 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -68,23 +68,21 @@ CheckStatement::checkPass(ModFileStructure &mod_file_struct) mod_file_struct.check_present = true; } -Model_InfoStatement::Model_InfoStatement(const OptionsList &options_list_arg) : +ModelInfoStatement::ModelInfoStatement(const OptionsList &options_list_arg) : options_list(options_list_arg) { } -void Model_InfoStatement::checkPass(ModFileStructure &mod_file_struct) +void ModelInfoStatement::checkPass(ModFileStructure &mod_file_struct) { - //mod_file_struct.model_info_present = true; } -void Model_InfoStatement::writeOutput(ostream &output, const string &basename) const +void ModelInfoStatement::writeOutput(ostream &output, const string &basename) const { options_list.writeOutput(output); output << "model_info();\n"; } - SimulStatement::SimulStatement(const OptionsList &options_list_arg) : options_list(options_list_arg) { diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 2fee306cc..c2d518638 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -98,7 +98,7 @@ class ParsingDriver; %token KALMAN_ALGO KALMAN_TOL %token LAPLACE LCC_COMPILER LIK_ALGO LIK_INIT LINEAR LOAD_MH_FILE LOGLINEAR LU MARKOWITZ MAX %token METHOD MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER MIN -%token MODE_CHECK MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MSHOCKS +%token MODE_CHECK MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS %token MODEL_COMPARISON_APPROXIMATION MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER %token NAME %token NO_COMPILER NOBS NOCONSTANT NOCORR NODIAGNOSTIC NOFUNCTIONS @@ -615,7 +615,7 @@ check_options : o_solve_algo; model_info : MODEL_INFO ';' { driver.model_info(); } - ; + ; simul : SIMUL ';' { driver.simulate(); } diff --git a/preprocessor/DynareMain.cc b/preprocessor/DynareMain.cc index 7a32a3a0a..61dc9bbb8 100644 --- a/preprocessor/DynareMain.cc +++ b/preprocessor/DynareMain.cc @@ -86,7 +86,6 @@ main(int argc, char** argv) } // Do the rest - main2(macro_output, basename, debug, clear_all); return 0; diff --git a/preprocessor/DynareMain2.cc b/preprocessor/DynareMain2.cc index 7061e71e2..53a5584d2 100644 --- a/preprocessor/DynareMain2.cc +++ b/preprocessor/DynareMain2.cc @@ -28,10 +28,10 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all) { ParsingDriver p; - //cout << "OK\n"; + // Do parsing and construct internal representation of mod file ModFile *mod_file = p.parse(in, debug); - //cout << "OK1\n"; + // Run checking pass mod_file->checkPass(); diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index ac254e3e9..267ed92a9 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -729,15 +729,13 @@ ParsingDriver::simul() options_list.clear(); } - void ParsingDriver::model_info() { - mod_file->addStatement(new Model_InfoStatement(options_list)); + mod_file->addStatement(new ModelInfoStatement(options_list)); options_list.clear(); } - void ParsingDriver::check() { diff --git a/preprocessor/include/ComputingTasks.hh b/preprocessor/include/ComputingTasks.hh index f497a45bf..1d5a749b5 100644 --- a/preprocessor/include/ComputingTasks.hh +++ b/preprocessor/include/ComputingTasks.hh @@ -76,12 +76,12 @@ public: virtual void writeOutput(ostream &output, const string &basename) const; }; -class Model_InfoStatement : public Statement +class ModelInfoStatement : public Statement { private: const OptionsList options_list; public: - Model_InfoStatement(const OptionsList &options_list_arg); + ModelInfoStatement(const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct); virtual void writeOutput(ostream &output, const string &basename) const; }; diff --git a/preprocessor/include/ParsingDriver.hh b/preprocessor/include/ParsingDriver.hh index c9da8d05b..fd2825385 100644 --- a/preprocessor/include/ParsingDriver.hh +++ b/preprocessor/include/ParsingDriver.hh @@ -54,7 +54,7 @@ using namespace std; class DynareFlex : public DynareFlexLexer { public: - DynareFlex(std::istream* in = 0, ostream* out = 0); + DynareFlex(istream* in = 0, ostream* out = 0); //! The main lexing function Dynare::parser::token_type lex(Dynare::parser::semantic_type *yylval, @@ -146,7 +146,7 @@ public: //! Starts parsing, and constructs the MOD file representation /*! The returned pointer should be deleted after use */ - ModFile *parse(std::istream &in, bool debug); + ModFile *parse(istream &in, bool debug); //! Reference to the lexer class DynareFlex *lexer; diff --git a/preprocessor/macro/MacroDriver.hh b/preprocessor/macro/MacroDriver.hh index 63bded30b..cb8a29e25 100644 --- a/preprocessor/macro/MacroDriver.hh +++ b/preprocessor/macro/MacroDriver.hh @@ -53,12 +53,12 @@ private: class ScanContext { public: - std::istream *input; + istream *input; struct yy_buffer_state *buffer; const Macro::parser::location_type yylloc; const string for_body; const Macro::parser::location_type for_body_loc; - ScanContext(std::istream *input_arg, struct yy_buffer_state *buffer_arg, + ScanContext(istream *input_arg, struct yy_buffer_state *buffer_arg, Macro::parser::location_type &yylloc_arg, const string &for_body_arg, Macro::parser::location_type &for_body_loc_arg) : input(input_arg), buffer(buffer_arg), yylloc(yylloc_arg), for_body(for_body_arg), @@ -70,7 +70,7 @@ private: //! Input stream used for initialization of current scanning context /*! Kept for deletion at end of current scanning buffer */ - std::istream *input; + istream *input; //! If current context is the body of a loop, contains the string of the loop body. Empty otherwise. string for_body; @@ -125,7 +125,7 @@ private: and initialise a new scanning context with the loop body */ bool iter_loop(MacroDriver &driver, Macro::parser::location_type *yylloc); public: - MacroFlex(std::istream* in = 0, ostream* out = 0); + MacroFlex(istream* in = 0, ostream* out = 0); //! The main lexing function Macro::parser::token_type lex(Macro::parser::semantic_type *yylval,