2605 ; |
2605 ; |
2606 |
2606 |
2607 simple_type_declaration: |
2607 simple_type_declaration: |
2608 /* simple_type_name ':' simple_spec_init */ |
2608 /* simple_type_name ':' simple_spec_init */ |
2609 /* To understand why simple_spec_init was brocken up into its consituent components in the following rules, please see note in the definition of 'enumerated_type_declaration'. */ |
2609 /* To understand why simple_spec_init was brocken up into its consituent components in the following rules, please see note in the definition of 'enumerated_type_declaration'. */ |
2610 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
2610 /* PRE_PARSING or SINGLE_PHASE_PARSING */ |
|
2611 /* The following rules will be run either by: |
|
2612 * - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen). |
|
2613 * - the standard single phase parser (when preparsing command line option is not chosen). |
|
2614 */ |
2611 identifier ':' simple_specification {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} |
2615 identifier ':' simple_specification {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} |
2612 {if (!get_preparse_state()) ERROR;} |
2616 {if (!get_preparse_state()) $$ = new simple_type_declaration_c($1, $3, locloc(@$));} |
2613 | identifier ':' elementary_type_name {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} ASSIGN constant |
2617 | identifier ':' elementary_type_name {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} ASSIGN constant |
2614 {if (!get_preparse_state()) ERROR;} |
2618 {if (!get_preparse_state()) $$ = new simple_type_declaration_c($1, new simple_spec_init_c($3, $6, locf(@3), locl(@5)), locloc(@$));} |
2615 | identifier ':' prev_declared_simple_type_name {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} ASSIGN constant |
2619 | identifier ':' prev_declared_simple_type_name {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} ASSIGN constant |
2616 {if (!get_preparse_state()) ERROR;} |
2620 {if (!get_preparse_state()) $$ = new simple_type_declaration_c($1, new simple_spec_init_c($3, $6, locf(@3), locl(@5)), locloc(@$));} |
2617 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
2621 /* POST_PARSING */ |
|
2622 /* These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */ |
2618 | prev_declared_simple_type_name ':' simple_spec_init |
2623 | prev_declared_simple_type_name ':' simple_spec_init |
2619 {$$ = new simple_type_declaration_c($1, $3, locloc(@$));} |
2624 {$$ = new simple_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier! |
2620 /* These three rules can now be safely replaced by the original rule abvoe!! */ |
2625 /* These three rules can now be safely replaced by the original rule abvoe!! */ |
2621 /* |
2626 /* |
2622 | prev_declared_simple_type_name ':' simple_specification |
2627 | prev_declared_simple_type_name ':' simple_specification |
2623 {$$ = new simple_type_declaration_c($1, $3, locloc(@$));} |
2628 {$$ = new simple_type_declaration_c($1, $3, locloc(@$));} |
2624 | prev_declared_simple_type_name ':' elementary_type_name ASSIGN constant |
2629 | prev_declared_simple_type_name ':' elementary_type_name ASSIGN constant |
2696 ; |
2701 ; |
2697 |
2702 |
2698 |
2703 |
2699 subrange_type_declaration: |
2704 subrange_type_declaration: |
2700 /* subrange_type_name ':' subrange_spec_init */ |
2705 /* subrange_type_name ':' subrange_spec_init */ |
2701 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
2706 /* PRE_PARSING or SINGLE_PHASE_PARSING */ |
|
2707 /* The following rules will be run either by: |
|
2708 * - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen). |
|
2709 * - the standard single phase parser (when preparsing command line option is not chosen). |
|
2710 */ |
2702 identifier ':' subrange_spec_init {library_element_symtable.insert($1, prev_declared_subrange_type_name_token);} |
2711 identifier ':' subrange_spec_init {library_element_symtable.insert($1, prev_declared_subrange_type_name_token);} |
2703 {if (!get_preparse_state()) ERROR;} |
2712 {if (!get_preparse_state()) $$ = new subrange_type_declaration_c($1, $3, locloc(@$));} |
2704 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
2713 /* POST_PARSING */ |
|
2714 /* These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */ |
2705 | prev_declared_subrange_type_name ':' subrange_spec_init |
2715 | prev_declared_subrange_type_name ':' subrange_spec_init |
2706 {$$ = new subrange_type_declaration_c($1, $3, locloc(@$));} |
2716 {$$ = new subrange_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier! |
2707 /* ERROR_CHECK_BEGIN */ |
2717 /* ERROR_CHECK_BEGIN */ |
2708 | error ':' subrange_spec_init |
2718 | error ':' subrange_spec_init |
2709 {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid name defined for subrange type declaration."); yyerrok;} |
2719 {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid name defined for subrange type declaration."); yyerrok;} |
2710 | identifier subrange_spec_init |
2720 | identifier subrange_spec_init |
2711 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in subrange type declaration."); yynerrs++;} |
2721 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in subrange type declaration."); yynerrs++;} |
2773 * |
2783 * |
2774 * If it were not for the above, we could use the rule |
2784 * If it were not for the above, we could use the rule |
2775 * identifier ':' enumerated_spec_init |
2785 * identifier ':' enumerated_spec_init |
2776 * and include the library_element_symtable.insert(...) code in the rule actions! |
2786 * and include the library_element_symtable.insert(...) code in the rule actions! |
2777 */ |
2787 */ |
2778 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
2788 /* PRE_PARSING or SINGLE_PHASE_PARSING */ |
|
2789 /* The following rules will be run either by: |
|
2790 * - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen). |
|
2791 * - the standard single phase parser (when preparsing command line option is not chosen). |
|
2792 */ |
2779 identifier ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} |
2793 identifier ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} |
2780 {if (!get_preparse_state()) ERROR;} |
2794 {if (!get_preparse_state()) $$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, NULL, locloc(@3)), locloc(@$));} |
2781 | identifier ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} ASSIGN enumerated_value |
2795 | identifier ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} ASSIGN enumerated_value |
2782 {if (!get_preparse_state()) ERROR;} |
2796 {if (!get_preparse_state()) $$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, $6, locf(@3), locl(@6)), locloc(@$));} |
2783 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
2797 /* POST_PARSING */ |
|
2798 /* These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */ |
2784 /* Since the enumerated type name is placed in the library_element_symtable during preparsing, we can now safely use the single rule: */ |
2799 /* Since the enumerated type name is placed in the library_element_symtable during preparsing, we can now safely use the single rule: */ |
2785 | prev_declared_enumerated_type_name ':' enumerated_spec_init |
2800 | prev_declared_enumerated_type_name ':' enumerated_spec_init |
2786 {$$ = new enumerated_type_declaration_c($1, $3, locloc(@$));} |
2801 {$$ = new enumerated_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier! |
2787 /* These two rules are equivalent to the above rule */ |
2802 /* These two rules are equivalent to the above rule */ |
2788 /* |
2803 /* |
2789 | prev_declared_enumerated_type_name ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} |
2804 | prev_declared_enumerated_type_name ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} |
2790 {$$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, NULL, locloc(@3)), locloc(@$));} |
2805 {$$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, NULL, locloc(@3)), locloc(@$));} |
2791 | prev_declared_enumerated_type_name ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} ASSIGN enumerated_value |
2806 | prev_declared_enumerated_type_name ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} ASSIGN enumerated_value |
2876 */ |
2891 */ |
2877 |
2892 |
2878 |
2893 |
2879 array_type_declaration: |
2894 array_type_declaration: |
2880 /* array_type_name ':' array_spec_init */ |
2895 /* array_type_name ':' array_spec_init */ |
2881 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
2896 /* PRE_PARSING or SINGLE_PHASE_PARSING */ |
|
2897 /* The following rules will be run either by: |
|
2898 * - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen). |
|
2899 * - the standard single phase parser (when preparsing command line option is not chosen). |
|
2900 */ |
2882 identifier ':' array_spec_init {library_element_symtable.insert($1, prev_declared_array_type_name_token);} |
2901 identifier ':' array_spec_init {library_element_symtable.insert($1, prev_declared_array_type_name_token);} |
2883 {if (!get_preparse_state()) ERROR;} |
2902 {if (!get_preparse_state()) new array_type_declaration_c($1, $3, locloc(@$));} |
2884 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
2903 /* POST_PARSING */ |
|
2904 /* These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */ |
2885 | prev_declared_array_type_name ':' array_spec_init |
2905 | prev_declared_array_type_name ':' array_spec_init |
2886 {$$ = new array_type_declaration_c($1, $3, locloc(@$));} |
2906 {$$ = new array_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier! |
2887 /* ERROR_CHECK_BEGIN */ |
2907 /* ERROR_CHECK_BEGIN */ |
2888 | identifier array_spec_init |
2908 | identifier array_spec_init |
2889 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in array type declaration."); yynerrs++;} |
2909 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in array type declaration."); yynerrs++;} |
2890 /* ERROR_CHECK_END */ |
2910 /* ERROR_CHECK_END */ |
2891 ; |
2911 ; |
3032 |
3052 |
3033 |
3053 |
3034 |
3054 |
3035 structure_type_declaration: |
3055 structure_type_declaration: |
3036 /* structure_type_name ':' structure_specification */ |
3056 /* structure_type_name ':' structure_specification */ |
3037 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
3057 /* PRE_PARSING or SINGLE_PHASE_PARSING */ |
|
3058 /* The following rules will be run either by: |
|
3059 * - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen). |
|
3060 * - the standard single phase parser (when preparsing command line option is not chosen). |
|
3061 */ |
3038 identifier ':' structure_specification {library_element_symtable.insert($1, prev_declared_structure_type_name_token);} |
3062 identifier ':' structure_specification {library_element_symtable.insert($1, prev_declared_structure_type_name_token);} |
3039 {if (!get_preparse_state()) ERROR;} |
3063 {if (!get_preparse_state()) $$ = new structure_type_declaration_c($1, $3, locloc(@$));} |
3040 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
3064 /* POST_PARSING */ |
|
3065 /* These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */ |
3041 | prev_declared_structure_type_name ':' structure_specification |
3066 | prev_declared_structure_type_name ':' structure_specification |
3042 {$$ = new structure_type_declaration_c($1, $3, locloc(@$));} |
3067 {$$ = new structure_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier! |
3043 /* ERROR_CHECK_BEGIN */ |
3068 /* ERROR_CHECK_BEGIN */ |
3044 | identifier structure_specification |
3069 | identifier structure_specification |
3045 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in structure type declaration."); yynerrs++;} |
3070 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in structure type declaration."); yynerrs++;} |
3046 /* ERROR_CHECK_END */ |
3071 /* ERROR_CHECK_END */ |
3047 ; |
3072 ; |
3219 string_type_name: identifier; |
3244 string_type_name: identifier; |
3220 */ |
3245 */ |
3221 |
3246 |
3222 string_type_declaration: |
3247 string_type_declaration: |
3223 /* string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */ |
3248 /* string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */ |
3224 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
3249 /* PRE_PARSING or SINGLE_PHASE_PARSING */ |
|
3250 /* The following rules will be run either by: |
|
3251 * - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen). |
|
3252 * - the standard single phase parser (when preparsing command line option is not chosen). |
|
3253 */ |
3225 identifier ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init {library_element_symtable.insert($1, prev_declared_string_type_name_token);} |
3254 identifier ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init {library_element_symtable.insert($1, prev_declared_string_type_name_token);} |
3226 {if (!get_preparse_state()) ERROR;} |
3255 {if (!get_preparse_state()) $$ = new string_type_declaration_c($1, $3, $4, $5, locloc(@$));} |
3227 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
3256 /* POST_PARSING */ |
|
3257 /* These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */ |
3228 | prev_declared_string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init |
3258 | prev_declared_string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init |
3229 {$$ = new string_type_declaration_c($1, $3, $4, $5, locloc(@$));} |
3259 {$$ = new string_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, $4, $5, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier! |
3230 ; |
3260 ; |
3231 |
3261 |
3232 |
3262 |
3233 /* helper symbol for string_type_declaration */ |
3263 /* helper symbol for string_type_declaration */ |
3234 string_type_declaration_size: |
3264 string_type_declaration_size: |
3349 {$$ = new ref_spec_init_c($1, $3, locloc(@$));} |
3379 {$$ = new ref_spec_init_c($1, $3, locloc(@$));} |
3350 */ |
3380 */ |
3351 ; |
3381 ; |
3352 |
3382 |
3353 ref_type_decl: /* defined in IEC 61131-3 v3 */ |
3383 ref_type_decl: /* defined in IEC 61131-3 v3 */ |
3354 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
3384 /* PRE_PARSING or SINGLE_PHASE_PARSING */ |
|
3385 /* The following rules will be run either by: |
|
3386 * - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen). |
|
3387 * - the standard single phase parser (when preparsing command line option is not chosen). |
|
3388 */ |
3355 identifier ':' ref_spec_init {library_element_symtable.insert($1, prev_declared_ref_type_name_token);} |
3389 identifier ':' ref_spec_init {library_element_symtable.insert($1, prev_declared_ref_type_name_token);} |
3356 {if (!get_preparse_state()) ERROR;} |
3390 {if (!get_preparse_state()) $$ = new ref_type_decl_c($1, $3, locloc(@$));} |
3357 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
3391 /* POST_PARSING */ |
|
3392 /* These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */ |
3358 | prev_declared_ref_type_name ':' ref_spec_init |
3393 | prev_declared_ref_type_name ':' ref_spec_init |
3359 {$$ = new ref_type_decl_c($1, $3, locloc(@$));} |
3394 {$$ = new ref_type_decl_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier! |
3360 ; |
3395 ; |
3361 |
|
3362 |
3396 |
3363 |
3397 |
3364 |
3398 |
3365 |
3399 |
3366 |
3400 |