New var_remove statement
parent
60ef6bbdbd
commit
342c4faf8d
|
@ -137,7 +137,7 @@ enum class SymbolType
|
|||
// Value 17 is unused for the time being (but could be reused)
|
||||
|
||||
epilogue = 18, //!< Variables created in epilogue block
|
||||
excludedVariable = 19 //!< Variable excluded via model_remove/include_eqs/exclude_eqs
|
||||
excludedVariable = 19 //!< Variable excluded via model_remove/var_remove/include_eqs/exclude_eqs
|
||||
};
|
||||
|
||||
enum class ExpressionType
|
||||
|
|
|
@ -184,6 +184,7 @@ class ParsingDriver;
|
|||
%token NO_IDENTIFICATION_MINIMAL NO_IDENTIFICATION_SPECTRUM NORMALIZE_JACOBIANS GRID_NBR
|
||||
%token TOL_RANK TOL_DERIV TOL_SV CHECKS_VIA_SUBSETS MAX_DIM_SUBSETS_GROUPS ZERO_MOMENTS_TOLERANCE
|
||||
%token MAX_NROWS SQUEEZE_SHOCK_DECOMPOSITION WITH_EPILOGUE MODEL_REMOVE MODEL_REPLACE MODEL_OPTIONS
|
||||
%token VAR_REMOVE
|
||||
|
||||
%token <vector<string>> SYMBOL_VEC
|
||||
|
||||
|
@ -345,6 +346,7 @@ statement : parameters
|
|||
| model_remove
|
||||
| model_replace
|
||||
| model_options
|
||||
| var_remove
|
||||
;
|
||||
|
||||
dsample : DSAMPLE INT_NUMBER ';'
|
||||
|
@ -398,6 +400,8 @@ var : VAR var_list ';'
|
|||
{ driver.end_nonstationary_var(true, $6); }
|
||||
;
|
||||
|
||||
var_remove : VAR_REMOVE symbol_list ';' { driver.var_remove(); };
|
||||
|
||||
var_model : VAR_MODEL '(' var_model_options_list ')' ';' { driver.var_model(); }
|
||||
;
|
||||
|
||||
|
|
|
@ -194,6 +194,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
|
|||
<INITIAL>compilation_setup {BEGIN DYNARE_STATEMENT; return token::COMPILATION_SETUP;}
|
||||
<INITIAL>model_remove {BEGIN DYNARE_STATEMENT; return token::MODEL_REMOVE;}
|
||||
<INITIAL>model_options {BEGIN DYNARE_STATEMENT; return token::MODEL_OPTIONS;}
|
||||
<INITIAL>var_remove {BEGIN DYNARE_STATEMENT; return token::VAR_REMOVE;}
|
||||
|
||||
<DYNARE_STATEMENT>; {
|
||||
if (!sigma_e)
|
||||
|
|
|
@ -782,7 +782,7 @@ VariableNode::prepareForDerivation()
|
|||
exit(EXIT_FAILURE);
|
||||
case SymbolType::excludedVariable:
|
||||
cerr << "VariableNode::prepareForDerivation: impossible case: "
|
||||
<< "You are trying to derive a variable that has been excluded via model_remove/include_eqs/exclude_eqs: "
|
||||
<< "You are trying to derive a variable that has been excluded via model_remove/var_remove/include_eqs/exclude_eqs: "
|
||||
<< datatree.symbol_table.getName(symb_id) << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ ParsingDriver::add_model_variable(const string &name)
|
|||
{
|
||||
symb_id = mod_file->symbol_table.getID(name);
|
||||
if (mod_file->symbol_table.getType(symb_id) == SymbolType::excludedVariable)
|
||||
error("Variable '" + name + "' can no longer be used since it has been excluded by a previous 'model_remove' statement");
|
||||
error("Variable '" + name + "' can no longer be used since it has been excluded by a previous 'model_remove' or 'var_remove' statement");
|
||||
}
|
||||
catch (SymbolTable::UnknownSymbolNameException &e)
|
||||
{
|
||||
|
@ -3544,3 +3544,15 @@ ParsingDriver::begin_model_replace(const vector<pair<string, string>> &listed_eq
|
|||
mod_file->dynamic_model.removeEquations(listed_eqs_by_tags, true, false);
|
||||
set_current_data_tree(&mod_file->dynamic_model);
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::var_remove()
|
||||
{
|
||||
for (const auto &name : symbol_list.getSymbols())
|
||||
{
|
||||
check_symbol_existence(name);
|
||||
int symb_id = mod_file->symbol_table.getID(name);
|
||||
mod_file->symbol_table.changeType(symb_id, SymbolType::excludedVariable);
|
||||
}
|
||||
symbol_list.clear();
|
||||
}
|
||||
|
|
|
@ -893,6 +893,8 @@ public:
|
|||
void model_remove(const vector<pair<string, string>> &listed_eqs_by_tags);
|
||||
// Begin a model_replace statement
|
||||
void begin_model_replace(const vector<pair<string, string>> &listed_eqs_by_tags);
|
||||
// Add a var_remove statement
|
||||
void var_remove();
|
||||
// Equivalent of MATLAB’s strsplit. Returns an empty vector given an empty string.
|
||||
static vector<string> strsplit(const string &str, char delim);
|
||||
// Returns true iff the string is a legal symbol identifier (see NAME token in lexer)
|
||||
|
|
Loading…
Reference in New Issue