# HG changeset patch # User mjsousa # Date 1418212663 0 # Node ID b05f63d9d0fa10a6a18897c001a6a6b10db543bf # Parent 8bfcc8e62bd6902f735247bbcddff7e1c56e47db# Parent 27063736913fe64553f6540aab85b1f30e616bbf merge diff -r 8bfcc8e62bd6 -r b05f63d9d0fa stage1_2/iec_bison.yy --- a/stage1_2/iec_bison.yy Sat Dec 06 19:14:23 2014 +0000 +++ b/stage1_2/iec_bison.yy Wed Dec 10 11:57:43 2014 +0000 @@ -739,6 +739,8 @@ %type subrange_spec_init %type subrange_specification %type subrange +/* A non standard construct, used to support the use of variables in array subranges. e.g.: ARRAY [12..max] OF INT */ +%type subrange_with_var %type enumerated_type_declaration %type enumerated_spec_init @@ -2769,9 +2771,16 @@ ; -subrange: +/* a non standard construct, used to allow the declaration of array subranges using a variable */ +subrange_with_var: signed_integer DOTDOT signed_integer {$$ = new subrange_c($1, $3, locloc(@$));} +| any_identifier DOTDOT signed_integer + {$$ = new subrange_c($1, $3, locloc(@$));} +| signed_integer DOTDOT any_identifier + {$$ = new subrange_c($1, $3, locloc(@$));} +| any_identifier DOTDOT any_identifier + {$$ = new subrange_c($1, $3, locloc(@$));} /* ERROR_CHECK_BEGIN */ | signed_integer signed_integer {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;} @@ -2784,6 +2793,23 @@ /* ERROR_CHECK_END */ ; + +subrange: + signed_integer DOTDOT signed_integer + {$$ = new subrange_c($1, $3, locloc(@$));} +/* ERROR_CHECK_BEGIN */ +| signed_integer signed_integer + {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;} +| signed_integer DOTDOT error + {$$ = NULL; + if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for upper bound in subrange definition.");} + else {print_err_msg(locf(@3), locl(@3), "invalid value for upper bound in subrange definition."); yyclearin;} + yyerrok; + } +/* ERROR_CHECK_END */ +; + + enumerated_type_declaration: /* enumerated_type_name ':' enumerated_spec_init */ /* 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 @@ -2989,9 +3015,10 @@ /* helper symbol for array_specification */ array_subrange_list: - subrange +/* 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 */ + subrange_with_var {$$ = new array_subrange_list_c(locloc(@$)); $$->add_element($1);} -| array_subrange_list ',' subrange +| array_subrange_list ',' subrange_with_var {$$ = $1; $$->add_element($3);} /* ERROR_CHECK_BEGIN */ | array_subrange_list subrange