2897 /* The following rules will be run either by: |
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). |
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). |
2899 * - the standard single phase parser (when preparsing command line option is not chosen). |
2900 */ |
2900 */ |
2901 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);} |
2902 {if (!get_preparse_state()) new array_type_declaration_c($1, $3, locloc(@$));} |
2902 {if (!get_preparse_state()) $$ = new array_type_declaration_c($1, $3, locloc(@$));} |
2903 /* POST_PARSING */ |
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). */ |
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). */ |
2905 | prev_declared_array_type_name ':' array_spec_init |
2905 | prev_declared_array_type_name ':' array_spec_init |
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! |
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! |
2907 /* ERROR_CHECK_BEGIN */ |
2907 /* ERROR_CHECK_BEGIN */ |
4931 | function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
4931 | function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
4932 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
4932 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
4933 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
4933 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
4934 variable_name_symtable.pop(); |
4934 variable_name_symtable.pop(); |
4935 direct_variable_symtable.pop(); |
4935 direct_variable_symtable.pop(); |
|
4936 library_element_symtable.insert($1, prev_declared_derived_function_name_token); |
4936 } |
4937 } |
4937 /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
4938 /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
4938 | function_name_declaration ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
4939 | function_name_declaration ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
4939 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
4940 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
4940 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
4941 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
4941 variable_name_symtable.pop(); |
4942 variable_name_symtable.pop(); |
4942 direct_variable_symtable.pop(); |
4943 direct_variable_symtable.pop(); |
|
4944 library_element_symtable.insert($1, prev_declared_derived_function_name_token); |
4943 } |
4945 } |
4944 /* ERROR_CHECK_BEGIN */ |
4946 /* ERROR_CHECK_BEGIN */ |
4945 | function_name_declaration elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
4947 | function_name_declaration elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
4946 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing after function name in function declaration."); yynerrs++;} |
4948 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing after function name in function declaration."); yynerrs++;} |
4947 | function_name_declaration derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
4949 | function_name_declaration derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
5136 |
5138 |
5137 derived_function_block_name: identifier; |
5139 derived_function_block_name: identifier; |
5138 |
5140 |
5139 |
5141 |
5140 function_block_declaration: |
5142 function_block_declaration: |
5141 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
5143 /* PRE_PARSING: The rules expected to be applied by the preparser. Will only run if pre-parsing command line option is ON. */ |
5142 FUNCTION_BLOCK derived_function_block_name END_FUNCTION_BLOCK /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */ |
5144 FUNCTION_BLOCK derived_function_block_name END_FUNCTION_BLOCK /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */ |
5143 {$$ = NULL; |
5145 {$$ = NULL; |
5144 if (get_preparse_state()) {library_element_symtable.insert($2, prev_declared_derived_function_block_name_token);} |
5146 if (get_preparse_state()) {library_element_symtable.insert($2, prev_declared_derived_function_block_name_token);} |
5145 else {print_err_msg(locl(@1), locf(@3), "FUNCTION_BLOCK with no variable declarations and no body."); yynerrs++;} |
5147 else {print_err_msg(locl(@1), locf(@3), "FUNCTION_BLOCK with no variable declarations and no body."); yynerrs++;} |
5146 } |
5148 } |
5147 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
5149 /* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */ |
5148 | FUNCTION_BLOCK prev_declared_derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK |
5150 | FUNCTION_BLOCK prev_declared_derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK |
5149 {$$ = new function_block_declaration_c($2, $3, $4, locloc(@$)); |
5151 {$$ = new function_block_declaration_c($2, $3, $4, locloc(@$)); |
5150 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5152 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5151 /* Clear the variable_name_symtable. Since |
5153 /* Clear the variable_name_symtable. Since we have finished parsing the function block, |
5152 * we have finished parsing the function block, |
5154 * the variable names are now out of scope, so are no longer valid! |
5153 * the variable names are now out of scope, so |
5155 */ |
5154 * are no longer valid! |
5156 variable_name_symtable.pop(); |
|
5157 direct_variable_symtable.pop(); |
|
5158 } |
|
5159 /* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */ |
|
5160 | FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK |
|
5161 {$$ = new function_block_declaration_c($2, $3, $4, locloc(@$)); |
|
5162 library_element_symtable.insert($2, prev_declared_derived_function_block_name_token); |
|
5163 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
|
5164 /* Clear the variable_name_symtable. Since we have finished parsing the function block, |
|
5165 * the variable names are now out of scope, so are no longer valid! |
5155 */ |
5166 */ |
5156 variable_name_symtable.pop(); |
5167 variable_name_symtable.pop(); |
5157 direct_variable_symtable.pop(); |
5168 direct_variable_symtable.pop(); |
5158 } |
5169 } |
5159 /* ERROR_CHECK_BEGIN */ |
5170 /* ERROR_CHECK_BEGIN */ |
5297 /**********************/ |
5308 /**********************/ |
5298 program_type_name: identifier; |
5309 program_type_name: identifier; |
5299 |
5310 |
5300 |
5311 |
5301 program_declaration: |
5312 program_declaration: |
5302 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
5313 /* PRE_PARSING: The rules expected to be applied by the preparser. Will only run if pre-parsing command line option is ON. */ |
5303 PROGRAM program_type_name END_PROGRAM /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */ |
5314 PROGRAM program_type_name END_PROGRAM /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */ |
5304 {$$ = NULL; |
5315 {$$ = NULL; |
5305 if (get_preparse_state()) {library_element_symtable.insert($2, prev_declared_program_type_name_token);} |
5316 if (get_preparse_state()) {library_element_symtable.insert($2, prev_declared_program_type_name_token);} |
5306 else {print_err_msg(locl(@1), locf(@3), "PROGRAM with no variable declarations and no body."); yynerrs++;} |
5317 else {print_err_msg(locl(@1), locf(@3), "PROGRAM with no variable declarations and no body."); yynerrs++;} |
5307 } |
5318 } |
5308 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
5319 /* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */ |
5309 | PROGRAM prev_declared_program_type_name program_var_declarations_list function_block_body END_PROGRAM |
5320 | PROGRAM prev_declared_program_type_name program_var_declarations_list function_block_body END_PROGRAM |
5310 {$$ = new program_declaration_c($2, $3, $4, locloc(@$)); |
5321 {$$ = new program_declaration_c($2, $3, $4, locloc(@$)); |
5311 /* Clear the variable_name_symtable. Since |
5322 /* Clear the variable_name_symtable. Since we have finished parsing the program declaration, |
5312 * we have finished parsing the program declaration, |
5323 * the variable names are now out of scope, so are no longer valid! |
5313 * the variable names are now out of scope, so |
5324 */ |
5314 * are no longer valid! |
5325 variable_name_symtable.pop(); |
|
5326 direct_variable_symtable.pop(); |
|
5327 } |
|
5328 /* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */ |
|
5329 | PROGRAM program_type_name {library_element_symtable.insert($2, prev_declared_program_type_name_token);} program_var_declarations_list function_block_body END_PROGRAM |
|
5330 {$$ = new program_declaration_c($2, $4, $5, locloc(@$)); |
|
5331 /* Clear the variable_name_symtable. Since we have finished parsing the program declaration, |
|
5332 * the variable names are now out of scope, so are no longer valid! |
5315 */ |
5333 */ |
5316 variable_name_symtable.pop(); |
5334 variable_name_symtable.pop(); |
5317 direct_variable_symtable.pop(); |
5335 direct_variable_symtable.pop(); |
5318 } |
5336 } |
5319 /* ERROR_CHECK_BEGIN */ |
5337 /* ERROR_CHECK_BEGIN */ |
5834 * |
5852 * |
5835 */ |
5853 */ |
5836 resource_type_name: any_identifier; |
5854 resource_type_name: any_identifier; |
5837 |
5855 |
5838 configuration_declaration: |
5856 configuration_declaration: |
5839 /* PRE_PARSING: The rules expected to be applied by the preparser. */ |
5857 /* PRE_PARSING: The rules expected to be applied by the preparser. Will only run if pre-parsing command line option is ON. */ |
5840 CONFIGURATION configuration_name END_CONFIGURATION /* rule that is only expected to be used during preparse state */ |
5858 CONFIGURATION configuration_name END_CONFIGURATION /* rule that is only expected to be used during preparse state */ |
5841 {$$ = NULL; |
5859 {$$ = NULL; |
5842 if (get_preparse_state()) {library_element_symtable.insert($2, prev_declared_configuration_name_token);} |
5860 if (get_preparse_state()) {library_element_symtable.insert($2, prev_declared_configuration_name_token);} |
5843 else {print_err_msg(locl(@1), locf(@3), "no resource(s) nor program(s) defined in configuration declaration."); yynerrs++;} |
5861 else {print_err_msg(locl(@1), locf(@3), "no resource(s) nor program(s) defined in configuration declaration."); yynerrs++;} |
5844 } |
5862 } |
5845 /* STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
5863 /* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */ |
5846 | CONFIGURATION prev_declared_configuration_name |
5864 | CONFIGURATION prev_declared_configuration_name |
5847 global_var_declarations_list |
5865 global_var_declarations_list |
5848 single_resource_declaration |
5866 single_resource_declaration |
5849 {variable_name_symtable.pop(); |
5867 {variable_name_symtable.pop(); |
5850 direct_variable_symtable.pop();} |
5868 direct_variable_symtable.pop();} |
5862 optional_instance_specific_initializations |
5880 optional_instance_specific_initializations |
5863 END_CONFIGURATION |
5881 END_CONFIGURATION |
5864 {$$ = new configuration_declaration_c($2, $3, $4, $5, $6, locloc(@$)); |
5882 {$$ = new configuration_declaration_c($2, $3, $4, $5, $6, locloc(@$)); |
5865 variable_name_symtable.pop(); |
5883 variable_name_symtable.pop(); |
5866 direct_variable_symtable.pop(); |
5884 direct_variable_symtable.pop(); |
|
5885 } |
|
5886 /* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */ |
|
5887 | CONFIGURATION configuration_name |
|
5888 global_var_declarations_list |
|
5889 single_resource_declaration |
|
5890 {variable_name_symtable.pop(); |
|
5891 direct_variable_symtable.pop();} |
|
5892 optional_access_declarations |
|
5893 optional_instance_specific_initializations |
|
5894 END_CONFIGURATION |
|
5895 {$$ = new configuration_declaration_c($2, $3, $4, $6, $7, locloc(@$)); |
|
5896 variable_name_symtable.pop(); |
|
5897 direct_variable_symtable.pop(); |
|
5898 library_element_symtable.insert($2, prev_declared_configuration_name_token); |
|
5899 } |
|
5900 | CONFIGURATION configuration_name |
|
5901 global_var_declarations_list |
|
5902 resource_declaration_list |
|
5903 optional_access_declarations |
|
5904 optional_instance_specific_initializations |
|
5905 END_CONFIGURATION |
|
5906 {$$ = new configuration_declaration_c($2, $3, $4, $5, $6, locloc(@$)); |
|
5907 variable_name_symtable.pop(); |
|
5908 direct_variable_symtable.pop(); |
|
5909 library_element_symtable.insert($2, prev_declared_configuration_name_token); |
5867 } |
5910 } |
5868 /* ERROR_CHECK_BEGIN */ |
5911 /* ERROR_CHECK_BEGIN */ |
5869 | CONFIGURATION |
5912 | CONFIGURATION |
5870 global_var_declarations_list |
5913 global_var_declarations_list |
5871 single_resource_declaration |
5914 single_resource_declaration |
8582 full_token_loc = runtime_options.full_token_loc; |
8625 full_token_loc = runtime_options.full_token_loc; |
8583 conversion_functions = runtime_options.conversion_functions; |
8626 conversion_functions = runtime_options.conversion_functions; |
8584 allow_ref_dereferencing = runtime_options.ref_standard_extensions; |
8627 allow_ref_dereferencing = runtime_options.ref_standard_extensions; |
8585 allow_ref_to_any = runtime_options.ref_nonstand_extensions; |
8628 allow_ref_to_any = runtime_options.ref_nonstand_extensions; |
8586 allow_ref_to_in_derived_datatypes = runtime_options.ref_nonstand_extensions; |
8629 allow_ref_to_in_derived_datatypes = runtime_options.ref_nonstand_extensions; |
8587 if (yyparse() != 0) ERROR; |
8630 if (yyparse() != 0) { |
|
8631 fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors in standard library. Bailing out!\n"); |
|
8632 exit(EXIT_FAILURE); |
|
8633 } |
8588 fclose(libfile); |
8634 fclose(libfile); |
8589 |
8635 |
8590 if (yynerrs > 0) { /* NOTE: yynerrs is a global variable */ |
8636 if (yynerrs > 0) { /* NOTE: yynerrs is a global variable */ |
8591 /* Hopefully the libraries do not contain any errors, so this should not occur! */ |
8637 /* Hopefully the libraries do not contain any errors, so this should not occur! */ |
8592 fprintf (stderr, "\n%d error(s) found in %s. Bailing out!\n", yynerrs, libfilename); |
8638 fprintf (stderr, "\n%d error(s) found in %s. Bailing out!\n", yynerrs, libfilename); |