Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dynare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
122
Issues
122
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dynare
dynare
Commits
27317d25
Commit
27317d25
authored
Dec 07, 2017
by
Houtan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preprocessor: add option to remove empty lines from macro-expanded mod file. closes #1551
parent
4a6fd427
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
5 deletions
+21
-5
doc/dynare.texi
doc/dynare.texi
+4
-0
preprocessor/DynareMain.cc
preprocessor/DynareMain.cc
+7
-3
preprocessor/DynareMain1.cc
preprocessor/DynareMain1.cc
+10
-2
No files found.
doc/dynare.texi
View file @
27317d25
...
...
@@ -843,6 +843,10 @@ step. Useful in conjunction with @code{savemacro} when one wants that to
reuse the intermediary @file{.mod} file, without having it cluttered by
line numbering directives.
@item noemptylinemacro
Passing this option removes all empty from the macro expanded mod file created
when the @code{savemacro} option is used.
@item nolog
Instructs Dynare to no create a logfile of this run in
@file{@var{FILENAME}.log}. The default is to create the logfile.
...
...
preprocessor/DynareMain.cc
View file @
27317d25
...
...
@@ -50,12 +50,12 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
);
void
main1
(
string
&
modfile
,
string
&
basename
,
string
&
modfiletxt
,
bool
debug
,
bool
save_macro
,
string
&
save_macro_file
,
bool
no_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
);
bool
no_line_macro
,
bool
no_empty_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
);
void
usage
()
{
cerr
<<
"Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
cerr
<<
"Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [no
emptylinemacro] [no
tmpterms] [nolog] [warn_uninit]"
<<
" [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
<<
" [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]"
<<
" [params_derivs_order=0|1|2]"
...
...
@@ -91,6 +91,7 @@ main(int argc, char **argv)
bool
no_tmp_terms
=
false
;
bool
only_macro
=
false
;
bool
no_line_macro
=
false
;
bool
no_empty_line_macro
=
false
;
bool
no_log
=
false
;
bool
no_warn
=
false
;
int
params_derivs_order
=
2
;
...
...
@@ -162,6 +163,8 @@ main(int argc, char **argv)
}
else
if
(
!
strcmp
(
argv
[
arg
],
"nolinemacro"
))
no_line_macro
=
true
;
else
if
(
!
strcmp
(
argv
[
arg
],
"noemptylinemacro"
))
no_empty_line_macro
=
true
;
else
if
(
!
strcmp
(
argv
[
arg
],
"notmpterms"
))
no_tmp_terms
=
true
;
else
if
(
!
strcmp
(
argv
[
arg
],
"nolog"
))
...
...
@@ -389,7 +392,8 @@ main(int argc, char **argv)
// Do macro processing
stringstream
macro_output
;
main1
(
modfile
,
basename
,
modfiletxt
,
debug
,
save_macro
,
save_macro_file
,
no_line_macro
,
defines
,
path
,
macro_output
);
main1
(
modfile
,
basename
,
modfiletxt
,
debug
,
save_macro
,
save_macro_file
,
no_line_macro
,
no_empty_line_macro
,
defines
,
path
,
macro_output
);
if
(
only_macro
)
return
EXIT_SUCCESS
;
...
...
preprocessor/DynareMain1.cc
View file @
27317d25
...
...
@@ -22,9 +22,13 @@
#include "macro/MacroDriver.hh"
bool
compareNewline
(
int
i
,
int
j
)
{
return
i
==
'\n'
&&
j
==
'\n'
;
}
void
main1
(
string
&
modfile
,
string
&
basename
,
string
&
modfiletxt
,
bool
debug
,
bool
save_macro
,
string
&
save_macro_file
,
bool
no_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
)
bool
no_line_macro
,
bool
no_empty_line_macro
,
map
<
string
,
string
>
&
defines
,
vector
<
string
>
&
path
,
stringstream
&
macro_output
)
{
// Do macro processing
MacroDriver
m
;
...
...
@@ -40,7 +44,11 @@ main1(string &modfile, string &basename, string &modfiletxt, bool debug, bool sa
cerr
<<
"Cannot open "
<<
save_macro_file
<<
" for macro output"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
macro_output_file
<<
macro_output
.
str
();
string
str
(
macro_output
.
str
());
if
(
no_empty_line_macro
)
str
.
erase
(
unique
(
str
.
begin
(),
str
.
end
(),
compareNewline
),
str
.
end
());
macro_output_file
<<
str
;
macro_output_file
.
close
();
}
}
Write
Preview
Markdown
is supported
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