Bison 3.2 now generates a default semantic action with variants

The minimal required version of Bison is bumped to 3.2, so that we can rely on
those default actions.
issue#70
Sébastien Villemot 2019-08-14 10:38:25 +02:00
parent 2c6a290fb3
commit 30aaf93ca7
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 5 additions and 60 deletions

View File

@ -19,7 +19,7 @@
*/
%language "c++"
%require "3.0"
%require "3.2"
%defines
%define api.value.type variant
%define api.namespace {Dynare}
@ -579,9 +579,7 @@ named_var_1 : '(' named_var_elem
;
named_var : named_var_1 ')'
{ $$ = $1; }
| named_var_1 COMMA ')'
{ $$ = $1; }
;
var_list : var_list symbol
@ -837,7 +835,6 @@ comma_expression : expression
expression_or_empty : %empty
{ $$ = driver.add_nan_constant(); }
| expression
{ $$ = $1; }
;
initval : INITVAL ';' initval_list END ';'
@ -1541,13 +1538,10 @@ signed_integer : PLUS INT_NUMBER
$$.insert(0, "-");
}
| INT_NUMBER
{ $$ = $1; }
;
non_negative_number : INT_NUMBER
{ $$ = $1; }
| FLOAT_NUMBER
{ $$ = $1; }
;
signed_number : PLUS non_negative_number
@ -1558,7 +1552,6 @@ signed_number : PLUS non_negative_number
$$.insert(0, "-");
}
| non_negative_number
{ $$ = $1; }
;
signed_inf : PLUS INF_CONSTANT
@ -1570,9 +1563,7 @@ signed_inf : PLUS INF_CONSTANT
;
signed_number_w_inf : signed_inf
{ $$ = $1; }
| signed_number
{ $$ = $1; }
;
estimated_params : ESTIMATED_PARAMS ';' estimated_list END ';' { driver.estimated_params(); };
@ -1789,10 +1780,8 @@ prior_pdf : BETA_PDF
;
date_str : DATES
{ $$ = $1; }
date_expr : date_str
{ $$ = $1; }
| date_expr PLUS INT_NUMBER
{ $$ = $1 + '+' + $3; }
;
@ -2099,7 +2088,6 @@ list_sub_sampling_option : QUOTED_STRING COMMA QUOTED_STRING
;
sub_sampling_options : list_sub_sampling_option
{ $$ = $1; }
| sub_sampling_options COMMA list_sub_sampling_option
{ $$ = $1 + ',' + $3; }
;
@ -2259,9 +2247,7 @@ model_comparison : MODEL_COMPARISON mc_filename_list ';'
;
filename : symbol
{ $$ = $1; }
| QUOTED_STRING
{ $$ = $1; }
;
parallel_local_filename_list : filename
@ -3781,7 +3767,6 @@ vec_int_number : INT_NUMBER
;
vec_int_elem : vec_int_number
{ $$ = $1; }
| INT_NUMBER ':' INT_NUMBER
{
$$ = vector<int>{};
@ -3807,9 +3792,7 @@ vec_int_1 : '[' vec_int_elem
;
vec_int : vec_int_1 ']'
{ $$ = $1; }
| vec_int_1 COMMA ']'
{ $$ = $1; }
;
vec_str_1 : '[' QUOTED_STRING
@ -3829,9 +3812,7 @@ vec_str_1 : '[' QUOTED_STRING
;
vec_str : vec_str_1 ']'
{ $$ = $1; }
| vec_str_1 COMMA ']'
{ $$ = $1; }
;
vec_value_1 : '[' signed_number
@ -3853,13 +3834,12 @@ vec_value : vec_value_1 ']'
vec_value_list : vec_value_list COMMA vec_value
{ $$ = $1 + ',' + $3; }
| vec_value
{ $$ = $1; }
;
vec_of_vec_value : '[' vec_value_list ']'
{ $$ = $2; }
| vec_value
{ $$ = $1; };
;
vec_value_1_w_inf : '[' signed_number_w_inf
{ $$ = '[' + $2; }
@ -3871,52 +3851,30 @@ vec_value_w_inf : vec_value_1_w_inf ']'
{ $$ = $1 + ']'; };
symbol : NAME
{ $$ = $1; }
| ALPHA
{ $$ = $1; }
| BETA
{ $$ = $1; }
| NINV
{ $$ = $1; }
| ABAND
{ $$ = $1; }
| CMS
{ $$ = $1; }
| NCMS
{ $$ = $1; }
| CNUM
{ $$ = $1; }
| GAMMA
{ $$ = $1; }
| INV_GAMMA
{ $$ = $1; }
| INV_GAMMA1
{ $$ = $1; }
| INV_GAMMA2
{ $$ = $1; }
| NORMAL
{ $$ = $1; }
| UNIFORM
{ $$ = $1; }
| EPS
{ $$ = $1; }
| PDF
{ $$ = $1; }
| FIG
{ $$ = $1; }
| NONE
{ $$ = $1; }
| DR
{ $$ = $1; }
| PRIOR
{ $$ = $1; }
;
number : INT_NUMBER
{ $$ = $1; }
| FLOAT_NUMBER
{ $$ = $1; }
;
%%

View File

@ -19,7 +19,7 @@
*/
%language "c++"
%require "3.0"
%require "3.2"
%defines
%define api.value.type variant
%define api.namespace {Tokenizer}
@ -90,8 +90,7 @@ using namespace macro;
%token <string> NAME TEXT QUOTED_STRING NUMBER EOL
%type <DirectivePtr> statement
%type <DirectivePtr> directive directive_one_line directive_multiline for if ifdef ifndef text
%type <EvalPtr> eval
%type <DirectivePtr> directive directive_one_line directive_multiline for if ifdef ifndef text eval
%type <ExpressionPtr> primary_expr oper_expr colon_expr expr
%type <FunctionPtr> function
%type <VariablePtr> symbol
@ -114,17 +113,12 @@ statements : statement
;
statement : directive
{ $$ = $1; }
| text
{ $$ = $1; }
| eval
{ $$ = $1; }
;
directive : directive_one_line EOL
{ $$ = $1; }
| directive_multiline EOL
{ $$ = $1; }
;
directive_one_line : INCLUDE expr
@ -146,13 +140,9 @@ directive_one_line : INCLUDE expr
;
directive_multiline : for
{ $$ = $1; }
| if
{ $$ = $1; }
| ifdef
{ $$ = $1; }
| ifndef
{ $$ = $1; }
;
for : FOR { driver.pushContext(); } NAME IN expr EOL statements ENDFOR
@ -290,7 +280,7 @@ tuple_comma_expr : %empty
primary_expr : LPAREN expr RPAREN
{ $$ = $2; }
| symbol
{ $$ = $1; }
{ $$ = $1; } // Explicit rule needed for type conversion
| NAME LPAREN comma_expr RPAREN
{ $$ = make_shared<Function>($1, $3, driver.env, @$); }
| TRUE
@ -388,7 +378,6 @@ primary_expr : LPAREN expr RPAREN
;
oper_expr : primary_expr
{ $$ = $1; }
| LPAREN BOOL RPAREN oper_expr %prec CAST
{ $$ = make_shared<UnaryOp>(codes::UnaryOp::cast_bool, $4, driver.env, @$); }
| LPAREN REAL RPAREN oper_expr %prec CAST
@ -428,9 +417,7 @@ colon_expr : oper_expr COLON oper_expr
;
expr : oper_expr
{ $$ = $1; }
| colon_expr
{ $$ = $1; }
| expr EQUAL_EQUAL expr
{ $$ = make_shared<BinaryOp>(codes::BinaryOp::equal_equal, $1, $3, driver.env, @$); }
| expr NOT_EQUAL expr