preprocessor: add VerbatimStatement class. Closes #953
parent
4102e0cc56
commit
f94c7ab332
|
@ -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_native_remove_charset(yytext, "\n");
|
||||
driver.add_verbatim_remove_charset(yytext, "\n");
|
||||
}
|
||||
<VERBATIM_BLOCK>. { yymore(); }
|
||||
<VERBATIM_BLOCK><<EOF>> {
|
||||
driver.add_native(eofbuff);
|
||||
driver.add_verbatim(eofbuff);
|
||||
yyterminate();
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
11
Statement.cc
11
Statement.cc
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue