201 /* A global flag used to tell the parser whether to include the full variable location when printing out error messages... */ |
201 /* A global flag used to tell the parser whether to include the full variable location when printing out error messages... */ |
202 extern bool full_token_loc; |
202 extern bool full_token_loc; |
203 |
203 |
204 /* A global flag used to tell the parser whether to generate conversion function for enumerated data types. */ |
204 /* A global flag used to tell the parser whether to generate conversion function for enumerated data types. */ |
205 extern bool conversion_functions; |
205 extern bool conversion_functions; |
|
206 |
|
207 /* A global flag used to tell the parser whether to disable generation of implicit EN and ENO parameters. */ |
|
208 extern bool disable_implicit_en_eno; |
206 |
209 |
207 /* A global flag used to tell the parser whether to allow use of DREF and '^' operators (defined in IEC 61131-3 v3) */ |
210 /* A global flag used to tell the parser whether to allow use of DREF and '^' operators (defined in IEC 61131-3 v3) */ |
208 extern bool allow_ref_dereferencing; |
211 extern bool allow_ref_dereferencing; |
209 |
212 |
210 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension to IEC 61131-3 v3) */ |
213 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension to IEC 61131-3 v3) */ |
4999 else {print_err_msg(locl(@1), locf(@3), "FUNCTION with no variable declarations and no body."); yynerrs++;} |
5002 else {print_err_msg(locl(@1), locf(@3), "FUNCTION with no variable declarations and no body."); yynerrs++;} |
5000 } |
5003 } |
5001 /* POST_PARSING and STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
5004 /* POST_PARSING and STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */ |
5002 | function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
5005 | function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
5003 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
5006 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
5004 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5007 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5005 variable_name_symtable.pop(); |
5008 variable_name_symtable.pop(); |
5006 direct_variable_symtable.pop(); |
5009 direct_variable_symtable.pop(); |
5007 library_element_symtable.insert($1, prev_declared_derived_function_name_token); |
5010 library_element_symtable.insert($1, prev_declared_derived_function_name_token); |
5008 } |
5011 } |
5009 /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
5012 /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
5010 | function_name_declaration ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
5013 | function_name_declaration ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION |
5011 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
5014 {$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$)); |
5012 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5015 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5013 variable_name_symtable.pop(); |
5016 variable_name_symtable.pop(); |
5014 direct_variable_symtable.pop(); |
5017 direct_variable_symtable.pop(); |
5015 library_element_symtable.insert($1, prev_declared_derived_function_name_token); |
5018 library_element_symtable.insert($1, prev_declared_derived_function_name_token); |
5016 } |
5019 } |
5017 /* ERROR_CHECK_BEGIN */ |
5020 /* ERROR_CHECK_BEGIN */ |
5218 else {print_err_msg(locl(@1), locf(@3), "FUNCTION_BLOCK with no variable declarations and no body."); yynerrs++;} |
5221 else {print_err_msg(locl(@1), locf(@3), "FUNCTION_BLOCK with no variable declarations and no body."); yynerrs++;} |
5219 } |
5222 } |
5220 /* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */ |
5223 /* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */ |
5221 | FUNCTION_BLOCK prev_declared_derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK |
5224 | FUNCTION_BLOCK prev_declared_derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK |
5222 {$$ = new function_block_declaration_c($2, $3, $4, locloc(@$)); |
5225 {$$ = new function_block_declaration_c($2, $3, $4, locloc(@$)); |
5223 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5226 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5224 /* Clear the variable_name_symtable. Since we have finished parsing the function block, |
5227 /* Clear the variable_name_symtable. Since we have finished parsing the function block, |
5225 * the variable names are now out of scope, so are no longer valid! |
5228 * the variable names are now out of scope, so are no longer valid! |
5226 */ |
5229 */ |
5227 variable_name_symtable.pop(); |
5230 variable_name_symtable.pop(); |
5228 direct_variable_symtable.pop(); |
5231 direct_variable_symtable.pop(); |
5229 } |
5232 } |
5230 /* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */ |
5233 /* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */ |
5231 | FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK |
5234 | FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK |
5232 {$$ = new function_block_declaration_c($2, $3, $4, locloc(@$)); |
5235 {$$ = new function_block_declaration_c($2, $3, $4, locloc(@$)); |
5233 library_element_symtable.insert($2, prev_declared_derived_function_block_name_token); |
5236 library_element_symtable.insert($2, prev_declared_derived_function_block_name_token); |
5234 add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5237 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */ |
5235 /* Clear the variable_name_symtable. Since we have finished parsing the function block, |
5238 /* Clear the variable_name_symtable. Since we have finished parsing the function block, |
5236 * the variable names are now out of scope, so are no longer valid! |
5239 * the variable names are now out of scope, so are no longer valid! |
5237 */ |
5240 */ |
5238 variable_name_symtable.pop(); |
5241 variable_name_symtable.pop(); |
5239 direct_variable_symtable.pop(); |
5242 direct_variable_symtable.pop(); |
8445 |
8448 |
8446 /* A global flag indicating whether to include the full variable location when printing out error messages... */ |
8449 /* A global flag indicating whether to include the full variable location when printing out error messages... */ |
8447 bool full_token_loc; |
8450 bool full_token_loc; |
8448 /* A global flag used to tell the parser whether to generate conversion function for enumerated data types. */ |
8451 /* A global flag used to tell the parser whether to generate conversion function for enumerated data types. */ |
8449 bool conversion_functions = false; |
8452 bool conversion_functions = false; |
|
8453 /* A global flag used to tell the parser whether to disable generation of implicit EN and ENO parameters. */ |
|
8454 bool disable_implicit_en_eno; |
8450 /* A global flag used to tell the parser whether to allow use of DREF and '^' operators (defined in IEC 61131-3 v3) */ |
8455 /* A global flag used to tell the parser whether to allow use of DREF and '^' operators (defined in IEC 61131-3 v3) */ |
8451 bool allow_ref_dereferencing; |
8456 bool allow_ref_dereferencing; |
8452 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */ |
8457 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */ |
8453 bool allow_ref_to_any = false; |
8458 bool allow_ref_to_any = false; |
8454 /* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */ |
8459 /* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */ |
8708 |
8713 |
8709 allow_function_overloading = true; |
8714 allow_function_overloading = true; |
8710 allow_extensible_function_parameters = true; |
8715 allow_extensible_function_parameters = true; |
8711 full_token_loc = runtime_options.full_token_loc; |
8716 full_token_loc = runtime_options.full_token_loc; |
8712 conversion_functions = runtime_options.conversion_functions; |
8717 conversion_functions = runtime_options.conversion_functions; |
|
8718 disable_implicit_en_eno = runtime_options.disable_implicit_en_eno; |
8713 allow_ref_dereferencing = runtime_options.ref_standard_extensions; |
8719 allow_ref_dereferencing = runtime_options.ref_standard_extensions; |
8714 allow_ref_to_any = runtime_options.ref_nonstand_extensions; |
8720 allow_ref_to_any = runtime_options.ref_nonstand_extensions; |
8715 allow_ref_to_in_derived_datatypes = runtime_options.ref_nonstand_extensions; |
8721 allow_ref_to_in_derived_datatypes = runtime_options.ref_nonstand_extensions; |
8716 if (yyparse() != 0) { |
8722 if (yyparse() != 0) { |
8717 fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors in standard library. Bailing out!\n"); |
8723 fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors in standard library. Bailing out!\n"); |
8745 |
8751 |
8746 allow_function_overloading = false; |
8752 allow_function_overloading = false; |
8747 allow_extensible_function_parameters = false; |
8753 allow_extensible_function_parameters = false; |
8748 full_token_loc = runtime_options.full_token_loc; |
8754 full_token_loc = runtime_options.full_token_loc; |
8749 conversion_functions = runtime_options.conversion_functions; |
8755 conversion_functions = runtime_options.conversion_functions; |
|
8756 disable_implicit_en_eno = runtime_options.disable_implicit_en_eno; |
8750 allow_ref_dereferencing = runtime_options.ref_standard_extensions; |
8757 allow_ref_dereferencing = runtime_options.ref_standard_extensions; |
8751 allow_ref_to_any = runtime_options.ref_nonstand_extensions; |
8758 allow_ref_to_any = runtime_options.ref_nonstand_extensions; |
8752 allow_ref_to_in_derived_datatypes = runtime_options.ref_nonstand_extensions; |
8759 allow_ref_to_in_derived_datatypes = runtime_options.ref_nonstand_extensions; |
8753 //allow_ref_to_any = false; /* we only allow REF_TO ANY in library functions/FBs, no matter what the user asks for in the command line */ |
8760 //allow_ref_to_any = false; /* we only allow REF_TO ANY in library functions/FBs, no matter what the user asks for in the command line */ |
8754 |
8761 |