fix lookbehind to handle `-` sign in substitution of dates in native statements

closes dynare#1708
issue#70
Houtan Bastani 2020-02-17 17:37:58 +01:00
parent 976e2ae17a
commit a778ba4ab4
No known key found for this signature in database
GPG Key ID: 000094FB955BE169
1 changed files with 2 additions and 2 deletions

View File

@ -54,8 +54,8 @@ NativeStatement::writeOutput(ostream &output, const string &basename, bool minim
{
using namespace boost::xpressive;
string date_regex = R"((-?\d+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4])))";
sregex regex_lookbehind = sregex::compile(R"((?<!\$|\d|[a-zA-Z_]|\'))" + date_regex);
sregex regex_dollar = sregex::compile(R"((\$))"+date_regex);
sregex regex_lookbehind = sregex::compile(R"((?<!\$|[a-zA-Z_]|-|'))" + date_regex);
sregex regex_dollar = sregex::compile(R"((\$))" + date_regex);
string ns = regex_replace(native_statement, regex_lookbehind, "dates('$&')");
ns = regex_replace(ns, regex_dollar, "$2"); //replace $DATE with DATE