Change the syntax for values of deterministic shocks:
Arbirtrary expressions after the "values" keywords must now be enclosed within parentheses; consider the following example: <code> periods 1:2; values -1 -2; </code> In the previous syntax, this was interpreted by the preprocessor as a shock of value -1-2 = -3 for periods 1 and 2, which is clearly not the intent of the user; with the new syntax, this will be rejected (too many values compared to the number of ranges). Also note that now commas are no longer required between arbitrary expressions, since the parentheses are sufficient for separating them.time-shift
parent
a03516b988
commit
76d5d441ea
|
@ -1524,7 +1524,7 @@ end;
|
|||
<synopfragment id="det_shock">
|
||||
<arg choice="plain">var <replaceable>VARIABLE_NAME</replaceable>;</arg>
|
||||
<arg choice="plain">periods <replaceable>INTEGER</replaceable><arg>:<replaceable>INTEGER</replaceable></arg><arg rep="repeat"><arg>,</arg> <replaceable>INTEGER</replaceable><arg>:<replaceable>INTEGER</replaceable></arg></arg>;</arg>
|
||||
<arg choice="plain">values <replaceable>EXPRESSION</replaceable> <arg rep="repeat"><arg>,</arg> <replaceable>EXPRESSION</replaceable></arg>;</arg>
|
||||
<arg choice="plain">values <group choice="plain"><arg choice="plain"><replaceable>DOUBLE</replaceable></arg><arg choice="plain">(<replaceable>EXPRESSION</replaceable>)</arg></group> <arg rep="repeat"><arg>,</arg> <group choice="plain"><arg choice="plain"><replaceable>DOUBLE</replaceable></arg><arg choice="plain">(<replaceable>EXPRESSION</replaceable>)</arg></group></arg>;</arg>
|
||||
</synopfragment>
|
||||
|
||||
<synopfragment id="sto_shock">
|
||||
|
@ -1554,6 +1554,12 @@ end;
|
|||
will have a constant value over the range.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note that shock values are not restricted to numerical constants: arbitrary
|
||||
expressions are also allowed, but you have to enclose them inside
|
||||
parentheses.
|
||||
</para>
|
||||
|
||||
<refsect3><title>Example</title>
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
|
@ -1567,6 +1573,9 @@ values 0;
|
|||
var v;
|
||||
periods 4:5 6 7:9;
|
||||
values 1 1.1 0.9;
|
||||
var w;
|
||||
periods 1 2;
|
||||
values (1+p) (exp(z));
|
||||
end;
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
|
|
@ -740,14 +740,19 @@ period_list : period_list COMMA INT_NUMBER
|
|||
|
||||
sigma_e : SIGMA_E EQUAL '[' triangular_matrix ']' ';' { driver.do_sigma_e(); };
|
||||
|
||||
value_list
|
||||
: value_list COMMA expression
|
||||
{driver.add_value($3);}
|
||||
| value_list number
|
||||
{driver.add_value($2);}
|
||||
| expression
|
||||
{driver.add_value($1);}
|
||||
;
|
||||
value_list : value_list COMMA '(' expression ')'
|
||||
{ driver.add_value($4); }
|
||||
| value_list '(' expression ')'
|
||||
{ driver.add_value($3); }
|
||||
| '(' expression ')'
|
||||
{ driver.add_value($2); }
|
||||
| value_list COMMA signed_float
|
||||
{ driver.add_value($3); }
|
||||
| value_list signed_float
|
||||
{ driver.add_value($2); }
|
||||
| signed_float
|
||||
{ driver.add_value($1); }
|
||||
;
|
||||
|
||||
triangular_matrix : triangular_matrix ';' triangular_row
|
||||
{ driver.end_of_row(); }
|
||||
|
|
|
@ -700,9 +700,15 @@ ParsingDriver::add_value(expr_t value)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_value(string *p1)
|
||||
ParsingDriver::add_value(string *v)
|
||||
{
|
||||
det_shocks_values.push_back(add_constant(p1));
|
||||
expr_t id;
|
||||
if (v->at(0) == '-')
|
||||
id = data_tree->AddUMinus(data_tree->AddNumConstant(v->substr(1, string::npos)));
|
||||
else
|
||||
id = data_tree->AddNumConstant(*v);
|
||||
delete v;
|
||||
det_shocks_values.push_back(id);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -283,7 +283,8 @@ public:
|
|||
//! Adds a deterministic shock value
|
||||
void add_value(expr_t value);
|
||||
//! Adds a deterministic shock value
|
||||
void add_value(string *p1);
|
||||
/*! \param v a string containing a (possibly negative) numeric constant */
|
||||
void add_value(string *v);
|
||||
//! Writes a Sigma_e block
|
||||
void do_sigma_e();
|
||||
//! Ends row of Sigma_e block
|
||||
|
|
Loading…
Reference in New Issue