Commit 72bac2d6 authored by sebastien's avatar sebastien
Browse files

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
parent 35aef658
......@@ -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 ';'
......
......@@ -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)
{
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment