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.
issue#70
Sébastien Villemot 2010-11-24 18:26:43 +01:00
parent 0269c5766c
commit 973c795db8
3 changed files with 23 additions and 11 deletions

View File

@ -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(); }

View File

@ -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

View File

@ -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