ParsingDriver.hh 22 KB
Newer Older
sebastien's avatar
sebastien committed
1
/*
2
 * Copyright (C) 2003-2011 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);

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

sebastien's avatar
sebastien committed
87
88
89
  //! 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);

90
  //! Stores temporary symbol table
sebastien's avatar
sebastien committed
91
  SymbolList symbol_list;
sebastien's avatar
sebastien committed
92

sebastien's avatar
sebastien committed
93
94
95
  //! The data tree in which to add expressions currently parsed
  DataTree *data_tree;

sebastien's avatar
sebastien committed
96
  //! The model tree in which to add expressions currently parsed
sebastien's avatar
sebastien committed
97
  /*! 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
98
99
  ModelTree *model_tree;

100
101
102
103
  //! 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
104
105
106
  //! Sets data_tree and model_tree pointers
  void set_current_data_tree(DataTree *data_tree_arg);

sebastien's avatar
sebastien committed
107
108
109
  //! Stores options lists
  OptionsList options_list;
  //! Temporary storage for trend elements
110
  ObservationTrendsStatement::trend_elements_t trend_elements;
sebastien's avatar
sebastien committed
111
  //! Temporary storage for filename list of ModelComparison
112
  ModelComparisonStatement::filename_list_t filename_list;
sebastien's avatar
sebastien committed
113
114
115
  //! Temporary storage for list of EstimationParams (from estimated_params* statements)
  vector<EstimationParams> estim_params_list;
  //! Temporary storage of variances from optim_weights
116
  OptimWeightsStatement::var_weights_t var_weights;
sebastien's avatar
sebastien committed
117
  //! Temporary storage of covariances from optim_weights
118
  OptimWeightsStatement::covar_weights_t covar_weights;
sebastien's avatar
sebastien committed
119
  //! Temporary storage for deterministic shocks
120
  ShocksStatement::det_shocks_t det_shocks;
sebastien's avatar
sebastien committed
121
122
123
  //! Temporary storage for periods of deterministic shocks
  vector<pair<int, int> > det_shocks_periods;
  //! Temporary storage for values of deterministic shocks
124
  vector<expr_t> det_shocks_values;
sebastien's avatar
sebastien committed
125
  //! Temporary storage for variances of shocks
126
  ShocksStatement::var_and_std_shocks_t var_shocks;
sebastien's avatar
sebastien committed
127
  //! Temporary storage for standard errors of shocks
128
  ShocksStatement::var_and_std_shocks_t std_shocks;
sebastien's avatar
sebastien committed
129
  //! Temporary storage for covariances of shocks
130
  ShocksStatement::covar_and_corr_shocks_t covar_shocks;
sebastien's avatar
sebastien committed
131
  //! Temporary storage for correlations of shocks
132
  ShocksStatement::covar_and_corr_shocks_t corr_shocks;
sebastien's avatar
sebastien committed
133
  //! Temporary storage for Sigma_e rows
134
  SigmaeStatement::row_t sigmae_row;
sebastien's avatar
sebastien committed
135
  //! Temporary storage for Sigma_e matrix
136
  SigmaeStatement::matrix_t sigmae_matrix;
sebastien's avatar
sebastien committed
137
  //! Temporary storage for initval/endval blocks
138
  InitOrEndValStatement::init_values_t init_values;
sebastien's avatar
sebastien committed
139
  //! Temporary storage for histval blocks
140
  HistValStatement::hist_values_t hist_values;
141
  //! Temporary storage for homotopy_setup blocks
142
  HomotopyStatement::homotopy_values_t homotopy_values;
houtanb's avatar
houtanb committed
143
  //! Temporary storage for svar_identification blocks
144
  SvarIdentificationStatement::svar_identification_exclusion_t svar_ident_exclusion_values;
145
  //! Temporary storage for mapping the equation number to the restrictions within an svar_identification block
146
  map<int, vector<int> > svar_equation_restrictions;
147
  //! Temporary storage for restrictions in an equation within an svar_identification block
148
  vector<int> svar_restriction_symbols;
149
150
151
  //! 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
152
  bool svar_upper_cholesky;
153
  //! Temporary storage for lower cholesky within an svar_identification block
houtanb's avatar
houtanb committed
154
  bool svar_lower_cholesky;
155

156
  //! Temporary storage for argument list of external function
157
  stack<vector<expr_t> >  stack_external_function_args;
158
  //! Temporary storage for the symb_id associated with the "name" symbol of the current external_function statement
159
  int current_external_function_id;
160
161
  //! Temporary storage for option list provided to external_function()
  ExternalFunctionsTable::external_function_options current_external_function_options;
162
163
164
165
  //! Temporary storage for declaring trend variables
  vector<int> declared_trend_vars;
  //! Temporary storage for declaring nonstationary variables
  vector<int> declared_nonstationary_vars;
166
167
  //! reset the values for temporary storage
  void reset_current_external_function_options();
168
  //! Adds a model lagged variable to ModelTree and VariableTable
169
  expr_t add_model_variable(int symb_id, int lag);
sebastien's avatar
sebastien committed
170

171
172
173
174
  //! The mod file representation constructed by this ParsingDriver
  ModFile *mod_file;
public:
  //! Starts parsing, and constructs the MOD file representation
sebastien's avatar
sebastien committed
175
  /*! The returned pointer should be deleted after use */
sebastien's avatar
sebastien committed
176
  ModFile *parse(istream &in, bool debug);
177

178
179
180
  //! Reference to the lexer
  class DynareFlex *lexer;

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

184
185
186
  //! Estimation parameters
  EstimationParams estim_params;

sebastien's avatar
sebastien committed
187
  //! Error handler with explicit location
188
  void error(const Dynare::parser::location_type &l, const string &m) __attribute__ ((noreturn));
sebastien's avatar
sebastien committed
189
  //! Error handler using saved location
190
  void error(const string &m) __attribute__ ((noreturn));
sebastien's avatar
sebastien committed
191
  //! Warning handler using saved location
sebastien's avatar
sebastien committed
192
  void warning(const string &m);
193

sebastien's avatar
sebastien committed
194
  //! Check if a given symbol exists in the parsing context, and is not a mod file local variable
195
  bool symbol_exists_and_is_not_modfile_local_or_external_function(const char *s);
sebastien's avatar
sebastien committed
196
  //! Sets mode of ModelTree class to use C output
197
  void use_dll();
198
199
200
201
  //! the modelis block decomposed
  void block();
  //! the model is stored in a binary file
  void byte_code();
202
203
  //! the static model is not computed
  void no_static();
204
205
206
207
  //! cutoff option of model block
  void cutoff(string *value);
  //! mfs option of model block
  void mfs(string *value);
sebastien's avatar
sebastien committed
208
  //! Sets the FILENAME for the initial value in initval
michel's avatar
michel committed
209
  void initval_file(string *filename);
sebastien's avatar
sebastien committed
210
  //! Declares an endogenous variable
211
  void declare_endogenous(string *name, string *tex_name = NULL);
sebastien's avatar
sebastien committed
212
  //! Declares an exogenous variable
213
  void declare_exogenous(string *name, string *tex_name = NULL);
sebastien's avatar
sebastien committed
214
  //! Declares an exogenous deterministic variable
215
  void declare_exogenous_det(string *name, string *tex_name = NULL);
sebastien's avatar
sebastien committed
216
  //! Declares a parameter
217
  void declare_parameter(string *name, string *tex_name = NULL);
218
219
  //! Declares declare_optimal_policy_discount_factor as a parameter and initializes it to exprnode
  void declare_optimal_policy_discount_factor_parameter(expr_t exprnode);
220
221
  //! Adds a predetermined_variable
  void add_predetermined_variable(string *name);
222
  //! Declares and initializes a local parameter
223
  void declare_and_init_model_local_variable(string *name, expr_t rhs);
224
225
  //! Changes type of a symbol
  void change_type(SymbolType new_type, vector<string *> *var_list);
226
  //! Adds a list of tags for the current equation
227
  void add_equation_tags(string *key, string *value);
228
229
  //! Adds a non-negative constant to DataTree
  expr_t add_non_negative_constant(string *constant);
230
  //! Adds a NaN constant to DataTree
231
  expr_t add_nan_constant();
232
  //! Adds an Inf constant to DataTree
233
  expr_t add_inf_constant();
234
  //! Adds a model variable to ModelTree and VariableTable
235
  expr_t add_model_variable(string *name);
236
  //! Adds an Expression's variable
237
  expr_t add_expression_variable(string *name);
sebastien's avatar
sebastien committed
238
239
240
241
242
243
  //! 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);
244
  //! Writes parameter intitialisation expression
245
  void init_param(string *name, expr_t rhs);
246
  //! Writes an initval block
247
  void init_val(string *name, expr_t rhs);
248
  //! Writes an histval block
249
  void hist_val(string *name, string *lag, expr_t rhs);
250
251
  //! Adds an entry in a homotopy_setup block
  /*! Second argument "val1" can be NULL if no initial value provided */
252
  void homotopy_val(string *name, expr_t val1, expr_t val2);
253
  //! Writes end of an initval block
254
  void end_initval();
255
  //! Writes end of an endval block
256
  void end_endval();
sebastien's avatar
sebastien committed
257
258
  //! Writes end of an histval block
  void end_histval();
259
260
  //! Writes end of an homotopy_setup block
  void end_homotopy();
sebastien's avatar
sebastien committed
261
262
  //! Begin a model block
  void begin_model();
sebastien's avatar
sebastien committed
263
  //! Writes a shocks statement
264
  void end_shocks();
sebastien's avatar
sebastien committed
265
266
  //! Writes a mshocks statement
  void end_mshocks();
267
268
  //! Adds a deterministic chock or a path element inside a conditional_forecast_paths block
  void add_det_shock(string *var, bool conditional_forecast);
269
  //! Adds a std error chock
270
  void add_stderr_shock(string *var, expr_t value);
271
  //! Adds a variance chock
272
  void add_var_shock(string *var, expr_t value);
273
  //! Adds a covariance chock
274
  void add_covar_shock(string *var1, string *var2, expr_t value);
275
  //! Adds a correlated chock
276
  void add_correl_shock(string *var1, string *var2, expr_t value);
277
  //! Adds a shock period range
278
  void add_period(string *p1, string *p2);
279
  //! Adds a shock period
280
  void add_period(string *p1);
sebastien's avatar
sebastien committed
281
  //! Adds a deterministic shock value
282
  void add_value(expr_t value);
ferhat's avatar
ferhat committed
283
  //! Adds a deterministic shock value
284
285
  /*! \param v a string containing a (possibly negative) numeric constant */
  void add_value(string *v);
286
  //! Writes a Sigma_e block
287
  void do_sigma_e();
288
  //! Ends row of Sigma_e block
289
  void end_of_row();
sebastien's avatar
sebastien committed
290
  //! Adds a constant element to current row of Sigma_e
291
  void add_to_row_const(string *v);
sebastien's avatar
sebastien committed
292
  //! Adds an expression element to current row of Sigma_e
293
  void add_to_row(expr_t v);
294
  //! Write a steady command
295
  void steady();
296
  //! Sets an option to a numerical value
297
298
299
  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);
300
  //! Sets an option to a numerical value
301
302
303
304
305
  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);
sebastien's avatar
sebastien committed
306
307
  //! Sets an option to a list of symbols (used in conjunction with add_in_symbol_list())
  void option_symbol_list(const string &name_option);
308
309
  //! 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
310
311
  //! Indicates that the model is linear
  void linear();
sebastien's avatar
sebastien committed
312
313
  //! Adds a variable to temporary symbol list
  void add_in_symbol_list(string *tmp_var);
314
  //! Writes a rplot() command
315
  void rplot();
316
  //! Writes a stock_simul command
317
  void stoch_simul();
318
  //! Writes a simul command
319
  void simul();
320
  //! Writes check command
321
  void check();
322
323
  //! Writes model_info command
  void model_info();
sebastien's avatar
sebastien committed
324
325
326
327
328
329
  //! 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();
330
331
332
333
334
335
  //! 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
336
337
  //! Add a line in an estimated params block
  void add_estimated_params_element();
338
  //! Runs estimation process
339
  void run_estimation();
340
341
  //! Runs dynare_sensitivy()
  void dynare_sensitivity();
sebastien's avatar
sebastien committed
342
343
344
345
  //! 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
346
347
348
349
  //! 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
350
  //! Svar_Identification Statement
Houtan Bastani's avatar
Houtan Bastani committed
351
  void begin_svar_identification();
houtanb's avatar
houtanb committed
352
  void end_svar_identification();
353
  //! Svar_Identification Statement: match list of restrictions and equation number with lag
houtanb's avatar
houtanb committed
354
  void combine_lag_and_restriction(string *lag);
355
  //! Svar_Identification Statement: match list of restrictions with equation number
houtanb's avatar
houtanb committed
356
  void add_restriction_in_equation(string *equation);
357
  //! Svar_Identification Statement: add list of restriction symbol ids
houtanb's avatar
houtanb committed
358
  void add_in_svar_restriction_symbols(string *name);
359
360
  //! Svar_Identification Statement: add exclusions of constants
  void add_constants_exclusion();
361
  //! Svar_Identification Statement: restriction of form upper cholesky
houtanb's avatar
houtanb committed
362
  void add_upper_cholesky();
363
  //! Svar_Identification Statement: restriction of form lower cholesky
houtanb's avatar
houtanb committed
364
  void add_lower_cholesky();
365
366
  //! Forecast Statement
  void forecast();
sebastien's avatar
sebastien committed
367
  void set_trends();
368
  void set_trend_element(string *arg1, expr_t arg2);
369
  void set_unit_root_vars();
sebastien's avatar
sebastien committed
370
  void optim_weights();
371
372
  void set_optim_weights(string *name, expr_t value);
  void set_optim_weights(string *name1, string *name2, expr_t value);
373
374
  void set_osr_params();
  void run_osr();
sebastien's avatar
trunk:    
sebastien committed
375
376
  void run_dynasave(string *filename);
  void run_dynatype(string *filename);
377
378
  void run_load_params_and_steady_state(string *filename);
  void run_save_params_and_steady_state(string *filename);
sebastien's avatar
sebastien committed
379
  void run_identification();
380
  void add_mc_filename(string *filename, string *prior = new string("1"));
381
  void run_model_comparison();
sebastien's avatar
sebastien committed
382
383
384
  //! Begin a planner_objective statement
  void begin_planner_objective();
  //! End a planner objective statement
385
  void end_planner_objective(expr_t expr);
386
  //! Ramsey policy statement
michel's avatar
michel committed
387
  void ramsey_policy();
388
389
  //! Discretionary policy statement
  void discretionary_policy();
390
391
392
393
  //! Adds a write_latex_dynamic_model statement
  void write_latex_dynamic_model();
  //! Adds a write_latex_static_model statement
  void write_latex_static_model();
394
395
396
397
  //! BVAR marginal density
  void bvar_density(string *maxnlags);
  //! BVAR forecast
  void bvar_forecast(string *nlags);
398
399
  //! SBVAR statement
  void sbvar();
Houtan Bastani's avatar
Houtan Bastani committed
400
401
402
403
404
405
406
407
408
409
410
411
412
413
  //! 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
414
415
  //! Svar statement
  void svar();
houtanb's avatar
houtanb committed
416
417
  //! MarkovSwitching statement
  void markov_switching();
418
419
  //! Shock decomposition
  void shock_decomposition();
420
421
422
423
424
425
  //! 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);
426
  //! Writes token "arg1=arg2" to model tree
427
  expr_t add_model_equal(expr_t arg1, expr_t arg2);
428
  //! Writes token "arg=0" to model tree
429
  expr_t add_model_equal_with_zero_rhs(expr_t arg);
430
  //! Writes token "arg1+arg2" to model tree
431
  expr_t add_plus(expr_t arg1, expr_t arg2);
432
  //! Writes token "arg1-arg2" to model tree
433
  expr_t add_minus(expr_t arg1,  expr_t arg2);
434
  //! Writes token "-arg1" to model tree
435
  expr_t add_uminus(expr_t arg1);
436
  //! Writes token "arg1*arg2" to model tree
437
  expr_t add_times(expr_t arg1,  expr_t arg2);
438
  //! Writes token "arg1/arg2" to model tree
439
  expr_t add_divide(expr_t arg1,  expr_t arg2);
ferhat's avatar
ferhat committed
440
  //! Writes token "arg1<arg2" to model tree
441
442
443
444
445
446
447
448
449
450
451
  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);
452
  //! Writes token "arg1^arg2" to model tree
453
  expr_t add_power(expr_t arg1,  expr_t arg2);
454
  //! Writes token "E(arg1)(arg2)" to model tree
455
  expr_t add_expectation(string *arg1,  expr_t arg2);
456
  //! Writes token "exp(arg1)" to model tree
457
  expr_t add_exp(expr_t arg1);
458
  //! Writes token "log(arg1)" to model tree
459
  expr_t add_log(expr_t arg1);
460
  //! Writes token "log10(arg1)" to model tree
461
  expr_t add_log10(expr_t arg1);
462
  //! Writes token "cos(arg1)" to model tree
463
  expr_t add_cos(expr_t arg1);
464
  //! Writes token "sin(arg1)" to model tree
465
  expr_t add_sin(expr_t arg1);
466
  //! Writes token "tan(arg1)" to model tree
467
  expr_t add_tan(expr_t arg1);
468
  //! Writes token "acos(arg1)" to model tree
469
  expr_t add_acos(expr_t arg1);
470
  //! Writes token "asin(arg1)" to model tree
471
  expr_t add_asin(expr_t arg1);
472
  //! Writes token "atan(arg1)" to model tree
473
  expr_t add_atan(expr_t arg1);
474
  //! Writes token "cosh(arg1)" to model tree
475
  expr_t add_cosh(expr_t arg1);
476
  //! Writes token "sinh(arg1)" to model tree
477
  expr_t add_sinh(expr_t arg1);
478
  //! Writes token "tanh(arg1)" to model tree
479
  expr_t add_tanh(expr_t arg1);
480
  //! Writes token "acosh(arg1)" to model tree
481
  expr_t add_acosh(expr_t arg1);
482
  //! Writes token "asin(arg1)" to model tree
483
  expr_t add_asinh(expr_t arg1);
484
  //! Writes token "atanh(arg1)" to model tree
485
  expr_t add_atanh(expr_t arg1);
486
  //! Writes token "sqrt(arg1)" to model tree
487
  expr_t add_sqrt(expr_t arg1);
488
489
490
491
  //! 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
492
  //! Writes token "max(arg1,arg2)" to model tree
493
  expr_t add_max(expr_t arg1, expr_t arg2);
sebastien's avatar
sebastien committed
494
  //! Writes token "min(arg1,arg2)" to model tree
495
  expr_t add_min(expr_t arg1, expr_t arg2);
sebastien's avatar
sebastien committed
496
  //! Writes token "normcdf(arg1,arg2,arg3)" to model tree
497
  expr_t add_normcdf(expr_t arg1, expr_t arg2, expr_t arg3);
sebastien's avatar
sebastien committed
498
  //! Writes token "normcdf(arg,0,1)" to model tree
499
  expr_t add_normcdf(expr_t arg);
500
  //! Writes token "normpdf(arg1,arg2,arg3)" to model tree
501
  expr_t add_normpdf(expr_t arg1, expr_t arg2, expr_t arg3);
502
  //! Writes token "normpdf(arg,0,1)" to model tree
503
  expr_t add_normpdf(expr_t arg);
504
  //! Writes token "erf(arg)" to model tree
505
  expr_t add_erf(expr_t arg);
506
  //! Writes token "steadyState(arg1)" to model tree
507
  expr_t add_steady_state(expr_t arg1);
508
509
510
  //! 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
511
  void add_external_function_arg(expr_t arg);
512
  //! Adds an external function call node
513
  expr_t add_model_var_or_external_function(string *function_name, bool in_model_block);
514
515
  //! Adds a native statement
  void add_native(const string &s);
516
  //! Adds a native statement, first removing the set of characters passed in token (and everything after)
517
  void add_native_remove_charset(const char *s, const string &token);
sebastien's avatar
sebastien committed
518
519
  //! Resets data_tree and model_tree pointers to default (i.e. mod_file->expressions_tree)
  void reset_data_tree();
520
521
522
  //! Begin a steady_state_model block
  void begin_steady_state_model();
  //! Add an assignment equation in steady_state_model block
523
  void add_steady_state_model_equal(string *varname, expr_t expr);
524
525
  //! Add a multiple assignment equation in steady_state_model block
  void add_steady_state_model_equal_multiple(expr_t expr);
526
527
528
529
530
531
532
533
534
535
  //! Switches datatree
  void begin_trend();
  //! Declares a trend variable with its growth factor
  void declare_trend_var(string *name, string *tex_name = NULL);
  //! 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
  void end_nonstationary_var(expr_t deflator);
536
537
538
};

#endif // ! PARSING_DRIVER_HH