Commit Graph

1965 Commits (9cf3e034de954f9b221fd72f6cd02334d47bda89)

Author SHA1 Message Date
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
Houtan Bastani 3776e3b890 only allow inline comments on statement lines. #4 2018-07-11 14:31:58 +02:00
Houtan Bastani aea9011745 Revert "macroprocessor: don’t interpret inline comments yet put them to output (ignored by dynare preprocessor, but printed in macro expanded file). #4"
This reverts commit 27e6d92af1.
2018-07-11 12:15:58 +02:00
Houtan Bastani 357320468b Revert "macroprocessor: support Matlab comments. #4"
This reverts commit 066942ef22.
2018-07-11 11:37:58 +02:00
Houtan Bastani a2fef7804e Revert "macroprocessor: support multi-line comments. #4"
This reverts commit 86a08f54ae.
2018-07-11 11:37:40 +02:00
Houtan Bastani 15f5f4f1be use front inserter instead of back inserter for unary/diff auxiliary equations
(cherry picked from commit 6a95831147d942c23fbc3a0a0b1506650eb49b7d)
2018-07-10 12:06:42 +02:00
Houtan Bastani 2c3d96a6ca update authors macroprocessor doc 2018-07-09 18:27:18 +02:00
Houtan Bastani dfb8c2f30e macroprocessor doc: update for microprocessing functions 2018-07-09 18:27:18 +02:00
Sébastien Villemot 7baee73126 Fix bug under MATLAB+Windows when "+" subdirectory is already present
Under MATLAB+Windows (but not under Octave nor under GNU/Linux or macOS), if we
directly remove the "+" subdirectory, then the preprocessor is not able to
recreate it afterwards (presumably because MATLAB maintains some sort of lock
on it). The workaround is to rename it before deleting it.
2018-07-09 18:18:26 +02:00
Houtan Bastani 86a08f54ae macroprocessor: support multi-line comments. #4 2018-07-09 16:55:59 +02:00
Houtan Bastani 066942ef22 macroprocessor: support Matlab comments. #4 2018-07-09 16:55:53 +02:00
Houtan Bastani 27e6d92af1 macroprocessor: don’t interpret inline comments yet put them to output (ignored by dynare preprocessor, but printed in macro expanded file). #4 2018-07-09 16:55:38 +02:00
Sébastien Villemot da917705ea Remove test for boost::lexical_cast (no longer used) 2018-07-09 15:17:49 +02:00
Houtan Bastani e0bf2b60b6 Modify 19048bdcae to store equation tags for variables declared in equation tags 2018-07-09 14:49:12 +02:00
Houtan Bastani 19048bdcae Allow for the declaration of endogenous, exogenous, parameters on-the-fly in equation tags 2018-07-09 14:39:13 +02:00
Houtan Bastani a7f8eaa336 remove warnings introduced in 244552393b 2018-07-09 11:55:39 +02:00
Houtan Bastani 853cce553f replace ‘typedef’ with ‘using’ 2018-07-09 11:49:17 +02:00
Houtan Bastani 244552393b macroprocessor: add support for functions that return strings. #3 2018-07-04 17:04:22 +02:00
Houtan Bastani a51dd224e4 simplify conversion of int to string 2018-07-04 16:07:16 +02:00
Sébastien Villemot 543e2b16e3 Simplify and modernize ConfigFile
- no longer use pointers
- use pass-by-value when possible
- use range-for loops when possible
2018-07-04 15:56:48 +02:00
Sébastien Villemot 53f83aeb12 No longer use boost::lexical_cast
Most cases can be handled in C++11 by std::stoi() and std::stod().

For the macroprocessor ArrayMV<T>::print() method, use template
specialization (instead of a lexical_cast to detect between T=int and
T=string).
2018-07-04 15:53:41 +02:00
Sébastien Villemot 30c205f418 C++11: replace calls to std::atof() by std::stod() 2018-07-04 14:53:13 +02:00
Sébastien Villemot 5e1d722013 C++11: replace most calls to std::atoi() by std::stoi()
The latter accepts a std::string as argument.
2018-07-04 14:53:08 +02:00
Sébastien Villemot e376267a28 Move json generated files to ${MODFILE}/model/json/ 2018-06-27 16:08:31 +02:00
Sébastien Villemot 988a9f6e2d std::open and std::fstream constructor accept a std::string for filename in C++11 2018-06-27 15:30:45 +02:00
Sébastien Villemot b91ed6f78c Move the location of static and dynamic files on the filesystem
- M and MEX files are now under +${MODELNAME}/
- bytecode and C source now under ${MODELNAME}/model/
2018-06-27 15:30:25 +02:00
Sébastien Villemot e5aefb9f0a Update AX_BOOST_BASE macro 2018-06-27 15:14:25 +02:00
Houtan Bastani 45f7e40a88 remove unused library 2018-06-27 13:50:15 +02:00
Houtan Bastani bbb2b067bf prevent compilation warning 2018-06-27 13:45:51 +02:00
Stéphane Adjemian(Charybdis) a2b19cbfff Added missing writeJsonOutput method for VarModelStatement. 2018-06-15 14:56:44 +02:00