v4.1 preprocessor:

* refactored code for the standard normcdf()
* cosmetic changes


git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2035 ac1d8469-bf42-47a9-8791-bf33cf982152
issue#70
sebastien 2008-09-04 08:10:42 +00:00
parent 35aef658f1
commit 72bac2d6fd
3 changed files with 16 additions and 16 deletions

View File

@ -350,19 +350,15 @@ expression : '(' expression ')'
| SQRT '(' expression ')'
{ $$ = driver.add_sqrt($3); }
| MAX '(' expression COMMA expression ')'
{ $$ = driver.add_max($3 , $5); }
{ $$ = driver.add_max($3, $5); }
| MIN '(' expression COMMA expression ')'
{ $$ = driver.add_min($3 , $5); }
{ $$ = driver.add_min($3, $5); }
| NAME '(' comma_expression ')'
{ $$ = driver.add_unknown_function($1); }
| NORMCDF '(' expression COMMA expression COMMA expression ')'
{ $$ = driver.add_normcdf($3,$5,$7);}
{ $$ = driver.add_normcdf($3, $5, $7); }
| NORMCDF '(' expression ')'
{
string *zero = new string("0");
string *one = new string("1");
$$ = driver.add_normcdf($3,driver.add_constant(zero),driver.add_constant(one));
}
{ $$ = driver.add_normcdf($3); }
;
comma_expression : expression
@ -504,17 +500,13 @@ hand_side : '(' hand_side ')'
| SQRT '(' hand_side ')'
{ $$ = driver.add_sqrt($3); }
| MAX '(' hand_side COMMA hand_side ')'
{ $$ = driver.add_max($3 , $5); }
{ $$ = driver.add_max($3, $5); }
| MIN '(' hand_side COMMA hand_side ')'
{ $$ = driver.add_min($3 , $5); }
{ $$ = driver.add_min($3, $5); }
| NORMCDF '(' hand_side COMMA hand_side COMMA hand_side ')'
{ $$ = driver.add_normcdf($3,$5,$7);}
{ $$ = driver.add_normcdf($3, $5, $7); }
| NORMCDF '(' hand_side ')'
{
string *zero = new string("0");
string *one = new string("1");
$$ = driver.add_normcdf($3,driver.add_constant(zero),driver.add_constant(one));
}
{ $$ = driver.add_normcdf($3); }
;
pound_expression: '#' NAME EQUAL hand_side ';'

View File

@ -1297,6 +1297,12 @@ ParsingDriver::add_normcdf(NodeID arg1, NodeID arg2, NodeID arg3)
return data_tree->AddNormcdf(arg1,arg2,arg3);
}
NodeID
ParsingDriver::add_normcdf(NodeID arg)
{
return add_normcdf(arg, data_tree->Zero, data_tree->One);
}
void
ParsingDriver::add_unknown_function_arg(NodeID arg)
{

View File

@ -402,6 +402,8 @@ public:
NodeID add_min(NodeID arg1, NodeID arg2);
//! Writes token "normcdf(arg1,arg2,arg3)" to model tree
NodeID add_normcdf(NodeID arg1, NodeID arg2, NodeID arg3);
//! Writes token "normcdf(arg,0,1)" to model tree
NodeID add_normcdf(NodeID arg);
//! Adds an unknwon function argument
void add_unknown_function_arg(NodeID arg);
//! Adds an unknown function call node