stage1_2/iec_bison.yy
changeset 963 e3d4dca7520b
parent 961 b05f63d9d0fa
child 971 8aee27d46208
equal deleted inserted replaced
962:98e7a0d3af21 963:e3d4dca7520b
  2774 /* a non standard construct, used to allow the declaration of array subranges using a variable */
  2774 /* a non standard construct, used to allow the declaration of array subranges using a variable */
  2775 subrange_with_var:
  2775 subrange_with_var:
  2776   signed_integer DOTDOT signed_integer
  2776   signed_integer DOTDOT signed_integer
  2777 	{$$ = new subrange_c($1, $3, locloc(@$));}
  2777 	{$$ = new subrange_c($1, $3, locloc(@$));}
  2778 | any_identifier DOTDOT signed_integer
  2778 | any_identifier DOTDOT signed_integer
  2779 	{$$ = new subrange_c($1, $3, locloc(@$));}
  2779 	{$$ = new subrange_c(new symbolic_constant_c($1, locloc(@1)), $3, locloc(@$));}
  2780 | signed_integer DOTDOT any_identifier
  2780 | signed_integer DOTDOT any_identifier
  2781 	{$$ = new subrange_c($1, $3, locloc(@$));}
  2781 	{$$ = new subrange_c($1, new symbolic_constant_c($3, locloc(@3)), locloc(@$));}
  2782 | any_identifier DOTDOT any_identifier
  2782 | any_identifier DOTDOT any_identifier
  2783 	{$$ = new subrange_c($1, $3, locloc(@$));}
  2783 	{$$ = new subrange_c(new symbolic_constant_c($1, locloc(@1)), new symbolic_constant_c($3, locloc(@3)), locloc(@$));}
  2784 /* ERROR_CHECK_BEGIN */
  2784 /* ERROR_CHECK_BEGIN */
  2785 | signed_integer signed_integer
  2785 | signed_integer signed_integer
  2786 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;}
  2786 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;}
  2787 | signed_integer DOTDOT error
  2787 | signed_integer DOTDOT error
  2788 	{$$ = NULL;
  2788 	{$$ = NULL;
  4331 	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after external variable declaration."); yynerrs++;}
  4331 	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after external variable declaration."); yynerrs++;}
  4332 /* ERROR_CHECK_END */
  4332 /* ERROR_CHECK_END */
  4333 ;
  4333 ;
  4334 
  4334 
  4335 
  4335 
       
  4336 
       
  4337 /* Warning: When handling VAR_EXTERNAL declarations, the constant folding algorithm may (depending on the command line parameters) 
       
  4338  *          set the symbol_c->const_value annotations on both the external_var_name as well as on its VAR_EXTERNAL datatype specification symbol.
       
  4339  *          Setting the const_value on the datatype specification symbol of a VAR_EXTERNAL declaration is only possible if the declaration of 
       
  4340  *          several external variables in a list is not allowed (as each variable could have a potentially distinct initial value).
       
  4341  *           VAR_EXTERNAL
       
  4342  *             a, b, c, d: INT;  (* incorrect syntax! *)
       
  4343  *           END_VAR
       
  4344  *          
       
  4345  *          If anybody considers extending this standard syntax to allow the above syntax (several variables in a list), then be sure to go
       
  4346  *          and fix the constant folding algorithm (more precisely, the constant_folding_c::handle_var_extern_global_pair() function.
       
  4347  */
  4336 external_declaration:
  4348 external_declaration:
  4337   global_var_name ':' simple_specification
  4349   global_var_name ':' simple_specification
  4338 	{$$ = new external_declaration_c($1, $3, locloc(@$));
  4350 	{$$ = new external_declaration_c($1, $3, locloc(@$));
  4339 	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
  4351 	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
  4340 	}
  4352 	}