Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dynare
Commits
06ab26f7
Commit
06ab26f7
authored
Oct 3, 2013
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
handle inline comments
parent
d3111863
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
preprocessor/Statement.cc
+33
-6
33 additions, 6 deletions
preprocessor/Statement.cc
with
33 additions
and
6 deletions
preprocessor/Statement.cc
+
33
−
6
View file @
06ab26f7
...
@@ -101,10 +101,11 @@ NativeStatement::computingPass()
...
@@ -101,10 +101,11 @@ NativeStatement::computingPass()
bool
skip
=
false
;
bool
skip
=
false
;
string
newstr
=
""
;
string
newstr
=
""
;
int
lastidx
=
0
;
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])"
);
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('$&')"
);
string
format
(
"dynDate('$&')"
);
for
(
size_t
i
=
0
;
i
<
apostrophes
.
size
();
i
++
)
size_t
length
,
i
,
lastidx
,
commentidx
;
length
=
lastidx
=
0
;
for
(
i
=
0
;
i
<
apostrophes
.
size
();
i
++
)
if
(
apostrophes
[
i
]
==
0
)
if
(
apostrophes
[
i
]
==
0
)
skip
=
true
;
skip
=
true
;
else
else
...
@@ -116,14 +117,40 @@ NativeStatement::computingPass()
...
@@ -116,14 +117,40 @@ NativeStatement::computingPass()
}
}
else
else
{
{
length
=
apostrophes
[
i
]
-
lastidx
;
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
;
while
(
i
++
<
apostrophes
.
size
())
{
newstr
.
append
(
native_statement
.
substr
(
lastidx
,
apostrophes
[
i
]
-
lastidx
));
lastidx
=
apostrophes
[
i
];
}
native_statement
=
newstr
;
return
;
}
skip
=
true
;
skip
=
true
;
newstr
.
append
(
regex_replace
(
native_statement
.
substr
(
lastidx
,
apostrophes
[
i
]
-
lastidx
),
date_expr
,
format
));
}
}
lastidx
=
apostrophes
[
i
];
lastidx
=
apostrophes
[
i
];
}
}
newstr
.
append
(
regex_replace
(
native_statement
.
substr
(
lastidx
,
native_statement
.
size
()
-
lastidx
),
length
=
native_statement
.
length
()
-
lastidx
;
date_expr
,
format
));
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
;
native_statement
=
newstr
;
}
}
...
...
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