Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
5d071454
Commit
5d071454
authored
Oct 02, 2013
by
Stéphane Adjemian
Browse files
Merge branch 'master' into add-simpsa-optimization-routine
parents
b00bf266
030fe52a
Changes
5
Hide whitespace changes
Inline
Side-by-side
matlab/stoch_simul.m
View file @
5d071454
...
...
@@ -176,6 +176,12 @@ if options_.irf
y
=
irf
(
oo_
.
dr
,
cs
(
M_
.
exo_names_orig_ord
,
i
),
options_
.
irf
,
options_
.
drop
,
...
options_
.
replic
,
options_
.
order
);
end
if
~
options_
.
noprint
&&
any
(
any
(
isnan
(
y
)))
&&
~
options_
.
pruning
&&
~
(
options_
.
order
==
1
)
fprintf
(
'\nSTOCH_SIMUL: The simulations conducted for generating IRFs to %s were explosive.\n'
,
M_
.
exo_names
(
i
,:))
fprintf
(
'STOCH_SIMUL: No IRFs will be displayed. Either reduce the shock size, \n'
)
fprintf
(
'STOCH_SIMUL: use pruning, or set the approximation order to 1.'
);
skipline
(
2
);
end
if
options_
.
relative_irf
y
=
100
*
y
/
cs
(
i
,
i
);
end
...
...
preprocessor/DynareFlex.ll
View file @
5d071454
...
...
@@ -691,7 +691,7 @@ string eofbuff;
return token::INT_NUMBER;
}
<DYNARE_STATEMENT,DYNARE_BLOCK>
([1-2]
[0-9]
{3}
[Mm](
(
[1-9]
)|(
1[0-2])
))|([1-2]
[0-9]
{3}
[Qq][1-4]
)|([1-2]
[0-9]
{3}
[Ww](
(
[1-9]{1}
)|(
[1-4][0-9]
)|([5]
[0-2])
))
{
<DYNARE_STATEMENT,DYNARE_BLOCK>
-?
[0-9]
+
[Mm]([1-9]
|
1[0-2])
|-?
[0-9]
+
[Qq][1-4]
|-?
[0-9]
+
[Ww]([1-9]{1}
|
[1-4][0-9]
|5
[0-2]) {
yylval->string_val = new string(yytext);
return token::DATE_NUMBER;
}
...
...
preprocessor/ParsingDriver.cc
View file @
5d071454
...
...
@@ -2449,7 +2449,8 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
void
ParsingDriver
::
add_native
(
const
string
&
s
)
{
mod_file
->
addStatement
(
new
NativeStatement
(
s
));
string
ss
=
string
(
s
);
mod_file
->
addStatement
(
new
NativeStatement
(
ss
));
}
void
...
...
preprocessor/Statement.cc
View file @
5d071454
...
...
@@ -18,6 +18,7 @@
*/
#include
"Statement.hh"
#include
<boost/xpressive/xpressive.hpp>
ModFileStructure
::
ModFileStructure
()
:
check_present
(
false
),
...
...
@@ -65,11 +66,77 @@ Statement::computingPass()
{
}
NativeStatement
::
NativeStatement
(
const
string
&
native_statement_arg
)
:
NativeStatement
::
NativeStatement
(
string
&
native_statement_arg
)
:
native_statement
(
native_statement_arg
)
{
}
void
NativeStatement
::
computingPass
()
{
using
namespace
boost
::
xpressive
;
// Return if this is a comment
sregex
comment_expr
=
sregex
::
compile
(
"\%.*"
);
match_results
<
string
::
const_iterator
>
results
;
if
(
regex_match
(
native_statement
,
results
,
comment_expr
))
return
;
// Otherwise, look at the line and consider substituting date
size_t
idx
=
-
1
;
vector
<
size_t
>
apostrophes
;
while
((
idx
=
native_statement
.
find
(
"'"
,
idx
+
1
))
!=
string
::
npos
)
if
(
apostrophes
.
size
()
<
2
)
apostrophes
.
push_back
(
idx
);
else
if
(
idx
==
apostrophes
.
back
()
+
1
)
apostrophes
.
pop_back
();
else
apostrophes
.
push_back
(
idx
);
if
(
apostrophes
.
size
()
%
2
)
{
cerr
<<
native_statement
<<
" seems to be invalid Matlab syntax (an odd number of apostrophes was encountered)"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
bool
skip
=
false
;
string
newstr
=
""
;
int
lastidx
=
0
;
sregex
date_expr
=
sregex
::
compile
(
"-?[0-9]+[Mm]([1-9]|1[0-2])|-?[0-9]+[Qq][1-4]|-?[0-9]+[Ww]([1-9]{1}|[1-4][0-9]|5[0-2])"
);
string
format
(
"dynDate('$&')"
);
for
(
size_t
i
=
0
;
i
<
apostrophes
.
size
();
i
++
)
if
(
apostrophes
[
i
]
==
0
)
skip
=
true
;
else
{
if
(
skip
)
{
skip
=
false
;
newstr
.
append
(
native_statement
.
substr
(
lastidx
,
apostrophes
[
i
]
-
lastidx
));
}
else
{
skip
=
true
;
newstr
.
append
(
regex_replace
(
native_statement
.
substr
(
lastidx
,
apostrophes
[
i
]
-
lastidx
),
date_expr
,
format
));
}
lastidx
=
apostrophes
[
i
];
}
//Replace last (or only) element
if
(
apostrophes
.
empty
())
lastidx
=
0
;
newstr
.
append
(
regex_replace
(
native_statement
.
substr
(
lastidx
,
native_statement
.
size
()
-
lastidx
),
date_expr
,
format
));
native_statement
=
newstr
;
}
void
regexReplace
()
{
}
void
NativeStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
{
...
...
preprocessor/Statement.hh
View file @
5d071454
...
...
@@ -121,10 +121,12 @@ public:
class
NativeStatement
:
public
Statement
{
private:
const
string
native_statement
;
string
native_statement
;
public:
NativeStatement
(
const
string
&
native_statement_arg
);
NativeStatement
(
string
&
native_statement_arg
);
virtual
void
computingPass
();
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
void
regexReplace
();
};
class
OptionsList
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment