v4 parser.src: undoing rev. 944
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@945 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
c04c947d4c
commit
68b552aef2
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
#define YY_BUF_SIZE 1000000
|
#define YY_BUF_SIZE 1000000
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "DynareScanner.h"
|
#include "DynareScanner.h"
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.hh"
|
# include "config.hh"
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,13 +11,13 @@
|
||||||
#define FINISH 0
|
#define FINISH 0
|
||||||
#define YY_READ_BUF_SIZE 1000000
|
#define YY_READ_BUF_SIZE 1000000
|
||||||
#include "ylmm/lexmm.hh"
|
#include "ylmm/lexmm.hh"
|
||||||
int lineno = 1;
|
int lineno = 1;
|
||||||
int comment_caller;
|
int comment_caller;
|
||||||
/* Particular value : when sigma_e command is found
|
/* Particular value : when sigma_e command is found
|
||||||
this flag is set to 1, when command finished it is set to 0
|
this flag is set to 1, when command finished it is set to 0
|
||||||
*/
|
*/
|
||||||
int sigma_e = 0;
|
int sigma_e = 0;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
%option stack
|
%option stack
|
||||||
|
@ -34,11 +34,11 @@ int sigma_e = 0;
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
<INITIAL,SET_STATEMENT,DYNARE_STATEMENT,DYNARE_BLOCK>["%"].*
|
<INITIAL,SET_STATEMENT,DYNARE_STATEMENT,DYNARE_BLOCK>["%"].*
|
||||||
<INITIAL,SET_STATEMENT,DYNARE_STATEMENT,DYNARE_BLOCK>["/"]["/"].*
|
<INITIAL,SET_STATEMENT,DYNARE_STATEMENT,DYNARE_BLOCK>["/"]["/"].*
|
||||||
<INITIAL,SET_STATEMENT,DYNARE_STATEMENT,DYNARE_BLOCK>"/*" {comment_caller = YYSTATE; BEGIN COMMENT;}
|
<INITIAL,SET_STATEMENT,DYNARE_STATEMENT,DYNARE_BLOCK>"/*" {comment_caller = YYSTATE; BEGIN COMMENT;}
|
||||||
|
|
||||||
<COMMENT>[^*\n]*
|
<COMMENT>[^*\n]*
|
||||||
<COMMENT>"*"+[^*/\n]*
|
<COMMENT>"*"+[^*/\n]*
|
||||||
<COMMENT>"*"+"/" {BEGIN comment_caller;}
|
<COMMENT>"*"+"/" {BEGIN comment_caller;}
|
||||||
|
|
||||||
/* Begin of a Dynare statement */
|
/* Begin of a Dynare statement */
|
||||||
|
@ -86,24 +86,24 @@ int sigma_e = 0;
|
||||||
<INITIAL>optim_weights {BEGIN DYNARE_BLOCK;return OPTIM_WEIGHTS;}
|
<INITIAL>optim_weights {BEGIN DYNARE_BLOCK;return OPTIM_WEIGHTS;}
|
||||||
|
|
||||||
/* End of a Dynare block */
|
/* End of a Dynare block */
|
||||||
<DYNARE_BLOCK>end[ \t\n]*; {BEGIN INITIAL;return END;}
|
<DYNARE_BLOCK>end[ \t\n]*; {BEGIN INITIAL;return END;}
|
||||||
|
|
||||||
/* Inside of a Dynare statement */
|
/* Inside of a Dynare statement */
|
||||||
<DYNARE_STATEMENT>datafile {return DATAFILE;}
|
<DYNARE_STATEMENT>datafile {return DATAFILE;}
|
||||||
<DYNARE_STATEMENT>nobs {return NOBS;}
|
<DYNARE_STATEMENT>nobs {return NOBS;}
|
||||||
<DYNARE_STATEMENT>first_obs {return FIRST_OBS;}
|
<DYNARE_STATEMENT>first_obs {return FIRST_OBS;}
|
||||||
<DYNARE_STATEMENT>prefilter {return PREFILTER;}
|
<DYNARE_STATEMENT>prefilter {return PREFILTER;}
|
||||||
<DYNARE_STATEMENT>presample {return PRESAMPLE;}
|
<DYNARE_STATEMENT>presample {return PRESAMPLE;}
|
||||||
<DYNARE_STATEMENT>lik_algo {return LIK_ALGO;}
|
<DYNARE_STATEMENT>lik_algo {return LIK_ALGO;}
|
||||||
<DYNARE_STATEMENT>lik_init {return LIK_INIT;}
|
<DYNARE_STATEMENT>lik_init {return LIK_INIT;}
|
||||||
<DYNARE_STATEMENT>graph {return GRAPH;}
|
<DYNARE_STATEMENT>graph {return GRAPH;}
|
||||||
<DYNARE_STATEMENT>nograph {return NOGRAPH;}
|
<DYNARE_STATEMENT>nograph {return NOGRAPH;}
|
||||||
<DYNARE_STATEMENT>print {return PRINT;}
|
<DYNARE_STATEMENT>print {return PRINT;}
|
||||||
<DYNARE_STATEMENT>noprint {return NOPRINT;}
|
<DYNARE_STATEMENT>noprint {return NOPRINT;}
|
||||||
<DYNARE_STATEMENT>conf_sig {return CONF_SIG;}
|
<DYNARE_STATEMENT>conf_sig {return CONF_SIG;}
|
||||||
<DYNARE_STATEMENT>mh_replic {return MH_REPLIC;}
|
<DYNARE_STATEMENT>mh_replic {return MH_REPLIC;}
|
||||||
<DYNARE_STATEMENT>mh_drop {return MH_DROP;}
|
<DYNARE_STATEMENT>mh_drop {return MH_DROP;}
|
||||||
<DYNARE_STATEMENT>mh_jscale {return MH_JSCALE;}
|
<DYNARE_STATEMENT>mh_jscale {return MH_JSCALE;}
|
||||||
<DYNARE_STATEMENT>mh_init_scale {return MH_INIT_SCALE;}
|
<DYNARE_STATEMENT>mh_init_scale {return MH_INIT_SCALE;}
|
||||||
<DYNARE_STATEMENT>mode_file {return MODE_FILE;}
|
<DYNARE_STATEMENT>mode_file {return MODE_FILE;}
|
||||||
<DYNARE_STATEMENT>mode_compute {return MODE_COMPUTE;}
|
<DYNARE_STATEMENT>mode_compute {return MODE_COMPUTE;}
|
||||||
|
@ -139,7 +139,7 @@ int sigma_e = 0;
|
||||||
|
|
||||||
<DYNARE_STATEMENT>[\$][^$]*[\$] {
|
<DYNARE_STATEMENT>[\$][^$]*[\$] {
|
||||||
strtok(yytext+1,"$");
|
strtok(yytext+1,"$");
|
||||||
_scanner->do_name(yytext+1);
|
_scanner->do_name(yytext+1);
|
||||||
return TEX_NAME;}
|
return TEX_NAME;}
|
||||||
|
|
||||||
/* Inside a Dynare block */
|
/* Inside a Dynare block */
|
||||||
|
@ -177,20 +177,15 @@ int sigma_e = 0;
|
||||||
<DYNARE_STATEMENT>simul {return SIMUL;}
|
<DYNARE_STATEMENT>simul {return SIMUL;}
|
||||||
<DYNARE_STATEMENT>autocorr {return AUTOCORR;}
|
<DYNARE_STATEMENT>autocorr {return AUTOCORR;}
|
||||||
<DYNARE_STATEMENT>olr_beta {return OLR_BETA;}
|
<DYNARE_STATEMENT>olr_beta {return OLR_BETA;}
|
||||||
<DYNARE_STATEMENT>xtick {return XTICK;}
|
<DYNARE_STATEMENT>xtick {return XTICK;}
|
||||||
<DYNARE_STATEMENT>xticklabel {return XTICKLABEL;}
|
<DYNARE_STATEMENT>xticklabel {return XTICKLABEL;}
|
||||||
<DYNARE_STATEMENT>xls_sheet {return XLS_SHEET;}
|
<DYNARE_STATEMENT>xls_sheet {return XLS_SHEET;}
|
||||||
<DYNARE_STATEMENT>xls_range {return XLS_RANGE;}
|
<DYNARE_STATEMENT>xls_range {return XLS_RANGE;}
|
||||||
|
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>use_dll {return USE_DLL;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>use_dll {return USE_DLL;}
|
||||||
|
|
||||||
/* New */
|
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>dll {return DLL;}
|
|
||||||
/* EndNew */
|
|
||||||
|
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>linear {return LINEAR;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>linear {return LINEAR;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[,] {_scanner->do_operator(COMMA); return COMMA;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[,] {_scanner->do_operator(COMMA); return COMMA;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[\(\)] {return yytext[0];}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[\(\)] {return yytext[0];}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[\[] {return yytext[0];}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[\[] {return yytext[0];}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[\]] {if (sigma_e) sigma_e=0; return yytext[0];}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[\]] {if (sigma_e) sigma_e=0; return yytext[0];}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[+] {_scanner->do_operator(PLUS); return PLUS;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[+] {_scanner->do_operator(PLUS); return PLUS;}
|
||||||
|
@ -219,7 +214,7 @@ int sigma_e = 0;
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>sqrt {_scanner->do_operator(SQRT);return SQRT;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>sqrt {_scanner->do_operator(SQRT);return SQRT;}
|
||||||
|
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[A-Za-z_][A-Za-z0-9_]* {
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[A-Za-z_][A-Za-z0-9_]* {
|
||||||
_scanner->do_name(yytext);
|
_scanner->do_name(yytext);
|
||||||
return NAME;}
|
return NAME;}
|
||||||
|
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>((([0-9]*\.[0-9]+)|([0-9]+\.))([edED][-+]?[0-9]+)?)|([0-9]+[edED][-+]?[0-9]+) {
|
<DYNARE_STATEMENT,DYNARE_BLOCK>((([0-9]*\.[0-9]+)|([0-9]+\.))([edED][-+]?[0-9]+)?)|([0-9]+[edED][-+]?[0-9]+) {
|
||||||
|
@ -229,11 +224,11 @@ int sigma_e = 0;
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[0-9]+ {
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[0-9]+ {
|
||||||
_scanner->do_num_constant(yytext);
|
_scanner->do_num_constant(yytext);
|
||||||
return INT_NUMBER;}
|
return INT_NUMBER;}
|
||||||
|
|
||||||
/* an instruction starting with a recognized symbol is passed as NAME,
|
/* an instruction starting with a recognized symbol is passed as NAME,
|
||||||
otherwise it is a native statement until the end of the line
|
otherwise it is a native statement until the end of the line
|
||||||
*/
|
*/
|
||||||
<INITIAL>[A-Za-z_][A-Za-z0-9_]* {
|
<INITIAL>[A-Za-z_][A-Za-z0-9_]* {
|
||||||
if (SymbolTable::getID(yytext) != -1)
|
if (SymbolTable::getID(yytext) != -1)
|
||||||
{
|
{
|
||||||
BEGIN DYNARE_STATEMENT;
|
BEGIN DYNARE_STATEMENT;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*! \file
|
/*! \file
|
||||||
\version 1.0
|
\version 1.0
|
||||||
\date 04/09/2004
|
\date 04/09/2004
|
||||||
\par This file implements the parser class methodes.
|
\par This file implements the parser class methodes.
|
||||||
|
@ -15,10 +15,6 @@
|
||||||
#include "ComputingTasks.h"
|
#include "ComputingTasks.h"
|
||||||
#include "TmpSymbolTable.h"
|
#include "TmpSymbolTable.h"
|
||||||
#include "DynareParser.h"
|
#include "DynareParser.h"
|
||||||
/*New*/
|
|
||||||
#include "BlockTriangular.h"
|
|
||||||
/*EndNew*/
|
|
||||||
|
|
||||||
|
|
||||||
string dynare::parser::file_name = "";
|
string dynare::parser::file_name = "";
|
||||||
void dynare::parser::set_file_name(string fname)
|
void dynare::parser::set_file_name(string fname)
|
||||||
|
@ -26,9 +22,9 @@ void dynare::parser::set_file_name(string fname)
|
||||||
file_name = fname;
|
file_name = fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dynare::parser::setoutput(ostringstream* ostr)
|
void dynare::parser::setoutput(ostringstream* ostr)
|
||||||
{
|
{
|
||||||
output = ostr;
|
output = ostr;
|
||||||
numerical_initialization.setOutput(ostr);
|
numerical_initialization.setOutput(ostr);
|
||||||
shocks.setOutput(ostr);
|
shocks.setOutput(ostr);
|
||||||
sigmae.setOutput(ostr);
|
sigmae.setOutput(ostr);
|
||||||
|
@ -38,7 +34,7 @@ void dynare::parser::setoutput(ostringstream* ostr)
|
||||||
dynare::Objects* dynare::parser::add_endogenous(Objects* obj, Objects* tex_name)
|
dynare::Objects* dynare::parser::add_endogenous(Objects* obj, Objects* tex_name)
|
||||||
{
|
{
|
||||||
//cout << "add_endogenous \n";
|
//cout << "add_endogenous \n";
|
||||||
|
|
||||||
obj->ID = (NodeID) symbol_table.AddSymbolDeclar(obj->symbol,eEndogenous, tex_name->symbol);
|
obj->ID = (NodeID) symbol_table.AddSymbolDeclar(obj->symbol,eEndogenous, tex_name->symbol);
|
||||||
obj->type = eEndogenous;
|
obj->type = eEndogenous;
|
||||||
return (obj);
|
return (obj);
|
||||||
|
@ -49,7 +45,7 @@ dynare::Objects* dynare::parser::add_exogenous(Objects* obj, Objects* tex_name)
|
||||||
obj->type = eExogenous;
|
obj->type = eExogenous;
|
||||||
return (obj);
|
return (obj);
|
||||||
}
|
}
|
||||||
dynare::Objects* dynare::parser::add_exogenous_det(Objects* obj, Objects* tex_name)
|
dynare::Objects* dynare::parser::add_exogenous_det(Objects* obj, Objects* tex_name)
|
||||||
{
|
{
|
||||||
obj->ID = (NodeID) symbol_table.AddSymbolDeclar(obj->symbol,eExogenousDet, tex_name->symbol);
|
obj->ID = (NodeID) symbol_table.AddSymbolDeclar(obj->symbol,eExogenousDet, tex_name->symbol);
|
||||||
obj->type = eExogenousDet;
|
obj->type = eExogenousDet;
|
||||||
|
@ -84,31 +80,25 @@ dynare::Objects* dynare::parser::add_variable(Objects* var)
|
||||||
{
|
{
|
||||||
//cout << "add_variable1 : " << var->symbol << endl;
|
//cout << "add_variable1 : " << var->symbol << endl;
|
||||||
var = get_symbol(var);
|
var = get_symbol(var);
|
||||||
if((var->type == eEndogenous)
|
if((var->type == eEndogenous)
|
||||||
|| (var->type == eExogenous)
|
|| (var->type == eExogenous)
|
||||||
|| (var->type == eExogenousDet))
|
|| (var->type == eExogenousDet))
|
||||||
variable_table.AddVariable(var->symbol,0);
|
variable_table.AddVariable(var->symbol,0);
|
||||||
//cout << "add_model_token : " << var->ID << endl;
|
//cout << "add_model_token : " << var->ID << endl;
|
||||||
NodeID id = model_tree.AddTerminal(var->symbol);
|
NodeID id = model_tree.AddTerminal(var->symbol);
|
||||||
/*New*/
|
|
||||||
if (var->type == eEndogenous)
|
|
||||||
{
|
|
||||||
block_triangular.fill_IM(ModelParameters::eq_nbr, symbol_table.getID(var->symbol), 0);
|
|
||||||
}
|
|
||||||
/*EndNew*/
|
|
||||||
return new Objects("", id, eTempResult);
|
return new Objects("", id, eTempResult);
|
||||||
}
|
}
|
||||||
dynare::Objects* dynare::parser::add_variable(Objects* var,Objects* olag)
|
dynare::Objects* dynare::parser::add_variable(Objects* var,Objects* olag)
|
||||||
{
|
{
|
||||||
//cout << "add_variable2\n";
|
//cout << "add_variable2\n";
|
||||||
|
|
||||||
var = get_symbol(var);
|
var = get_symbol(var);
|
||||||
int lag = atoi((olag->symbol).c_str());
|
int lag = atoi((olag->symbol).c_str());
|
||||||
//cout << "symbol = " << olag->symbol << endl;
|
//cout << "symbol = " << olag->symbol << endl;
|
||||||
//cout << "lag = " << lag << endl;
|
//cout << "lag = " << lag << endl;
|
||||||
if ((var->type == eExogenous) && lag != 0)
|
if ((var->type == eExogenous) && lag != 0)
|
||||||
{
|
{
|
||||||
std::cout << "Warning: exogenous variable "
|
std::cout << "Warning: exogenous variable "
|
||||||
<< var->symbol
|
<< var->symbol
|
||||||
<< " has lag " << lag << "\n";
|
<< " has lag " << lag << "\n";
|
||||||
}
|
}
|
||||||
|
@ -116,14 +106,6 @@ dynare::Objects* dynare::parser::add_variable(Objects* var,Objects* olag)
|
||||||
variable_table.AddVariable(var->symbol,lag);
|
variable_table.AddVariable(var->symbol,lag);
|
||||||
//cout << "add_model_token : " << var->ID << endl;
|
//cout << "add_model_token : " << var->ID << endl;
|
||||||
NodeID id = model_tree.AddTerminal(var->symbol,lag);
|
NodeID id = model_tree.AddTerminal(var->symbol,lag);
|
||||||
/*New*/
|
|
||||||
if (var->type == eEndogenous)
|
|
||||||
{
|
|
||||||
//cout << "var->symbol : " << var->symbol << symbol_table.getID(var->symbol) << "\n";
|
|
||||||
//cout << "ModelParameters::eq_nbr : " << ModelParameters::eq_nbr << "\n";
|
|
||||||
block_triangular.fill_IM(ModelParameters::eq_nbr, symbol_table.getID(var->symbol), lag);
|
|
||||||
}
|
|
||||||
/*EndNew*/
|
|
||||||
return new Objects("", id, eTempResult);
|
return new Objects("", id, eTempResult);
|
||||||
}
|
}
|
||||||
dynare::Objects* dynare::parser::get_symbol(Objects* obj)
|
dynare::Objects* dynare::parser::get_symbol(Objects* obj)
|
||||||
|
@ -199,7 +181,7 @@ dynare::Objects* dynare::parser::add_expression_token( Objects* arg1, Objects* o
|
||||||
//cout << "after add_expression_token\n";
|
//cout << "after add_expression_token\n";
|
||||||
return new Objects("", (NodeID) id, eTempResult);
|
return new Objects("", (NodeID) id, eTempResult);
|
||||||
}
|
}
|
||||||
dynare::Objects* dynare::parser::get_expression(Objects* exp)
|
dynare::Objects* dynare::parser::get_expression(Objects* exp)
|
||||||
{
|
{
|
||||||
if (exp->type == eTempResult)
|
if (exp->type == eTempResult)
|
||||||
{
|
{
|
||||||
|
@ -230,7 +212,7 @@ void dynare::parser::init_param(Objects* lhs, Objects* rhs)
|
||||||
void dynare::parser::init_param(Objects* lhs)
|
void dynare::parser::init_param(Objects* lhs)
|
||||||
{
|
{
|
||||||
//cout << "Befor set\n";
|
//cout << "Befor set\n";
|
||||||
expression.set();
|
expression.set();
|
||||||
numerical_initialization.SetConstant(lhs->symbol, expression.get());
|
numerical_initialization.SetConstant(lhs->symbol, expression.get());
|
||||||
expression.clear();
|
expression.clear();
|
||||||
}
|
}
|
||||||
|
@ -246,52 +228,28 @@ void dynare::parser::hist_val(Objects* lhs, Objects* slag, Objects* rhs)
|
||||||
void dynare::parser::hist_val(Objects* lhs, Objects* slag)
|
void dynare::parser::hist_val(Objects* lhs, Objects* slag)
|
||||||
{
|
{
|
||||||
int lag = atoi((slag->symbol).c_str());
|
int lag = atoi((slag->symbol).c_str());
|
||||||
expression.set();
|
expression.set();
|
||||||
numerical_initialization.SetHist(lhs->symbol, lag, expression.get());
|
numerical_initialization.SetHist(lhs->symbol, lag, expression.get());
|
||||||
expression.clear();
|
expression.clear();
|
||||||
}
|
}
|
||||||
void dynare::parser::initialize_model(void)
|
void dynare::parser::initialize_model(void)
|
||||||
{
|
{
|
||||||
/*New*/
|
|
||||||
block_triangular.init_incidence_matrix();
|
|
||||||
/*EndNew*/
|
|
||||||
}
|
}
|
||||||
void dynare::parser::use_dll(void)
|
void dynare::parser::use_dll(void)
|
||||||
{
|
{
|
||||||
// Setting variable mumber offset to use C outputs
|
// Seetting variable momber offset to use C outputs
|
||||||
model_tree.offset = 0;
|
model_tree.offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*New*/
|
|
||||||
void dynare::parser::dll(void)
|
|
||||||
{
|
|
||||||
// Seetting variable mumber offset to use C outputs
|
|
||||||
model_tree.offset = 2;
|
|
||||||
}
|
|
||||||
/*EndNew*/
|
|
||||||
|
|
||||||
void dynare::parser::check_model(void)
|
void dynare::parser::check_model(void)
|
||||||
{
|
{
|
||||||
/*New*/
|
|
||||||
if (block_triangular.bt_verbose)
|
|
||||||
{
|
|
||||||
/*cout << "block_triangular.bt_verbose : " << block_triangular.bt_verbose << "\n";
|
|
||||||
cout << "----------------------------------------------------------------------------\n";*/
|
|
||||||
cout << "The gross incidence matrix \n";
|
|
||||||
block_triangular.Print_IM(ModelParameters::endo_nbr);
|
|
||||||
cout << "First ordering \n";
|
|
||||||
}
|
|
||||||
//block_triangular.Normalize_and_BlockDecompose_0();
|
|
||||||
block_triangular.Normalize_and_BlockDecompose_Static_Model();
|
|
||||||
/*EndNew*/
|
|
||||||
symbol_table.clean();
|
symbol_table.clean();
|
||||||
}
|
}
|
||||||
void dynare::parser::finish(void)
|
void dynare::parser::finish(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
string model_file_name(file_name);
|
||||||
|
|
||||||
string model_file_name(file_name);
|
// Setting flags to compute what is necessary
|
||||||
|
|
||||||
// Setting flags to compute what is necessary
|
|
||||||
if (order == 1 || linear == 1)
|
if (order == 1 || linear == 1)
|
||||||
{
|
{
|
||||||
model_tree.computeJacobianExo = true;
|
model_tree.computeJacobianExo = true;
|
||||||
|
@ -314,28 +272,22 @@ void dynare::parser::finish(void)
|
||||||
{
|
{
|
||||||
model_tree.derive(1);
|
model_tree.derive(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Processing outputs ...\n";
|
cout << "Processing outputs ...\n";
|
||||||
model_tree.setStaticModel();
|
model_tree.setStaticModel();
|
||||||
/*New*/
|
model_tree.setDynamicModel();
|
||||||
if (model_tree.offset == 2)
|
|
||||||
model_tree.setDynamicModel_New(block_triangular.ModelBlock,block_triangular.Index_Var_IM);
|
if (model_tree.offset == 0)
|
||||||
else
|
|
||||||
model_tree.setDynamicModel();
|
|
||||||
if (model_tree.offset != 1)
|
|
||||||
/*EndNew*/
|
|
||||||
{
|
{
|
||||||
model_tree.OpenCFiles(model_file_name+"_static", model_file_name+"_dynamic");
|
model_tree.OpenCFiles(model_file_name+"_static", model_file_name+"_dynamic");
|
||||||
/*New*/
|
model_tree.SaveCFiles();
|
||||||
model_tree.SaveCFiles(block_triangular.ModelBlock);
|
|
||||||
/*EndNew*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model_tree.OpenMFiles(model_file_name+"_static", model_file_name+"_dynamic");
|
model_tree.OpenMFiles(model_file_name+"_static", model_file_name+"_dynamic");
|
||||||
model_tree.SaveMFiles();
|
model_tree.SaveMFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
*output << "save('" << model_file_name << "_results', 'oo_');\n";
|
*output << "save('" << model_file_name << "_results', 'oo_');\n";
|
||||||
*output << "diary off\n";
|
*output << "diary off\n";
|
||||||
|
|
||||||
|
@ -389,7 +341,7 @@ void dynare::parser::add_det_shock(Objects* var)
|
||||||
case eExogenousDet:
|
case eExogenousDet:
|
||||||
shocks.AddDetShockExoDet(id);
|
shocks.AddDetShockExoDet(id);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
error("Shocks can only be applied to exogenous variables");
|
error("Shocks can only be applied to exogenous variables");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -690,13 +642,13 @@ dynare::Objects* dynare::parser::add_equal(Objects* arg1, Objects* arg2)
|
||||||
model_parameters.eq_nbr++;
|
model_parameters.eq_nbr++;
|
||||||
return new Objects("", id, eTempResult);
|
return new Objects("", id, eTempResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynare::Objects* dynare::parser::init_local_parameter(Objects* arg1, Objects* arg2)
|
dynare::Objects* dynare::parser::init_local_parameter(Objects* arg1, Objects* arg2)
|
||||||
{
|
{
|
||||||
NodeID id = model_tree.AddAssign(arg1->ID, arg2->ID);
|
NodeID id = model_tree.AddAssign(arg1->ID, arg2->ID);
|
||||||
return new Objects("", id, eTempResult);
|
return new Objects("", id, eTempResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynare::Objects* dynare::parser::add_plus(Objects* arg1, Objects* arg2)
|
dynare::Objects* dynare::parser::add_plus(Objects* arg1, Objects* arg2)
|
||||||
{
|
{
|
||||||
NodeID id = model_tree.AddPlus(arg1->ID, arg2->ID);
|
NodeID id = model_tree.AddPlus(arg1->ID, arg2->ID);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
||||||
/*! \file
|
/*! \file
|
||||||
\version 1.0
|
\version 1.0
|
||||||
\date 04/09/2004
|
\date 04/09/2004
|
||||||
\par This file implements the VariableTable class methodes.
|
\par This file implements the VariableTable class methodes.
|
||||||
|
@ -12,13 +12,13 @@ using namespace std;
|
||||||
#include "VariableTable.h"
|
#include "VariableTable.h"
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
map<varKey,int> VariableTable::mVariableTable = *(new map<varKey,int>);
|
map<varKey,int> VariableTable::mVariableTable = *(new map<varKey,int>);
|
||||||
vector<varKey> VariableTable::mVariableIndex = *(new vector<varKey>);
|
vector<varKey> VariableTable::mVariableIndex = *(new vector<varKey>);
|
||||||
vector<int> VariableTable::mSortedVariableID = *(new vector<int>);
|
vector<int> VariableTable::mSortedVariableID = *(new vector<int>);
|
||||||
vector<int> VariableTable::mPrintFormatIndex = *(new vector<int>);
|
vector<int> VariableTable::mPrintFormatIndex = *(new vector<int>);
|
||||||
void (* VariableTable::error) (const char* ) = NULL;
|
void (* VariableTable::error) (const char* ) = NULL;
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
VariableTable::VariableTable()
|
VariableTable::VariableTable()
|
||||||
{
|
{
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -29,10 +29,10 @@ VariableTable::~VariableTable()
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int VariableTable::AddVariable(string iName, int iLag)
|
int VariableTable::AddVariable(string iName, int iLag)
|
||||||
{
|
{
|
||||||
int lVariableID;
|
int lVariableID;
|
||||||
//Variable lVariable;
|
//Variable lVariable;
|
||||||
varKey key;
|
varKey key;
|
||||||
// Testing if symbol exists
|
// Testing if symbol exists
|
||||||
if (!SymbolTable::Exist(iName))
|
if (!SymbolTable::Exist(iName))
|
||||||
{
|
{
|
||||||
string msg = "unknown symbol: " + iName;
|
string msg = "unknown symbol: " + iName;
|
||||||
|
@ -51,7 +51,7 @@ int VariableTable::AddVariable(string iName, int iLag)
|
||||||
//lVariable.symbol_id = SymbolTable::getID(iName);
|
//lVariable.symbol_id = SymbolTable::getID(iName);
|
||||||
//lVariable.variable_id = lVariableID;
|
//lVariable.variable_id = lVariableID;
|
||||||
key = make_pair(iName,iLag);
|
key = make_pair(iName,iLag);
|
||||||
// Pushing variable on VariableTable
|
// Pushing variable on VariableTable
|
||||||
//mVariableTable[key] = lVariable;
|
//mVariableTable[key] = lVariable;
|
||||||
mVariableTable[key] = lVariableID;
|
mVariableTable[key] = lVariableID;
|
||||||
mVariableIndex.push_back(key);
|
mVariableIndex.push_back(key);
|
||||||
|
@ -114,7 +114,7 @@ int VariableTable::AddVariable(string iName, int iLag)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mVariableIndex.size()-1;
|
return mVariableIndex.size()-1;
|
||||||
|
@ -122,7 +122,7 @@ int VariableTable::AddVariable(string iName, int iLag)
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void VariableTable::decSymbolID(string iName, int id, int iLag, Type iType)
|
void VariableTable::decSymbolID(string iName, int id, int iLag, Type iType)
|
||||||
{
|
{
|
||||||
int lVariableID;
|
int lVariableID;
|
||||||
Variable lVariable;
|
Variable lVariable;
|
||||||
varKey key;
|
varKey key;
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ void VariableTable::Sort(void)
|
||||||
vector<int> IDs;
|
vector<int> IDs;
|
||||||
vector<int> Lags;
|
vector<int> Lags;
|
||||||
vector<Type> Types;
|
vector<Type> Types;
|
||||||
|
|
||||||
if (mVariableIndex.size() == 1)
|
if (mVariableIndex.size() == 1)
|
||||||
{
|
{
|
||||||
mSortedVariableID.push_back(0);
|
mSortedVariableID.push_back(0);
|
||||||
|
@ -172,20 +172,20 @@ void VariableTable::Sort(void)
|
||||||
unsigned long long int type = Types[id];
|
unsigned long long int type = Types[id];
|
||||||
type = type << 8*sizeof(int);
|
type = type << 8*sizeof(int);
|
||||||
unsigned long long int sort_pound = IDs[id]+lag+type;
|
unsigned long long int sort_pound = IDs[id]+lag+type;
|
||||||
VarToSort.push_back(make_pair(sort_pound,id));
|
VarToSort.push_back(make_pair(sort_pound,id));
|
||||||
}
|
}
|
||||||
// Uncomment this to debug
|
// Uncomment this to debug
|
||||||
/*
|
/*
|
||||||
cout << "Before sorting\n";
|
cout << "Before sorting\n";
|
||||||
cout << "S T L ID pound \n";
|
cout << "S T L ID pound \n";
|
||||||
for (int id=0; id < VarToSort.size(); id++)
|
for (int id=0; id < VarToSort.size(); id++)
|
||||||
{
|
{
|
||||||
Type type = Types[VarToSort[id].second];
|
Type type = Types[VarToSort[id].second];
|
||||||
int lag = Lags[VarToSort[id].second];
|
int lag = Lags[VarToSort[id].second];
|
||||||
int ID = IDs[VarToSort[id].second];
|
int ID = IDs[VarToSort[id].second];
|
||||||
cout << SymbolTable::getNameByID(type, ID) << " "
|
cout << SymbolTable::getNameByID(type, ID) << " "
|
||||||
<< type << " "
|
<< type << " "
|
||||||
<< lag << " "
|
<< lag << " "
|
||||||
<< ID << " "
|
<< ID << " "
|
||||||
<< VarToSort[id].first << "\n";
|
<< VarToSort[id].first << "\n";
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ void VariableTable::Sort(void)
|
||||||
Type type = Types[VarToSort[0].second];
|
Type type = Types[VarToSort[0].second];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (unsigned int id = 0; id < VarToSort.size(); id++)
|
for (unsigned int id = 0; id < VarToSort.size(); id++)
|
||||||
{
|
{
|
||||||
int id2 = VarToSort[id].second;
|
int id2 = VarToSort[id].second;
|
||||||
mSortedVariableID[id2] = id;
|
mSortedVariableID[id2] = id;
|
||||||
if (type == Types[id2])
|
if (type == Types[id2])
|
||||||
|
@ -207,7 +207,7 @@ void VariableTable::Sort(void)
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mPrintFormatIndex[id2] = 0;
|
mPrintFormatIndex[id2] = 0;
|
||||||
type = Types[id2];
|
type = Types[id2];
|
||||||
index = 1;
|
index = 1;
|
||||||
|
@ -218,13 +218,13 @@ void VariableTable::Sort(void)
|
||||||
cout << "After sorting\n";
|
cout << "After sorting\n";
|
||||||
cout << "S T L ID SVID PIDX\n";
|
cout << "S T L ID SVID PIDX\n";
|
||||||
for (int id=0; id < VarToSort.size(); id++)
|
for (int id=0; id < VarToSort.size(); id++)
|
||||||
{
|
{
|
||||||
Type type = Types[VarToSort[id].second];
|
Type type = Types[VarToSort[id].second];
|
||||||
int lag = Lags[VarToSort[id].second];
|
int lag = Lags[VarToSort[id].second];
|
||||||
int ID = IDs[VarToSort[id].second];
|
int ID = IDs[VarToSort[id].second];
|
||||||
cout << SymbolTable::getNameByID(Types[id], IDs[id]) << " "
|
cout << SymbolTable::getNameByID(Types[id], IDs[id]) << " "
|
||||||
<< Types[id] << " "
|
<< Types[id] << " "
|
||||||
<< Lags[id] << " "
|
<< Lags[id] << " "
|
||||||
<< IDs[id] << " "
|
<< IDs[id] << " "
|
||||||
<< mSortedVariableID[id] << " "
|
<< mSortedVariableID[id] << " "
|
||||||
<< mPrintFormatIndex[id] << "\n";
|
<< mPrintFormatIndex[id] << "\n";
|
||||||
|
@ -232,91 +232,3 @@ void VariableTable::Sort(void)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/*New*/
|
|
||||||
int* VariableTable::GetVariableTable(int* Size)
|
|
||||||
{
|
|
||||||
int* Table;
|
|
||||||
varKey key;
|
|
||||||
int variable,id, ind;
|
|
||||||
*Size=0;
|
|
||||||
//cout << "S T L ID SVID PIDX\n";
|
|
||||||
//cout << "mVariableIndex.size() : " << mVariableIndex.size() << "\n";
|
|
||||||
for (id=0; id < mVariableIndex.size(); id++)
|
|
||||||
{
|
|
||||||
key = mVariableIndex[id];
|
|
||||||
variable = mVariableTable[key];
|
|
||||||
if(getType(variable)==eEndogenous)
|
|
||||||
(*Size)++;
|
|
||||||
}
|
|
||||||
//cout << "*Size : " << (*Size) << "\n";
|
|
||||||
Table=(int*)malloc((*Size)*sizeof(*Table)*4);
|
|
||||||
ind=0;
|
|
||||||
for (id=0; id < mVariableIndex.size(); id++)
|
|
||||||
{
|
|
||||||
//Type type = Types[VarToSort[id].second];
|
|
||||||
//int lag = Lags[VarToSort[id].second];
|
|
||||||
//int ID = IDs[VarToSort[id].second];
|
|
||||||
key = mVariableIndex[id];
|
|
||||||
variable = mVariableTable[key];
|
|
||||||
if (getType(variable)==eEndogenous)
|
|
||||||
{
|
|
||||||
Table[ind*4]= getSymbolID(id);
|
|
||||||
Table[ind*4+1]= key.second;
|
|
||||||
Table[ind*4+2]= mPrintFormatIndex[id];
|
|
||||||
Table[ind*4+3]= 1;
|
|
||||||
ind++;
|
|
||||||
//cout << SymbolTable::getNameByID(Types[id], IDs[id]) << " "
|
|
||||||
// << Types[id] << " "
|
|
||||||
// << Lags[id] << " "
|
|
||||||
// << IDs[id] << " "
|
|
||||||
// << mSortedVariableID[id] << " "
|
|
||||||
// << mPrintFormatIndex[id] << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(Table);
|
|
||||||
}
|
|
||||||
|
|
||||||
int VariableTable::GetVariableID(std::string name, int lead_lag)
|
|
||||||
{
|
|
||||||
int found=-1;
|
|
||||||
varKey key;
|
|
||||||
int variable;
|
|
||||||
for (int id=0; id < mVariableIndex.size(); id++)
|
|
||||||
{
|
|
||||||
key=mVariableIndex[id];
|
|
||||||
variable = mVariableTable[key];
|
|
||||||
if((SymbolTable::getNameByID(getType(id), getSymbolID(variable))==name) && (lead_lag==key.second))
|
|
||||||
found=mPrintFormatIndex[id];
|
|
||||||
}
|
|
||||||
return(found);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int VariableTable::getIDS(int id, int lead_lag)
|
|
||||||
{
|
|
||||||
/*int found=-1;*/
|
|
||||||
varKey key;
|
|
||||||
int variable;
|
|
||||||
/*for (int id=0; id < mVariableIndex.size(); id++)
|
|
||||||
{*/
|
|
||||||
key=mVariableIndex[id];
|
|
||||||
variable = mVariableTable[key];
|
|
||||||
/*if((SymbolTable::getNameByID(getType(id), getSymbolID(variable))==name) && (lead_lag==key.second))
|
|
||||||
found=mPrintFormatIndex[id];
|
|
||||||
}*/
|
|
||||||
return(variable);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string VariableTable::GetVariableName(int id)
|
|
||||||
{
|
|
||||||
varKey key;
|
|
||||||
int variable;
|
|
||||||
key=mVariableIndex[id];
|
|
||||||
variable = mVariableTable[key];
|
|
||||||
return SymbolTable::getNameByID(getType(id), getSymbolID(variable));
|
|
||||||
}
|
|
||||||
/*EndNew*/
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
|
@ -1,351 +1,349 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.1. */
|
/* A Bison parser, made by GNU Bison 2.1. */
|
||||||
|
|
||||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
Boston, MA 02110-1301, USA. */
|
Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
/* As a special exception, when this file is copied by Bison into a
|
/* As a special exception, when this file is copied by Bison into a
|
||||||
Bison output file, you may use that output file without restriction.
|
Bison output file, you may use that output file without restriction.
|
||||||
This special exception was added by the Free Software Foundation
|
This special exception was added by the Free Software Foundation
|
||||||
in version 1.24 of Bison. */
|
in version 1.24 of Bison. */
|
||||||
|
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
#ifndef YYTOKENTYPE
|
#ifndef YYTOKENTYPE
|
||||||
# define YYTOKENTYPE
|
# define YYTOKENTYPE
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
know about them. */
|
know about them. */
|
||||||
enum yytokentype {
|
enum yytokentype {
|
||||||
AR = 258,
|
AR = 258,
|
||||||
AUTOCORR = 259,
|
AUTOCORR = 259,
|
||||||
BAYESIAN_IRF = 260,
|
BAYESIAN_IRF = 260,
|
||||||
BETA_PDF = 261,
|
BETA_PDF = 261,
|
||||||
CALIB = 262,
|
CALIB = 262,
|
||||||
CALIB_VAR = 263,
|
CALIB_VAR = 263,
|
||||||
CHECK = 264,
|
CHECK = 264,
|
||||||
CONF_SIG = 265,
|
CONF_SIG = 265,
|
||||||
CORR = 266,
|
CORR = 266,
|
||||||
COVAR = 267,
|
COVAR = 267,
|
||||||
DATAFILE = 268,
|
DATAFILE = 268,
|
||||||
DIAGNOSTIC = 269,
|
DIAGNOSTIC = 269,
|
||||||
DIFFUSE_D = 270,
|
DIFFUSE_D = 270,
|
||||||
DLL = 271,
|
DOLLAR = 271,
|
||||||
DOLLAR = 272,
|
DR_ALGO = 272,
|
||||||
DR_ALGO = 273,
|
DROP = 273,
|
||||||
DROP = 274,
|
DSAMPLE = 274,
|
||||||
DSAMPLE = 275,
|
DYN2VEC = 275,
|
||||||
DYN2VEC = 276,
|
DYNASAVE = 276,
|
||||||
DYNASAVE = 277,
|
DYNATYPE = 277,
|
||||||
DYNATYPE = 278,
|
END = 278,
|
||||||
END = 279,
|
ENDVAL = 279,
|
||||||
ENDVAL = 280,
|
EQUAL = 280,
|
||||||
EQUAL = 281,
|
ESTIMATION = 281,
|
||||||
ESTIMATION = 282,
|
ESTIMATED_PARAMS = 282,
|
||||||
ESTIMATED_PARAMS = 283,
|
ESTIMATED_PARAMS_BOUNDS = 283,
|
||||||
ESTIMATED_PARAMS_BOUNDS = 284,
|
ESTIMATED_PARAMS_INIT = 284,
|
||||||
ESTIMATED_PARAMS_INIT = 285,
|
FILTERED_VARS = 285,
|
||||||
FILTERED_VARS = 286,
|
FIRST_OBS = 286,
|
||||||
FIRST_OBS = 287,
|
FLOAT_NUMBER = 287,
|
||||||
FLOAT_NUMBER = 288,
|
FORECAST = 288,
|
||||||
FORECAST = 289,
|
FUNCTIONS = 289,
|
||||||
FUNCTIONS = 290,
|
GAMMA_PDF = 290,
|
||||||
GAMMA_PDF = 291,
|
GRAPH = 291,
|
||||||
GRAPH = 292,
|
HISTVAL = 292,
|
||||||
HISTVAL = 293,
|
HP_FILTER = 293,
|
||||||
HP_FILTER = 294,
|
HP_NGRID = 294,
|
||||||
HP_NGRID = 295,
|
INITVAL = 295,
|
||||||
INITVAL = 296,
|
INITVALF = 296,
|
||||||
INITVALF = 297,
|
INT_NUMBER = 297,
|
||||||
INT_NUMBER = 298,
|
INV_GAMMA_PDF = 298,
|
||||||
INV_GAMMA_PDF = 299,
|
INV_GAMMA1_PDF = 299,
|
||||||
INV_GAMMA1_PDF = 300,
|
INV_GAMMA2_PDF = 300,
|
||||||
INV_GAMMA2_PDF = 301,
|
IRF = 301,
|
||||||
IRF = 302,
|
KALMAN_ALGO = 302,
|
||||||
KALMAN_ALGO = 303,
|
KALMAN_TOL = 303,
|
||||||
KALMAN_TOL = 304,
|
CONSTANT = 304,
|
||||||
CONSTANT = 305,
|
NOCONSTANT = 305,
|
||||||
NOCONSTANT = 306,
|
LAPLACE = 306,
|
||||||
LAPLACE = 307,
|
LIK_ALGO = 307,
|
||||||
LIK_ALGO = 308,
|
LIK_INIT = 308,
|
||||||
LIK_INIT = 309,
|
LINEAR = 309,
|
||||||
LINEAR = 310,
|
LOAD_MH_FILE = 310,
|
||||||
LOAD_MH_FILE = 311,
|
LOGLINEAR = 311,
|
||||||
LOGLINEAR = 312,
|
MH_DROP = 312,
|
||||||
MH_DROP = 313,
|
MH_INIT_SCALE = 313,
|
||||||
MH_INIT_SCALE = 314,
|
MH_JSCALE = 314,
|
||||||
MH_JSCALE = 315,
|
MH_MODE = 315,
|
||||||
MH_MODE = 316,
|
MH_NBLOCKS = 316,
|
||||||
MH_NBLOCKS = 317,
|
MH_REPLIC = 317,
|
||||||
MH_REPLIC = 318,
|
MODE_CHECK = 318,
|
||||||
MODE_CHECK = 319,
|
MODE_COMPUTE = 319,
|
||||||
MODE_COMPUTE = 320,
|
MODE_FILE = 320,
|
||||||
MODE_FILE = 321,
|
MODEL = 321,
|
||||||
MODEL = 322,
|
MODEL_COMPARISON = 322,
|
||||||
MODEL_COMPARISON = 323,
|
MODEL_COMPARISON_APPROXIMATION = 323,
|
||||||
MODEL_COMPARISON_APPROXIMATION = 324,
|
MODIFIEDHARMONICMEAN = 324,
|
||||||
MODIFIEDHARMONICMEAN = 325,
|
MOMENTS = 325,
|
||||||
MOMENTS = 326,
|
MOMENTS_VARENDO = 326,
|
||||||
MOMENTS_VARENDO = 327,
|
MSHOCKS = 327,
|
||||||
MSHOCKS = 328,
|
NAME = 328,
|
||||||
NAME = 329,
|
NOBS = 329,
|
||||||
NOBS = 330,
|
NOCORR = 330,
|
||||||
NOCORR = 331,
|
NODIAGNOSTIC = 331,
|
||||||
NODIAGNOSTIC = 332,
|
NOFUNCTIONS = 332,
|
||||||
NOFUNCTIONS = 333,
|
NOGRAPH = 333,
|
||||||
NOGRAPH = 334,
|
XLS_SHEET = 334,
|
||||||
XLS_SHEET = 335,
|
XLS_RANGE = 335,
|
||||||
XLS_RANGE = 336,
|
NOMOMENTS = 336,
|
||||||
NOMOMENTS = 337,
|
NOPRINT = 337,
|
||||||
NOPRINT = 338,
|
NORMAL_PDF = 338,
|
||||||
NORMAL_PDF = 339,
|
OBSERVATION_TRENDS = 339,
|
||||||
OBSERVATION_TRENDS = 340,
|
OLR = 340,
|
||||||
OLR = 341,
|
OLR_INST = 341,
|
||||||
OLR_INST = 342,
|
OLR_BETA = 342,
|
||||||
OLR_BETA = 343,
|
OPTIM = 343,
|
||||||
OPTIM = 344,
|
OPTIM_WEIGHTS = 344,
|
||||||
OPTIM_WEIGHTS = 345,
|
ORDER = 345,
|
||||||
ORDER = 346,
|
OSR = 346,
|
||||||
OSR = 347,
|
OSR_PARAMS = 347,
|
||||||
OSR_PARAMS = 348,
|
PARAMETERS = 348,
|
||||||
PARAMETERS = 349,
|
PERIODS = 349,
|
||||||
PERIODS = 350,
|
PREFILTER = 350,
|
||||||
PREFILTER = 351,
|
PRESAMPLE = 351,
|
||||||
PRESAMPLE = 352,
|
PRINT = 352,
|
||||||
PRINT = 353,
|
PRIOR_TRUNC = 353,
|
||||||
PRIOR_TRUNC = 354,
|
FILTER_STEP_AHEAD = 354,
|
||||||
FILTER_STEP_AHEAD = 355,
|
QZ_CRITERIUM = 355,
|
||||||
QZ_CRITERIUM = 356,
|
RELATIVE_IRF = 356,
|
||||||
RELATIVE_IRF = 357,
|
REPLIC = 357,
|
||||||
REPLIC = 358,
|
RESOL = 358,
|
||||||
RESOL = 359,
|
RPLOT = 359,
|
||||||
RPLOT = 360,
|
SHOCKS = 360,
|
||||||
SHOCKS = 361,
|
SIGMA_E = 361,
|
||||||
SIGMA_E = 362,
|
SIMUL = 362,
|
||||||
SIMUL = 363,
|
SIMUL_ALGO = 363,
|
||||||
SIMUL_ALGO = 364,
|
SIMUL_SEED = 364,
|
||||||
SIMUL_SEED = 365,
|
SMOOTHER = 365,
|
||||||
SMOOTHER = 366,
|
SOLVE_ALGO = 366,
|
||||||
SOLVE_ALGO = 367,
|
STDERR = 367,
|
||||||
STDERR = 368,
|
STEADY = 368,
|
||||||
STEADY = 369,
|
STOCH_SIMUL = 369,
|
||||||
STOCH_SIMUL = 370,
|
TEX = 370,
|
||||||
TEX = 371,
|
TEX_NAME = 371,
|
||||||
TEX_NAME = 372,
|
UNIFORM_PDF = 372,
|
||||||
UNIFORM_PDF = 373,
|
UNIT_ROOT_VARS = 373,
|
||||||
UNIT_ROOT_VARS = 374,
|
USE_DLL = 374,
|
||||||
USE_DLL = 375,
|
VALUES = 375,
|
||||||
VALUES = 376,
|
VAR = 376,
|
||||||
VAR = 377,
|
VAREXO = 377,
|
||||||
VAREXO = 378,
|
VAREXO_DET = 378,
|
||||||
VAREXO_DET = 379,
|
VAROBS = 379,
|
||||||
VAROBS = 380,
|
XTICK = 380,
|
||||||
XTICK = 381,
|
XTICKLABEL = 381,
|
||||||
XTICKLABEL = 382,
|
COMMA = 382,
|
||||||
COMMA = 383,
|
MINUS = 383,
|
||||||
MINUS = 384,
|
PLUS = 384,
|
||||||
PLUS = 385,
|
DIVIDE = 385,
|
||||||
DIVIDE = 386,
|
TIMES = 386,
|
||||||
TIMES = 387,
|
UMINUS = 387,
|
||||||
UMINUS = 388,
|
POWER = 388,
|
||||||
POWER = 389,
|
FACTORIAL = 389,
|
||||||
FACTORIAL = 390,
|
EXP = 390,
|
||||||
EXP = 391,
|
LOG = 391,
|
||||||
LOG = 392,
|
LOG10 = 392,
|
||||||
LOG10 = 393,
|
LN = 393,
|
||||||
LN = 394,
|
SIN = 394,
|
||||||
SIN = 395,
|
COS = 395,
|
||||||
COS = 396,
|
TAN = 396,
|
||||||
TAN = 397,
|
ASIN = 397,
|
||||||
ASIN = 398,
|
ACOS = 398,
|
||||||
ACOS = 399,
|
ATAN = 399,
|
||||||
ATAN = 400,
|
SINH = 400,
|
||||||
SINH = 401,
|
COSH = 401,
|
||||||
COSH = 402,
|
TANH = 402,
|
||||||
TANH = 403,
|
ASINH = 403,
|
||||||
ASINH = 404,
|
ACOSH = 404,
|
||||||
ACOSH = 405,
|
ATANH = 405,
|
||||||
ATANH = 406,
|
SQRT = 406,
|
||||||
SQRT = 407,
|
ASSIGN = 407
|
||||||
ASSIGN = 408
|
};
|
||||||
};
|
#endif
|
||||||
#endif
|
/* Tokens. */
|
||||||
/* Tokens. */
|
#define AR 258
|
||||||
#define AR 258
|
#define AUTOCORR 259
|
||||||
#define AUTOCORR 259
|
#define BAYESIAN_IRF 260
|
||||||
#define BAYESIAN_IRF 260
|
#define BETA_PDF 261
|
||||||
#define BETA_PDF 261
|
#define CALIB 262
|
||||||
#define CALIB 262
|
#define CALIB_VAR 263
|
||||||
#define CALIB_VAR 263
|
#define CHECK 264
|
||||||
#define CHECK 264
|
#define CONF_SIG 265
|
||||||
#define CONF_SIG 265
|
#define CORR 266
|
||||||
#define CORR 266
|
#define COVAR 267
|
||||||
#define COVAR 267
|
#define DATAFILE 268
|
||||||
#define DATAFILE 268
|
#define DIAGNOSTIC 269
|
||||||
#define DIAGNOSTIC 269
|
#define DIFFUSE_D 270
|
||||||
#define DIFFUSE_D 270
|
#define DOLLAR 271
|
||||||
#define DLL 271
|
#define DR_ALGO 272
|
||||||
#define DOLLAR 272
|
#define DROP 273
|
||||||
#define DR_ALGO 273
|
#define DSAMPLE 274
|
||||||
#define DROP 274
|
#define DYN2VEC 275
|
||||||
#define DSAMPLE 275
|
#define DYNASAVE 276
|
||||||
#define DYN2VEC 276
|
#define DYNATYPE 277
|
||||||
#define DYNASAVE 277
|
#define END 278
|
||||||
#define DYNATYPE 278
|
#define ENDVAL 279
|
||||||
#define END 279
|
#define EQUAL 280
|
||||||
#define ENDVAL 280
|
#define ESTIMATION 281
|
||||||
#define EQUAL 281
|
#define ESTIMATED_PARAMS 282
|
||||||
#define ESTIMATION 282
|
#define ESTIMATED_PARAMS_BOUNDS 283
|
||||||
#define ESTIMATED_PARAMS 283
|
#define ESTIMATED_PARAMS_INIT 284
|
||||||
#define ESTIMATED_PARAMS_BOUNDS 284
|
#define FILTERED_VARS 285
|
||||||
#define ESTIMATED_PARAMS_INIT 285
|
#define FIRST_OBS 286
|
||||||
#define FILTERED_VARS 286
|
#define FLOAT_NUMBER 287
|
||||||
#define FIRST_OBS 287
|
#define FORECAST 288
|
||||||
#define FLOAT_NUMBER 288
|
#define FUNCTIONS 289
|
||||||
#define FORECAST 289
|
#define GAMMA_PDF 290
|
||||||
#define FUNCTIONS 290
|
#define GRAPH 291
|
||||||
#define GAMMA_PDF 291
|
#define HISTVAL 292
|
||||||
#define GRAPH 292
|
#define HP_FILTER 293
|
||||||
#define HISTVAL 293
|
#define HP_NGRID 294
|
||||||
#define HP_FILTER 294
|
#define INITVAL 295
|
||||||
#define HP_NGRID 295
|
#define INITVALF 296
|
||||||
#define INITVAL 296
|
#define INT_NUMBER 297
|
||||||
#define INITVALF 297
|
#define INV_GAMMA_PDF 298
|
||||||
#define INT_NUMBER 298
|
#define INV_GAMMA1_PDF 299
|
||||||
#define INV_GAMMA_PDF 299
|
#define INV_GAMMA2_PDF 300
|
||||||
#define INV_GAMMA1_PDF 300
|
#define IRF 301
|
||||||
#define INV_GAMMA2_PDF 301
|
#define KALMAN_ALGO 302
|
||||||
#define IRF 302
|
#define KALMAN_TOL 303
|
||||||
#define KALMAN_ALGO 303
|
#define CONSTANT 304
|
||||||
#define KALMAN_TOL 304
|
#define NOCONSTANT 305
|
||||||
#define CONSTANT 305
|
#define LAPLACE 306
|
||||||
#define NOCONSTANT 306
|
#define LIK_ALGO 307
|
||||||
#define LAPLACE 307
|
#define LIK_INIT 308
|
||||||
#define LIK_ALGO 308
|
#define LINEAR 309
|
||||||
#define LIK_INIT 309
|
#define LOAD_MH_FILE 310
|
||||||
#define LINEAR 310
|
#define LOGLINEAR 311
|
||||||
#define LOAD_MH_FILE 311
|
#define MH_DROP 312
|
||||||
#define LOGLINEAR 312
|
#define MH_INIT_SCALE 313
|
||||||
#define MH_DROP 313
|
#define MH_JSCALE 314
|
||||||
#define MH_INIT_SCALE 314
|
#define MH_MODE 315
|
||||||
#define MH_JSCALE 315
|
#define MH_NBLOCKS 316
|
||||||
#define MH_MODE 316
|
#define MH_REPLIC 317
|
||||||
#define MH_NBLOCKS 317
|
#define MODE_CHECK 318
|
||||||
#define MH_REPLIC 318
|
#define MODE_COMPUTE 319
|
||||||
#define MODE_CHECK 319
|
#define MODE_FILE 320
|
||||||
#define MODE_COMPUTE 320
|
#define MODEL 321
|
||||||
#define MODE_FILE 321
|
#define MODEL_COMPARISON 322
|
||||||
#define MODEL 322
|
#define MODEL_COMPARISON_APPROXIMATION 323
|
||||||
#define MODEL_COMPARISON 323
|
#define MODIFIEDHARMONICMEAN 324
|
||||||
#define MODEL_COMPARISON_APPROXIMATION 324
|
#define MOMENTS 325
|
||||||
#define MODIFIEDHARMONICMEAN 325
|
#define MOMENTS_VARENDO 326
|
||||||
#define MOMENTS 326
|
#define MSHOCKS 327
|
||||||
#define MOMENTS_VARENDO 327
|
#define NAME 328
|
||||||
#define MSHOCKS 328
|
#define NOBS 329
|
||||||
#define NAME 329
|
#define NOCORR 330
|
||||||
#define NOBS 330
|
#define NODIAGNOSTIC 331
|
||||||
#define NOCORR 331
|
#define NOFUNCTIONS 332
|
||||||
#define NODIAGNOSTIC 332
|
#define NOGRAPH 333
|
||||||
#define NOFUNCTIONS 333
|
#define XLS_SHEET 334
|
||||||
#define NOGRAPH 334
|
#define XLS_RANGE 335
|
||||||
#define XLS_SHEET 335
|
#define NOMOMENTS 336
|
||||||
#define XLS_RANGE 336
|
#define NOPRINT 337
|
||||||
#define NOMOMENTS 337
|
#define NORMAL_PDF 338
|
||||||
#define NOPRINT 338
|
#define OBSERVATION_TRENDS 339
|
||||||
#define NORMAL_PDF 339
|
#define OLR 340
|
||||||
#define OBSERVATION_TRENDS 340
|
#define OLR_INST 341
|
||||||
#define OLR 341
|
#define OLR_BETA 342
|
||||||
#define OLR_INST 342
|
#define OPTIM 343
|
||||||
#define OLR_BETA 343
|
#define OPTIM_WEIGHTS 344
|
||||||
#define OPTIM 344
|
#define ORDER 345
|
||||||
#define OPTIM_WEIGHTS 345
|
#define OSR 346
|
||||||
#define ORDER 346
|
#define OSR_PARAMS 347
|
||||||
#define OSR 347
|
#define PARAMETERS 348
|
||||||
#define OSR_PARAMS 348
|
#define PERIODS 349
|
||||||
#define PARAMETERS 349
|
#define PREFILTER 350
|
||||||
#define PERIODS 350
|
#define PRESAMPLE 351
|
||||||
#define PREFILTER 351
|
#define PRINT 352
|
||||||
#define PRESAMPLE 352
|
#define PRIOR_TRUNC 353
|
||||||
#define PRINT 353
|
#define FILTER_STEP_AHEAD 354
|
||||||
#define PRIOR_TRUNC 354
|
#define QZ_CRITERIUM 355
|
||||||
#define FILTER_STEP_AHEAD 355
|
#define RELATIVE_IRF 356
|
||||||
#define QZ_CRITERIUM 356
|
#define REPLIC 357
|
||||||
#define RELATIVE_IRF 357
|
#define RESOL 358
|
||||||
#define REPLIC 358
|
#define RPLOT 359
|
||||||
#define RESOL 359
|
#define SHOCKS 360
|
||||||
#define RPLOT 360
|
#define SIGMA_E 361
|
||||||
#define SHOCKS 361
|
#define SIMUL 362
|
||||||
#define SIGMA_E 362
|
#define SIMUL_ALGO 363
|
||||||
#define SIMUL 363
|
#define SIMUL_SEED 364
|
||||||
#define SIMUL_ALGO 364
|
#define SMOOTHER 365
|
||||||
#define SIMUL_SEED 365
|
#define SOLVE_ALGO 366
|
||||||
#define SMOOTHER 366
|
#define STDERR 367
|
||||||
#define SOLVE_ALGO 367
|
#define STEADY 368
|
||||||
#define STDERR 368
|
#define STOCH_SIMUL 369
|
||||||
#define STEADY 369
|
#define TEX 370
|
||||||
#define STOCH_SIMUL 370
|
#define TEX_NAME 371
|
||||||
#define TEX 371
|
#define UNIFORM_PDF 372
|
||||||
#define TEX_NAME 372
|
#define UNIT_ROOT_VARS 373
|
||||||
#define UNIFORM_PDF 373
|
#define USE_DLL 374
|
||||||
#define UNIT_ROOT_VARS 374
|
#define VALUES 375
|
||||||
#define USE_DLL 375
|
#define VAR 376
|
||||||
#define VALUES 376
|
#define VAREXO 377
|
||||||
#define VAR 377
|
#define VAREXO_DET 378
|
||||||
#define VAREXO 378
|
#define VAROBS 379
|
||||||
#define VAREXO_DET 379
|
#define XTICK 380
|
||||||
#define VAROBS 380
|
#define XTICKLABEL 381
|
||||||
#define XTICK 381
|
#define COMMA 382
|
||||||
#define XTICKLABEL 382
|
#define MINUS 383
|
||||||
#define COMMA 383
|
#define PLUS 384
|
||||||
#define MINUS 384
|
#define DIVIDE 385
|
||||||
#define PLUS 385
|
#define TIMES 386
|
||||||
#define DIVIDE 386
|
#define UMINUS 387
|
||||||
#define TIMES 387
|
#define POWER 388
|
||||||
#define UMINUS 388
|
#define FACTORIAL 389
|
||||||
#define POWER 389
|
#define EXP 390
|
||||||
#define FACTORIAL 390
|
#define LOG 391
|
||||||
#define EXP 391
|
#define LOG10 392
|
||||||
#define LOG 392
|
#define LN 393
|
||||||
#define LOG10 393
|
#define SIN 394
|
||||||
#define LN 394
|
#define COS 395
|
||||||
#define SIN 395
|
#define TAN 396
|
||||||
#define COS 396
|
#define ASIN 397
|
||||||
#define TAN 397
|
#define ACOS 398
|
||||||
#define ASIN 398
|
#define ATAN 399
|
||||||
#define ACOS 399
|
#define SINH 400
|
||||||
#define ATAN 400
|
#define COSH 401
|
||||||
#define SINH 401
|
#define TANH 402
|
||||||
#define COSH 402
|
#define ASINH 403
|
||||||
#define TANH 403
|
#define ACOSH 404
|
||||||
#define ASINH 404
|
#define ATANH 405
|
||||||
#define ACOSH 405
|
#define SQRT 406
|
||||||
#define ATANH 406
|
#define ASSIGN 407
|
||||||
#define SQRT 407
|
|
||||||
#define ASSIGN 408
|
|
||||||
|
|
||||||
|
|
||||||
|
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||||
|
typedef int YYSTYPE;
|
||||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
typedef int YYSTYPE;
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
#endif
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
|
||||||
#endif
|
extern YYSTYPE yylval;
|
||||||
|
|
||||||
extern YYSTYPE yylval;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef DYNAREPARSER_H
|
#ifndef DYNAREPARSER_H
|
||||||
#define DYNAREPARSER_H
|
#define DYNAREPARSER_H
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/*! \file
|
/*! \file
|
||||||
\version 1.0
|
\version 1.0
|
||||||
\date 04/27/2004
|
\date 04/27/2004
|
||||||
\par This file defines the parser class.
|
\par This file defines the parser class.
|
||||||
|
@ -18,11 +18,8 @@
|
||||||
#include "SigmaeInitialization.h"
|
#include "SigmaeInitialization.h"
|
||||||
#include "ComputingTasks.h"
|
#include "ComputingTasks.h"
|
||||||
#include "TmpSymbolTable.h"
|
#include "TmpSymbolTable.h"
|
||||||
#include "Objects.h"
|
#include "Objects.h"
|
||||||
/*New*/
|
#ifndef YLMM_basic_parser
|
||||||
#include "BlockTriangular.h"
|
|
||||||
/*EndNew*/
|
|
||||||
#ifndef YLMM_basic_parser
|
|
||||||
#include "ylmm/basic_parser.hh"
|
#include "ylmm/basic_parser.hh"
|
||||||
#endif
|
#endif
|
||||||
#ifndef YLMM_basic_scanner
|
#ifndef YLMM_basic_scanner
|
||||||
|
@ -36,13 +33,13 @@
|
||||||
extern int yylineno;
|
extern int yylineno;
|
||||||
/*! \namespace dynare
|
/*! \namespace dynare
|
||||||
*/
|
*/
|
||||||
namespace dynare
|
namespace dynare
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
\class parser
|
\class parser
|
||||||
\brief Member functions of this class are called from DyanreBison.y
|
\brief Member functions of this class are called from DyanreBison.y
|
||||||
*/
|
*/
|
||||||
class parser : public ylmm::basic_parser<Objects*>
|
class parser : public ylmm::basic_parser<Objects*>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ylmm::basic_scanner<Objects*>& _scanner;
|
ylmm::basic_scanner<Objects*>& _scanner;
|
||||||
|
@ -79,21 +76,18 @@ namespace dynare
|
||||||
int order;
|
int order;
|
||||||
/*! Value of option linear */
|
/*! Value of option linear */
|
||||||
int linear;
|
int linear;
|
||||||
EstimationParams estim_params;
|
EstimationParams estim_params;
|
||||||
/*New*/
|
|
||||||
BlockTriangular block_triangular;
|
|
||||||
/*EndNew*/
|
|
||||||
/*! Prints an arror to stdout */
|
/*! Prints an arror to stdout */
|
||||||
static void error(const char* m)
|
static void error(const char* m)
|
||||||
{
|
{
|
||||||
std::cout << file_name << " : Error in line " << yylineno << " : " << m << endl;
|
std::cout << file_name << " : Error in line " << yylineno << " : " << m << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
Constuctor
|
Constuctor
|
||||||
\param s reference to scanner
|
\param s reference to scanner
|
||||||
*/
|
*/
|
||||||
parser(ylmm::basic_scanner<Objects*>& s) : _scanner(s)
|
parser(ylmm::basic_scanner<Objects*>& s) : _scanner(s)
|
||||||
{
|
{
|
||||||
order = -1;
|
order = -1;
|
||||||
linear = -1;
|
linear = -1;
|
||||||
|
@ -106,17 +100,17 @@ namespace dynare
|
||||||
tmp_symbol_table.error = error;
|
tmp_symbol_table.error = error;
|
||||||
}
|
}
|
||||||
/*! Destructor */
|
/*! Destructor */
|
||||||
virtual ~parser() {}
|
virtual ~parser() {}
|
||||||
/*!
|
/*!
|
||||||
Scan input
|
Scan input
|
||||||
\param arg Optional argument
|
\param arg Optional argument
|
||||||
\return The next token ID
|
\return The next token ID
|
||||||
*/
|
*/
|
||||||
int scan(void* arg=0) {
|
int scan(void* arg=0) {
|
||||||
if (need_where())
|
if (need_where())
|
||||||
return _scanner.next(*_token,*_location);
|
return _scanner.next(*_token,*_location);
|
||||||
return _scanner.next(*_token);
|
return _scanner.next(*_token);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*! Sets output file name */
|
/*! Sets output file name */
|
||||||
void set_file_name(string fname);
|
void set_file_name(string fname);
|
||||||
|
@ -129,10 +123,7 @@ namespace dynare
|
||||||
/*! Initializes the model */
|
/*! Initializes the model */
|
||||||
void initialize_model(void);
|
void initialize_model(void);
|
||||||
/*! Sets variable offset of ModelTree class to use C output */
|
/*! Sets variable offset of ModelTree class to use C output */
|
||||||
void use_dll(void);
|
void use_dll(void);
|
||||||
/*New*/
|
|
||||||
void dll(void);
|
|
||||||
/*EndNew*/
|
|
||||||
/*! Adds an endogenous variable to SymbolTable*/
|
/*! Adds an endogenous variable to SymbolTable*/
|
||||||
Objects* add_endogenous(Objects* name, Objects* tex_name = new Objects("",NULL, eUNDEF));
|
Objects* add_endogenous(Objects* name, Objects* tex_name = new Objects("",NULL, eUNDEF));
|
||||||
/*! Adds an exogenous variable to SymbolTable*/
|
/*! Adds an exogenous variable to SymbolTable*/
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef MODELTREE_H
|
#ifndef MODELTREE_H
|
||||||
#define MODELTREE_H
|
#define MODELTREE_H
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/*! \file
|
/*! \file
|
||||||
\version 1.0
|
\version 1.0
|
||||||
\date 04/13/2003
|
\date 04/13/2003
|
||||||
\par This file defines the ModelTree class.
|
\par This file defines the ModelTree class.
|
||||||
|
@ -20,9 +20,6 @@
|
||||||
#include "NumericalConstants.h"
|
#include "NumericalConstants.h"
|
||||||
#include "ModelTypes.h"
|
#include "ModelTypes.h"
|
||||||
#include "DataTree.h"
|
#include "DataTree.h"
|
||||||
/*New*/
|
|
||||||
#include "BlockTriangular.h"
|
|
||||||
/*EndNew*/
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/*!
|
/*!
|
||||||
\class ModelTree
|
\class ModelTree
|
||||||
|
@ -71,9 +68,9 @@ class ModelTree : public DataTree
|
||||||
inline std::string getExpression(NodeID StartID, EquationType iEquationType, int iEquationID = -1);
|
inline std::string getExpression(NodeID StartID, EquationType iEquationType, int iEquationID = -1);
|
||||||
/*!
|
/*!
|
||||||
Return true if node is to be writen as temp result
|
Return true if node is to be writen as temp result
|
||||||
depending on its time cost and number of times it is referenced in model tree
|
depending on its time cost and number of times it is referenced in model tree
|
||||||
*/
|
*/
|
||||||
inline bool writeAsTemp(NodeID id);
|
inline bool writeAsTemp(NodeID id);
|
||||||
/*! Remove unreferenced tokens after a derivation */
|
/*! Remove unreferenced tokens after a derivation */
|
||||||
//void RemoveUnref(int iBeginID, int iEndID, int iOrder);
|
//void RemoveUnref(int iBeginID, int iEndID, int iOrder);
|
||||||
/*! Decrementing reference couter of unreferenced tokens in last derivative */
|
/*! Decrementing reference couter of unreferenced tokens in last derivative */
|
||||||
|
@ -96,31 +93,22 @@ class ModelTree : public DataTree
|
||||||
void OpenCFiles(std::string iModelFileName1, std::string iModelFileName2 = "");
|
void OpenCFiles(std::string iModelFileName1, std::string iModelFileName2 = "");
|
||||||
/*! Saves output string into output M files */
|
/*! Saves output string into output M files */
|
||||||
void SaveMFiles();
|
void SaveMFiles();
|
||||||
|
|
||||||
/*! Saves output string into output C files */
|
/*! Saves output string into output C files */
|
||||||
/*New*/
|
void SaveCFiles();
|
||||||
void SaveCFiles(Model_Block* ModelBlock);
|
|
||||||
/*EndNew*/
|
|
||||||
/*! Computes derivatives of ModelTree */
|
/*! Computes derivatives of ModelTree */
|
||||||
void derive(int iOrder);
|
void derive(int iOrder);
|
||||||
/*!
|
/*!
|
||||||
Writes output file for static model :
|
Writes output file for static model :
|
||||||
- equations
|
- equations
|
||||||
- 1st order derivatives with respect to endogenous variables (without lags)
|
- 1st order derivatives with respect to endogenous variables (without lags)
|
||||||
*/
|
*/
|
||||||
std::string setStaticModel(void);
|
std::string setStaticModel(void);
|
||||||
/*!
|
/*!
|
||||||
Writes output file for dynamic stochastic model :
|
Writes output file for dynamic stochastic model :
|
||||||
- equations
|
- equations
|
||||||
- 1st order and 2nd order derivatives with respect to endogenous, exogenous, exogenous_det (in specific order)
|
- 1st order and 2nd order derivatives with respect to endogenous, exogenous, exogenous_det (in specific order)
|
||||||
*/
|
*/
|
||||||
std::string setDynamicModel(void);
|
std::string setDynamicModel(void);
|
||||||
|
|
||||||
/*New*/
|
|
||||||
std::string setDynamicModel_New(Model_Block* ModelBlock, simple* Index_Var_IM);
|
|
||||||
/*EndNew*/
|
|
||||||
|
|
||||||
|
|
||||||
/*! Writes initialization of various Matlab variables */
|
/*! Writes initialization of various Matlab variables */
|
||||||
void ModelInitialization(void);
|
void ModelInitialization(void);
|
||||||
/*! Returns string output for main file */
|
/*! Returns string output for main file */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef VARIABLETABLE_H
|
#ifndef VARIABLETABLE_H
|
||||||
#define VARIABLETABLE_H
|
#define VARIABLETABLE_H
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** \file
|
/** \file
|
||||||
* \version 1.0
|
* \version 1.0
|
||||||
* \date 12/16/2003
|
* \date 12/16/2003
|
||||||
* \par This file defines the VariableTable class .
|
* \par This file defines the VariableTable class .
|
||||||
|
@ -11,11 +11,11 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include "SymbolTable.h"
|
#include "SymbolTable.h"
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/*!
|
/*!
|
||||||
\class Variable
|
\class Variable
|
||||||
\brief Variable struct
|
\brief Variable struct
|
||||||
*/
|
*/
|
||||||
struct Variable {
|
struct Variable {
|
||||||
/*! Variable type */
|
/*! Variable type */
|
||||||
|
@ -29,12 +29,12 @@ struct Variable {
|
||||||
typedef std::pair<std::string, int> varKey;
|
typedef std::pair<std::string, int> varKey;
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/*!
|
/*!
|
||||||
\class VariableTable
|
\class VariableTable
|
||||||
\brief This class is used to store variables as they appear
|
\brief This class is used to store variables as they appear
|
||||||
in the model (with their lead or lag)
|
in the model (with their lead or lag)
|
||||||
*/
|
*/
|
||||||
class VariableTable
|
class VariableTable
|
||||||
{
|
{
|
||||||
private :
|
private :
|
||||||
/*! Variable table data */
|
/*! Variable table data */
|
||||||
//static std::map<varKey,Variable> mVariableTable;
|
//static std::map<varKey,Variable> mVariableTable;
|
||||||
|
@ -44,19 +44,19 @@ class VariableTable
|
||||||
/*! Variable IDs of sorted variable table */
|
/*! Variable IDs of sorted variable table */
|
||||||
static std::vector<int> mSortedVariableID;
|
static std::vector<int> mSortedVariableID;
|
||||||
/*! Output index for variable table */
|
/*! Output index for variable table */
|
||||||
static std::vector<int> mPrintFormatIndex;
|
static std::vector<int> mPrintFormatIndex;
|
||||||
public :
|
public :
|
||||||
/*! */
|
/*! */
|
||||||
VariableTable();
|
VariableTable();
|
||||||
/*! */
|
/*! */
|
||||||
~VariableTable();
|
~VariableTable();
|
||||||
/*! Find type and ID in SymbolTable
|
/*! Find type and ID in SymbolTable
|
||||||
- Increment variable_id;
|
- Increment variable_id;
|
||||||
- Make variable
|
- Make variable
|
||||||
- Push variable on variabletable
|
- Push variable on variabletable
|
||||||
*/
|
*/
|
||||||
static int AddVariable(std::string iName, int iLag);
|
static int AddVariable(std::string iName, int iLag);
|
||||||
/*! Pointer to error function of parser class */
|
/*! Pointer to error function of parser class */
|
||||||
static void (* error) (const char* m);
|
static void (* error) (const char* m);
|
||||||
/*! Decremente a symbol id of a variable */
|
/*! Decremente a symbol id of a variable */
|
||||||
static void decSymbolID(std::string iName, int id, int iLag, Type iType);
|
static void decSymbolID(std::string iName, int id, int iLag, Type iType);
|
||||||
|
@ -76,12 +76,6 @@ class VariableTable
|
||||||
inline static int getPrintIndex(int iVarID);
|
inline static int getPrintIndex(int iVarID);
|
||||||
/*! Sorts variable table */
|
/*! Sorts variable table */
|
||||||
static void Sort(void);
|
static void Sort(void);
|
||||||
/*New*/
|
|
||||||
static int* GetVariableTable(int* Size);
|
|
||||||
static int GetVariableID(std::string name, int lead_lag);
|
|
||||||
static std::string GetVariableName(int id);
|
|
||||||
static int getIDS(int id, int lead_lag);
|
|
||||||
/*EndNew*/
|
|
||||||
};
|
};
|
||||||
inline int VariableTable::getSortID(int iVarID)
|
inline int VariableTable::getSortID(int iVarID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
// $Id: basic_buffer.hh,v 1.13 2004/03/09 02:38:01 cholm Exp $
|
// $Id: basic_buffer.hh,v 1.13 2004/03/09 02:38:01 cholm Exp $
|
||||||
//
|
//
|
||||||
// basic_buffer.hh
|
// basic_buffer.hh
|
||||||
// Copyright (C) 2002 Christian Holm Christensen <cholm@nbi.dk>
|
// Copyright (C) 2002 Christian Holm Christensen <cholm@nbi.dk>
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
// as published by the Free Software Foundation; either version 2.1
|
// as published by the Free Software Foundation; either version 2.1
|
||||||
// of the License, or (at your option) any later version.
|
// of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This library is distributed in the hope that it will be useful,
|
// This library is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// Lesser General Public License for more details.
|
// Lesser General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License along with this library; if not, write to the Free
|
// License along with this library; if not, write to the Free
|
||||||
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
// 02111-1307 USA
|
// 02111-1307 USA
|
||||||
//
|
//
|
||||||
#ifndef YLMM_basic_buffer
|
#ifndef YLMM_basic_buffer
|
||||||
#define YLMM_basic_buffer
|
#define YLMM_basic_buffer
|
||||||
|
@ -35,10 +35,10 @@
|
||||||
@date Mon Sep 30 00:08:22 2002
|
@date Mon Sep 30 00:08:22 2002
|
||||||
@brief Declaration of scanner ABC. */
|
@brief Declaration of scanner ABC. */
|
||||||
|
|
||||||
namespace ylmm
|
namespace ylmm
|
||||||
{
|
{
|
||||||
/** @class basic_buffer basic_buffer.hh <ylmm/basic_buffer.hh>
|
/** @class basic_buffer basic_buffer.hh <ylmm/basic_buffer.hh>
|
||||||
@brief ABC for scanner buffers.
|
@brief ABC for scanner buffers.
|
||||||
|
|
||||||
This class is used by the ylmm::basic_scanner class to read
|
This class is used by the ylmm::basic_scanner class to read
|
||||||
input. Internally it uses a std::istream to read from. User
|
input. Internally it uses a std::istream to read from. User
|
||||||
|
@ -48,12 +48,12 @@ namespace ylmm
|
||||||
or the standard input (for example via readline), then the
|
or the standard input (for example via readline), then the
|
||||||
client code is much better off making a customised
|
client code is much better off making a customised
|
||||||
std::streambuf layer - it really isn't as hard as the standard
|
std::streambuf layer - it really isn't as hard as the standard
|
||||||
leaves you thinking it may be, and it's really powerful.
|
leaves you thinking it may be, and it's really powerful.
|
||||||
@see @ref buffer_issues.
|
@see @ref buffer_issues.
|
||||||
|
|
||||||
To do a proper interface to @b Flex notion of buffers, there's
|
To do a proper interface to @b Flex notion of buffers, there's
|
||||||
an extra data member, and some extra member functions. These
|
an extra data member, and some extra member functions. These
|
||||||
are @e not used by other kinds implmentations of @b Lex.
|
are @e not used by other kinds implmentations of @b Lex.
|
||||||
@ingroup lex
|
@ingroup lex
|
||||||
*/
|
*/
|
||||||
class basic_buffer
|
class basic_buffer
|
||||||
|
@ -73,22 +73,22 @@ namespace ylmm
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// @name Automatic updates
|
/// @name Automatic updates
|
||||||
/** Do an automatic incrementation.
|
/** Do an automatic incrementation.
|
||||||
@param c the character read. */
|
@param c the character read. */
|
||||||
void increment_it(char c);
|
void increment_it(char c);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// @name Actual reading
|
/// @name Actual reading
|
||||||
/** Read at most @p max characters into buffer @p buf. See also
|
/** Read at most @p max characters into buffer @p buf. See also
|
||||||
the public input method.
|
the public input method.
|
||||||
@param buf The buffer to read into
|
@param buf The buffer to read into
|
||||||
@param max The maximum number of characters to read
|
@param max The maximum number of characters to read
|
||||||
@return The number of characters read */
|
@return The number of characters read */
|
||||||
virtual int read_buffered(char* buf, int max);
|
virtual int read_buffered(char* buf, int max);
|
||||||
/** Read at most @p max characters from input, or up to the first
|
/** Read at most @p max characters from input, or up to the first
|
||||||
occurence of delimiter. See also the public input method.
|
occurence of delimiter. See also the public input method.
|
||||||
@param buf The buffer to read into
|
@param buf The buffer to read into
|
||||||
@param max The maximum number of characters to read
|
@param max The maximum number of characters to read
|
||||||
@param delim the delimiter to read to
|
@param delim the delimiter to read to
|
||||||
@return The number of characters read */
|
@return The number of characters read */
|
||||||
|
@ -97,47 +97,47 @@ namespace ylmm
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// @name Extra functions to help with @b Flex
|
/// @name Extra functions to help with @b Flex
|
||||||
/** An extra action to take when creating a new buffer.
|
/** An extra action to take when creating a new buffer.
|
||||||
@param size is the size of the buffer */
|
@param size is the size of the buffer */
|
||||||
void new_extra(int size);
|
void new_extra(int size);
|
||||||
/** An extra action to take when deallocating the buffer.*/
|
/** An extra action to take when deallocating the buffer.*/
|
||||||
void delete_extra();
|
void delete_extra();
|
||||||
/** An extra action to take when flushing the buffer. */
|
/** An extra action to take when flushing the buffer. */
|
||||||
void flush_extra();
|
void flush_extra();
|
||||||
/** An extra action to take when making interactive or buffered.
|
/** An extra action to take when making interactive or buffered.
|
||||||
@param inter Whether it's interactive (ignored) */
|
@param inter Whether it's interactive (ignored) */
|
||||||
void interactive_extra(bool inter);
|
void interactive_extra(bool inter);
|
||||||
/** An extra action to take when setting begning-of-line flag
|
/** An extra action to take when setting begning-of-line flag
|
||||||
@param bol ignored */
|
@param bol ignored */
|
||||||
void at_bol_extra(bool bol);
|
void at_bol_extra(bool bol);
|
||||||
//@}
|
//@}
|
||||||
public:
|
public:
|
||||||
/** Make a new state.
|
/** Make a new state.
|
||||||
@param stream Stream to read from. This could be a
|
@param stream Stream to read from. This could be a
|
||||||
@c std::istream like @c std::cin, or a @c std::stringstream
|
@c std::istream like @c std::cin, or a @c std::stringstream
|
||||||
refering to an external string buffer. If argument is null (0)
|
refering to an external string buffer. If argument is null (0)
|
||||||
then the stream is set to @c std::cin and interactive reads
|
then the stream is set to @c std::cin and interactive reads
|
||||||
are enabled.
|
are enabled.
|
||||||
@param inter Is this stream interactive or not.
|
@param inter Is this stream interactive or not.
|
||||||
@param autoinc Should we do automatic location tracking? That
|
@param autoinc Should we do automatic location tracking? That
|
||||||
is should we set the _line and _column number automatically by
|
is should we set the _line and _column number automatically by
|
||||||
parsing the read stream, or should we let the client code do
|
parsing the read stream, or should we let the client code do
|
||||||
that job for us. */
|
that job for us. */
|
||||||
basic_buffer(std::istream& stream, bool inter=true, bool autoinc=false);
|
basic_buffer(std::istream& stream, bool inter=true, bool autoinc=false);
|
||||||
/** Make a new state.
|
/** Make a new state.
|
||||||
@param filename Name of a file to read from. If this is `-'
|
@param filename Name of a file to read from. If this is `-'
|
||||||
then std::cin is opened for input. If file can not be found,
|
then std::cin is opened for input. If file can not be found,
|
||||||
then this throws a std::runtime_error.
|
then this throws a std::runtime_error.
|
||||||
@param inter Is this stream interactive or not.
|
@param inter Is this stream interactive or not.
|
||||||
@param autoinc Should we do automatic location tracking? That
|
@param autoinc Should we do automatic location tracking? That
|
||||||
is should we set the _line and _column number automatically by
|
is should we set the _line and _column number automatically by
|
||||||
parsing the read stream, or should we let the client code do
|
parsing the read stream, or should we let the client code do
|
||||||
that job for us.
|
that job for us.
|
||||||
@exception std::runtime_error Thrown if named file cannot be
|
@exception std::runtime_error Thrown if named file cannot be
|
||||||
found. */
|
found. */
|
||||||
basic_buffer(const std::string& filename,
|
basic_buffer(const std::string& filename,
|
||||||
bool inter=false, bool autoinc=true);
|
bool inter=false, bool autoinc=true);
|
||||||
/** Free this buffer.
|
/** Free this buffer.
|
||||||
If this buffer is the @e owner of the used input stream, that
|
If this buffer is the @e owner of the used input stream, that
|
||||||
is, if this buffer opened it because it was constructed using
|
is, if this buffer opened it because it was constructed using
|
||||||
the string constructor, then the underlying stream is closed
|
the string constructor, then the underlying stream is closed
|
||||||
|
@ -147,24 +147,24 @@ namespace ylmm
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// @name Stream
|
/// @name Stream
|
||||||
/** Get the input stream
|
/** Get the input stream
|
||||||
@return the input stream */
|
@return the input stream */
|
||||||
std::istream* stream() { return _stream; }
|
std::istream* stream() { return _stream; }
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// @name position handling
|
/// @name position handling
|
||||||
/** Get the line number
|
/** Get the line number
|
||||||
@return the line number */
|
@return the line number */
|
||||||
int line() const { return _line; }
|
int line() const { return _line; }
|
||||||
/** Get the column number
|
/** Get the column number
|
||||||
@return the column number */
|
@return the column number */
|
||||||
int column() const { return _column; }
|
int column() const { return _column; }
|
||||||
/** Increment line and possibly column
|
/** Increment line and possibly column
|
||||||
@param l number to add to current line number
|
@param l number to add to current line number
|
||||||
@param c number to add to current column number */
|
@param c number to add to current column number */
|
||||||
virtual void increment_line(int l, int c=0);
|
virtual void increment_line(int l, int c=0);
|
||||||
/** Increment the column
|
/** Increment the column
|
||||||
@param c number to add to current column number */
|
@param c number to add to current column number */
|
||||||
virtual void increment_column(int c) { _column += c; }
|
virtual void increment_column(int c) { _column += c; }
|
||||||
//@}
|
//@}
|
||||||
|
@ -173,54 +173,54 @@ namespace ylmm
|
||||||
/// @name Read handling
|
/// @name Read handling
|
||||||
/** Flush the buffer */
|
/** Flush the buffer */
|
||||||
void flush() { flush_extra(); }
|
void flush() { flush_extra(); }
|
||||||
/** Read one character from input
|
/** Read one character from input
|
||||||
Note, when EOF is encountered, 0 (and not EOF) is returned.
|
Note, when EOF is encountered, 0 (and not EOF) is returned.
|
||||||
@return the character read */
|
@return the character read */
|
||||||
virtual int read();
|
virtual int read();
|
||||||
/** Read at most @p max characters into buffer @p buf.
|
/** Read at most @p max characters into buffer @p buf.
|
||||||
@param buf Buffer of at least size @p max to read into.
|
@param buf Buffer of at least size @p max to read into.
|
||||||
@param max Maximum number of characters to read from input.
|
@param max Maximum number of characters to read from input.
|
||||||
@return The number of characters read. Returns -1 in case of
|
@return The number of characters read. Returns -1 in case of
|
||||||
errors. */
|
errors. */
|
||||||
virtual int read(char* buf, int max);
|
virtual int read(char* buf, int max);
|
||||||
/** Put one character back into the stream.
|
/** Put one character back into the stream.
|
||||||
@param c character to put back. */
|
@param c character to put back. */
|
||||||
virtual void putback(int c);
|
virtual void putback(int c);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// @name Miscellanious
|
/// @name Miscellanious
|
||||||
/** Are we doing automatic increments?
|
/** Are we doing automatic increments?
|
||||||
@return true if auto incrementing */
|
@return true if auto incrementing */
|
||||||
bool auto_increment() const { return _auto_increment; }
|
bool auto_increment() const { return _auto_increment; }
|
||||||
/** Set wether we should do automatic increments.
|
/** Set wether we should do automatic increments.
|
||||||
@param ai If true, auto increment, otherwise don't
|
@param ai If true, auto increment, otherwise don't
|
||||||
@return true if auto incrementing */
|
@return true if auto incrementing */
|
||||||
bool auto_increment(bool ai) { return _auto_increment = ai; }
|
bool auto_increment(bool ai) { return _auto_increment = ai; }
|
||||||
/** Test if we're at the start of a line
|
/** Test if we're at the start of a line
|
||||||
@return true if last read characer was a newline */
|
@return true if last read characer was a newline */
|
||||||
bool at_bol() const { return _last_read == '\n'; }
|
bool at_bol() const { return _last_read == '\n'; }
|
||||||
/** Set wether we're at the start of a line
|
/** Set wether we're at the start of a line
|
||||||
@param bol set the last read character to be a newline
|
@param bol set the last read character to be a newline
|
||||||
@return true if last read characer was a newline */
|
@return true if last read characer was a newline */
|
||||||
bool at_bol(bool bol);
|
bool at_bol(bool bol);
|
||||||
/** Check if buffer is interactive
|
/** Check if buffer is interactive
|
||||||
@return true if we're reading interactively */
|
@return true if we're reading interactively */
|
||||||
bool interactive() const { return _interactive; }
|
bool interactive() const { return _interactive; }
|
||||||
/** Set whether buffer is interactive
|
/** Set whether buffer is interactive
|
||||||
@param inter if true, read inteactively
|
@param inter if true, read inteactively
|
||||||
@return true if we're reading interactively */
|
@return true if we're reading interactively */
|
||||||
bool interactive(bool inter);
|
bool interactive(bool inter);
|
||||||
/** Called when this buffer is restored as current buffer.
|
/** Called when this buffer is restored as current buffer.
|
||||||
@return true if this is the current buffer after activation */
|
@return true if this is the current buffer after activation */
|
||||||
bool activate();
|
bool activate();
|
||||||
//@}
|
//@}
|
||||||
};
|
};
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline
|
inline
|
||||||
basic_buffer::basic_buffer(std::istream& stream, bool inter,
|
basic_buffer::basic_buffer(std::istream& stream, bool inter,
|
||||||
bool autoinc)
|
bool autoinc)
|
||||||
{
|
{
|
||||||
_interactive = inter;
|
_interactive = inter;
|
||||||
_stream = (!stream ? &std::cin : &stream);
|
_stream = (!stream ? &std::cin : &stream);
|
||||||
|
@ -233,9 +233,9 @@ namespace ylmm
|
||||||
new_extra(0);
|
new_extra(0);
|
||||||
}
|
}
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline
|
inline
|
||||||
basic_buffer::basic_buffer(const std::string& filename, bool inter,
|
basic_buffer::basic_buffer(const std::string& filename, bool inter,
|
||||||
bool autoinc)
|
bool autoinc)
|
||||||
{
|
{
|
||||||
_interactive = inter;
|
_interactive = inter;
|
||||||
if (filename.empty()) throw std::runtime_error("no filename given");
|
if (filename.empty()) throw std::runtime_error("no filename given");
|
||||||
|
@ -245,7 +245,7 @@ namespace ylmm
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_stream = new std::ifstream(filename.data());
|
_stream = new std::ifstream(filename.data());
|
||||||
if (!_stream || _stream->bad())
|
if (!_stream || _stream->bad())
|
||||||
throw std::runtime_error("failed to open file");
|
throw std::runtime_error("failed to open file");
|
||||||
_is_owner = true;
|
_is_owner = true;
|
||||||
}
|
}
|
||||||
|
@ -258,17 +258,17 @@ namespace ylmm
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline
|
inline
|
||||||
basic_buffer::~basic_buffer()
|
basic_buffer::~basic_buffer()
|
||||||
{
|
{
|
||||||
delete_extra();
|
delete_extra();
|
||||||
if (_is_owner && _stream) {
|
if (_is_owner && _stream) {
|
||||||
std::ifstream* is;
|
std::ifstream* is;
|
||||||
if ((is = dynamic_cast<std::ifstream*>(_stream))) is->close();
|
if ((is = dynamic_cast<std::ifstream*>(_stream))) is->close();
|
||||||
delete _stream;
|
delete _stream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline void basic_buffer::increment_it(char c)
|
inline void basic_buffer::increment_it(char c)
|
||||||
{
|
{
|
||||||
|
@ -279,20 +279,20 @@ namespace ylmm
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline int basic_buffer::read_buffered(char* buf, int max)
|
inline int basic_buffer::read_buffered(char* buf, int max)
|
||||||
{
|
{
|
||||||
if (!_stream || _stream->eof()) return 0;
|
if (!_stream || _stream->eof()) return 0;
|
||||||
_stream->read(buf, max);
|
_stream->read(buf, max);
|
||||||
if (_stream->bad()) return -1;
|
if (_stream->bad()) return -1;
|
||||||
int c = _stream->gcount();
|
int c = _stream->gcount();
|
||||||
_last_read = buf[c-1];
|
_last_read = buf[c-1];
|
||||||
if (_auto_increment) {
|
if (_auto_increment) {
|
||||||
for (int i = 0; i < c; i++) increment_it(buf[i]); }
|
for (int i = 0; i < c; i++) increment_it(buf[i]); }
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline int basic_buffer::read_interactive(char* buf, int max, char delim)
|
inline int basic_buffer::read_interactive(char* buf, int max, char delim)
|
||||||
{
|
{
|
||||||
if (max <= 0 || !_stream || _stream->eof()) return 0;
|
if (max <= 0 || !_stream || _stream->eof()) return 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -306,30 +306,30 @@ namespace ylmm
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline void basic_buffer::increment_line(int l, int c)
|
inline void basic_buffer::increment_line(int l, int c)
|
||||||
{
|
{
|
||||||
if (_auto_increment) return;
|
if (_auto_increment) return;
|
||||||
_line = l;
|
_line = l;
|
||||||
_column = c;
|
_column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline bool basic_buffer::at_bol(bool bol)
|
inline bool basic_buffer::at_bol(bool bol)
|
||||||
{
|
{
|
||||||
at_bol_extra(bol);
|
at_bol_extra(bol);
|
||||||
_last_read = bol ? '\n' : '\0'; return bol;
|
_last_read = bol ? '\n' : '\0'; return bol;
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline bool basic_buffer::interactive(bool inter)
|
inline bool basic_buffer::interactive(bool inter)
|
||||||
{
|
{
|
||||||
interactive_extra(inter);
|
interactive_extra(inter);
|
||||||
return _interactive = inter;
|
return _interactive = inter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline int basic_buffer::read()
|
inline int basic_buffer::read()
|
||||||
{
|
{
|
||||||
_last_read = _stream->get();
|
_last_read = _stream->get();
|
||||||
if (_stream->eof()) return 0;
|
if (_stream->eof()) return 0;
|
||||||
if (_stream->bad()) return -1;
|
if (_stream->bad()) return -1;
|
||||||
|
@ -338,17 +338,17 @@ namespace ylmm
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline int basic_buffer::read(char* buf, int max)
|
inline int basic_buffer::read(char* buf, int max)
|
||||||
{
|
{
|
||||||
if (_interactive) return read_interactive(buf, max, '\n');
|
if (_interactive) return read_interactive(buf, max, '\n');
|
||||||
else return read_buffered(buf, max);
|
else return read_buffered(buf, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline void basic_buffer::putback(int c)
|
inline void basic_buffer::putback(int c)
|
||||||
{
|
{
|
||||||
_stream->putback(char(c));
|
_stream->putback(char(c));
|
||||||
if (!_stream->bad() && _auto_increment) _column--;
|
if (!_stream->bad() && _auto_increment) _column--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,8 +357,8 @@ namespace ylmm
|
||||||
@param o output stream to write to
|
@param o output stream to write to
|
||||||
@param b the ylmm::basic_buffer to write out
|
@param b the ylmm::basic_buffer to write out
|
||||||
@return @a o */
|
@return @a o */
|
||||||
inline std::ostream&
|
inline std::ostream&
|
||||||
operator<<(std::ostream& o, const ylmm::basic_buffer& b)
|
operator<<(std::ostream& o, const ylmm::basic_buffer& b)
|
||||||
{
|
{
|
||||||
return o << b.line() << "," << b.column();
|
return o << b.line() << "," << b.column();
|
||||||
}
|
}
|
||||||
|
@ -367,69 +367,69 @@ operator<<(std::ostream& o, const ylmm::basic_buffer& b)
|
||||||
#define YLMM_flex_buffer_impl
|
#define YLMM_flex_buffer_impl
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
/** Create a new Flex buffer.
|
/** Create a new Flex buffer.
|
||||||
@param file The file to associate with the buffer. Can be NULL.
|
@param file The file to associate with the buffer. Can be NULL.
|
||||||
@param size The size of the buffer
|
@param size The size of the buffer
|
||||||
@return A newly allocated buffer. */
|
@return A newly allocated buffer. */
|
||||||
extern YY_BUFFER_STATE yy_create_buffer(FILE *file, int size);
|
extern YY_BUFFER_STATE yy_create_buffer(FILE *file, int size);
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ylmm::basic_buffer::new_extra(int size)
|
ylmm::basic_buffer::new_extra(int size)
|
||||||
{
|
{
|
||||||
// If size is not given (0 or less), then use the default.
|
// If size is not given (0 or less), then use the default.
|
||||||
if (size < 0) { _extra = 0; return; }
|
if (size < 0) { _extra = 0; return; }
|
||||||
if (size == 0) size = YY_BUF_SIZE;
|
if (size == 0) size = YY_BUF_SIZE;
|
||||||
_extra = static_cast<YY_BUFFER_STATE>(yy_create_buffer(0, size));
|
_extra = static_cast<YY_BUFFER_STATE>(yy_create_buffer(0, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
/** De-allocate a Flex buffer.
|
/** De-allocate a Flex buffer.
|
||||||
@param b The buffer to de-allocate. */
|
@param b The buffer to de-allocate. */
|
||||||
extern void yy_delete_buffer(YY_BUFFER_STATE b);
|
extern void yy_delete_buffer(YY_BUFFER_STATE b);
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ylmm::basic_buffer::delete_extra()
|
ylmm::basic_buffer::delete_extra()
|
||||||
{
|
{
|
||||||
yy_delete_buffer(static_cast<YY_BUFFER_STATE>(_extra));
|
yy_delete_buffer(static_cast<YY_BUFFER_STATE>(_extra));
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
/** Switch to another Flex buffer
|
/** Switch to another Flex buffer
|
||||||
@param b The buffer to switch to. */
|
@param b The buffer to switch to. */
|
||||||
extern void yy_switch_to_buffer(YY_BUFFER_STATE b);
|
extern void yy_switch_to_buffer(YY_BUFFER_STATE b);
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ylmm::basic_buffer::activate()
|
ylmm::basic_buffer::activate()
|
||||||
{
|
{
|
||||||
yy_switch_to_buffer(static_cast<YY_BUFFER_STATE>(_extra));
|
yy_switch_to_buffer(static_cast<YY_BUFFER_STATE>(_extra));
|
||||||
return static_cast<YY_BUFFER_STATE>(_extra) == YY_CURRENT_BUFFER;
|
return static_cast<YY_BUFFER_STATE>(_extra) == YY_CURRENT_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline void
|
inline void
|
||||||
ylmm::basic_buffer::interactive_extra(bool inter)
|
ylmm::basic_buffer::interactive_extra(bool inter)
|
||||||
{
|
{
|
||||||
(static_cast<YY_BUFFER_STATE>(_extra))->yy_is_interactive = inter ? 1 : 0;
|
(static_cast<YY_BUFFER_STATE>(_extra))->yy_is_interactive = inter ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline void
|
inline void
|
||||||
ylmm::basic_buffer::at_bol_extra(bool inter)
|
ylmm::basic_buffer::at_bol_extra(bool inter)
|
||||||
{
|
{
|
||||||
(static_cast<YY_BUFFER_STATE>(_extra))->yy_at_bol = inter ? 1 : 0;
|
(static_cast<YY_BUFFER_STATE>(_extra))->yy_at_bol = inter ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
/** Flush a buffer.
|
/** Flush a buffer.
|
||||||
@param b The buffer to flush. */
|
@param b The buffer to flush. */
|
||||||
extern void yy_flush_buffer(YY_BUFFER_STATE b);
|
extern void yy_flush_buffer(YY_BUFFER_STATE b);
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ylmm::basic_buffer::flush_extra()
|
ylmm::basic_buffer::flush_extra()
|
||||||
{
|
{
|
||||||
yy_flush_buffer(static_cast<YY_BUFFER_STATE>(_extra));
|
yy_flush_buffer(static_cast<YY_BUFFER_STATE>(_extra));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
//__________________________________________________________________
|
//__________________________________________________________________
|
||||||
inline void ylmm::basic_buffer::new_extra(int size) {}
|
inline void ylmm::basic_buffer::new_extra(int size) {}
|
||||||
|
@ -443,5 +443,5 @@ inline bool ylmm::basic_buffer::activate() { return true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue