ParsingDriver.hh 27.9 KB
Newer Older
sebastien's avatar
sebastien committed
1
/*
2
 * Copyright (C) 2003-2013 Dynare Team
sebastien's avatar
sebastien committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of Dynare.
 *
 * Dynare is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Dynare is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 */

20
21
22
#ifndef _PARSING_DRIVER_HH
#define _PARSING_DRIVER_HH

sebastien's avatar
sebastien committed
23
24
25
26
27
#ifdef _MACRO_DRIVER_HH
# error Impossible to include both ParsingDriver.hh and MacroDriver.hh
#endif

#include <string>
sebastien's avatar
sebastien committed
28
#include <vector>
sebastien's avatar
sebastien committed
29
#include <istream>
30
#include <stack>
31

32
#include "ModFile.hh"
sebastien's avatar
sebastien committed
33
#include "SymbolList.hh"
34
35
36

class ParsingDriver;
#include "ExprNode.hh"
37
#include "DynareBison.hh"
38

39
#include "ComputingTasks.hh"
sebastien's avatar
sebastien committed
40
41
42
#include "Shocks.hh"
#include "SigmaeInitialization.hh"
#include "NumericalInitialization.hh"
43
#include "DynamicModel.hh"
44

45
46
using namespace std;

47
48
// Declare DynareFlexLexer class
#ifndef __FLEX_LEXER_H
sebastien's avatar
sebastien committed
49
# define yyFlexLexer DynareFlexLexer
sebastien's avatar
sebastien committed
50
# include <FlexLexer.h>
sebastien's avatar
sebastien committed
51
# undef yyFlexLexer
52
53
54
55
#endif

//! The lexer class
/*! Actually it was necessary to subclass the DynareFlexLexer class generated by Flex,
56
  since the prototype for DynareFlexLexer::yylex() was not convenient.
57
58
59
60
*/
class DynareFlex : public DynareFlexLexer
{
public:
61
  DynareFlex(istream *in = 0, ostream *out = 0);
62
63

  //! The main lexing function
64
65
66
  Dynare::parser::token_type lex(Dynare::parser::semantic_type *yylval,
                                 Dynare::parser::location_type *yylloc,
                                 ParsingDriver &driver);
67
68
69
70

  //! The filename being parsed
  /*! The bison parser locations (begin and end) contain a pointer to that string */
  string filename;
71
72
73

  //! Increment the location counter given a token
  void location_increment(Dynare::parser::location_type *yylloc, const char *yytext);
74
};
75
76
77
78
79
80

//! Drives the scanning and parsing of the .mod file, and constructs its abstract representation
/*! It is built along the guidelines given in Bison 2.3 manual. */
class ParsingDriver
{
private:
81
82
83
  //! Checks that a given symbol exists, and stops with an error message if it doesn't
  void check_symbol_existence(const string &name);

84
85
86
  //! Checks that a given symbol exists and is a parameter, and stops with an error message if it isn't
  void check_symbol_is_parameter(string *name);

87
88
89
  //! Checks that a given symbol was assigned within a Statement
  void check_symbol_is_statement_variable(string *name);

90
91
92
  //! Checks that a given symbol exists and is a endogenous or exogenous, and stops with an error message if it isn't
  void check_symbol_is_endogenous_or_exogenous(string *name);

sebastien's avatar
sebastien committed
93
  //! Helper to add a symbol declaration
94
  void declare_symbol(const string *name, SymbolType type, const string *tex_name);
sebastien's avatar
sebastien committed
95

sebastien's avatar
sebastien committed
96
97
98
  //! Creates option "optim_opt" in OptionsList if it doesn't exist, else add a comma, and adds the option name
  void optim_options_helper(const string &name);

99
  //! Stores temporary symbol table
sebastien's avatar
sebastien committed
100
  SymbolList symbol_list;
sebastien's avatar
sebastien committed
101

sebastien's avatar
sebastien committed
102
103
104
  //! The data tree in which to add expressions currently parsed
  DataTree *data_tree;

sebastien's avatar
sebastien committed
105
  //! The model tree in which to add expressions currently parsed
sebastien's avatar
sebastien committed
106
  /*! It is only a dynamic cast of data_tree pointer, and is therefore null if data_tree is not a ModelTree instance */
sebastien's avatar
sebastien committed
107
108
  ModelTree *model_tree;

109
110
111
112
  //! The dynamic model tree in which to add expressions currently parsed
  /*! It is only a dynamic cast of data_tree pointer, and is therefore null if data_tree is not a DynamicModel instance */
  DynamicModel *dynamic_model;

sebastien's avatar
sebastien committed
113
114
115
  //! Sets data_tree and model_tree pointers
  void set_current_data_tree(DataTree *data_tree_arg);

sebastien's avatar
sebastien committed
116
117
118
  //! Stores options lists
  OptionsList options_list;
  //! Temporary storage for trend elements
119
  ObservationTrendsStatement::trend_elements_t trend_elements;
sebastien's avatar
sebastien committed
120
  //! Temporary storage for filename list of ModelComparison
121
  ModelComparisonStatement::filename_list_t filename_list;
sebastien's avatar
sebastien committed
122
123
124
  //! Temporary storage for list of EstimationParams (from estimated_params* statements)
  vector<EstimationParams> estim_params_list;
  //! Temporary storage of variances from optim_weights
125
  OptimWeightsStatement::var_weights_t var_weights;
sebastien's avatar
sebastien committed
126
  //! Temporary storage of covariances from optim_weights
127
  OptimWeightsStatement::covar_weights_t covar_weights;
sebastien's avatar
sebastien committed
128
  //! Temporary storage for deterministic shocks
129
  ShocksStatement::det_shocks_t det_shocks;
sebastien's avatar
sebastien committed
130
131
132
  //! Temporary storage for periods of deterministic shocks
  vector<pair<int, int> > det_shocks_periods;
  //! Temporary storage for values of deterministic shocks
133
  vector<expr_t> det_shocks_values;
134
135
  //! Temporary storage for perfect foresight of deterministic shocks in conditional forecast
  bool det_shocks_expectation_pf;
sebastien's avatar
sebastien committed
136
  //! Temporary storage for variances of shocks
137
  ShocksStatement::var_and_std_shocks_t var_shocks;
sebastien's avatar
sebastien committed
138
  //! Temporary storage for standard errors of shocks
139
  ShocksStatement::var_and_std_shocks_t std_shocks;
sebastien's avatar
sebastien committed
140
  //! Temporary storage for covariances of shocks
141
  ShocksStatement::covar_and_corr_shocks_t covar_shocks;
sebastien's avatar
sebastien committed
142
  //! Temporary storage for correlations of shocks
143
  ShocksStatement::covar_and_corr_shocks_t corr_shocks;
sebastien's avatar
sebastien committed
144
  //! Temporary storage for Sigma_e rows
145
  SigmaeStatement::row_t sigmae_row;
sebastien's avatar
sebastien committed
146
  //! Temporary storage for Sigma_e matrix
147
  SigmaeStatement::matrix_t sigmae_matrix;
sebastien's avatar
sebastien committed
148
  //! Temporary storage for initval/endval blocks
149
  InitOrEndValStatement::init_values_t init_values;
sebastien's avatar
sebastien committed
150
  //! Temporary storage for histval blocks
151
  HistValStatement::hist_values_t hist_values;
152
  //! Temporary storage for homotopy_setup blocks
153
  HomotopyStatement::homotopy_values_t homotopy_values;
houtanb's avatar
houtanb committed
154
  //! Temporary storage for svar_identification blocks
155
  SvarIdentificationStatement::svar_identification_restrictions_t svar_ident_restrictions;
156
  //! Temporary storage for mapping the equation number to the restrictions within an svar_identification block
157
  map<int, vector<int> > svar_equation_restrictions;
158
  //! Temporary storage for restrictions in an equation within an svar_identification block
159
  vector<int> svar_restriction_symbols;
160
161
162
  //! Temporary storage for constants exculsion within an svar_identification 
  bool svar_constants_exclusion;
  //! Temporary storage for upper cholesky within an svar_identification block
houtanb's avatar
houtanb committed
163
  bool svar_upper_cholesky;
164
  //! Temporary storage for lower cholesky within an svar_identification block
houtanb's avatar
houtanb committed
165
  bool svar_lower_cholesky;
166
167
168
169
170
  //! Temporary storage for equation number for a restriction within an svar_identification block
  int svar_equation_nbr;
  //! Temporary storage for left/right handside of a restriction equation within an svar_identificaton block
  bool svar_left_handside;
  //! Temporary storage for current restriction number in svar_identification block
171
172
  map<int,int> svar_Qi_restriction_nbr;
  map<int,int> svar_Ri_restriction_nbr;
173
174
175
176
177
178
179
180
  //! Temporary storage for restriction type
  enum SvarRestrictionType
    {
      NOT_SET,
      Qi_TYPE,
      Ri_TYPE
    };
  SvarRestrictionType svar_restriction_type;
181

182
  //! Temporary storage for argument list of external function
183
  stack<vector<expr_t> >  stack_external_function_args;
184
  //! Temporary storage for the symb_id associated with the "name" symbol of the current external_function statement
185
  int current_external_function_id;
186
187
  //! Temporary storage for option list provided to external_function()
  ExternalFunctionsTable::external_function_options current_external_function_options;
188
189
190
191
  //! Temporary storage for declaring trend variables
  vector<int> declared_trend_vars;
  //! Temporary storage for declaring nonstationary variables
  vector<int> declared_nonstationary_vars;
192
193
  //! Temporary storage for a variance declared in the prior statement
  expr_t prior_variance;
194
  SubsamplesStatement::subsample_declaration_map_t subsample_declaration_map;
195
  //! Temporary storage for subsample statement: map<pair<var_name1, var_name2>>, subsample_declaration_map >
196
  typedef map<pair<string, string >, SubsamplesStatement::subsample_declaration_map_t > subsample_declarations_t;
197
  subsample_declarations_t subsample_declarations;
198
199
  //! reset the values for temporary storage
  void reset_current_external_function_options();
200
  //! Adds a model lagged variable to ModelTree and VariableTable
201
  expr_t add_model_variable(int symb_id, int lag);
202
203
  //! For parsing the graph_format option
  SymbolList graph_formats;
sebastien's avatar
sebastien committed
204

205
206
  //! The mod file representation constructed by this ParsingDriver
  ModFile *mod_file;
207

208
209
  WarningConsolidation &warnings;

210
public:
211
212
  ParsingDriver(WarningConsolidation &warnings_arg) : warnings(warnings_arg) { };

213
  //! Starts parsing, and constructs the MOD file representation
sebastien's avatar
sebastien committed
214
  /*! The returned pointer should be deleted after use */
sebastien's avatar
sebastien committed
215
  ModFile *parse(istream &in, bool debug);
216

217
218
219
  //! Reference to the lexer
  class DynareFlex *lexer;

sebastien's avatar
sebastien committed
220
221
222
  //! Copy of parsing location, maintained by YYLLOC_DEFAULT macro in DynareBison.yy
  Dynare::parser::location_type location;

223
224
225
  //! Estimation parameters
  EstimationParams estim_params;

226
227
228
  //! Temporary storage for the prior shape
  PriorDistributions prior_shape;

sebastien's avatar
sebastien committed
229
  //! Error handler with explicit location
230
  void error(const Dynare::parser::location_type &l, const string &m) __attribute__ ((noreturn));
sebastien's avatar
sebastien committed
231
  //! Error handler using saved location
232
  void error(const string &m) __attribute__ ((noreturn));
sebastien's avatar
sebastien committed
233
  //! Warning handler using saved location
sebastien's avatar
sebastien committed
234
  void warning(const string &m);
235

sebastien's avatar
sebastien committed
236
  //! Check if a given symbol exists in the parsing context, and is not a mod file local variable
237
  bool symbol_exists_and_is_not_modfile_local_or_external_function(const char *s);
sebastien's avatar
sebastien committed
238
  //! Sets mode of ModelTree class to use C output
239
  void use_dll();
240
241
242
243
  //! the modelis block decomposed
  void block();
  //! the model is stored in a binary file
  void byte_code();
244
245
  //! the static model is not computed
  void no_static();
246
247
248
249
  //! cutoff option of model block
  void cutoff(string *value);
  //! mfs option of model block
  void mfs(string *value);
250
251
  //! transform_logpow for model
  void transform_logpow(void);
sebastien's avatar
sebastien committed
252
  //! Sets the FILENAME for the initial value in initval
michel's avatar
michel committed
253
  void initval_file(string *filename);
sebastien's avatar
sebastien committed
254
  //! Declares an endogenous variable
255
  void declare_endogenous(string *name, string *tex_name = NULL);
sebastien's avatar
sebastien committed
256
  //! Declares an exogenous variable
257
  void declare_exogenous(string *name, string *tex_name = NULL);
sebastien's avatar
sebastien committed
258
  //! Declares an exogenous deterministic variable
259
  void declare_exogenous_det(string *name, string *tex_name = NULL);
sebastien's avatar
sebastien committed
260
  //! Declares a parameter
261
  void declare_parameter(string *name, string *tex_name = NULL);
262
263
264
  //! Declares a statement local variable
  void declare_statement_local_variable(string *name);
  //! Completes a subsample statement
265
  void set_subsamples(string *name1, string *name2);
266
267
  //! Declares a subsample, assigning the value to name
  void set_subsample_name_equal_to_date_range(string *name, string *date1, string *date2);
268
269
270
  //! Checks that a subsample statement (and given name) were provided for the pair name1 & name2
  void check_subsample_declaration_exists(string *name1, string *subsample_name);
  void check_subsample_declaration_exists(string *name1, string *name2, string *subsample_name);
271
272
  //! Copies the set of subsamples from_name to_name
  void copy_subsamples(string *to_name1, string *to_name2, string *from_name1, string *from_name2);
273
274
  //! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
  void declare_optimal_policy_discount_factor_parameter(expr_t exprnode);
275
276
  //! Adds a predetermined_variable
  void add_predetermined_variable(string *name);
277
  //! Declares and initializes a local parameter
278
  void declare_and_init_model_local_variable(string *name, expr_t rhs);
279
280
  //! Changes type of a symbol
  void change_type(SymbolType new_type, vector<string *> *var_list);
281
  //! Adds a list of tags for the current equation
282
  void add_equation_tags(string *key, string *value);
283
284
  //! Adds a non-negative constant to DataTree
  expr_t add_non_negative_constant(string *constant);
285
  //! Adds a NaN constant to DataTree
286
  expr_t add_nan_constant();
287
  //! Adds an Inf constant to DataTree
288
  expr_t add_inf_constant();
289
  //! Adds a model variable to ModelTree and VariableTable
290
  expr_t add_model_variable(string *name);
291
  //! Adds an Expression's variable
292
  expr_t add_expression_variable(string *name);
sebastien's avatar
sebastien committed
293
294
295
296
297
298
  //! Adds a "periods" statement
  void periods(string *periods);
  //! Adds a "dsample" statement
  void dsample(string *arg1);
  //! Adds a "dsample" statement
  void dsample(string *arg1, string *arg2);
299
  //! Writes parameter intitialisation expression
300
  void init_param(string *name, expr_t rhs);
301
  //! Writes an initval block
302
  void init_val(string *name, expr_t rhs);
303
  //! Writes an histval block
304
  void hist_val(string *name, string *lag, expr_t rhs);
305
306
  //! Adds an entry in a homotopy_setup block
  /*! Second argument "val1" can be NULL if no initial value provided */
307
  void homotopy_val(string *name, expr_t val1, expr_t val2);
308
  //! Writes end of an initval block
309
  void end_initval(bool all_values_required);
310
  //! Writes end of an endval block
311
  void end_endval(bool all_values_required);
sebastien's avatar
sebastien committed
312
313
  //! Writes end of an histval block
  void end_histval();
314
315
  //! Writes end of an homotopy_setup block
  void end_homotopy();
sebastien's avatar
sebastien committed
316
317
  //! Begin a model block
  void begin_model();
sebastien's avatar
sebastien committed
318
  //! Writes a shocks statement
319
  void end_shocks();
sebastien's avatar
sebastien committed
320
321
  //! Writes a mshocks statement
  void end_mshocks();
322
323
  //! Adds a deterministic chock or a path element inside a conditional_forecast_paths block
  void add_det_shock(string *var, bool conditional_forecast);
324
  //! Adds a std error chock
325
  void add_stderr_shock(string *var, expr_t value);
326
  //! Adds a variance chock
327
  void add_var_shock(string *var, expr_t value);
328
  //! Adds a covariance chock
329
  void add_covar_shock(string *var1, string *var2, expr_t value);
330
  //! Adds a correlated chock
331
  void add_correl_shock(string *var1, string *var2, expr_t value);
332
  //! Adds a shock period range
333
  void add_period(string *p1, string *p2);
334
  //! Adds a shock period
335
  void add_period(string *p1);
sebastien's avatar
sebastien committed
336
  //! Adds a deterministic shock value
337
  void add_value(expr_t value);
ferhat's avatar
ferhat committed
338
  //! Adds a deterministic shock value
339
340
  /*! \param v a string containing a (possibly negative) numeric constant */
  void add_value(string *v);
341
342
  //! Adds a expectation type for conditional forecast with deterministic simulation
  void add_expectation_pf(bool pf);
343
  //! Writes a Sigma_e block
344
  void do_sigma_e();
345
  //! Ends row of Sigma_e block
346
  void end_of_row();
sebastien's avatar
sebastien committed
347
  //! Adds a constant element to current row of Sigma_e
348
  void add_to_row_const(string *v);
sebastien's avatar
sebastien committed
349
  //! Adds an expression element to current row of Sigma_e
350
  void add_to_row(expr_t v);
351
  //! Write a steady command
352
  void steady();
353
  //! Sets an option to a numerical value
354
355
356
  void option_num(const string &name_option, string *opt);
  //! Sets an option to a numerical value
  void option_num(const string &name_option, const string &opt);
357
  //! Sets an option to a numerical value
358
359
360
361
362
  void option_num(const string &name_option, string *opt1, string *opt2);
  //! Sets an option to a string value
  void option_str(const string &name_option, string *opt);
  //! Sets an option to a string value
  void option_str(const string &name_option, const string &opt);
363
364
365
366
  //! Sets an option to a date value
  void option_date(const string &name_option, string *opt);
  //! Sets an option to a date value
  void option_date(const string &name_option, const string &opt);
sebastien's avatar
sebastien committed
367
368
  //! Sets an option to a list of symbols (used in conjunction with add_in_symbol_list())
  void option_symbol_list(const string &name_option);
369
370
  //! Sets an option to a vector of integers
  void option_vec_int(const string &name_option, const vector<int> *opt);
sebastien's avatar
sebastien committed
371
372
  //! Indicates that the model is linear
  void linear();
sebastien's avatar
sebastien committed
373
374
  //! Adds a variable to temporary symbol list
  void add_in_symbol_list(string *tmp_var);
375
  //! Writes a rplot() command
376
  void rplot();
377
  //! Writes a stock_simul command
378
  void stoch_simul();
379
  //! Writes a simul command
380
  void simul();
381
  //! Writes check command
382
  void check();
383
384
  //! Writes model_info command
  void model_info();
sebastien's avatar
sebastien committed
385
386
387
388
389
390
  //! Writes estimated params command
  void estimated_params();
  //! Writes estimated params init command
  void estimated_params_init();
  //! Writes estimated params bound command
  void estimated_params_bounds();
391
392
393
394
395
396
  //! Adds a declaration for a user-defined external function
  void external_function();
  //! Sets an external_function option to a string value
  void external_function_option(const string &name_option, string *opt);
  //! Sets an external_function option to a string value
  void external_function_option(const string &name_option, const string &opt);
sebastien's avatar
sebastien committed
397
398
  //! Add a line in an estimated params block
  void add_estimated_params_element();
399
400
  //! Sets the frequency of the data
  void set_time(string *arg);
401
402
  //! Estimation Data
  void estimation_data();
403
  //! Sets the prior for a parameter
404
  void set_prior(string *arg1, string *arg2);
405
  //! Adds the variance option to its temporary holding place
406
  void set_prior_variance(expr_t variance=NULL);
407
408
409
  //! Copies the prior from_name to_name
  void copy_prior(string *to_declaration_type, string *to_name1, string *to_name2, string *to_subsample_name,
                  string *from_declaration_type, string *from_name1, string *from_name2, string *from_subsample_name);
410
  //! Sets the options for a parameter
411
  void set_options(string *arg1, string *arg2);
412
413
414
  //! Copies the options from_name to_name
  void copy_options(string *to_declaration_type, string *to_name1, string *to_name2, string *to_subsample_name,
                    string *from_declaration_type, string *from_name1, string *from_name2, string *from_subsample_name);
415
  //! Sets the prior for estimated std dev
416
  void set_std_prior(string *arg1, string *arg2);
417
  //! Sets the options for estimated std dev
418
  void set_std_options(string *arg1, string *arg2);
419
  //! Sets the prior for estimated correlation
420
  void set_corr_prior(string *arg1, string *arg2, string *arg3);
421
 //! Sets the options for estimated correlation
422
  void set_corr_options(string *arg1, string *arg2, string *arg3);
423
  //! Runs estimation process
424
  void run_estimation();
425
426
  //! Runs dynare_sensitivy()
  void dynare_sensitivity();
sebastien's avatar
sebastien committed
427
428
429
430
  //! Adds an optimization option (string value)
  void optim_options_string(string *name, string *value);
  //! Adds an optimization option (numeric value)
  void optim_options_num(string *name, string *value);
Sébastien Villemot's avatar
Sébastien Villemot committed
431
432
433
434
  //! Check that no observed variable has yet be defined
  void check_varobs();
  //! Add a new observed variable
  void add_varobs(string *name);
houtanb's avatar
houtanb committed
435
  //! Svar_Identification Statement
Houtan Bastani's avatar
Houtan Bastani committed
436
  void begin_svar_identification();
houtanb's avatar
houtanb committed
437
  void end_svar_identification();
438
  //! Svar_Identification Statement: match list of restrictions and equation number with lag
houtanb's avatar
houtanb committed
439
  void combine_lag_and_restriction(string *lag);
440
  //! Svar_Identification Statement: match list of restrictions with equation number
houtanb's avatar
houtanb committed
441
  void add_restriction_in_equation(string *equation);
442
  //! Svar_Identification Statement: add list of restriction symbol ids
houtanb's avatar
houtanb committed
443
  void add_in_svar_restriction_symbols(string *name);
444
445
  //! Svar_Identification Statement: add exclusions of constants
  void add_constants_exclusion();
446
  //! Svar_Identification Statement: add equation number for following restriction equations
447
  void add_restriction_equation_nbr(string *eq_nbr);
448
  //! Svar_Identification Statement: record presence of equal sign
449
  void add_restriction_equal();
450
  //! Svar_Idenditification Statement: add coefficient of a linear restriction (positive value) 
451
  void add_positive_restriction_element(expr_t value, string *variable, string *lag);
452
  //! Svar_Idenditification Statement: add unit coefficient of a linear restriction 
453
  void add_positive_restriction_element(string *variable, string *lag);
454
  //! Svar_Idenditification Statement: add coefficient of a linear restriction (negative value) 
455
  void add_negative_restriction_element(expr_t value, string *variable, string *lag);
456
  //! Svar_Idenditification Statement: add negative unit coefficient of a linear restriction
457
  void add_negative_restriction_element(string *variable, string *lag);
458
459
  //! Svar_Idenditification Statement: add restriction element
  void add_restriction_element(expr_t value, string *variable, string *lag);
460
461
  //! Svar_Identification Statement: check that restriction is homogenous
  void check_restriction_expression_constant(expr_t value);
462
  //! Svar_Identification Statement: restriction of form upper cholesky
houtanb's avatar
houtanb committed
463
  void add_upper_cholesky();
464
  //! Svar_Identification Statement: restriction of form lower cholesky
houtanb's avatar
houtanb committed
465
  void add_lower_cholesky();
466
467
  //! Forecast Statement
  void forecast();
sebastien's avatar
sebastien committed
468
  void set_trends();
469
  void set_trend_element(string *arg1, expr_t arg2);
470
  void set_unit_root_vars();
sebastien's avatar
sebastien committed
471
  void optim_weights();
472
473
  void set_optim_weights(string *name, expr_t value);
  void set_optim_weights(string *name1, string *name2, expr_t value);
474
475
  void set_osr_params();
  void run_osr();
sebastien's avatar
trunk:    
sebastien committed
476
477
  void run_dynasave(string *filename);
  void run_dynatype(string *filename);
478
479
  void run_load_params_and_steady_state(string *filename);
  void run_save_params_and_steady_state(string *filename);
sebastien's avatar
sebastien committed
480
  void run_identification();
481
  void add_mc_filename(string *filename, string *prior = new string("1"));
482
  void run_model_comparison();
sebastien's avatar
sebastien committed
483
484
485
  //! Begin a planner_objective statement
  void begin_planner_objective();
  //! End a planner objective statement
486
  void end_planner_objective(expr_t expr);
487
  //! Ramsey policy statement
michel's avatar
michel committed
488
  void ramsey_policy();
489
490
  //! Discretionary policy statement
  void discretionary_policy();
491
492
493
494
  //! Adds a write_latex_dynamic_model statement
  void write_latex_dynamic_model();
  //! Adds a write_latex_static_model statement
  void write_latex_static_model();
495
496
497
498
  //! BVAR marginal density
  void bvar_density(string *maxnlags);
  //! BVAR forecast
  void bvar_forecast(string *nlags);
499
500
  //! SBVAR statement
  void sbvar();
Houtan Bastani's avatar
Houtan Bastani committed
501
502
503
504
505
506
507
508
509
510
511
512
513
514
  //! Markov Switching Statement: Estimation
  void ms_estimation();
  //! Markov Switching Statement: Simulation
  void ms_simulation();
  //! Markov Switching Statement: MDD
  void ms_compute_mdd();
  //! Markov Switching Statement: Probabilities
  void ms_compute_probabilities();
  //! Markov Switching Statement: IRF
  void ms_irf();
  //! Markov Switching Statement: Forecast
  void ms_forecast();
  //! Markov Switching Statement: Variance Decomposition
  void ms_variance_decomposition();
houtanb's avatar
houtanb committed
515
516
  //! Svar statement
  void svar();
houtanb's avatar
houtanb committed
517
518
  //! MarkovSwitching statement
  void markov_switching();
519
520
  //! Shock decomposition
  void shock_decomposition();
521
522
523
524
525
526
  //! Conditional forecast statement
  void conditional_forecast();
  //! Conditional forecast paths block
  void conditional_forecast_paths();
  //! Plot conditional forecast statement
  void plot_conditional_forecast(string *periods = NULL);
527
528
  //! Smoother on calibrated models
  void calib_smoother();
529
530
  //! Extended path
  void extended_path();
531
  //! Writes token "arg1=arg2" to model tree
532
  expr_t add_model_equal(expr_t arg1, expr_t arg2);
533
  //! Writes token "arg=0" to model tree
534
  expr_t add_model_equal_with_zero_rhs(expr_t arg);
535
  //! Writes token "arg1+arg2" to model tree
536
  expr_t add_plus(expr_t arg1, expr_t arg2);
537
  //! Writes token "arg1-arg2" to model tree
538
  expr_t add_minus(expr_t arg1,  expr_t arg2);
539
  //! Writes token "-arg1" to model tree
540
  expr_t add_uminus(expr_t arg1);
541
  //! Writes token "arg1*arg2" to model tree
542
  expr_t add_times(expr_t arg1,  expr_t arg2);
543
  //! Writes token "arg1/arg2" to model tree
544
  expr_t add_divide(expr_t arg1,  expr_t arg2);
ferhat's avatar
ferhat committed
545
  //! Writes token "arg1<arg2" to model tree
546
547
548
549
550
551
552
553
554
555
556
  expr_t add_less(expr_t arg1, expr_t arg2);
  //! Writes token "arg1>arg2" to model treeexpr_t
  expr_t add_greater(expr_t arg1, expr_t arg2);
  //! Writes token "arg1<=arg2" to model treeexpr_t
  expr_t add_less_equal(expr_t arg1, expr_t arg2);
  //! Writes token "arg1>=arg2" to model treeexpr_t
  expr_t add_greater_equal(expr_t arg1, expr_t arg2);
  //! Writes token "arg1==arg2" to model treeexpr_texpr_t
  expr_t add_equal_equal(expr_t arg1, expr_t arg2);
  //! Writes token "arg1!=arg2" to model treeexpr_texpr_t
  expr_t add_different(expr_t arg1, expr_t arg2);
557
  //! Writes token "arg1^arg2" to model tree
558
  expr_t add_power(expr_t arg1,  expr_t arg2);
559
  //! Writes token "E(arg1)(arg2)" to model tree
560
  expr_t add_expectation(string *arg1,  expr_t arg2);
561
  //! Writes token "exp(arg1)" to model tree
562
  expr_t add_exp(expr_t arg1);
563
  //! Writes token "log(arg1)" to model tree
564
  expr_t add_log(expr_t arg1);
565
  //! Writes token "log10(arg1)" to model tree
566
  expr_t add_log10(expr_t arg1);
567
  //! Writes token "cos(arg1)" to model tree
568
  expr_t add_cos(expr_t arg1);
569
  //! Writes token "sin(arg1)" to model tree
570
  expr_t add_sin(expr_t arg1);
571
  //! Writes token "tan(arg1)" to model tree
572
  expr_t add_tan(expr_t arg1);
573
  //! Writes token "acos(arg1)" to model tree
574
  expr_t add_acos(expr_t arg1);
575
  //! Writes token "asin(arg1)" to model tree
576
  expr_t add_asin(expr_t arg1);
577
  //! Writes token "atan(arg1)" to model tree
578
  expr_t add_atan(expr_t arg1);
579
  //! Writes token "cosh(arg1)" to model tree
580
  expr_t add_cosh(expr_t arg1);
581
  //! Writes token "sinh(arg1)" to model tree
582
  expr_t add_sinh(expr_t arg1);
583
  //! Writes token "tanh(arg1)" to model tree
584
  expr_t add_tanh(expr_t arg1);
585
  //! Writes token "acosh(arg1)" to model tree
586
  expr_t add_acosh(expr_t arg1);
587
  //! Writes token "asin(arg1)" to model tree
588
  expr_t add_asinh(expr_t arg1);
589
  //! Writes token "atanh(arg1)" to model tree
590
  expr_t add_atanh(expr_t arg1);
591
  //! Writes token "sqrt(arg1)" to model tree
592
  expr_t add_sqrt(expr_t arg1);
593
594
595
596
  //! Writes token "abs(arg1)" to model tree
  expr_t add_abs(expr_t arg1);
  //! Writes token "sign(arg1)" to model tree
  expr_t add_sign(expr_t arg1);
sebastien's avatar
sebastien committed
597
  //! Writes token "max(arg1,arg2)" to model tree
598
  expr_t add_max(expr_t arg1, expr_t arg2);
sebastien's avatar
sebastien committed
599
  //! Writes token "min(arg1,arg2)" to model tree
600
  expr_t add_min(expr_t arg1, expr_t arg2);
sebastien's avatar
sebastien committed
601
  //! Writes token "normcdf(arg1,arg2,arg3)" to model tree
602
  expr_t add_normcdf(expr_t arg1, expr_t arg2, expr_t arg3);
sebastien's avatar
sebastien committed
603
  //! Writes token "normcdf(arg,0,1)" to model tree
604
  expr_t add_normcdf(expr_t arg);
605
  //! Writes token "normpdf(arg1,arg2,arg3)" to model tree
606
  expr_t add_normpdf(expr_t arg1, expr_t arg2, expr_t arg3);
607
  //! Writes token "normpdf(arg,0,1)" to model tree
608
  expr_t add_normpdf(expr_t arg);
609
  //! Writes token "erf(arg)" to model tree
610
  expr_t add_erf(expr_t arg);
611
  //! Writes token "steadyState(arg1)" to model tree
612
  expr_t add_steady_state(expr_t arg1);
613
614
615
  //! Pushes empty vector onto stack when a symbol is encountered (mod_var or ext_fun)
  void push_external_function_arg_vector_onto_stack();
  //! Adds an external function argument
616
  void add_external_function_arg(expr_t arg);
617
  //! Adds an external function call node
618
  expr_t add_model_var_or_external_function(string *function_name, bool in_model_block);
619
620
  //! Adds a native statement
  void add_native(const string &s);
621
  //! Adds a native statement, first removing the set of characters passed in token (and everything after)
622
  void add_native_remove_charset(const char *s, const string &token);
sebastien's avatar
sebastien committed
623
624
  //! Resets data_tree and model_tree pointers to default (i.e. mod_file->expressions_tree)
  void reset_data_tree();
625
626
627
  //! Begin a steady_state_model block
  void begin_steady_state_model();
  //! Add an assignment equation in steady_state_model block
628
  void add_steady_state_model_equal(string *varname, expr_t expr);
629
630
  //! Add a multiple assignment equation in steady_state_model block
  void add_steady_state_model_equal_multiple(expr_t expr);
631
632
633
  //! Switches datatree
  void begin_trend();
  //! Declares a trend variable with its growth factor
634
  void declare_trend_var(bool log_trend, string *name, string *tex_name = NULL);
635
636
637
638
639
  //! Ends declaration of trend variable
  void end_trend_var(expr_t growth_factor);
  //! Declares a nonstationary variable with its deflator
  void declare_nonstationary_var(string *name, string *tex_name = NULL);
  //! Ends declaration of nonstationary variable
640
  void end_nonstationary_var(bool log_deflator, expr_t deflator);
641
642
643
644
  //! Add a graph format to the list of formats requested
  void add_graph_format(const string &name);
  //! Add the graph_format option to the OptionsList structure
  void process_graph_format_option();
645
646
  //! Model diagnostics
  void model_diagnostics();
647
648
649
};

#endif // ! PARSING_DRIVER_HH