Commit Graph

1994 Commits (d657f77149032b83bd1b37a65717d87cbc7068b6)

Author SHA1 Message Date
Houtan Bastani d657f77149 fix typo :) 2018-08-09 13:27:05 +02:00
Houtan Bastani 719630a53c macroprocessor: allow looping over tuples. #5 2018-08-08 17:23:33 +02:00
Houtan Bastani ca066ea398 macroprocessor: introduce shortcut for Cartesion product (^). #5 2018-08-08 15:58:49 +02:00
Houtan Bastani d9c0568075 macroprocessor: introduce Cartesion product. #5 2018-08-08 15:11:06 +02:00
Houtan Bastani e24cabe3a5 var_expectation: print type specific id for discount index 2018-08-08 14:59:50 +02:00
Houtan Bastani 27d088da7e macroprocessor: fix bug in set difference introduced in 5f1465f9 2018-08-08 14:35:09 +02:00
Houtan Bastani 428b5023d3 macroprocessor: intersection operator. #5 2018-08-08 14:15:39 +02:00
Houtan Bastani 039b27bbaf macroprocessor: union operator. #5 2018-08-08 14:12:04 +02:00
Houtan Bastani 1285473aa1 macroprocessor: introduce tuple type. #5 2018-08-07 17:36:13 +02:00
Houtan Bastani c342489397 update gitignore to ignore output files created by preprocessor 2018-08-07 17:19:45 +02:00
Houtan Bastani 88a0162202 macroprocessor: remove terminals not used in grammar 2018-08-07 17:19:45 +02:00
Stéphane Adjemian(Charybdis) b20da7c43f Fixed timing issue in VAR_EXPECTATION expansion. 2018-08-06 21:36:52 +02:00
Stéphane Adjemian(Charybdis) 32da131a77 Added associated index in M_.endo_names for expected variable. 2018-08-04 19:50:12 +02:00
Stéphane Adjemian(Charybdis) ed32caeb46 Added missing field in VAR_EXPECTATION_MODEL description (variable). 2018-08-04 12:03:53 +02:00
Stéphane Adjemian(Charybdis) 022395aaf6 Fixed param_indices vector for VAR_EXPECTATION_MODEL. 2018-08-04 11:46:31 +02:00
Sébastien Villemot f3c2a1bf87 New var_expectation_model statement and re-design of var_expectation operator
Given a previously declared var_model, the var_expectation_model statement is
used to declare a way of forming expectations with this VAR (possibly using a
finite or infinite discounted sum). The var_expectation operator now takes a
single argument, the name of the var_expectation_model.

For the moment, this only works when the var_model is using equations
explicitly declared in the model block.
2018-08-02 08:39:09 +02:00
Sébastien Villemot 8a03532c78 ParsingDriver: factorize code to check symbol types 2018-08-01 10:47:56 +02:00
Sébastien Villemot 122e154764 PlannerObjectiveStatement now owns its model_tree
By the way, error out if the planner_objective statement is used two times.
2018-07-31 13:00:41 +02:00
Sébastien Villemot 0a063eecc1 More smart pointers 2018-07-31 13:00:39 +02:00
Sébastien Villemot 66a712253a Macroprocessor: cosmetic change 2018-07-31 12:02:26 +02:00
Sébastien Villemot df01e52859 Use new syntax for various Bison options 2018-07-31 12:02:26 +02:00
Sébastien Villemot 4302307f7d Force Emacs to use C++ mode when opening Bison and Flex files 2018-07-31 12:02:24 +02:00
Sébastien Villemot 7280c92642 Use variant semantic values in the Bison parser
We can therefore manipulate objects by value rather than by pointers, which
saves a lot of memory manipulations (and avoid potential segfaults and memory
leaks).

Note that there is no default action ("$$ = $1") when using the variant type,
so we add them explicitly.
2018-07-31 11:48:08 +02:00
Sébastien Villemot 725b91e5d6 Several fixes to computing tasks statements
- store objects whose persistence is not guaranteed (e.g. strings) as values
  instead of references (to avoid possible segfaults)
- on the contrary, always store the SymbolTable as a reference, since its
  persistence is guaranteed, and we don't want to copy it
- use pass-by-value in constructors whenever possible
- remove useless const keyword when passing by value
2018-07-31 10:51:28 +02:00
Sébastien Villemot 107ad1432b Fix various Bison warnings 2018-07-30 19:38:46 +02:00
Sébastien Villemot 45cd8e6853 Fix regression in nested diffs introduced in 90d8b579
See McModelTeam/McModelProject/issues/97.
2018-07-30 12:53:23 +02:00
Sébastien Villemot b9ee0bb204 aux_equations may diverge from those in the main model
aux_equations only contain the definition of auxiliary variables, and
may diverge from those in the main model (equations), if other model
transformations applied subsequently. This is not a problem, since
aux_equations is only used for regenerating the values of auxiliaries
given the others.

For example, such a divergence appears when there is an expectation
operator in a ramsey model, see
tests/optimal_policy/nk_ramsey_expectation.mod */
2018-07-27 14:20:36 +02:00
Sébastien Villemot 762f25abe9 Remove useless separate list for diff auxiliary variables
This table serves no useful purpose. It is better to append auxiliary equations
at the time they are created, to avoid messing with the recursive ordering.
2018-07-26 17:41:58 +02:00
Sébastien Villemot 90d8b579cc Fix incorrect recursive ordering of aux vars with diff not used at current period
Ensure that all diff operators appear once with their argument at current
period (i.e. maxLag=0).
If it is not the case, generate the corresponding expressions.

This is necessary to avoid lags of more than one in the auxiliary
equation, which would then be modified by subsequent transformations
(removing lags > 1), which in turn would break the recursive ordering
of auxiliary equations.

See McModelTeam/McModelProject/issues/95 for an example.
2018-07-26 17:41:58 +02:00
Sébastien Villemot 9cf3e034de Macroprocessor: allow empty arrays
This is now easy to implement, thanks to the refactoring allowing any type of
objects in arrays.

Closes DynareTeam/dynare#707
2018-07-25 18:46:55 +02:00
Sébastien Villemot 88fab669c6 Macroprocessor: length() operator called on a string returns the number of characters
Closes DynareTeam/Dynare#1547
2018-07-25 18:42:23 +02:00
Sébastien Villemot 5f1465f9d1 Macroprocessor: replace naked pointers by smart pointers
- use std::unique_ptr for MacroDriver::lexer
- use std::shared_ptr for MacroValue objects constructed by the parser
  This is made possible using Bison 3.0 variant value type.
  Using non-pointer type is not possible since MacroValue is polymorphic.
  Using std::unique_ptr is not possible since the value type must be
  copyable (see
  https://lists.gnu.org/archive/html/bug-bison/2015-03/msg00004.html).
  Define a new type MacroValuePtr == shared_ptr<const MacroValue> for code
  clarity.
  Use the following convention for shared_ptr arguments to functions:
  + if pass-by-value, means that the callee acquires ownership
  + if pass-by-const-reference, the callee does not acquire ownership
- naked pointers are still used for tracking the filename in Bison's location
  type, since we don't have control over that

Also, by the way:
- arrays can now contain elements of any type
- simplify MacroDriver::loop_stack using std::tuple
- toArray() method now fails on function objects
- no need to use const qualifiers, since all MacroValue objects are immutable
- use an exception for detecting division by zero
2018-07-25 18:40:23 +02:00
Sébastien Villemot 372005ed27 Bison: use the %language directive instead of %skeleton for specifying C++ 2018-07-24 14:02:10 +02:00
Sébastien Villemot 937659747a Macroprocessor: error out when length() operator called on a string or an int
Closes DynareTeam/Dynare#1547
2018-07-24 12:49:08 +02:00
Stéphane Adjemian(Charybdis) 49e1c43aed Partially reverted 19048bdca.
There is no reason to associate an exogenous variable or parameter to a
specific equation. For these types the user can use the pipe
notation (|x, |p) in any equations or the usual parameters and varexo statements.
2018-07-19 23:29:27 +02:00
Sébastien Villemot 4a04a38374 C++11: convert ExtendedPreprocessorTypes to class enums 2018-07-18 17:28:26 +02:00
Sébastien Villemot 97868cbd2a Remove unneeded enum keyword 2018-07-18 17:28:26 +02:00
Sébastien Villemot 04b6690d5a C++11: convert ExternalFunctionType to a class enum 2018-07-18 17:28:23 +02:00
Sébastien Villemot 14948401e4 C++11: convert PriorDistributions to a class enum 2018-07-18 16:52:12 +02:00
Sébastien Villemot edddc9d8ca C++11: convert NodeTreeReference to a class enum 2018-07-18 16:35:19 +02:00
Sébastien Villemot 4ad0e500d4 C++11: convert {Unary,Binary,Trinary}Opcode to class enums 2018-07-18 16:18:26 +02:00
Sébastien Villemot 11b1fdcffd Fix implicit narrowing conversions (omitted in previous commit) 2018-07-18 15:12:00 +02:00
Sébastien Villemot d6055c1407 C++11: convert SymbolType to a class enum 2018-07-17 18:55:26 +02:00
Sébastien Villemot c12088f314 C++11: convert AuxVarType to class enum 2018-07-17 17:38:26 +02:00
Sébastien Villemot 89832db1db C++11: convert MatrixForm to a class enum 2018-07-17 17:31:20 +02:00
Sébastien Villemot 946d105c04 Remove C and C++ preprocessor output types
This code is broken since the temporary terms array changes. It is probably not
worth maintaining it.
2018-07-17 16:52:11 +02:00
Sébastien Villemot b8a5dfdc39 Replace several usages of C macroprocessor with C++ constructs 2018-07-17 16:36:58 +02:00
Houtan Bastani 827fc4942b update travis-ci 2018-07-11 18:04:05 +02:00
Houtan Bastani 8cf4fedac2 macroprocessor: change type of function arguments 2018-07-11 15:57:51 +02:00
Houtan Bastani 73f71862ee doc: macroprocessor: clarify statements on macro functions 2018-07-11 14:59:12 +02:00