nostrict command-line option ignores extraneous assignments in initval. closes #1

time-shift
Houtan Bastani 2013-09-16 16:13:56 -04:00
parent 20dba7e623
commit ebd9d9dee7
4 changed files with 17 additions and 5 deletions

View File

@ -785,9 +785,11 @@ Defines a macro-variable from the command line (the same effect as using
the Macro directive @code{@@#define} in a model file, @pxref{Macro-processing language}).
@item nostrict
Allows Dynare to continue processing when there are more endogenous
variables than equations, issuing a warning for each endogenous
variable ignored.
Allows Dynare to issue a warning and continue processing when
@enumerate
@item there are more endogenous variables than equations
@item an undeclared symbol is assigned in @code{initval}
@end enumerate
@end table
@outputhead

View File

@ -36,7 +36,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm
{
WarningConsolidation warnings(no_warn);
ParsingDriver p(warnings);
ParsingDriver p(warnings, nostrict);
// Do parsing and construct internal representation of mod file
ModFile *mod_file = p.parse(in, debug);

View File

@ -401,6 +401,14 @@ ParsingDriver::init_param(string *name, expr_t rhs)
void
ParsingDriver::init_val(string *name, expr_t rhs)
{
if (nostrict)
if (!mod_file->symbol_table.exists(*name))
{
warnings << "WARNING: discarding '" << *name << "' not recognized in initval statement" << endl;
delete name;
return;
}
check_symbol_existence(*name);
int symb_id = mod_file->symbol_table.getID(*name);
SymbolType type = mod_file->symbol_table.getType(symb_id);

View File

@ -209,8 +209,10 @@ private:
WarningConsolidation &warnings;
bool nostrict;
public:
ParsingDriver(WarningConsolidation &warnings_arg) : warnings(warnings_arg) { };
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : warnings(warnings_arg), nostrict(nostrict_arg) { };
//! Starts parsing, and constructs the MOD file representation
/*! The returned pointer should be deleted after use */