stage1_2/iec_bison.yy
changeset 960 27063736913f
parent 946 c012a64dc2fa
child 961 b05f63d9d0fa
equal deleted inserted replaced
947:aca1ab9fcb6d 960:27063736913f
   734 
   734 
   735 %type  <leaf>	subrange_type_declaration
   735 %type  <leaf>	subrange_type_declaration
   736 %type  <leaf>	subrange_spec_init
   736 %type  <leaf>	subrange_spec_init
   737 %type  <leaf>	subrange_specification
   737 %type  <leaf>	subrange_specification
   738 %type  <leaf>	subrange
   738 %type  <leaf>	subrange
       
   739 /* A non standard construct, used to support the use of variables in array subranges. e.g.: ARRAY [12..max] OF INT */
       
   740 %type  <leaf>	subrange_with_var
   739 
   741 
   740 %type  <leaf>	enumerated_type_declaration
   742 %type  <leaf>	enumerated_type_declaration
   741 %type  <leaf>	enumerated_spec_init
   743 %type  <leaf>	enumerated_spec_init
   742 %type  <leaf>	enumerated_specification
   744 %type  <leaf>	enumerated_specification
   743 /* helper symbol for enumerated_value */
   745 /* helper symbol for enumerated_value */
  2726 	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing after subrange defined in subrange specification."); yyerrok;}
  2728 	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing after subrange defined in subrange specification."); yyerrok;}
  2727 /* ERROR_CHECK_END */
  2729 /* ERROR_CHECK_END */
  2728 ;
  2730 ;
  2729 
  2731 
  2730 
  2732 
  2731 subrange:
  2733 /* a non standard construct, used to allow the declaration of array subranges using a variable */
       
  2734 subrange_with_var:
  2732   signed_integer DOTDOT signed_integer
  2735   signed_integer DOTDOT signed_integer
       
  2736 	{$$ = new subrange_c($1, $3, locloc(@$));}
       
  2737 | any_identifier DOTDOT signed_integer
       
  2738 	{$$ = new subrange_c($1, $3, locloc(@$));}
       
  2739 | signed_integer DOTDOT any_identifier
       
  2740 	{$$ = new subrange_c($1, $3, locloc(@$));}
       
  2741 | any_identifier DOTDOT any_identifier
  2733 	{$$ = new subrange_c($1, $3, locloc(@$));}
  2742 	{$$ = new subrange_c($1, $3, locloc(@$));}
  2734 /* ERROR_CHECK_BEGIN */
  2743 /* ERROR_CHECK_BEGIN */
  2735 | signed_integer signed_integer
  2744 | signed_integer signed_integer
  2736 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;}
  2745 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;}
  2737 | signed_integer DOTDOT error
  2746 | signed_integer DOTDOT error
  2740 	 else {print_err_msg(locf(@3), locl(@3), "invalid value for upper bound in subrange definition."); yyclearin;}
  2749 	 else {print_err_msg(locf(@3), locl(@3), "invalid value for upper bound in subrange definition."); yyclearin;}
  2741 	 yyerrok;
  2750 	 yyerrok;
  2742 	}
  2751 	}
  2743 /* ERROR_CHECK_END */
  2752 /* ERROR_CHECK_END */
  2744 ;
  2753 ;
       
  2754 
       
  2755 
       
  2756 subrange:
       
  2757   signed_integer DOTDOT signed_integer
       
  2758 	{$$ = new subrange_c($1, $3, locloc(@$));}
       
  2759 /* ERROR_CHECK_BEGIN */
       
  2760 | signed_integer signed_integer
       
  2761 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;}
       
  2762 | signed_integer DOTDOT error
       
  2763 	{$$ = NULL;
       
  2764 	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for upper bound in subrange definition.");}
       
  2765 	 else {print_err_msg(locf(@3), locl(@3), "invalid value for upper bound in subrange definition."); yyclearin;}
       
  2766 	 yyerrok;
       
  2767 	}
       
  2768 /* ERROR_CHECK_END */
       
  2769 ;
       
  2770 
  2745 
  2771 
  2746 enumerated_type_declaration:
  2772 enumerated_type_declaration:
  2747 /*  enumerated_type_name ':' enumerated_spec_init */
  2773 /*  enumerated_type_name ':' enumerated_spec_init */
  2748 /* NOTE: The 'identifier' used for the name of the new enumerated type is inserted early into the library_element_symtable so it may be used
  2774 /* NOTE: The 'identifier' used for the name of the new enumerated type is inserted early into the library_element_symtable so it may be used
  2749  *       in defining the default initial value of this type, using the fully qualified enumerated constant syntax: type_name#enum_value
  2775  *       in defining the default initial value of this type, using the fully qualified enumerated constant syntax: type_name#enum_value
  2922 /* ERROR_CHECK_END */
  2948 /* ERROR_CHECK_END */
  2923 ;
  2949 ;
  2924 
  2950 
  2925 /* helper symbol for array_specification */
  2951 /* helper symbol for array_specification */
  2926 array_subrange_list:
  2952 array_subrange_list:
  2927   subrange
  2953 /* the construct 'subrange' has been replaced with 'subrange_with_var' in order to support the declaration of array ranges using a varable: e.g. ARRAY [2..max] OF INT */
       
  2954   subrange_with_var
  2928 	{$$ = new array_subrange_list_c(locloc(@$)); $$->add_element($1);}
  2955 	{$$ = new array_subrange_list_c(locloc(@$)); $$->add_element($1);}
  2929 | array_subrange_list ',' subrange
  2956 | array_subrange_list ',' subrange_with_var
  2930 	{$$ = $1; $$->add_element($3);}
  2957 	{$$ = $1; $$->add_element($3);}
  2931 /* ERROR_CHECK_BEGIN */
  2958 /* ERROR_CHECK_BEGIN */
  2932 | array_subrange_list subrange
  2959 | array_subrange_list subrange
  2933 	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in subrange list."); yynerrs++;}
  2960 	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in subrange list."); yynerrs++;}
  2934 | array_subrange_list ',' error
  2961 | array_subrange_list ',' error