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
MichelJuillard
dynare
Commits
aeb1542b
Commit
aeb1542b
authored
Jun 16, 2015
by
Houtan Bastani
Browse files
preprocessor: add VerbatimStatement class. Closes #953
parent
44fd0b37
Changes
6
Hide whitespace changes
Inline
Side-by-side
preprocessor/DynareFlex.ll
View file @
aeb1542b
...
...
@@ -819,11 +819,11 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
}
<VERBATIM_BLOCK>\n {
if (strlen(yytext) > 1)
driver.add_
n
ati
ve
_remove_charset(yytext, "
\n
");
driver.add_
verb
ati
m
_remove_charset(yytext, "
\n
");
}
<VERBATIM_BLOCK>. { yymore(); }
<VERBATIM_BLOCK><<EOF>> {
driver.add_
n
ati
ve
(eofbuff);
driver.add_
verb
ati
m
(eofbuff);
yyterminate();
}
...
...
preprocessor/ParsingDriver.cc
View file @
aeb1542b
...
...
@@ -2586,6 +2586,23 @@ ParsingDriver::add_native_remove_charset(const char *s, const string &token)
add_native
(
str
);
}
void
ParsingDriver
::
add_verbatim
(
const
string
&
s
)
{
mod_file
->
addStatement
(
new
VerbatimStatement
(
s
));
}
void
ParsingDriver
::
add_verbatim_remove_charset
(
const
char
*
s
,
const
string
&
token
)
{
string
str
=
string
(
s
);
size_t
found
=
str
.
find
(
token
);
assert
(
found
!=
string
::
npos
);
str
.
resize
(
found
);
add_verbatim
(
str
);
}
void
ParsingDriver
::
begin_steady_state_model
()
{
...
...
preprocessor/ParsingDriver.hh
View file @
aeb1542b
...
...
@@ -658,6 +658,10 @@ public:
void
add_native
(
const
string
&
s
);
//! Adds a native statement, first removing the set of characters passed in token (and everything after)
void
add_native_remove_charset
(
const
char
*
s
,
const
string
&
token
);
//! Adds a verbatim statement
void
add_verbatim
(
const
string
&
s
);
//! Adds a verbatim statement, first removing the set of characters passed in token (and everything after)
void
add_verbatim_remove_charset
(
const
char
*
s
,
const
string
&
token
);
//! Resets data_tree and model_tree pointers to default (i.e. mod_file->expressions_tree)
void
reset_data_tree
();
//! Begin a steady_state_model block
...
...
preprocessor/Statement.cc
View file @
aeb1542b
...
...
@@ -92,6 +92,17 @@ NativeStatement::writeOutput(ostream &output, const string &basename, bool minim
output
<<
ns
<<
endl
;
}
VerbatimStatement
::
VerbatimStatement
(
const
string
&
verbatim_statement_arg
)
:
verbatim_statement
(
verbatim_statement_arg
)
{
}
void
VerbatimStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
{
output
<<
verbatim_statement
<<
endl
;
}
void
OptionsList
::
writeOutput
(
ostream
&
output
)
const
{
...
...
preprocessor/Statement.hh
View file @
aeb1542b
...
...
@@ -149,6 +149,15 @@ public:
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
};
class
VerbatimStatement
:
public
Statement
{
private:
const
string
verbatim_statement
;
public:
VerbatimStatement
(
const
string
&
verbatim_statement_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
;
};
class
OptionsList
{
public:
...
...
tests/example1.mod
View file @
aeb1542b
...
...
@@ -4,7 +4,7 @@ varexo e, u;
verbatim;
% I want these comments included in
% example1.m
% example1.m
1999q1 1999y
%
var = 1;
end;
...
...
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