Skip to content
Snippets Groups Projects
Commit e12726a3 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

preprocessor: deal with dates in NativeStatement

parent d2e93452
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include "Statement.hh" #include "Statement.hh"
#include <boost/xpressive/xpressive.hpp>
ModFileStructure::ModFileStructure() : ModFileStructure::ModFileStructure() :
check_present(false), check_present(false),
...@@ -74,7 +75,14 @@ NativeStatement::NativeStatement(const string &native_statement_arg) : ...@@ -74,7 +75,14 @@ NativeStatement::NativeStatement(const string &native_statement_arg) :
void void
NativeStatement::writeOutput(ostream &output, const string &basename) const NativeStatement::writeOutput(ostream &output, const string &basename) const
{ {
output << native_statement << endl; using namespace boost::xpressive;
string date_regex = "(-?\\d+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4]\\d|5[0-2])))";
sregex regex_lookbehind = sregex::compile("(?<!\\$|\\d|[a-zA-Z]|\\')" + date_regex);
sregex regex_dollar = sregex::compile("(\\$)"+date_regex);
string ns = regex_replace(native_statement, regex_lookbehind, "dates('$&')");
ns = regex_replace(ns, regex_dollar, "$2" ); //replace $DATE with DATE
output << ns << endl;
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment