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
374b36b9
Commit
374b36b9
authored
Oct 10, 2013
by
Houtan Bastani
Browse files
Revert "preprocessor: replace dates with dynDates"
This reverts commit
030fe52a
. Conflicts: preprocessor/Statement.cc
parent
404f29e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
preprocessor/ParsingDriver.cc
View file @
374b36b9
...
@@ -2449,8 +2449,7 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
...
@@ -2449,8 +2449,7 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
void
void
ParsingDriver
::
add_native
(
const
string
&
s
)
ParsingDriver
::
add_native
(
const
string
&
s
)
{
{
string
ss
=
string
(
s
);
mod_file
->
addStatement
(
new
NativeStatement
(
s
));
mod_file
->
addStatement
(
new
NativeStatement
(
ss
));
}
}
void
void
...
...
preprocessor/Statement.cc
View file @
374b36b9
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
*/
*/
#include "Statement.hh"
#include "Statement.hh"
#include <boost/xpressive/xpressive.hpp>
ModFileStructure
::
ModFileStructure
()
:
ModFileStructure
::
ModFileStructure
()
:
check_present
(
false
),
check_present
(
false
),
...
@@ -66,76 +65,11 @@ Statement::computingPass()
...
@@ -66,76 +65,11 @@ Statement::computingPass()
{
{
}
}
NativeStatement
::
NativeStatement
(
string
&
native_statement_arg
)
:
NativeStatement
::
NativeStatement
(
const
string
&
native_statement_arg
)
:
native_statement
(
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
(
"
\\
s*\%.*"
);
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
);
bool
skip
=
false
;
string
newstr
=
""
;
sregex
date_expr
=
sregex
::
compile
(
"-?[0-9]+[Mm](1[0-2]|[1-9])|-?[0-9]+[Qq][1-4]|-?[0-9]+[Ww]([1-4][0-9]|5[0-2]|[1-9])"
);
string
format
(
"dynDate('$&')"
);
size_t
lastidx
=
0
;
for
(
size_t
i
=
0
;
i
<
apostrophes
.
size
();
i
++
)
if
(
apostrophes
[
i
]
==
0
)
skip
=
true
;
else
if
(
skip
)
{
newstr
.
append
(
native_statement
.
substr
(
lastidx
,
apostrophes
[
i
]
-
lastidx
));
lastidx
=
apostrophes
[
i
];
skip
=
false
;
}
else
{
newstr
.
append
(
regex_replace
(
native_statement
.
substr
(
lastidx
,
apostrophes
[
i
]
-
lastidx
),
date_expr
,
format
));
lastidx
=
apostrophes
[
i
];
skip
=
true
;
}
size_t
length
=
native_statement
.
length
()
-
lastidx
;
size_t
commentidx
=
native_statement
.
substr
(
lastidx
,
length
).
find
(
"%"
,
0
);
if
(
commentidx
!=
string
::
npos
)
length
=
commentidx
;
newstr
.
append
(
regex_replace
(
native_statement
.
substr
(
lastidx
,
length
),
date_expr
,
format
));
if
(
commentidx
!=
string
::
npos
)
{
lastidx
+=
commentidx
;
newstr
.
append
(
native_statement
.
substr
(
lastidx
,
native_statement
.
length
()
-
lastidx
));
}
native_statement
=
newstr
;
}
void
regexReplace
()
{
}
void
void
NativeStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
NativeStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
{
{
...
...
preprocessor/Statement.hh
View file @
374b36b9
...
@@ -121,12 +121,10 @@ public:
...
@@ -121,12 +121,10 @@ public:
class
NativeStatement
:
public
Statement
class
NativeStatement
:
public
Statement
{
{
private:
private:
string
native_statement
;
const
string
native_statement
;
public:
public:
NativeStatement
(
string
&
native_statement_arg
);
NativeStatement
(
const
string
&
native_statement_arg
);
virtual
void
computingPass
();
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
void
regexReplace
();
};
};
class
OptionsList
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