v4 parser.src: undoing rev. 944

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@945 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2006-10-04 18:32:33 +00:00
parent c04c947d4c
commit 68b552aef2
10 changed files with 3025 additions and 3923 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
#define YY_BUF_SIZE 1000000
#include <unistd.h>
#include <string.h>
#include "DynareScanner.h"
#include "DynareScanner.h"
#ifdef HAVE_CONFIG_H
# include "config.hh"
#endif
@ -11,13 +11,13 @@
#define FINISH 0
#define YY_READ_BUF_SIZE 1000000
#include "ylmm/lexmm.hh"
int lineno = 1;
int lineno = 1;
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
*/
int sigma_e = 0;
%}
%}
%option stack
@ -34,11 +34,11 @@ int sigma_e = 0;
/* 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>"/*" {comment_caller = YYSTATE; BEGIN COMMENT;}
<COMMENT>[^*\n]*
<COMMENT>"*"+[^*/\n]*
<COMMENT>[^*\n]*
<COMMENT>"*"+[^*/\n]*
<COMMENT>"*"+"/" {BEGIN comment_caller;}
/* Begin of a Dynare statement */
@ -86,24 +86,24 @@ int sigma_e = 0;
<INITIAL>optim_weights {BEGIN DYNARE_BLOCK;return OPTIM_WEIGHTS;}
/* 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 */
<DYNARE_STATEMENT>datafile {return DATAFILE;}
<DYNARE_STATEMENT>nobs {return NOBS;}
<DYNARE_STATEMENT>first_obs {return FIRST_OBS;}
<DYNARE_STATEMENT>prefilter {return PREFILTER;}
<DYNARE_STATEMENT>presample {return PRESAMPLE;}
<DYNARE_STATEMENT>lik_algo {return LIK_ALGO;}
<DYNARE_STATEMENT>lik_init {return LIK_INIT;}
<DYNARE_STATEMENT>graph {return GRAPH;}
<DYNARE_STATEMENT>nograph {return NOGRAPH;}
<DYNARE_STATEMENT>print {return PRINT;}
<DYNARE_STATEMENT>noprint {return NOPRINT;}
<DYNARE_STATEMENT>conf_sig {return CONF_SIG;}
<DYNARE_STATEMENT>mh_replic {return MH_REPLIC;}
<DYNARE_STATEMENT>mh_drop {return MH_DROP;}
<DYNARE_STATEMENT>mh_jscale {return MH_JSCALE;}
<DYNARE_STATEMENT>prefilter {return PREFILTER;}
<DYNARE_STATEMENT>presample {return PRESAMPLE;}
<DYNARE_STATEMENT>lik_algo {return LIK_ALGO;}
<DYNARE_STATEMENT>lik_init {return LIK_INIT;}
<DYNARE_STATEMENT>graph {return GRAPH;}
<DYNARE_STATEMENT>nograph {return NOGRAPH;}
<DYNARE_STATEMENT>print {return PRINT;}
<DYNARE_STATEMENT>noprint {return NOPRINT;}
<DYNARE_STATEMENT>conf_sig {return CONF_SIG;}
<DYNARE_STATEMENT>mh_replic {return MH_REPLIC;}
<DYNARE_STATEMENT>mh_drop {return MH_DROP;}
<DYNARE_STATEMENT>mh_jscale {return MH_JSCALE;}
<DYNARE_STATEMENT>mh_init_scale {return MH_INIT_SCALE;}
<DYNARE_STATEMENT>mode_file {return MODE_FILE;}
<DYNARE_STATEMENT>mode_compute {return MODE_COMPUTE;}
@ -139,7 +139,7 @@ int sigma_e = 0;
<DYNARE_STATEMENT>[\$][^$]*[\$] {
strtok(yytext+1,"$");
_scanner->do_name(yytext+1);
_scanner->do_name(yytext+1);
return TEX_NAME;}
/* Inside a Dynare block */
@ -177,20 +177,15 @@ int sigma_e = 0;
<DYNARE_STATEMENT>simul {return SIMUL;}
<DYNARE_STATEMENT>autocorr {return AUTOCORR;}
<DYNARE_STATEMENT>olr_beta {return OLR_BETA;}
<DYNARE_STATEMENT>xtick {return XTICK;}
<DYNARE_STATEMENT>xticklabel {return XTICKLABEL;}
<DYNARE_STATEMENT>xtick {return XTICK;}
<DYNARE_STATEMENT>xticklabel {return XTICKLABEL;}
<DYNARE_STATEMENT>xls_sheet {return XLS_SHEET;}
<DYNARE_STATEMENT>xls_range {return XLS_RANGE;}
<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>[,] {_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>[\]] {if (sigma_e) sigma_e=0; return yytext[0];}
<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>[A-Za-z_][A-Za-z0-9_]* {
_scanner->do_name(yytext);
_scanner->do_name(yytext);
return NAME;}
<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]+ {
_scanner->do_num_constant(yytext);
return INT_NUMBER;}
/* an instruction starting with a recognized symbol is passed as NAME,
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)
{
BEGIN DYNARE_STATEMENT;

View File

@ -1,4 +1,4 @@
/*! \file
/*! \file
\version 1.0
\date 04/09/2004
\par This file implements the parser class methodes.
@ -15,10 +15,6 @@
#include "ComputingTasks.h"
#include "TmpSymbolTable.h"
#include "DynareParser.h"
/*New*/
#include "BlockTriangular.h"
/*EndNew*/
string dynare::parser::file_name = "";
void dynare::parser::set_file_name(string fname)
@ -26,9 +22,9 @@ void dynare::parser::set_file_name(string fname)
file_name = fname;
}
void dynare::parser::setoutput(ostringstream* ostr)
void dynare::parser::setoutput(ostringstream* ostr)
{
output = ostr;
output = ostr;
numerical_initialization.setOutput(ostr);
shocks.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)
{
//cout << "add_endogenous \n";
obj->ID = (NodeID) symbol_table.AddSymbolDeclar(obj->symbol,eEndogenous, tex_name->symbol);
obj->type = eEndogenous;
return (obj);
@ -49,7 +45,7 @@ dynare::Objects* dynare::parser::add_exogenous(Objects* obj, Objects* tex_name)
obj->type = eExogenous;
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->type = eExogenousDet;
@ -84,31 +80,25 @@ dynare::Objects* dynare::parser::add_variable(Objects* var)
{
//cout << "add_variable1 : " << var->symbol << endl;
var = get_symbol(var);
if((var->type == eEndogenous)
if((var->type == eEndogenous)
|| (var->type == eExogenous)
|| (var->type == eExogenousDet))
variable_table.AddVariable(var->symbol,0);
//cout << "add_model_token : " << var->ID << endl;
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);
}
dynare::Objects* dynare::parser::add_variable(Objects* var,Objects* olag)
{
//cout << "add_variable2\n";
var = get_symbol(var);
int lag = atoi((olag->symbol).c_str());
//cout << "symbol = " << olag->symbol << endl;
//cout << "lag = " << lag << endl;
if ((var->type == eExogenous) && lag != 0)
{
std::cout << "Warning: exogenous variable "
std::cout << "Warning: exogenous variable "
<< var->symbol
<< " has lag " << lag << "\n";
}
@ -116,14 +106,6 @@ dynare::Objects* dynare::parser::add_variable(Objects* var,Objects* olag)
variable_table.AddVariable(var->symbol,lag);
//cout << "add_model_token : " << var->ID << endl;
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);
}
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";
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)
{
@ -230,7 +212,7 @@ void dynare::parser::init_param(Objects* lhs, Objects* rhs)
void dynare::parser::init_param(Objects* lhs)
{
//cout << "Befor set\n";
expression.set();
expression.set();
numerical_initialization.SetConstant(lhs->symbol, expression.get());
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)
{
int lag = atoi((slag->symbol).c_str());
expression.set();
expression.set();
numerical_initialization.SetHist(lhs->symbol, lag, expression.get());
expression.clear();
}
void dynare::parser::initialize_model(void)
{
/*New*/
block_triangular.init_incidence_matrix();
/*EndNew*/
}
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;
}
/*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)
{
/*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();
}
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)
{
model_tree.computeJacobianExo = true;
@ -314,28 +272,22 @@ void dynare::parser::finish(void)
{
model_tree.derive(1);
}
cout << "Processing outputs ...\n";
model_tree.setStaticModel();
/*New*/
if (model_tree.offset == 2)
model_tree.setDynamicModel_New(block_triangular.ModelBlock,block_triangular.Index_Var_IM);
else
model_tree.setDynamicModel();
if (model_tree.offset != 1)
/*EndNew*/
model_tree.setDynamicModel();
if (model_tree.offset == 0)
{
model_tree.OpenCFiles(model_file_name+"_static", model_file_name+"_dynamic");
/*New*/
model_tree.SaveCFiles(block_triangular.ModelBlock);
/*EndNew*/
model_tree.SaveCFiles();
}
else
{
model_tree.OpenMFiles(model_file_name+"_static", model_file_name+"_dynamic");
model_tree.SaveMFiles();
}
*output << "save('" << model_file_name << "_results', 'oo_');\n";
*output << "diary off\n";
@ -389,7 +341,7 @@ void dynare::parser::add_det_shock(Objects* var)
case eExogenousDet:
shocks.AddDetShockExoDet(id);
return;
default:
default:
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++;
return new Objects("", id, eTempResult);
}
dynare::Objects* dynare::parser::init_local_parameter(Objects* arg1, Objects* arg2)
{
NodeID id = model_tree.AddAssign(arg1->ID, arg2->ID);
return new Objects("", id, eTempResult);
}
dynare::Objects* dynare::parser::add_plus(Objects* arg1, Objects* arg2)
{
NodeID id = model_tree.AddPlus(arg1->ID, arg2->ID);

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/*! \file
/*! \file
\version 1.0
\date 04/09/2004
\par This file implements the VariableTable class methodes.
@ -12,13 +12,13 @@ using namespace std;
#include "VariableTable.h"
//------------------------------------------------------------------------------
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::mPrintFormatIndex = *(new vector<int>);
void (* VariableTable::error) (const char* ) = NULL;
//------------------------------------------------------------------------------
VariableTable::VariableTable()
{
{
// Empty
}
//------------------------------------------------------------------------------
@ -29,10 +29,10 @@ VariableTable::~VariableTable()
//------------------------------------------------------------------------------
int VariableTable::AddVariable(string iName, int iLag)
{
int lVariableID;
int lVariableID;
//Variable lVariable;
varKey key;
// Testing if symbol exists
// Testing if symbol exists
if (!SymbolTable::Exist(iName))
{
string msg = "unknown symbol: " + iName;
@ -51,7 +51,7 @@ int VariableTable::AddVariable(string iName, int iLag)
//lVariable.symbol_id = SymbolTable::getID(iName);
//lVariable.variable_id = lVariableID;
key = make_pair(iName,iLag);
// Pushing variable on VariableTable
// Pushing variable on VariableTable
//mVariableTable[key] = lVariable;
mVariableTable[key] = lVariableID;
mVariableIndex.push_back(key);
@ -114,7 +114,7 @@ int VariableTable::AddVariable(string iName, int iLag)
}
break;
default:
;
;
}
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)
{
int lVariableID;
int lVariableID;
Variable lVariable;
varKey key;
@ -150,7 +150,7 @@ void VariableTable::Sort(void)
vector<int> IDs;
vector<int> Lags;
vector<Type> Types;
if (mVariableIndex.size() == 1)
{
mSortedVariableID.push_back(0);
@ -172,20 +172,20 @@ void VariableTable::Sort(void)
unsigned long long int type = Types[id];
type = type << 8*sizeof(int);
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
/*
cout << "Before sorting\n";
cout << "S T L ID pound \n";
for (int id=0; id < VarToSort.size(); id++)
{
{
Type type = Types[VarToSort[id].second];
int lag = Lags[VarToSort[id].second];
int ID = IDs[VarToSort[id].second];
cout << SymbolTable::getNameByID(type, ID) << " "
<< type << " "
<< lag << " "
cout << SymbolTable::getNameByID(type, ID) << " "
<< type << " "
<< lag << " "
<< ID << " "
<< VarToSort[id].first << "\n";
}
@ -198,7 +198,7 @@ void VariableTable::Sort(void)
Type type = Types[VarToSort[0].second];
int index = 0;
for (unsigned int id = 0; id < VarToSort.size(); id++)
{
{
int id2 = VarToSort[id].second;
mSortedVariableID[id2] = id;
if (type == Types[id2])
@ -207,7 +207,7 @@ void VariableTable::Sort(void)
index++;
}
else
{
{
mPrintFormatIndex[id2] = 0;
type = Types[id2];
index = 1;
@ -218,13 +218,13 @@ void VariableTable::Sort(void)
cout << "After sorting\n";
cout << "S T L ID SVID PIDX\n";
for (int id=0; id < VarToSort.size(); id++)
{
{
Type type = Types[VarToSort[id].second];
int lag = Lags[VarToSort[id].second];
int ID = IDs[VarToSort[id].second];
cout << SymbolTable::getNameByID(Types[id], IDs[id]) << " "
<< Types[id] << " "
<< Lags[id] << " "
cout << SymbolTable::getNameByID(Types[id], IDs[id]) << " "
<< Types[id] << " "
<< Lags[id] << " "
<< IDs[id] << " "
<< mSortedVariableID[id] << " "
<< 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*/
//------------------------------------------------------------------------------

View File

@ -1,351 +1,349 @@
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
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
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
AR = 258,
AUTOCORR = 259,
BAYESIAN_IRF = 260,
BETA_PDF = 261,
CALIB = 262,
CALIB_VAR = 263,
CHECK = 264,
CONF_SIG = 265,
CORR = 266,
COVAR = 267,
DATAFILE = 268,
DIAGNOSTIC = 269,
DIFFUSE_D = 270,
DLL = 271,
DOLLAR = 272,
DR_ALGO = 273,
DROP = 274,
DSAMPLE = 275,
DYN2VEC = 276,
DYNASAVE = 277,
DYNATYPE = 278,
END = 279,
ENDVAL = 280,
EQUAL = 281,
ESTIMATION = 282,
ESTIMATED_PARAMS = 283,
ESTIMATED_PARAMS_BOUNDS = 284,
ESTIMATED_PARAMS_INIT = 285,
FILTERED_VARS = 286,
FIRST_OBS = 287,
FLOAT_NUMBER = 288,
FORECAST = 289,
FUNCTIONS = 290,
GAMMA_PDF = 291,
GRAPH = 292,
HISTVAL = 293,
HP_FILTER = 294,
HP_NGRID = 295,
INITVAL = 296,
INITVALF = 297,
INT_NUMBER = 298,
INV_GAMMA_PDF = 299,
INV_GAMMA1_PDF = 300,
INV_GAMMA2_PDF = 301,
IRF = 302,
KALMAN_ALGO = 303,
KALMAN_TOL = 304,
CONSTANT = 305,
NOCONSTANT = 306,
LAPLACE = 307,
LIK_ALGO = 308,
LIK_INIT = 309,
LINEAR = 310,
LOAD_MH_FILE = 311,
LOGLINEAR = 312,
MH_DROP = 313,
MH_INIT_SCALE = 314,
MH_JSCALE = 315,
MH_MODE = 316,
MH_NBLOCKS = 317,
MH_REPLIC = 318,
MODE_CHECK = 319,
MODE_COMPUTE = 320,
MODE_FILE = 321,
MODEL = 322,
MODEL_COMPARISON = 323,
MODEL_COMPARISON_APPROXIMATION = 324,
MODIFIEDHARMONICMEAN = 325,
MOMENTS = 326,
MOMENTS_VARENDO = 327,
MSHOCKS = 328,
NAME = 329,
NOBS = 330,
NOCORR = 331,
NODIAGNOSTIC = 332,
NOFUNCTIONS = 333,
NOGRAPH = 334,
XLS_SHEET = 335,
XLS_RANGE = 336,
NOMOMENTS = 337,
NOPRINT = 338,
NORMAL_PDF = 339,
OBSERVATION_TRENDS = 340,
OLR = 341,
OLR_INST = 342,
OLR_BETA = 343,
OPTIM = 344,
OPTIM_WEIGHTS = 345,
ORDER = 346,
OSR = 347,
OSR_PARAMS = 348,
PARAMETERS = 349,
PERIODS = 350,
PREFILTER = 351,
PRESAMPLE = 352,
PRINT = 353,
PRIOR_TRUNC = 354,
FILTER_STEP_AHEAD = 355,
QZ_CRITERIUM = 356,
RELATIVE_IRF = 357,
REPLIC = 358,
RESOL = 359,
RPLOT = 360,
SHOCKS = 361,
SIGMA_E = 362,
SIMUL = 363,
SIMUL_ALGO = 364,
SIMUL_SEED = 365,
SMOOTHER = 366,
SOLVE_ALGO = 367,
STDERR = 368,
STEADY = 369,
STOCH_SIMUL = 370,
TEX = 371,
TEX_NAME = 372,
UNIFORM_PDF = 373,
UNIT_ROOT_VARS = 374,
USE_DLL = 375,
VALUES = 376,
VAR = 377,
VAREXO = 378,
VAREXO_DET = 379,
VAROBS = 380,
XTICK = 381,
XTICKLABEL = 382,
COMMA = 383,
MINUS = 384,
PLUS = 385,
DIVIDE = 386,
TIMES = 387,
UMINUS = 388,
POWER = 389,
FACTORIAL = 390,
EXP = 391,
LOG = 392,
LOG10 = 393,
LN = 394,
SIN = 395,
COS = 396,
TAN = 397,
ASIN = 398,
ACOS = 399,
ATAN = 400,
SINH = 401,
COSH = 402,
TANH = 403,
ASINH = 404,
ACOSH = 405,
ATANH = 406,
SQRT = 407,
ASSIGN = 408
};
#endif
/* Tokens. */
#define AR 258
#define AUTOCORR 259
#define BAYESIAN_IRF 260
#define BETA_PDF 261
#define CALIB 262
#define CALIB_VAR 263
#define CHECK 264
#define CONF_SIG 265
#define CORR 266
#define COVAR 267
#define DATAFILE 268
#define DIAGNOSTIC 269
#define DIFFUSE_D 270
#define DLL 271
#define DOLLAR 272
#define DR_ALGO 273
#define DROP 274
#define DSAMPLE 275
#define DYN2VEC 276
#define DYNASAVE 277
#define DYNATYPE 278
#define END 279
#define ENDVAL 280
#define EQUAL 281
#define ESTIMATION 282
#define ESTIMATED_PARAMS 283
#define ESTIMATED_PARAMS_BOUNDS 284
#define ESTIMATED_PARAMS_INIT 285
#define FILTERED_VARS 286
#define FIRST_OBS 287
#define FLOAT_NUMBER 288
#define FORECAST 289
#define FUNCTIONS 290
#define GAMMA_PDF 291
#define GRAPH 292
#define HISTVAL 293
#define HP_FILTER 294
#define HP_NGRID 295
#define INITVAL 296
#define INITVALF 297
#define INT_NUMBER 298
#define INV_GAMMA_PDF 299
#define INV_GAMMA1_PDF 300
#define INV_GAMMA2_PDF 301
#define IRF 302
#define KALMAN_ALGO 303
#define KALMAN_TOL 304
#define CONSTANT 305
#define NOCONSTANT 306
#define LAPLACE 307
#define LIK_ALGO 308
#define LIK_INIT 309
#define LINEAR 310
#define LOAD_MH_FILE 311
#define LOGLINEAR 312
#define MH_DROP 313
#define MH_INIT_SCALE 314
#define MH_JSCALE 315
#define MH_MODE 316
#define MH_NBLOCKS 317
#define MH_REPLIC 318
#define MODE_CHECK 319
#define MODE_COMPUTE 320
#define MODE_FILE 321
#define MODEL 322
#define MODEL_COMPARISON 323
#define MODEL_COMPARISON_APPROXIMATION 324
#define MODIFIEDHARMONICMEAN 325
#define MOMENTS 326
#define MOMENTS_VARENDO 327
#define MSHOCKS 328
#define NAME 329
#define NOBS 330
#define NOCORR 331
#define NODIAGNOSTIC 332
#define NOFUNCTIONS 333
#define NOGRAPH 334
#define XLS_SHEET 335
#define XLS_RANGE 336
#define NOMOMENTS 337
#define NOPRINT 338
#define NORMAL_PDF 339
#define OBSERVATION_TRENDS 340
#define OLR 341
#define OLR_INST 342
#define OLR_BETA 343
#define OPTIM 344
#define OPTIM_WEIGHTS 345
#define ORDER 346
#define OSR 347
#define OSR_PARAMS 348
#define PARAMETERS 349
#define PERIODS 350
#define PREFILTER 351
#define PRESAMPLE 352
#define PRINT 353
#define PRIOR_TRUNC 354
#define FILTER_STEP_AHEAD 355
#define QZ_CRITERIUM 356
#define RELATIVE_IRF 357
#define REPLIC 358
#define RESOL 359
#define RPLOT 360
#define SHOCKS 361
#define SIGMA_E 362
#define SIMUL 363
#define SIMUL_ALGO 364
#define SIMUL_SEED 365
#define SMOOTHER 366
#define SOLVE_ALGO 367
#define STDERR 368
#define STEADY 369
#define STOCH_SIMUL 370
#define TEX 371
#define TEX_NAME 372
#define UNIFORM_PDF 373
#define UNIT_ROOT_VARS 374
#define USE_DLL 375
#define VALUES 376
#define VAR 377
#define VAREXO 378
#define VAREXO_DET 379
#define VAROBS 380
#define XTICK 381
#define XTICKLABEL 382
#define COMMA 383
#define MINUS 384
#define PLUS 385
#define DIVIDE 386
#define TIMES 387
#define UMINUS 388
#define POWER 389
#define FACTORIAL 390
#define EXP 391
#define LOG 392
#define LOG10 393
#define LN 394
#define SIN 395
#define COS 396
#define TAN 397
#define ASIN 398
#define ACOS 399
#define ATAN 400
#define SINH 401
#define COSH 402
#define TANH 403
#define ASINH 404
#define ACOSH 405
#define ATANH 406
#define SQRT 407
#define ASSIGN 408
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
typedef int YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
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
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
AR = 258,
AUTOCORR = 259,
BAYESIAN_IRF = 260,
BETA_PDF = 261,
CALIB = 262,
CALIB_VAR = 263,
CHECK = 264,
CONF_SIG = 265,
CORR = 266,
COVAR = 267,
DATAFILE = 268,
DIAGNOSTIC = 269,
DIFFUSE_D = 270,
DOLLAR = 271,
DR_ALGO = 272,
DROP = 273,
DSAMPLE = 274,
DYN2VEC = 275,
DYNASAVE = 276,
DYNATYPE = 277,
END = 278,
ENDVAL = 279,
EQUAL = 280,
ESTIMATION = 281,
ESTIMATED_PARAMS = 282,
ESTIMATED_PARAMS_BOUNDS = 283,
ESTIMATED_PARAMS_INIT = 284,
FILTERED_VARS = 285,
FIRST_OBS = 286,
FLOAT_NUMBER = 287,
FORECAST = 288,
FUNCTIONS = 289,
GAMMA_PDF = 290,
GRAPH = 291,
HISTVAL = 292,
HP_FILTER = 293,
HP_NGRID = 294,
INITVAL = 295,
INITVALF = 296,
INT_NUMBER = 297,
INV_GAMMA_PDF = 298,
INV_GAMMA1_PDF = 299,
INV_GAMMA2_PDF = 300,
IRF = 301,
KALMAN_ALGO = 302,
KALMAN_TOL = 303,
CONSTANT = 304,
NOCONSTANT = 305,
LAPLACE = 306,
LIK_ALGO = 307,
LIK_INIT = 308,
LINEAR = 309,
LOAD_MH_FILE = 310,
LOGLINEAR = 311,
MH_DROP = 312,
MH_INIT_SCALE = 313,
MH_JSCALE = 314,
MH_MODE = 315,
MH_NBLOCKS = 316,
MH_REPLIC = 317,
MODE_CHECK = 318,
MODE_COMPUTE = 319,
MODE_FILE = 320,
MODEL = 321,
MODEL_COMPARISON = 322,
MODEL_COMPARISON_APPROXIMATION = 323,
MODIFIEDHARMONICMEAN = 324,
MOMENTS = 325,
MOMENTS_VARENDO = 326,
MSHOCKS = 327,
NAME = 328,
NOBS = 329,
NOCORR = 330,
NODIAGNOSTIC = 331,
NOFUNCTIONS = 332,
NOGRAPH = 333,
XLS_SHEET = 334,
XLS_RANGE = 335,
NOMOMENTS = 336,
NOPRINT = 337,
NORMAL_PDF = 338,
OBSERVATION_TRENDS = 339,
OLR = 340,
OLR_INST = 341,
OLR_BETA = 342,
OPTIM = 343,
OPTIM_WEIGHTS = 344,
ORDER = 345,
OSR = 346,
OSR_PARAMS = 347,
PARAMETERS = 348,
PERIODS = 349,
PREFILTER = 350,
PRESAMPLE = 351,
PRINT = 352,
PRIOR_TRUNC = 353,
FILTER_STEP_AHEAD = 354,
QZ_CRITERIUM = 355,
RELATIVE_IRF = 356,
REPLIC = 357,
RESOL = 358,
RPLOT = 359,
SHOCKS = 360,
SIGMA_E = 361,
SIMUL = 362,
SIMUL_ALGO = 363,
SIMUL_SEED = 364,
SMOOTHER = 365,
SOLVE_ALGO = 366,
STDERR = 367,
STEADY = 368,
STOCH_SIMUL = 369,
TEX = 370,
TEX_NAME = 371,
UNIFORM_PDF = 372,
UNIT_ROOT_VARS = 373,
USE_DLL = 374,
VALUES = 375,
VAR = 376,
VAREXO = 377,
VAREXO_DET = 378,
VAROBS = 379,
XTICK = 380,
XTICKLABEL = 381,
COMMA = 382,
MINUS = 383,
PLUS = 384,
DIVIDE = 385,
TIMES = 386,
UMINUS = 387,
POWER = 388,
FACTORIAL = 389,
EXP = 390,
LOG = 391,
LOG10 = 392,
LN = 393,
SIN = 394,
COS = 395,
TAN = 396,
ASIN = 397,
ACOS = 398,
ATAN = 399,
SINH = 400,
COSH = 401,
TANH = 402,
ASINH = 403,
ACOSH = 404,
ATANH = 405,
SQRT = 406,
ASSIGN = 407
};
#endif
/* Tokens. */
#define AR 258
#define AUTOCORR 259
#define BAYESIAN_IRF 260
#define BETA_PDF 261
#define CALIB 262
#define CALIB_VAR 263
#define CHECK 264
#define CONF_SIG 265
#define CORR 266
#define COVAR 267
#define DATAFILE 268
#define DIAGNOSTIC 269
#define DIFFUSE_D 270
#define DOLLAR 271
#define DR_ALGO 272
#define DROP 273
#define DSAMPLE 274
#define DYN2VEC 275
#define DYNASAVE 276
#define DYNATYPE 277
#define END 278
#define ENDVAL 279
#define EQUAL 280
#define ESTIMATION 281
#define ESTIMATED_PARAMS 282
#define ESTIMATED_PARAMS_BOUNDS 283
#define ESTIMATED_PARAMS_INIT 284
#define FILTERED_VARS 285
#define FIRST_OBS 286
#define FLOAT_NUMBER 287
#define FORECAST 288
#define FUNCTIONS 289
#define GAMMA_PDF 290
#define GRAPH 291
#define HISTVAL 292
#define HP_FILTER 293
#define HP_NGRID 294
#define INITVAL 295
#define INITVALF 296
#define INT_NUMBER 297
#define INV_GAMMA_PDF 298
#define INV_GAMMA1_PDF 299
#define INV_GAMMA2_PDF 300
#define IRF 301
#define KALMAN_ALGO 302
#define KALMAN_TOL 303
#define CONSTANT 304
#define NOCONSTANT 305
#define LAPLACE 306
#define LIK_ALGO 307
#define LIK_INIT 308
#define LINEAR 309
#define LOAD_MH_FILE 310
#define LOGLINEAR 311
#define MH_DROP 312
#define MH_INIT_SCALE 313
#define MH_JSCALE 314
#define MH_MODE 315
#define MH_NBLOCKS 316
#define MH_REPLIC 317
#define MODE_CHECK 318
#define MODE_COMPUTE 319
#define MODE_FILE 320
#define MODEL 321
#define MODEL_COMPARISON 322
#define MODEL_COMPARISON_APPROXIMATION 323
#define MODIFIEDHARMONICMEAN 324
#define MOMENTS 325
#define MOMENTS_VARENDO 326
#define MSHOCKS 327
#define NAME 328
#define NOBS 329
#define NOCORR 330
#define NODIAGNOSTIC 331
#define NOFUNCTIONS 332
#define NOGRAPH 333
#define XLS_SHEET 334
#define XLS_RANGE 335
#define NOMOMENTS 336
#define NOPRINT 337
#define NORMAL_PDF 338
#define OBSERVATION_TRENDS 339
#define OLR 340
#define OLR_INST 341
#define OLR_BETA 342
#define OPTIM 343
#define OPTIM_WEIGHTS 344
#define ORDER 345
#define OSR 346
#define OSR_PARAMS 347
#define PARAMETERS 348
#define PERIODS 349
#define PREFILTER 350
#define PRESAMPLE 351
#define PRINT 352
#define PRIOR_TRUNC 353
#define FILTER_STEP_AHEAD 354
#define QZ_CRITERIUM 355
#define RELATIVE_IRF 356
#define REPLIC 357
#define RESOL 358
#define RPLOT 359
#define SHOCKS 360
#define SIGMA_E 361
#define SIMUL 362
#define SIMUL_ALGO 363
#define SIMUL_SEED 364
#define SMOOTHER 365
#define SOLVE_ALGO 366
#define STDERR 367
#define STEADY 368
#define STOCH_SIMUL 369
#define TEX 370
#define TEX_NAME 371
#define UNIFORM_PDF 372
#define UNIT_ROOT_VARS 373
#define USE_DLL 374
#define VALUES 375
#define VAR 376
#define VAREXO 377
#define VAREXO_DET 378
#define VAROBS 379
#define XTICK 380
#define XTICKLABEL 381
#define COMMA 382
#define MINUS 383
#define PLUS 384
#define DIVIDE 385
#define TIMES 386
#define UMINUS 387
#define POWER 388
#define FACTORIAL 389
#define EXP 390
#define LOG 391
#define LOG10 392
#define LN 393
#define SIN 394
#define COS 395
#define TAN 396
#define ASIN 397
#define ACOS 398
#define ATAN 399
#define SINH 400
#define COSH 401
#define TANH 402
#define ASINH 403
#define ACOSH 404
#define ATANH 405
#define SQRT 406
#define ASSIGN 407
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
typedef int YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;

View File

@ -1,7 +1,7 @@
#ifndef DYNAREPARSER_H
#define DYNAREPARSER_H
//------------------------------------------------------------------------------
/*! \file
/*! \file
\version 1.0
\date 04/27/2004
\par This file defines the parser class.
@ -18,11 +18,8 @@
#include "SigmaeInitialization.h"
#include "ComputingTasks.h"
#include "TmpSymbolTable.h"
#include "Objects.h"
/*New*/
#include "BlockTriangular.h"
/*EndNew*/
#ifndef YLMM_basic_parser
#include "Objects.h"
#ifndef YLMM_basic_parser
#include "ylmm/basic_parser.hh"
#endif
#ifndef YLMM_basic_scanner
@ -36,13 +33,13 @@
extern int yylineno;
/*! \namespace dynare
*/
namespace dynare
namespace dynare
{
/*!
\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:
ylmm::basic_scanner<Objects*>& _scanner;
@ -79,21 +76,18 @@ namespace dynare
int order;
/*! Value of option linear */
int linear;
EstimationParams estim_params;
/*New*/
BlockTriangular block_triangular;
/*EndNew*/
EstimationParams estim_params;
/*! Prints an arror to stdout */
static void error(const char* m)
{
{
std::cout << file_name << " : Error in line " << yylineno << " : " << m << endl;
exit(-1);
}
/*!
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;
linear = -1;
@ -106,17 +100,17 @@ namespace dynare
tmp_symbol_table.error = error;
}
/*! Destructor */
virtual ~parser() {}
virtual ~parser() {}
/*!
Scan input
\param arg Optional argument
\return The next token ID
Scan input
\param arg Optional argument
\return The next token ID
*/
int scan(void* arg=0) {
if (need_where())
return _scanner.next(*_token,*_location);
int scan(void* arg=0) {
if (need_where())
return _scanner.next(*_token,*_location);
return _scanner.next(*_token);
}
/*! Sets output file name */
void set_file_name(string fname);
@ -129,10 +123,7 @@ namespace dynare
/*! Initializes the model */
void initialize_model(void);
/*! Sets variable offset of ModelTree class to use C output */
void use_dll(void);
/*New*/
void dll(void);
/*EndNew*/
void use_dll(void);
/*! Adds an endogenous variable to SymbolTable*/
Objects* add_endogenous(Objects* name, Objects* tex_name = new Objects("",NULL, eUNDEF));
/*! Adds an exogenous variable to SymbolTable*/

View File

@ -1,7 +1,7 @@
#ifndef MODELTREE_H
#define MODELTREE_H
//------------------------------------------------------------------------------
/*! \file
/*! \file
\version 1.0
\date 04/13/2003
\par This file defines the ModelTree class.
@ -20,9 +20,6 @@
#include "NumericalConstants.h"
#include "ModelTypes.h"
#include "DataTree.h"
/*New*/
#include "BlockTriangular.h"
/*EndNew*/
//------------------------------------------------------------------------------
/*!
\class ModelTree
@ -71,9 +68,9 @@ class ModelTree : public DataTree
inline std::string getExpression(NodeID StartID, EquationType iEquationType, int iEquationID = -1);
/*!
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 */
//void RemoveUnref(int iBeginID, int iEndID, int iOrder);
/*! 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 = "");
/*! Saves output string into output M files */
void SaveMFiles();
/*! Saves output string into output C files */
/*New*/
void SaveCFiles(Model_Block* ModelBlock);
/*EndNew*/
void SaveCFiles();
/*! Computes derivatives of ModelTree */
void derive(int iOrder);
/*!
Writes output file for static model :
- equations
- 1st order derivatives with respect to endogenous variables (without lags)
- equations
- 1st order derivatives with respect to endogenous variables (without lags)
*/
std::string setStaticModel(void);
/*!
/*!
Writes output file for dynamic stochastic model :
- equations
- 1st order and 2nd order derivatives with respect to endogenous, exogenous, exogenous_det (in specific order)
- equations
- 1st order and 2nd order derivatives with respect to endogenous, exogenous, exogenous_det (in specific order)
*/
std::string setDynamicModel(void);
/*New*/
std::string setDynamicModel_New(Model_Block* ModelBlock, simple* Index_Var_IM);
/*EndNew*/
/*! Writes initialization of various Matlab variables */
void ModelInitialization(void);
/*! Returns string output for main file */

View File

@ -1,7 +1,7 @@
#ifndef VARIABLETABLE_H
#define VARIABLETABLE_H
//------------------------------------------------------------------------------
/** \file
/** \file
* \version 1.0
* \date 12/16/2003
* \par This file defines the VariableTable class .
@ -11,11 +11,11 @@
#include <string>
#include <vector>
//------------------------------------------------------------------------------
#include "SymbolTable.h"
#include "SymbolTable.h"
//------------------------------------------------------------------------------
/*!
/*!
\class Variable
\brief Variable struct
\brief Variable struct
*/
struct Variable {
/*! Variable type */
@ -29,12 +29,12 @@ struct Variable {
typedef std::pair<std::string, int> varKey;
//------------------------------------------------------------------------------
/*!
\class VariableTable
\brief This class is used to store variables as they appear
\class VariableTable
\brief This class is used to store variables as they appear
in the model (with their lead or lag)
*/
class VariableTable
{
{
private :
/*! Variable table data */
//static std::map<varKey,Variable> mVariableTable;
@ -44,19 +44,19 @@ class VariableTable
/*! Variable IDs of sorted variable table */
static std::vector<int> mSortedVariableID;
/*! Output index for variable table */
static std::vector<int> mPrintFormatIndex;
static std::vector<int> mPrintFormatIndex;
public :
/*! */
VariableTable();
/*! */
~VariableTable();
/*! Find type and ID in SymbolTable
- Increment variable_id;
- Make variable
- Push variable on variabletable
*/
static int AddVariable(std::string iName, int iLag);
/*! Pointer to error function of parser class */
/*! Find type and ID in SymbolTable
- Increment variable_id;
- Make variable
- Push variable on variabletable
*/
static int AddVariable(std::string iName, int iLag);
/*! Pointer to error function of parser class */
static void (* error) (const char* m);
/*! Decremente a symbol id of a variable */
static void decSymbolID(std::string iName, int id, int iLag, Type iType);
@ -76,12 +76,6 @@ class VariableTable
inline static int getPrintIndex(int iVarID);
/*! Sorts variable table */
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)
{

View File

@ -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
// 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
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1
// of the License, or (at your option) any later version.
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1
// of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
// 02111-1307 USA
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
// 02111-1307 USA
//
#ifndef YLMM_basic_buffer
#define YLMM_basic_buffer
@ -35,10 +35,10 @@
@date Mon Sep 30 00:08:22 2002
@brief Declaration of scanner ABC. */
namespace ylmm
namespace ylmm
{
/** @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
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
client code is much better off making a customised
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.
To do a proper interface to @b Flex notion of buffers, there's
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
*/
class basic_buffer
@ -73,22 +73,22 @@ namespace ylmm
//@{
/// @name Automatic updates
/** Do an automatic incrementation.
/** Do an automatic incrementation.
@param c the character read. */
void increment_it(char c);
//@}
//@{
/// @name Actual reading
/// @name Actual reading
/** 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 max The maximum number of characters to read
@return The number of characters read */
virtual int read_buffered(char* buf, int max);
/** Read at most @p max characters from input, or up to the first
occurence of delimiter. See also the public input method.
@param buf The buffer to read into
occurence of delimiter. See also the public input method.
@param buf The buffer to read into
@param max The maximum number of characters to read
@param delim the delimiter to read to
@return The number of characters read */
@ -97,47 +97,47 @@ namespace ylmm
//@{
/// @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 */
void new_extra(int size);
/** An extra action to take when deallocating the buffer.*/
void delete_extra();
void delete_extra();
/** An extra action to take when flushing the buffer. */
void flush_extra();
/** An extra action to take when making interactive or buffered.
void flush_extra();
/** An extra action to take when making interactive or buffered.
@param inter Whether it's interactive (ignored) */
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 */
void at_bol_extra(bool bol);
//@}
public:
/** Make a new state.
/** Make a new state.
@param stream Stream to read from. This could be a
@c std::istream like @c std::cin, or a @c std::stringstream
refering to an external string buffer. If argument is null (0)
then the stream is set to @c std::cin and interactive reads
are enabled.
@param inter Is this stream interactive or not.
are enabled.
@param inter Is this stream interactive or not.
@param autoinc Should we do automatic location tracking? That
is should we set the _line and _column number automatically by
parsing the read stream, or should we let the client code do
that job for us. */
basic_buffer(std::istream& stream, bool inter=true, bool autoinc=false);
/** Make a new state.
@param filename Name of a file to read from. If this is `-'
/** Make a new state.
@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 this throws a std::runtime_error.
@param inter Is this stream interactive or not.
then this throws a std::runtime_error.
@param inter Is this stream interactive or not.
@param autoinc Should we do automatic location tracking? That
is should we set the _line and _column number automatically by
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
found. */
basic_buffer(const std::string& filename,
basic_buffer(const std::string& filename,
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
is, if this buffer opened it because it was constructed using
the string constructor, then the underlying stream is closed
@ -147,24 +147,24 @@ namespace ylmm
//@{
/// @name Stream
/** Get the input stream
/** Get the input stream
@return the input stream */
std::istream* stream() { return _stream; }
//@}
//@{
/// @name position handling
/** Get the line number
/// @name position handling
/** Get the line number
@return the line number */
int line() const { return _line; }
/** Get the column number
/** Get the column number
@return the column number */
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 c number to add to current column number */
virtual void increment_line(int l, int c=0);
/** Increment the column
/** Increment the column
@param c number to add to current column number */
virtual void increment_column(int c) { _column += c; }
//@}
@ -173,54 +173,54 @@ namespace ylmm
/// @name Read handling
/** Flush the buffer */
void flush() { flush_extra(); }
/** Read one character from input
Note, when EOF is encountered, 0 (and not EOF) is returned.
/** Read one character from input
Note, when EOF is encountered, 0 (and not EOF) is returned.
@return the character read */
virtual int read();
/** Read at most @p max characters into buffer @p buf.
@param buf Buffer of at least size @p max to read into.
@param max Maximum number of characters to read from input.
/** Read at most @p max characters into buffer @p buf.
@param buf Buffer of at least size @p max to read into.
@param max Maximum number of characters to read from input.
@return The number of characters read. Returns -1 in case of
errors. */
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. */
virtual void putback(int c);
//@}
//@{
/// @name Miscellanious
/** Are we doing automatic increments?
/** Are we doing automatic increments?
@return true if auto incrementing */
bool auto_increment() const { return _auto_increment; }
/** Set wether we should do automatic increments.
@param ai If true, auto increment, otherwise don't
@return true if auto incrementing */
/** Set wether we should do automatic increments.
@param ai If true, auto increment, otherwise don't
@return true if auto incrementing */
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 */
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
@return true if last read characer was a newline */
bool at_bol(bool bol);
/** Check if buffer is interactive
/** Check if buffer is interactive
@return true if we're reading interactively */
bool interactive() const { return _interactive; }
/** Set whether buffer is interactive
/** Set whether buffer is interactive
@param inter if true, read inteactively
@return true if we're reading interactively */
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 */
bool activate();
//@}
};
//__________________________________________________________________
inline
basic_buffer::basic_buffer(std::istream& stream, bool inter,
bool autoinc)
inline
basic_buffer::basic_buffer(std::istream& stream, bool inter,
bool autoinc)
{
_interactive = inter;
_stream = (!stream ? &std::cin : &stream);
@ -233,9 +233,9 @@ namespace ylmm
new_extra(0);
}
//__________________________________________________________________
inline
basic_buffer::basic_buffer(const std::string& filename, bool inter,
bool autoinc)
inline
basic_buffer::basic_buffer(const std::string& filename, bool inter,
bool autoinc)
{
_interactive = inter;
if (filename.empty()) throw std::runtime_error("no filename given");
@ -245,7 +245,7 @@ namespace ylmm
}
else {
_stream = new std::ifstream(filename.data());
if (!_stream || _stream->bad())
if (!_stream || _stream->bad())
throw std::runtime_error("failed to open file");
_is_owner = true;
}
@ -258,17 +258,17 @@ namespace ylmm
}
//__________________________________________________________________
inline
basic_buffer::~basic_buffer()
inline
basic_buffer::~basic_buffer()
{
delete_extra();
delete_extra();
if (_is_owner && _stream) {
std::ifstream* is;
std::ifstream* is;
if ((is = dynamic_cast<std::ifstream*>(_stream))) is->close();
delete _stream;
}
}
//__________________________________________________________________
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;
_stream->read(buf, max);
if (_stream->bad()) return -1;
int c = _stream->gcount();
_last_read = buf[c-1];
if (_auto_increment) {
if (_auto_increment) {
for (int i = 0; i < c; i++) increment_it(buf[i]); }
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;
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;
_line = l;
_column = c;
if (_auto_increment) return;
_line = l;
_column = c;
}
//__________________________________________________________________
inline bool basic_buffer::at_bol(bool bol)
{
inline bool basic_buffer::at_bol(bool 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);
return _interactive = inter;
return _interactive = inter;
}
//__________________________________________________________________
inline int basic_buffer::read()
{
inline int basic_buffer::read()
{
_last_read = _stream->get();
if (_stream->eof()) return 0;
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');
else return read_buffered(buf, max);
else return read_buffered(buf, max);
}
//__________________________________________________________________
inline void basic_buffer::putback(int c)
{
_stream->putback(char(c));
if (!_stream->bad() && _auto_increment) _column--;
inline void basic_buffer::putback(int c)
{
_stream->putback(char(c));
if (!_stream->bad() && _auto_increment) _column--;
}
}
@ -357,8 +357,8 @@ namespace ylmm
@param o output stream to write to
@param b the ylmm::basic_buffer to write out
@return @a o */
inline std::ostream&
operator<<(std::ostream& o, const ylmm::basic_buffer& b)
inline std::ostream&
operator<<(std::ostream& o, const ylmm::basic_buffer& b)
{
return o << b.line() << "," << b.column();
}
@ -367,69 +367,69 @@ operator<<(std::ostream& o, const ylmm::basic_buffer& b)
#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 size The size of the 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
ylmm::basic_buffer::new_extra(int size)
inline void
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) size = YY_BUF_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. */
extern void yy_delete_buffer(YY_BUFFER_STATE b);
inline void
ylmm::basic_buffer::delete_extra()
inline void
ylmm::basic_buffer::delete_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. */
extern void yy_switch_to_buffer(YY_BUFFER_STATE b);
inline bool
ylmm::basic_buffer::activate()
inline bool
ylmm::basic_buffer::activate()
{
yy_switch_to_buffer(static_cast<YY_BUFFER_STATE>(_extra));
return static_cast<YY_BUFFER_STATE>(_extra) == YY_CURRENT_BUFFER;
}
//__________________________________________________________________
inline void
ylmm::basic_buffer::interactive_extra(bool inter)
inline void
ylmm::basic_buffer::interactive_extra(bool inter)
{
(static_cast<YY_BUFFER_STATE>(_extra))->yy_is_interactive = inter ? 1 : 0;
}
//__________________________________________________________________
inline void
ylmm::basic_buffer::at_bol_extra(bool inter)
inline void
ylmm::basic_buffer::at_bol_extra(bool inter)
{
(static_cast<YY_BUFFER_STATE>(_extra))->yy_at_bol = inter ? 1 : 0;
}
//__________________________________________________________________
/** Flush a buffer.
/** Flush a buffer.
@param b The buffer to flush. */
extern void yy_flush_buffer(YY_BUFFER_STATE b);
inline void
ylmm::basic_buffer::flush_extra()
inline void
ylmm::basic_buffer::flush_extra()
{
yy_flush_buffer(static_cast<YY_BUFFER_STATE>(_extra));
}
#else
#else
//__________________________________________________________________
inline void ylmm::basic_buffer::new_extra(int size) {}
@ -443,5 +443,5 @@ inline bool ylmm::basic_buffer::activate() { return true; }
#endif