equal
deleted
inserted
replaced
200 |
200 |
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 |
206 |
207 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */ |
207 /* 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; |
|
209 |
|
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) */ |
208 extern bool allow_ref_to_any; |
211 extern bool allow_ref_to_any; |
209 |
212 |
210 /* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */ |
213 /* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */ |
211 extern bool allow_ref_to_in_derived_datatypes; |
214 extern bool allow_ref_to_in_derived_datatypes; |
212 |
215 |
2550 structure_type_name: identifier; |
2553 structure_type_name: identifier; |
2551 */ |
2554 */ |
2552 |
2555 |
2553 data_type_declaration: |
2556 data_type_declaration: |
2554 TYPE type_declaration_list END_TYPE |
2557 TYPE type_declaration_list END_TYPE |
2555 {$$ = new data_type_declaration_c($2, locloc(@$)); if (conversion_functions_) include_string((create_enumtype_conversion_functions_c::get_declaration($$)).c_str());} |
2558 {$$ = new data_type_declaration_c($2, locloc(@$)); if (conversion_functions) include_string((create_enumtype_conversion_functions_c::get_declaration($$)).c_str());} |
2556 /* ERROR_CHECK_BEGIN */ |
2559 /* ERROR_CHECK_BEGIN */ |
2557 | TYPE END_TYPE |
2560 | TYPE END_TYPE |
2558 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no data type declared in data type(s) declaration."); yynerrs++;} |
2561 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no data type declared in data type(s) declaration."); yynerrs++;} |
2559 | TYPE error type_declaration_list END_TYPE |
2562 | TYPE error type_declaration_list END_TYPE |
2560 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'TYPE' in data type(s) declaration."); yyerrok;} |
2563 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'TYPE' in data type(s) declaration."); yyerrok;} |
3401 | identifier |
3404 | identifier |
3402 {$$ = new symbolic_variable_c($1, locloc(@$));} |
3405 {$$ = new symbolic_variable_c($1, locloc(@$));} |
3403 */ |
3406 */ |
3404 | symbolic_variable '^' |
3407 | symbolic_variable '^' |
3405 /* Dereferencing operator defined in IEC 61131-3 v3. However, implemented here differently then how it is defined in the standard! See following note for explanation! */ |
3408 /* Dereferencing operator defined in IEC 61131-3 v3. However, implemented here differently then how it is defined in the standard! See following note for explanation! */ |
3406 {$$ = new deref_expression_c($1, locloc(@$));} |
3409 {$$ = new deref_expression_c($1, locloc(@$)); |
|
3410 if (!allow_ref_dereferencing) { |
|
3411 print_err_msg(locf(@$), locl(@$), "Derefencing REF_TO datatypes with '^' is not allowed (use -r option to activate support for this IEC 61131-3 v3 feature)."); |
|
3412 yynerrs++; |
|
3413 } |
|
3414 } |
3407 ; |
3415 ; |
3408 /* |
3416 /* |
3409 * NOTE: The syntax defined in the v3 standard for the dereferencing operator '^' seems to me to be un-intentionally |
3417 * NOTE: The syntax defined in the v3 standard for the dereferencing operator '^' seems to me to be un-intentionally |
3410 * limited. For example |
3418 * limited. For example |
3411 * ref_to_bool_var := REF( array_of_bool [1] ); <--- Allowed! |
3419 * ref_to_bool_var := REF( array_of_bool [1] ); <--- Allowed! |
8246 */ |
8254 */ |
8247 bool allow_extensible_function_parameters = false; |
8255 bool allow_extensible_function_parameters = false; |
8248 |
8256 |
8249 /* A global flag indicating whether to include the full variable location when printing out error messages... */ |
8257 /* A global flag indicating whether to include the full variable location when printing out error messages... */ |
8250 bool full_token_loc; |
8258 bool full_token_loc; |
|
8259 /* A global flag used to tell the parser whether to generate conversion function for enumerated data types. */ |
|
8260 bool conversion_functions = false; |
|
8261 /* A global flag used to tell the parser whether to allow use of DREF and '^' operators (defined in IEC 61131-3 v3) */ |
|
8262 bool allow_ref_dereferencing; |
8251 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */ |
8263 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */ |
8252 bool allow_ref_to_any = false; |
8264 bool allow_ref_to_any = false; |
8253 /* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */ |
8265 /* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */ |
8254 bool allow_ref_to_in_derived_datatypes = false; |
8266 bool allow_ref_to_in_derived_datatypes = false; |
8255 |
8267 |
8472 #define DEF_LIBFILENAME LIBDIRECTORY "/" LIBFILE |
8484 #define DEF_LIBFILENAME LIBDIRECTORY "/" LIBFILE |
8473 |
8485 |
8474 extern const char *INCLUDE_DIRECTORIES[]; |
8486 extern const char *INCLUDE_DIRECTORIES[]; |
8475 |
8487 |
8476 |
8488 |
8477 |
|
8478 int stage2__(const char *filename, |
8489 int stage2__(const char *filename, |
8479 const char *includedir, /* Include directory, where included files will be searched for... */ |
|
8480 symbol_c **tree_root_ref, |
8490 symbol_c **tree_root_ref, |
8481 bool full_token_loc_, /* error messages specify full token location */ |
8491 stage1_2_options_t options |
8482 bool allow_ref_to_nonstandard_extensions_ /* allow use of non-standard REF_TO ANY datatypes, and REF_TO inside structs and arrays */ |
8492 ) { |
8483 ) { |
|
8484 char *libfilename = NULL; |
8493 char *libfilename = NULL; |
8485 |
8494 |
8486 if (includedir != NULL) { |
8495 if (options.includedir != NULL) { |
8487 INCLUDE_DIRECTORIES[0] = includedir; |
8496 INCLUDE_DIRECTORIES[0] = options.includedir; |
8488 } |
8497 } |
8489 |
8498 |
8490 /* first parse the standard library file... */ |
8499 /* first parse the standard library file... */ |
8491 /* Do not debug the standard library, even if debug flag is set! */ |
8500 /* Do not debug the standard library, even if debug flag is set! */ |
8492 /* |
8501 /* |
8509 return -1; |
8518 return -1; |
8510 } |
8519 } |
8511 |
8520 |
8512 allow_function_overloading = true; |
8521 allow_function_overloading = true; |
8513 allow_extensible_function_parameters = true; |
8522 allow_extensible_function_parameters = true; |
8514 full_token_loc = full_token_loc_; |
8523 full_token_loc = options.full_token_loc; |
8515 allow_ref_to_any = allow_ref_to_nonstandard_extensions_; |
8524 conversion_functions = options.conversion_functions; |
8516 allow_ref_to_in_derived_datatypes = allow_ref_to_nonstandard_extensions_; |
8525 allow_ref_dereferencing = options.ref_standard_extensions; |
|
8526 allow_ref_to_any = options.ref_nonstand_extensions; |
|
8527 allow_ref_to_in_derived_datatypes = options.ref_nonstand_extensions; |
8517 if (yyparse() != 0) |
8528 if (yyparse() != 0) |
8518 ERROR; |
8529 ERROR; |
8519 fclose(libfile); |
8530 fclose(libfile); |
8520 |
8531 |
8521 if (yynerrs > 0) { |
8532 if (yynerrs > 0) { |
8544 return -1; |
8555 return -1; |
8545 } |
8556 } |
8546 |
8557 |
8547 allow_function_overloading = false; |
8558 allow_function_overloading = false; |
8548 allow_extensible_function_parameters = false; |
8559 allow_extensible_function_parameters = false; |
8549 full_token_loc = full_token_loc_; |
8560 full_token_loc = options.full_token_loc; |
8550 allow_ref_to_any = allow_ref_to_nonstandard_extensions_; |
8561 conversion_functions = options.conversion_functions; |
8551 allow_ref_to_in_derived_datatypes = allow_ref_to_nonstandard_extensions_; |
8562 allow_ref_dereferencing = options.ref_standard_extensions; |
|
8563 allow_ref_to_any = options.ref_nonstand_extensions; |
|
8564 allow_ref_to_in_derived_datatypes = options.ref_nonstand_extensions; |
8552 //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 */ |
8565 //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 */ |
8553 |
8566 |
8554 if (yyparse() != 0) { |
8567 if (yyparse() != 0) { |
8555 fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n"); |
8568 fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n"); |
8556 exit(EXIT_FAILURE); |
8569 exit(EXIT_FAILURE); |