Commit 90c1999c authored by sebastien's avatar sebastien
Browse files

trunk: allow the possibility of modifying Matlab matrices which have been...

trunk: allow the possibility of modifying Matlab matrices which have been earlier used in initval/endval

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2437 ac1d8469-bf42-47a9-8791-bf33cf982152
parent ce1b0122
...@@ -387,12 +387,17 @@ int sigma_e = 0; ...@@ -387,12 +387,17 @@ int sigma_e = 0;
return token::QUOTED_STRING; return token::QUOTED_STRING;
} }
/* an instruction starting with a recognized symbol (which is not a modfile local variable) /* An instruction starting with a recognized symbol (which is not a modfile local
is passed as NAME, or an unknown function) is passed as NAME, otherwise it is a native statement
otherwise it is a native statement until the end of the line until the end of the line.
We exclude modfile local vars because the user may want to modify their value
using a Matlab assignment statement.
We also exclude unknown functions because the user may have used a Matlab matrix
element in initval (in which case Dynare recognizes the matrix name as an unknown
function symbol), and may want to modify the matrix later with Matlab statements.
*/ */
<INITIAL>[A-Za-z_][A-Za-z0-9_]* { <INITIAL>[A-Za-z_][A-Za-z0-9_]* {
if (driver.symbol_exists_and_is_not_modfile_local_variable(yytext)) if (driver.symbol_exists_and_is_not_modfile_local_or_unknown_function(yytext))
{ {
BEGIN DYNARE_STATEMENT; BEGIN DYNARE_STATEMENT;
yylval->string_val = new string(yytext); yylval->string_val = new string(yytext);
......
...@@ -25,12 +25,14 @@ ...@@ -25,12 +25,14 @@
#include "Statement.hh" #include "Statement.hh"
bool bool
ParsingDriver::symbol_exists_and_is_not_modfile_local_variable(const char *s) ParsingDriver::symbol_exists_and_is_not_modfile_local_or_unknown_function(const char *s)
{ {
if (!mod_file->symbol_table.exists(s)) if (!mod_file->symbol_table.exists(s))
return false; return false;
return(mod_file->symbol_table.getType(s) != eModFileLocalVariable); SymbolType type = mod_file->symbol_table.getType(s);
return(type != eModFileLocalVariable && type != eUnknownFunction);
} }
void void
......
...@@ -162,7 +162,7 @@ public: ...@@ -162,7 +162,7 @@ public:
void warning(const string &m); void warning(const string &m);
//! Check if a given symbol exists in the parsing context, and is not a mod file local variable //! Check if a given symbol exists in the parsing context, and is not a mod file local variable
bool symbol_exists_and_is_not_modfile_local_variable(const char *s); bool symbol_exists_and_is_not_modfile_local_or_unknown_function(const char *s);
//! Sets mode of ModelTree class to use C output //! Sets mode of ModelTree class to use C output
void use_dll(); void use_dll();
//! Sets mode of ModelTree class to block decompose the model and triggers the creation of the incidence matrix in a C context //! Sets mode of ModelTree class to block decompose the model and triggers the creation of the incidence matrix in a C context
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment