Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Normann Rion
preprocessor
Commits
677370d3
Verified
Commit
677370d3
authored
7 months ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
Add some more comments about the mechanism that substitutes dates inside the .mod file
parent
f1beaa39
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/DynareFlex.ll
+3
-0
3 additions, 0 deletions
src/DynareFlex.ll
src/Statement.cc
+5
-0
5 additions, 0 deletions
src/Statement.cc
with
8 additions
and
0 deletions
src/DynareFlex.ll
+
3
−
0
View file @
677370d3
...
@@ -258,6 +258,9 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
...
@@ -258,6 +258,9 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
/* Inside of a Dynare statement */
/* Inside of a Dynare statement */
<DYNARE_STATEMENT>{DATE} {
<DYNARE_STATEMENT>{DATE} {
/* If a date is found within a statement, substitute it with a call to
the dates() constructor in the input character stream. Then it will
be handled by the rule that follows the present one. */
char* yycopy = strdup(yytext);
char* yycopy = strdup(yytext);
char* uput = yycopy + yyleng;
char* uput = yycopy + yyleng;
unput(')');
unput(')');
...
...
This diff is collapsed.
Click to expand it.
src/Statement.cc
+
5
−
0
View file @
677370d3
...
@@ -50,6 +50,11 @@ NativeStatement::writeOutput(ostream& output, [[maybe_unused]] const string& bas
...
@@ -50,6 +50,11 @@ NativeStatement::writeOutput(ostream& output, [[maybe_unused]] const string& bas
boost::xpressive does not look for the longest match in an alternation, but stops at the first
boost::xpressive does not look for the longest match in an alternation, but stops at the first
match from left to right. */
match from left to right. */
string
date_regex
=
R"((-?\d+([YyAa]|[Mm](1[0-2]|[1-9])|[Qq][1-4]|[SsHh][1-2])))"
;
string
date_regex
=
R"((-?\d+([YyAa]|[Mm](1[0-2]|[1-9])|[Qq][1-4]|[SsHh][1-2])))"
;
/* NB: the following dance around the dollar sign (exclude it from lookbehind, then use it in a
temporary string after the first replace, then remove it in the second replace) has a purpose:
it allows the user to disable the substitution mechanism. For example, if the user writes
“$2024Q4” in a native statement, it will be transformed into “2024Q4” and not
“$dates('2024Q4')”. */
sregex
regex_lookbehind
=
sregex
::
compile
(
R"((?<!\$|\d|[a-zA-Z_]|-|'))"
+
date_regex
);
sregex
regex_lookbehind
=
sregex
::
compile
(
R"((?<!\$|\d|[a-zA-Z_]|-|'))"
+
date_regex
);
sregex
regex_dollar
=
sregex
::
compile
(
R"((\$))"
+
date_regex
);
sregex
regex_dollar
=
sregex
::
compile
(
R"((\$))"
+
date_regex
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment