DynareBison.yy 173 KB
Newer Older
sebastien's avatar
sebastien committed
1
/*
2
 * Copyright (C) 2003-2017 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
%skeleton "lalr1.cc"
21
%require "2.5"
22 23
%defines

24
%code top {
25
class ParsingDriver;
26
}
27

28
%code requires {
sebastien's avatar
sebastien committed
29
#include "ExprNode.hh"
30
#include "CodeInterpreter.hh"
31
}
sebastien's avatar
sebastien committed
32

33
%name-prefix "Dynare"
34

35 36
%parse-param { ParsingDriver &driver }
%lex-param { ParsingDriver &driver }
37 38

%locations
39 40
%initial-action
{
41 42
  // Initialize the locations' filenames to the filename maintained by the lexer
  @$.begin.filename = @$.end.filename = &(driver.lexer->filename);
43
}
44 45 46 47 48 49

%debug
%error-verbose

%union
{
50
  string *string_val;
51
  expr_t node_val;
52 53
  SymbolType symbol_type_val;
  vector<string *> *vector_string_val;
54
  vector<int> *vector_int_val;
55
  pair<string *, string *> *string_pair_val;
56
  vector<pair<string *, string *> *> *vector_string_pair_val;
57
  PriorDistributions prior_distributions_val;
58 59
};

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
%code {
/* Little hack: we redefine the macro which computes the locations, because
   we need to access the location from within the parsing driver for error
   and warning messages. */
#define YYLLOC_DEFAULT(Current, Rhs, N)                         \
  do {                                                          \
    if (N)                                                      \
      {                                                         \
        (Current).begin = YYRHSLOC(Rhs, 1).begin;               \
        (Current).end   = YYRHSLOC(Rhs, N).end;                 \
      }                                                         \
    else                                                        \
      {                                                         \
        (Current).begin = (Current).end = YYRHSLOC(Rhs, 0).end;	\
      }                                                         \
    driver.location = (Current);                                \
  } while(false)

78
#include "ParsingDriver.hh"
79 80 81 82 83 84

/* this "connects" the bison parser in the driver to the flex scanner class
 * object. it defines the yylex() function call to pull the next token from the
 * current lexer object of the driver context. */
#undef yylex
#define yylex driver.lexer->lex
85
}
86

87 88
%token AIM_SOLVER ANALYTIC_DERIVATION ANALYTIC_DERIVATION_MODE AR AUTOCORR POSTERIOR_SAMPLING_METHOD
%token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION SILENT_OPTIMIZER
89 90 91 92
%token BVAR_DENSITY BVAR_FORECAST NODECOMPOSITION DR_DISPLAY_TOL HUGE_NUMBER FIG_NAME WRITE_XLS
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA INTERACTIVE SCREEN_SHOCKS STEADYSTATE
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN DETAIL_PLOT TYPE
%token BVAR_REPLIC BYTECODE ALL_VALUES_REQUIRED PROPOSAL_DISTRIBUTION REALTIME VINTAGE
93
%token CALIB_SMOOTHER CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF CYCLE_REDUCTION LOGARITHMIC_REDUCTION
94
%token CONSIDER_ALL_ENDOGENOUS CONSIDER_ONLY_OBSERVED INITIAL_CONDITION_DECOMPOSITION
95
%token DATAFILE FILE SERIES DOUBLING DR_CYCLE_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_MAXITER DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION DIFFERENTIATE_FORWARD_VARS
96
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT EXTENDED_PATH ENDOGENOUS_PRIOR
97
%token FILENAME DIRNAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME OSR_PARAMS_BOUNDS KEEP_KALMAN_ALGO_IF_SINGULARITY_IS_DETECTED
98
%token <string_val> FLOAT_NUMBER DATES
99
%token DEFAULT FIXED_POINT OPT_ALGO
100
%token FORECAST K_ORDER_SOLVER INSTRUMENTS SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN
101
%token GAMMA_PDF GRAPH GRAPH_FORMAT CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK STD
102
%token HISTVAL HISTVAL_FILE HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID HYBRID ONE_SIDED_HP_FILTER
103
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT INFILE INVARS
104
%token <string_val> INT_NUMBER
105
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD IRF_CALIBRATION
106
%token FAST_KALMAN_FILTER KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF TOLX PLOT_INIT_DATE PLOT_END_DATE
107
%token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_RESULTS_AFTER_LOAD_MH LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LOGDATA LYAPUNOV LINEAR_APPROXIMATION
108
%token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT
Johannes Pfeifer's avatar
Johannes Pfeifer committed
109
%token MFS MH_CONF_SIG MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER POSTERIOR_MAX_SUBSAMPLE_DRAWS MIN MINIMAL_SOLVING_PERIODS
110
%token MODE_CHECK MODE_CHECK_NEIGHBOURHOOD_SIZE MODE_CHECK_SYMMETRIC_PLOTS MODE_CHECK_NUMBER_OF_POINTS MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN
111
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO CONTEMPORANEOUS_CORRELATION DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL RAFTERY_LEWIS_QRS RAFTERY_LEWIS_DIAGNOSTICS MCMC_JUMPING_COVARIANCE MOMENT_CALIBRATION
112
%token NUMBER_OF_PARTICLES RESAMPLING SYSTEMATIC GENERIC RESAMPLING_THRESHOLD RESAMPLING_METHOD KITAGAWA STRATIFIED SMOOTH
113
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW WRITE_EQUATION_TAGS
114
%token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
115
%token <string_val> NAME
116
%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE RESCALE_PREDICTION_ERROR_COVARIANCE GENERATE_IRFS
117
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY
118
%token NOGRAPH POSTERIOR_NOGRAPH POSTERIOR_GRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS STDERR_MULTIPLES DIAGONAL_ONLY
119
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE
120
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
121
%token PERFECT_FORESIGHT_SETUP PERFECT_FORESIGHT_SOLVER NO_POSTERIOR_KERNEL_DENSITY FUNCTION
122
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN MLE_MODE PRUNING
sebastien's avatar
sebastien committed
123
%token <string_val> QUOTED_STRING
124
%token QZ_CRITERIUM QZ_ZERO_THRESHOLD FULL DSGE_VAR DSGE_VARLAG DSGE_PRIOR_WEIGHT TRUNCATE
125
%token RELATIVE_IRF REPLIC SIMUL_REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE PARAMETER_UNCERTAINTY
126
%token SHOCKS SHOCK_DECOMPOSITION SHOCK_GROUPS USE_SHOCK_GROUPS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED ENDOGENOUS_TERMINAL_PERIOD
127
%token SMOOTHER SMOOTHER2HISTVAL SQUARE_ROOT_SOLVER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO SOLVER_PERIODS ROBUST_LIN_SOLVE
128
%token STDERR STEADY STOCH_SIMUL SURPRISE SYLVESTER SYLVESTER_FIXED_POINT_TOL REGIMES REGIME REALTIME_SHOCK_DECOMPOSITION
129
%token TEX RAMSEY_MODEL RAMSEY_POLICY RAMSEY_CONSTRAINTS PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
130
%token <string_val> TEX_NAME
131
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR GSA_SAMPLE_FILE USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED
132
%token VALUES VAR VAREXO VAREXO_DET VAROBS PREDETERMINED_VARIABLES PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
133
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL WRITE_LATEX_STEADY_STATE_MODEL
134
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP QOQ YOY AOA
135
%left COMMA
136 137
%left EQUAL_EQUAL EXCLAMATION_EQUAL
%left LESS GREATER LESS_EQUAL GREATER_EQUAL
138 139
%left PLUS MINUS
%left TIMES DIVIDE
140
%left UMINUS UPLUS
141
%nonassoc POWER
142
%token EXP LOG LN LOG10 SIN COS TAN ASIN ACOS ATAN SINH COSH TANH ERF
143
%token ASINH ACOSH ATANH SQRT NORMCDF NORMPDF STEADY_STATE EXPECTATION
144
/* GSA analysis */
145
%token DYNARE_SENSITIVITY MORRIS STAB REDFORM PPRIOR PRIOR_RANGE PPOST ILPTAU MORRIS_NLIV
146
%token MORRIS_NTRA NSAM LOAD_REDFORM LOAD_RMSE LOAD_STAB ALPHA2_STAB LOGTRANS_REDFORM THRESHOLD_REDFORM
147
%token KSSTAT_REDFORM ALPHA2_REDFORM NAMENDO NAMLAGENDO NAMEXO RMSE LIK_ONLY VAR_RMSE PFILT_RMSE ISTART_RMSE
148
%token ALPHA_RMSE ALPHA2_RMSE
149
/* end of GSA analysis*/
150
%token FREQ INITIAL_YEAR INITIAL_SUBPERIOD FINAL_YEAR FINAL_SUBPERIOD DATA VLIST LOG_VAR PERCENT_VAR
151
%token VLISTLOG VLISTPER SPECTRAL_DENSITY
152
%token RESTRICTION RESTRICTION_FNAME CROSS_RESTRICTIONS NLAGS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST
153
%token DUMMY_OBS NSTATES INDXSCALESSTATES NO_BAYESIAN_PRIOR SPECIFICATION SIMS_ZHA
154
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM EPS PDF FIG DR NONE PRIOR PRIOR_VARIANCE HESSIAN IDENTITY_MATRIX DIRICHLET DIAGONAL OPTIMAL
155
%token GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD WEIBULL WEIBULL_PDF
156
%token INDXPARR INDXOVR INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
157
%token INDXESTIMA INDXGDLS EQ_MS FILTER_COVARIANCE FILTER_DECOMPOSITION SMOOTHED_STATE_UNCERTAINTY
158
%token EQ_CMS TLINDX TLNUMBER BANACT RESTRICTIONS POSTERIOR_SAMPLER_OPTIONS
159
%token OUTPUT_FILE_TAG DRAWS_NBR_BURN_IN_1 DRAWS_NBR_BURN_IN_2 HORIZON
Houtan Bastani's avatar
Houtan Bastani committed
160 161
%token SBVAR TREND_VAR DEFLATOR GROWTH_FACTOR MS_IRF MS_VARIANCE_DECOMPOSITION
%token MS_ESTIMATION MS_SIMULATION MS_COMPUTE_MDD MS_COMPUTE_PROBABILITIES MS_FORECAST
162
%token SVAR_IDENTIFICATION EQUATION EXCLUSION LAG UPPER_CHOLESKY LOWER_CHOLESKY MONTHLY QUARTERLY
163
%token MARKOV_SWITCHING CHAIN DURATION NUMBER_OF_REGIMES NUMBER_OF_LAGS
164
%token SVAR SVAR_GLOBAL_IDENTIFICATION_CHECK COEFF COEFFICIENTS VARIANCES CONSTANTS EQUATIONS
165
%token EXTERNAL_FUNCTION EXT_FUNC_NAME EXT_FUNC_NARGS FIRST_DERIV_PROVIDED SECOND_DERIV_PROVIDED
166
%token SELECTED_VARIABLES_ONLY COVA_COMPUTE SIMULATION_FILE_TAG FILE_TAG
167
%token NO_ERROR_BANDS ERROR_BAND_PERCENTILES SHOCKS_PER_PARAMETER NO_CREATE_INIT
168
%token SHOCK_DRAWS FREE_PARAMETERS MEDIAN DATA_OBS_NBR NEIGHBORHOOD_WIDTH PVALUE_KS PVALUE_CORR
169
%token FILTERED_PROBABILITIES REAL_TIME_SMOOTHED PRIOR_FUNCTION POSTERIOR_FUNCTION SAMPLING_DRAWS
Houtan Bastani's avatar
Houtan Bastani committed
170
%token PROPOSAL_TYPE PROPOSAL_UPPER_BOUND PROPOSAL_LOWER_BOUND PROPOSAL_DRAWS USE_MEAN_CENTER
171
%token ADAPTIVE_MH_DRAWS THINNING_FACTOR COEFFICIENTS_PRIOR_HYPERPARAMETERS SMM_ESTIMATION GMM_ESTIMATION
Houtan Bastani's avatar
Houtan Bastani committed
172 173
%token CONVERGENCE_STARTING_VALUE CONVERGENCE_ENDING_VALUE CONVERGENCE_INCREMENT_VALUE
%token MAX_ITERATIONS_STARTING_VALUE MAX_ITERATIONS_INCREMENT_VALUE MAX_BLOCK_ITERATIONS
174
%token MAX_REPEATED_OPTIMIZATION_RUNS FUNCTION_CONVERGENCE_CRITERION SAVE_REALTIME
Houtan Bastani's avatar
Houtan Bastani committed
175 176 177
%token PARAMETER_CONVERGENCE_CRITERION NUMBER_OF_LARGE_PERTURBATIONS NUMBER_OF_SMALL_PERTURBATIONS
%token NUMBER_OF_POSTERIOR_DRAWS_AFTER_PERTURBATION MAX_NUMBER_OF_STAGES
%token RANDOM_FUNCTION_CONVERGENCE_CRITERION RANDOM_PARAMETER_CONVERGENCE_CRITERION
178 179 180 181
%token CENTERED_MOMENTS AUTOLAG RECURSIVE_ORDER_ESTIMATION BARTLETT_KERNEL_LAG WEIGHTING_MATRIX PENALIZED_ESTIMATOR VERBOSE
%token SIMULATION_MULTIPLE SEED BOUNDED_SHOCK_SUPPORT
%token ANALYTICAL_GIRF IRF_IN_PERCENT EMAS_GIRF EMAS_DROP EMAS_TOLF EMAS_MAX_ITER

182
%token <vector_string_val> SYMBOL_VEC
183

michel's avatar
michel committed
184
%type <node_val> expression expression_or_empty
185
%type <node_val> equation hand_side
186 187
%type <string_val> non_negative_number signed_number signed_integer date_str
%type <string_val> filename symbol vec_of_vec_value vec_value_list date_expr
188
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
189
%type <string_val> range vec_value_w_inf vec_value_1_w_inf
190
%type <string_val> integer_range signed_integer_range sub_sampling_options list_sub_sampling_option
191 192
%type <string_pair_val> named_var_elem
%type <vector_string_pair_val> named_var named_var_1
193
%type <symbol_type_val> change_type_arg
194
%type <vector_string_val> change_type_var_list subsamples_eq_opt prior_eq_opt options_eq_opt calibration_range
195
%type <vector_int_val> vec_int_elem vec_int_1 vec_int vec_int_number
196
%type <prior_distributions_val> prior_pdf prior_distribution
michel's avatar
michel committed
197 198
%%

199 200
%start statement_list;

201 202 203 204
statement_list : statement
               | statement_list statement
               ;

205 206 207 208
statement : parameters
          | var
          | varexo
          | varexo_det
209
          | predetermined_variables
210
          | model_local_variable
211
          | change_type
212 213 214
          | periods
          | model
          | initval
michel's avatar
michel committed
215
          | initval_file
216 217 218 219 220 221 222 223 224 225 226 227 228 229
          | endval
          | histval
          | init_param
          | shocks
          | mshocks
          | sigma_e
          | steady
          | check
          | simul
          | stoch_simul
          | estimation
          | estimated_params
          | estimated_params_bounds
          | estimated_params_init
230
          | set_time
231
          | data
232
          | prior
233
          | prior_eq
234
          | subsamples
235
          | subsamples_eq
236
          | options
237
          | options_eq
238 239 240 241 242 243 244
          | varobs
          | observation_trends
          | unit_root_vars
          | dsample
          | rplot
          | optim_weights
          | osr_params
245
          | osr_params_bounds
246 247 248 249
          | osr
          | dynatype
          | dynasave
          | model_comparison
250
          | model_info
251
          | planner_objective
252
          | ramsey_model
253
          | ramsey_policy
254 255
	  | ramsey_constraints
	  | discretionary_policy
256 257
          | bvar_density
          | bvar_forecast
258
          | sbvar
259
          | dynare_sensitivity
260
          | homotopy_setup
261
          | forecast
262 263
          | load_params_and_steady_state
          | save_params_and_steady_state
sebastien's avatar
sebastien committed
264
          | identification
265 266
          | write_latex_dynamic_model
          | write_latex_static_model
267
          | write_latex_original_model
268
          | write_latex_steady_state_model
269
          | shock_decomposition
270
          | realtime_shock_decomposition
271
          | plot_shock_decomposition
272
          | initial_condition_decomposition
273 274 275
          | conditional_forecast
          | conditional_forecast_paths
          | plot_conditional_forecast
276
          | svar_identification
277
          | svar_global_identification_check
278 279
          | markov_switching
          | svar
280
          | external_function
281
          | steady_state_model
282
          | trend_var
283
          | generate_irfs
284
          | log_trend_var
Houtan Bastani's avatar
Houtan Bastani committed
285 286 287 288 289 290 291
          | ms_estimation
          | ms_simulation
          | ms_compute_mdd
          | ms_compute_probabilities
          | ms_forecast
          | ms_irf
          | ms_variance_decomposition
292
          | calib_smoother
293
          | extended_path
294
          | model_diagnostics
295 296
          | moment_calibration
          | irf_calibration
297 298
          | smoother2histval
          | histval_file
299 300
          | perfect_foresight_setup
          | perfect_foresight_solver
301 302
          | prior_function
          | posterior_function
303 304
          | gmm_estimation
          | smm_estimation
305
          | shock_groups
306 307 308 309 310 311
          ;

dsample : DSAMPLE INT_NUMBER ';'
          { driver.dsample($2); }
        | DSAMPLE INT_NUMBER INT_NUMBER ';'
          { driver.dsample($2, $3); }
michel's avatar
michel committed
312 313
        ;

314
rplot : RPLOT symbol_list ';' { driver.rplot(); };
315

316 317 318 319 320
trend_var : TREND_VAR '(' GROWTH_FACTOR EQUAL { driver.begin_trend(); } hand_side ')' trend_var_list ';'
            { driver.end_trend_var($6); }
          ;

trend_var_list : trend_var_list symbol
321
                 { driver.declare_trend_var(false, $2); }
322
               | trend_var_list COMMA symbol
323
                 { driver.declare_trend_var(false, $3); }
324
               | symbol
325
                 { driver.declare_trend_var(false, $1); }
326
               | trend_var_list symbol TEX_NAME
327
                 { driver.declare_trend_var(false, $2, $3); }
328
               | trend_var_list COMMA symbol TEX_NAME
329
                 { driver.declare_trend_var(false, $3, $4); }
330
               | symbol TEX_NAME
331
                 { driver.declare_trend_var(false, $1, $2); }
332 333
               ;

334
log_trend_var : LOG_TREND_VAR '(' LOG_GROWTH_FACTOR EQUAL { driver.begin_trend(); } hand_side ')' log_trend_var_list ';'
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
                { driver.end_trend_var($6); }
              ;

log_trend_var_list : log_trend_var_list symbol
                     { driver.declare_trend_var(true, $2); }
                   | log_trend_var_list COMMA symbol
                     { driver.declare_trend_var(true, $3); }
                   | symbol
                     { driver.declare_trend_var(true, $1); }
                   | log_trend_var_list symbol TEX_NAME
                     { driver.declare_trend_var(true, $2, $3); }
                   | log_trend_var_list COMMA symbol TEX_NAME
                     { driver.declare_trend_var(true, $3, $4); }
                   | symbol TEX_NAME
                     { driver.declare_trend_var(true, $1, $2); }
                   ;

352 353
var : VAR var_list ';'
    | VAR '(' DEFLATOR EQUAL { driver.begin_trend(); } hand_side ')' nonstationary_var_list ';'
354 355 356
      { driver.end_nonstationary_var(false, $6); }
    | VAR '(' LOG_DEFLATOR EQUAL { driver.begin_trend(); } hand_side ')' nonstationary_var_list ';'
      { driver.end_nonstationary_var(true, $6); }
357 358 359 360 361 362 363 364
    ;

nonstationary_var_list : nonstationary_var_list symbol
                         { driver.declare_nonstationary_var($2); }
                       | nonstationary_var_list COMMA symbol
                         { driver.declare_nonstationary_var($3); }
                       | symbol
                         { driver.declare_nonstationary_var($1); }
365 366 367 368 369 370
                       |  nonstationary_var_list symbol named_var
                         { driver.declare_nonstationary_var($2, NULL, $3); }
                       | nonstationary_var_list COMMA symbol named_var
                         { driver.declare_nonstationary_var($3, NULL, $4); }
                       | symbol named_var
                         { driver.declare_nonstationary_var($1, NULL, $2); }
371 372 373 374 375 376
                       | nonstationary_var_list symbol TEX_NAME
                         { driver.declare_nonstationary_var($2, $3); }
                       | nonstationary_var_list COMMA symbol TEX_NAME
                         { driver.declare_nonstationary_var($3, $4); }
                       | symbol TEX_NAME
                         { driver.declare_nonstationary_var($1, $2); }
377 378 379 380 381 382
                       | nonstationary_var_list symbol TEX_NAME named_var
                         { driver.declare_nonstationary_var($2, $3, $4); }
                       | nonstationary_var_list COMMA symbol TEX_NAME named_var
                         { driver.declare_nonstationary_var($3, $4, $5); }
                       | symbol TEX_NAME named_var
                         { driver.declare_nonstationary_var($1, $2, $3); }
383
                       ;
384 385 386 387 388

varexo : VAREXO varexo_list ';';

varexo_det : VAREXO_DET varexo_det_list ';';

389 390
predetermined_variables : PREDETERMINED_VARIABLES predetermined_variables_list ';';

391 392
parameters : PARAMETERS parameter_list ';';

393 394
model_local_variable : MODEL_LOCAL_VARIABLE model_local_variable_list ';';

395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
named_var_elem : symbol EQUAL QUOTED_STRING
               {
                  pair<string *, string *> *pr = new pair<string *, string *>($1, $3);
                  $$ = pr;
               }

named_var_1 : '(' named_var_elem
              {
                $$ = new vector<pair<string *, string *> *>();
                $$->push_back($2);
              }
            | '(' COMMA named_var_elem
              {
                $$ = new vector<pair<string *, string *> *>();
                $$->push_back($3);
              }
            | named_var_1 named_var_elem
              {
                $1->push_back($2);
                $$ = $1;
              }
            | named_var_1 COMMA named_var_elem
              {
                $1->push_back($3);
                $$ = $1;
              }
            ;

named_var : named_var_1 ')' { $$ = $1; }
          | named_var_1 COMMA ')' { $$ = $1; }
425 426
          ;

427
var_list : var_list symbol
428
           { driver.declare_endogenous($2); }
429
         | var_list COMMA symbol
430
           { driver.declare_endogenous($3); }
431
         | symbol
432
           { driver.declare_endogenous($1); }
433 434 435 436 437 438
         | var_list symbol named_var
           { driver.declare_endogenous($2, NULL, $3); }
         | var_list COMMA symbol named_var
           { driver.declare_endogenous($3, NULL, $4); }
         | symbol named_var
           { driver.declare_endogenous($1, NULL, $2); }
439
         | var_list symbol TEX_NAME
440
           { driver.declare_endogenous($2, $3); }
441
         | var_list COMMA symbol TEX_NAME
442
           { driver.declare_endogenous($3, $4); }
443
         | symbol TEX_NAME
444
           { driver.declare_endogenous($1, $2); }
445 446 447 448 449 450
         | var_list symbol TEX_NAME named_var
           { driver.declare_endogenous($2, $3, $4); }
         | var_list COMMA symbol TEX_NAME named_var
           { driver.declare_endogenous($3, $4, $5); }
         | symbol TEX_NAME named_var
           { driver.declare_endogenous($1, $2, $3); }
451
         ;
michel's avatar
michel committed
452

453
varexo_list : varexo_list symbol
454
              { driver.declare_exogenous($2); }
455
            | varexo_list COMMA symbol
456
              { driver.declare_exogenous($3); }
457
            | symbol
458
              { driver.declare_exogenous($1); }
459 460 461 462 463 464
            | varexo_list symbol named_var
              { driver.declare_exogenous($2, NULL, $3); }
            | varexo_list COMMA symbol named_var
              { driver.declare_exogenous($3, NULL, $4); }
            | symbol named_var
              { driver.declare_exogenous($1, NULL, $2); }
465
            | varexo_list symbol TEX_NAME
466
              { driver.declare_exogenous($2, $3); }
467
            | varexo_list COMMA symbol TEX_NAME
468
              { driver.declare_exogenous($3, $4); }
469
            | symbol TEX_NAME
470
              { driver.declare_exogenous($1, $2); }
471 472 473 474 475 476
            | varexo_list symbol TEX_NAME named_var
              { driver.declare_exogenous($2, $3, $4); }
            | varexo_list COMMA symbol TEX_NAME named_var
              { driver.declare_exogenous($3, $4, $5); }
            | symbol TEX_NAME named_var
              { driver.declare_exogenous($1, $2, $3); }
477
            ;
michel's avatar
michel committed
478

479
varexo_det_list : varexo_det_list symbol
480
                  { driver.declare_exogenous_det($2); }
481
                | varexo_det_list COMMA symbol
482
                  { driver.declare_exogenous_det($3); }
483
                | symbol
484
                  { driver.declare_exogenous_det($1); }
485 486 487 488 489 490
                | varexo_det_list symbol named_var
                  { driver.declare_exogenous_det($2, NULL, $3); }
                | varexo_det_list COMMA symbol named_var
                  { driver.declare_exogenous_det($3, NULL, $4); }
                | symbol named_var
                  { driver.declare_exogenous_det($1, NULL, $2); }
491
                | varexo_det_list symbol TEX_NAME
492
                  { driver.declare_exogenous_det($2, $3); }
493
                | varexo_det_list COMMA symbol TEX_NAME
494
                  { driver.declare_exogenous_det($3, $4); }
495
                | symbol TEX_NAME
496
                   { driver.declare_exogenous_det($1, $2); }
497 498 499 500 501 502
                | varexo_det_list symbol TEX_NAME named_var
                  { driver.declare_exogenous_det($2, $3, $4); }
                | varexo_det_list COMMA symbol TEX_NAME named_var
                  { driver.declare_exogenous_det($3, $4, $5); }
                | symbol TEX_NAME named_var
                   { driver.declare_exogenous_det($1, $2, $3); }
503
                ;
504

505
parameter_list : parameter_list symbol
506
                 { driver.declare_parameter($2); }
507
               | parameter_list COMMA symbol
508
                 { driver.declare_parameter($3); }
509
               | symbol
510
                 { driver.declare_parameter($1); }
511 512 513 514 515 516
               | parameter_list symbol named_var
                 { driver.declare_parameter($2, NULL, $3); }
               | parameter_list COMMA symbol named_var
                 { driver.declare_parameter($3, NULL, $4); }
               | symbol named_var
                 { driver.declare_parameter($1, NULL, $2); }
517
               | parameter_list symbol TEX_NAME
518
                 { driver.declare_parameter($2, $3); }
519
               | parameter_list COMMA symbol TEX_NAME
520
                 { driver.declare_parameter($3, $4); }
521
               | symbol TEX_NAME
522
                 { driver.declare_parameter($1, $2); }
523 524 525 526 527 528
               | parameter_list symbol TEX_NAME named_var
                 { driver.declare_parameter($2, $3, $4); }
               | parameter_list COMMA symbol TEX_NAME named_var
                 { driver.declare_parameter($3, $4, $5); }
               | symbol TEX_NAME named_var
                 { driver.declare_parameter($1, $2, $3); }
529
               ;
530

531 532 533 534 535 536 537 538
predetermined_variables_list : predetermined_variables_list symbol
                               { driver.add_predetermined_variable($2); }
                             | predetermined_variables_list COMMA symbol
                               { driver.add_predetermined_variable($3); }
                             | symbol
                               { driver.add_predetermined_variable($1); }
                             ;

539 540 541 542 543 544 545 546 547 548 549 550 551 552
model_local_variable_list : model_local_variable_list symbol
                            { driver.declare_model_local_variable($2); }
                          | model_local_variable_list COMMA symbol
                            { driver.declare_model_local_variable($3); }
                          | symbol
                            { driver.declare_model_local_variable($1); }
                          | model_local_variable_list symbol TEX_NAME
                            { driver.declare_model_local_variable($2, $3); }
                          | model_local_variable_list COMMA symbol TEX_NAME
                            { driver.declare_model_local_variable($3, $4); }
                          | symbol TEX_NAME
                            { driver.declare_model_local_variable($1, $2); }
                          ;

553 554 555 556 557 558 559 560 561 562 563 564 565 566
change_type : CHANGE_TYPE '(' change_type_arg ')' change_type_var_list ';'
              { driver.change_type($3, $5); }
            ;

change_type_arg : PARAMETERS
                  { $$ = eParameter; }
                | VAR
                  { $$ = eEndogenous; }
                | VAREXO
                  { $$ = eExogenous; }
                | VAREXO_DET
                  { $$ = eExogenousDet; }
                ;

567
change_type_var_list : symbol
568
                       { $$ = new vector<string *>(); $$->push_back($1); }
569
                     | change_type_var_list symbol
570
                       { $$ = $1; $1->push_back($2); }
571
                     | change_type_var_list COMMA symbol
572 573 574
                       { $$ = $1; $1->push_back($3); }
                     ;

575 576 577 578 579
periods : PERIODS INT_NUMBER ';'
          { driver.periods($2); }
        | PERIODS EQUAL INT_NUMBER ';'
          { driver.periods($3); }
        ;
580

581
init_param : symbol EQUAL expression ';' { driver.init_param($1, $3); };
582 583 584

expression : '(' expression ')'
             { $$ = $2;}
585
           | symbol
586
             { $$ = driver.add_expression_variable($1); }
587 588
           | non_negative_number
             { $$ = driver.add_non_negative_constant($1); }
589 590 591 592 593 594 595 596 597 598
           | expression PLUS expression
             { $$ = driver.add_plus($1, $3); }
           | expression MINUS expression
             { $$ = driver.add_minus($1, $3); }
           | expression DIVIDE expression
             { $$ = driver.add_divide($1, $3); }
           | expression TIMES expression
             { $$ = driver.add_times($1, $3); }
           | expression POWER expression
             { $$ = driver.add_power($1, $3); }
ferhat's avatar
ferhat committed
599 600 601 602 603 604 605 606 607 608 609 610
           | expression LESS expression
             { $$ = driver.add_less($1, $3); }
           | expression GREATER expression
             { $$ = driver.add_greater($1, $3); }
           | expression LESS_EQUAL expression
             { $$ = driver.add_less_equal($1, $3); }
           | expression GREATER_EQUAL expression
             { $$ = driver.add_greater_equal($1, $3); }
           | expression EQUAL_EQUAL expression
             { $$ = driver.add_equal_equal($1, $3); }
           | expression EXCLAMATION_EQUAL expression
             { $$ = driver.add_different($1, $3); }
611 612
           | MINUS expression %prec UMINUS
             { $$ = driver.add_uminus($2); }
613
           | PLUS expression %prec UPLUS
614 615 616 617 618
             { $$ = $2; }
           | EXP '(' expression ')'
             { $$ = driver.add_exp($3); }
           | LOG '(' expression ')'
             { $$ = driver.add_log($3); }
619 620
           | LN '(' expression ')'
             { $$ = driver.add_log($3); }
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
           | LOG10 '(' expression ')'
             { $$ = driver.add_log10($3); }
           | SIN '(' expression ')'
             { $$ = driver.add_sin($3); }
           | COS '(' expression ')'
             { $$ = driver.add_cos($3); }
           | TAN '(' expression ')'
             { $$ = driver.add_tan($3); }
           | ASIN '(' expression ')'
             { $$ = driver.add_asin($3); }
           | ACOS '(' expression ')'
             { $$ = driver.add_acos($3); }
           | ATAN '(' expression ')'
             { $$ = driver.add_atan($3); }
           | SQRT '(' expression ')'
             { $$ = driver.add_sqrt($3); }
637 638 639 640
           | ABS '(' expression ')'
             { $$ = driver.add_abs($3); }
           | SIGN '(' expression ')'
             { $$ = driver.add_sign($3); }
641
           | MAX '(' expression COMMA expression ')'
sebastien's avatar
sebastien committed
642
             { $$ = driver.add_max($3, $5); }
643
           | MIN '(' expression COMMA expression ')'
sebastien's avatar
sebastien committed
644
             { $$ = driver.add_min($3, $5); }
645
           | symbol { driver.push_external_function_arg_vector_onto_stack(); } '(' comma_expression ')'
646
             { $$ = driver.add_model_var_or_external_function($1, false); }
647
           | NORMCDF '(' expression COMMA expression COMMA expression ')'
sebastien's avatar
sebastien committed
648
             { $$ = driver.add_normcdf($3, $5, $7); }
649
           | NORMCDF '(' expression ')'
sebastien's avatar
sebastien committed
650
             { $$ = driver.add_normcdf($3); }
651 652 653 654
           | NORMPDF '(' expression COMMA expression COMMA expression ')'
             { $$ = driver.add_normpdf($3, $5, $7); }
           | NORMPDF '(' expression ')'
             { $$ = driver.add_normpdf($3); }
655 656
           | ERF '(' expression ')'
             { $$ = driver.add_erf($3); }
657 658 659 660
           | NAN_CONSTANT
             { $$ = driver.add_nan_constant(); }
           | INF_CONSTANT
             { $$ = driver.add_inf_constant(); }
661
           ;
662

663
comma_expression : expression
664 665 666
                   { driver.add_external_function_arg($1); }
                 | comma_expression COMMA expression
                   { driver.add_external_function_arg($3); }
667
                 ;
michel's avatar
michel committed
668

michel's avatar
michel committed
669
expression_or_empty : {$$ = driver.add_nan_constant();}
670 671
                    | expression
	            ;
michel's avatar
michel committed
672

673
initval : INITVAL ';' initval_list END ';'
674 675 676 677
          { driver.end_initval(false); }
        | INITVAL '(' ALL_VALUES_REQUIRED ')' ';' initval_list END ';'
          { driver.end_initval(true); }
        ;
michel's avatar
michel committed
678

sebastien's avatar
sebastien committed
679
initval_file : INITVAL_FILE '(' FILENAME EQUAL filename ')' ';'
michel's avatar
michel committed
680 681
               { driver.initval_file($5); }
             ;
682

683 684 685 686 687
endval : ENDVAL ';' initval_list END ';'
         { driver.end_endval(false); }
       | ENDVAL '(' ALL_VALUES_REQUIRED ')' ';' initval_list END ';'
         { driver.end_endval(true); }
       ;
688 689 690 691 692

initval_list : initval_list initval_elem
             | initval_elem
             ;

693
initval_elem : symbol EQUAL expression ';' { driver.init_val($1, $3); };
694

695 696 697 698 699
histval : HISTVAL ';' histval_list END ';'
          { driver.end_histval(false); };
        | HISTVAL '(' ALL_VALUES_REQUIRED ')' ';' histval_list END ';'
          { driver.end_histval(true); }
        ;
700 701 702 703 704

histval_list : histval_list histval_elem
             | histval_elem
             ;

705
histval_elem : symbol '(' signed_integer ')' EQUAL expression ';' { driver.hist_val($1, $3, $6); };
706

707 708 709 710
histval_file : HISTVAL_FILE '(' FILENAME EQUAL filename ')' ';'
               { driver.histval_file($5); }
             ;

711 712
model_options : BLOCK { driver.block(); }
              | o_cutoff
713
							| o_mfs
714 715
              | BYTECODE { driver.byte_code(); }
              | USE_DLL { driver.use_dll(); }
716
              | NO_STATIC { driver.no_static();}
717 718
              | DIFFERENTIATE_FORWARD_VARS { driver.differentiate_forward_vars_all(); }
              | DIFFERENTIATE_FORWARD_VARS EQUAL '(' symbol_list ')' { driver.differentiate_forward_vars_some(); }
719
              | o_linear
720
              | PARALLEL_LOCAL_FILES EQUAL '(' parallel_local_filename_list ')'
721 722 723 724 725
              ;

model_options_list : model_options_list COMMA model_options
                   | model_options
                   ;
michel's avatar
michel committed
726

727
model : MODEL ';' { driver.begin_model(); }
728
        equation_list END ';' { driver.end_model(); }
729
      | MODEL '(' model_options_list ')' ';' { driver.begin_model(); }
730
        equation_list END ';' { driver.end_model(); }
731 732 733 734 735 736 737
      ;

equation_list : equation_list equation
              | equation_list pound_expression
              | equation
              | pound_expression
              ;
michel's avatar
michel committed
738

739 740 741 742
equation : hand_side EQUAL hand_side ';'
           { $$ = driver.add_model_equal($1, $3); }
         | hand_side ';'
           { $$ = driver.add_model_equal_with_zero_rhs($1); }
743 744 745 746 747 748 749 750 751 752 753 754
         | '[' tags_list ']' hand_side EQUAL hand_side ';'
           { $$ = driver.add_model_equal($4, $6); }
         | '[' tags_list ']' hand_side ';'
           { $$ = driver.add_model_equal_with_zero_rhs($4); }
         ;

tags_list : tags_list COMMA tag_pair
          | tag_pair
          ;

tag_pair : NAME EQUAL QUOTED_STRING
           { driver.add_equation_tags($1, $3); }
755 756
         | NAME
           { driver.add_equation_tags($1, new string()); }
757
         ;
michel's avatar
michel committed
758

759 760
hand_side : '(' hand_side ')'
            { $$ = $2;}
761 762
          | symbol
            { $$ = driver.add_model_variable($1); }
763 764
          | non_negative_number
            { $$ = driver.add_non_negative_constant($1); }
765 766 767 768 769 770 771 772
          | hand_side PLUS hand_side
            { $$ = driver.add_plus($1, $3); }
          | hand_side MINUS hand_side
            { $$ = driver.add_minus($1, $3); }
          | hand_side DIVIDE hand_side
            { $$ = driver.add_divide($1, $3); }
          | hand_side TIMES hand_side
            { $$ = driver.add_times($1, $3); }
ferhat's avatar
ferhat committed
773 774 775 776 777 778 779 780 781 782 783 784
          | hand_side LESS hand_side
            { $$ = driver.add_less($1, $3); }
          | hand_side GREATER hand_side
            { $$ = driver.add_greater($1, $3); }
          | hand_side LESS_EQUAL hand_side
            { $$ = driver.add_less_equal($1, $3); }
          | hand_side GREATER_EQUAL hand_side
            { $$ = driver.add_greater_equal($1, $3); }
          | hand_side EQUAL_EQUAL hand_side
            { $$ = driver.add_equal_equal($1, $3); }
          | hand_side EXCLAMATION_EQUAL hand_side
            { $$ = driver.add_different($1, $3); }
785 786
          | hand_side POWER hand_side
            { $$ = driver.add_power($1, $3); }
787
          | EXPECTATION '(' signed_integer ')''(' hand_side ')'
788
	    { $$ = driver.add_expectation($3, $6); }
789 790 791 792 793 794 795 796
          | MINUS hand_side %prec UMINUS
            { $$ = driver.add_uminus($2); }
          | PLUS hand_side
            { $$ = $2; }
          | EXP '(' hand_side ')'
            { $$ = driver.add_exp($3); }
          | LOG '(' hand_side ')'
            { $$ = driver.add_log($3); }
797 798
          | LN '(' hand_side ')'
            { $$ = driver.add_log($3); }
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
          | LOG10 '(' hand_side ')'
            { $$ = driver.add_log10($3); }
          | SIN '(' hand_side ')'
            { $$ = driver.add_sin($3); }
          | COS '(' hand_side ')'
            { $$ = driver.add_cos($3); }
          | TAN '(' hand_side ')'
            { $$ = driver.add_tan($3); }
          | ASIN '(' hand_side ')'
            { $$ = driver.add_asin($3); }
          | ACOS '(' hand_side ')'
            { $$ = driver.add_acos($3); }
          | ATAN '(' hand_side ')'
            { $$ = driver.add_atan($3); }
          | SQRT '(' hand_side ')'
            { $$ = driver.add_sqrt($3); }
815 816 817 818
          | ABS '(' hand_side ')'
            { $$ = driver.add_abs($3); }
          | SIGN '(' hand_side ')'
            { $$ = driver.add_sign($3); }
819
          | MAX '(' hand_side COMMA hand_side ')'
820
            { $$ = driver.add_max($3, $5); }
821
          | MIN '(' hand_side COMMA hand_side ')'
822
            { $$ = driver.add_min($3, $5); }
823
          | symbol { driver.push_external_function_arg_vector_onto_stack(); } '(' comma_hand_side ')'
824
            { $$ = driver.add_model_var_or_external_function($1, true); }
825
          | NORMCDF '(' hand_side COMMA hand_side COMMA hand_side ')'
826
            { $$ = driver.add_normcdf($3, $5, $7); }
827
          | NORMCDF '(' hand_side ')'
828
            { $$ = driver.add_normcdf($3); }
829 830 831 832
          | NORMPDF '(' hand_side COMMA hand_side COMMA hand_side ')'
            { $$ = driver.add_normpdf($3, $5, $7); }
          | NORMPDF '(' hand_side ')'
            { $$ = driver.add_normpdf($3); }
833 834
          | ERF '(' hand_side ')'
            { $$ = driver.add_erf($3); }
835
          | STEADY_STATE '(' hand_side ')'
836
            { $$ = driver.add_steady_state($3); }
837 838
          ;

839 840 841 842
comma_hand_side : hand_side
                  { driver.add_external_function_arg($1); }
                | comma_hand_side COMMA hand_side
                  { driver.add_external_function_arg($3); }
843
                ;
844

845
pound_expression: '#' symbol EQUAL hand_side ';'
846 847
                  { driver.declare_and_init_model_local_variable($2, $4); };

848 849 850
shocks : SHOCKS ';' shock_list END ';' { driver.end_shocks(false); }
       | SHOCKS '(' OVERWRITE ')' ';' shock_list END ';' { driver.end_shocks(true); }
       ;
851 852 853 854 855

shock_list : shock_list shock_elem
           | shock_elem
           ;

856
shock_elem : det_shock_elem
857
           | VAR symbol ';' STDERR expression ';'
858
             { driver.add_stderr_shock($2, $5); }
859
           | VAR symbol EQUAL expression ';'
860
             { driver.add_var_shock($2, $4); }
861
           | VAR symbol COMMA symbol EQUAL expression ';'
862
             { driver.add_covar_shock($2, $4, $6); }
863
           | CORR symbol COMMA symbol EQUAL expression ';'
864 865 866
             { driver.add_correl_shock($2, $4, $6); }
           ;

867 868 869 870
det_shock_elem : VAR symbol ';' PERIODS period_list ';' VALUES value_list ';'
                 { driver.add_det_shock($2, false); }
               ;

Houtan Bastani's avatar
Houtan Bastani committed
871
svar_identification : SVAR_IDENTIFICATION {driver.begin_svar_identification();} ';' svar_identification_list END ';'
houtanb's avatar
houtanb committed
872
                      { driver.end_svar_identification(); }
873 874
                    ;

875 876 877 878 879 880 881 882
svar_identification_list : svar_identification_list svar_identification_elem
                         | svar_identification_elem
                         ;

svar_identification_elem : EXCLUSION LAG INT_NUMBER ';' svar_equation_list
                           { driver.combine_lag_and_restriction($3); }
                         | EXCLUSION CONSTANTS ';'
                           { driver.add_constants_exclusion(); }
883 884
                         | RESTRICTION EQUATION INT_NUMBER COMMA
			 { driver.add_restriction_equation_nbr($3);}
885 886
                           restriction_expression EQUAL
                                {driver.add_restriction_equal();}
887
                           restriction_expression ';'
888
                         | UPPER_CHOLESKY ';'
houtanb's avatar
houtanb committed
889
                           { driver.add_upper_cholesky(); }
890
                         | LOWER_CHOLESKY ';'
houtanb's avatar
houtanb committed
891
                           { driver.add_lower_cholesky(); }
892 893 894
                         ;

svar_equation_list : svar_equation_list EQUATION INT_NUMBER COMMA svar_var_list ';'
houtanb's avatar
houtanb committed
895
                     { driver.add_restriction_in_equation($3); }
896
                   | EQUATION INT_NUMBER COMMA svar_var_list ';'
houtanb's avatar
houtanb committed
897
                     { driver.add_restriction_in_equation($2); }
898 899 900
                   ;

svar_var_list : svar_var_list COMMA symbol
houtanb's avatar
houtanb committed
901
                { driver.add_in_svar_restriction_symbols($3); }
902
              | symbol
houtanb's avatar
houtanb committed
903
                { driver.add_in_svar_restriction_symbols($1); }
904 905
              ;

906
restriction_expression : expression {driver.check_restriction_expression_constant($1);}
907 908 909 910 911
                       | restriction_expression_1
                       ;

restriction_expression_1 : restriction_elem_expression
                         | restriction_expression_1 restriction_elem_expression
912
                         ;
913 914 915

restriction_elem_expression : COEFF '(' symbol COMMA INT_NUMBER ')'
                                 { driver.add_positive_restriction_element($3,$5);}
916 917
                            | PLUS COEFF '(' symbol COMMA INT_NUMBER ')'
		                 { driver.add_positive_restriction_element($4,$6);}
918 919 920 921 922
                            | MINUS COEFF '(' symbol COMMA INT_NUMBER ')'
		                 { driver.add_negative_restriction_element($4,$6);}
                            | expression TIMES COEFF '(' symbol COMMA INT_NUMBER ')'
                                 { driver.add_positive_restriction_element($1,$5,$7);}
                            ;
923

924 925 926 927
svar_global_identification_check: SVAR_GLOBAL_IDENTIFICATION_CHECK ';'
                                  { driver.add_svar_global_identification_check(); }
                                ;
				
928
markov_switching : MARKOV_SWITCHING '(' ms_options_list ')' ';'
houtanb's avatar
houtanb committed
929
                   { driver.markov_switching(); }
930 931 932 933 934 935 936 937
                 ;

ms_options_list : ms_options_list COMMA ms_options
                | ms_options
                ;

ms_options : o_chain
           | o_duration
938
           | o_restrictions
939
           | o_number_of_regimes
940 941
           | o_number_of_lags
           | o_parameters
942 943 944
           ;

svar : SVAR '(' svar_options_list ')' ';'
houtanb's avatar
houtanb committed
945
       { driver.svar(); }
946 947 948 949 950 951 952 953
     ;

svar_options_list : svar_options_list COMMA svar_options
                  | svar_options
                  ;

svar_options : o_coefficients
             | o_variances
houtanb's avatar
houtanb committed
954
             | o_equations
955 956 957
             | o_chain
             ;

958 959 960
mshocks : MSHOCKS ';' mshock_list END ';' { driver.end_mshocks(false); }
        | MSHOCKS '(' OVERWRITE ')' ';' mshock_list END ';' { driver.end_mshocks(true); }
        ;
961 962 963 964 965

mshock_list : mshock_list det_shock_elem
            | det_shock_elem
            ;

966
period_list : period_list COMMA INT_NUMBER
967
              { driver.add_period($3); }
ferhat's avatar
ferhat committed
968 969
            | period_list INT_NUMBER
              { driver.add_period($2); }
970 971
            | period_list COMMA INT_NUMBER ':' INT_NUMBER
              { driver.add_period($3, $5); }
ferhat's avatar
ferhat committed
972 973
            | period_list INT_NUMBER ':' INT_NUMBER
              { driver.add_period($2, $4); }
974 975 976 977 978 979 980
            | INT_NUMBER ':' INT_NUMBER
              { driver.add_period($1, $3); }
            | INT_NUMBER
              { driver.add_period($1); }
            ;

sigma_e : SIGMA_E EQUAL '[' triangular_matrix ']' ';' { driver.do_sigma_e(); };
michel's avatar
michel committed
981

982 983 984 985 986 987
value_list : value_list COMMA '(' expression ')'
             { driver.add_value($4); }
           | value_list '(' expression ')'
             { driver.add_value($3); }
           | '(' expression ')'
             { driver.add_value($2); }
988
           | value_list COMMA signed_number
989
             { driver.add_value($3); }
990
           | value_list signed_number
991
             { driver.add_value($2); }
992
           | signed_number
993 994
             { driver.add_value($1); }
           ;
995

996 997 998 999 1000 1001 1002 1003
triangular_matrix : triangular_matrix ';' triangular_row
                    { driver.end_of_row(); }
                  | triangular_row
                    { driver.end_of_row(); }
                  ;

triangular_row : triangular_row COMMA '(' expression ')'
                 { driver.add_to_row($4); }
1004
               | triangular_row COMMA signed_number
1005 1006 1007
                 { driver.add_to_row_const($3); }
               | triangular_row '(' expression ')'
                 { driver.add_to_row($3); }
1008
               | triangular_row signed_number
1009 1010 1011
                 { driver.add_to_row_const($2); }
               | '(' expression ')'
                 { driver.add_to_row($2); }
1012
               | signed_number
1013
                 { driver.add_to_row_const($1); }
michel's avatar
michel committed
1014 1015
               ;

1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
steady : STEADY ';'
         { driver.steady(); }
       | STEADY '(' steady_options_list ')' ';'
         { driver.steady(); }
       ;

steady_options_list : steady_options_list COMMA steady_options
                    | steady_options
                    ;

1026 1027 1028
steady_options : o_solve_algo
               | o_homotopy_mode
               | o_homotopy_steps
1029
               | o_homotopy_force_continue
1030
               | o_markowitz
1031
               | o_steady_maxit
1032
               | o_nocheck
1033
               | o_steady_tolf