equal
deleted
inserted
replaced
205 |
205 |
206 /* A global flag used to tell the parser whether to generate conversion function |
206 /* A global flag used to tell the parser whether to generate conversion function |
207 * for enumerated data types. |
207 * for enumerated data types. |
208 */ |
208 */ |
209 extern bool conversion_functions_; |
209 extern bool conversion_functions_; |
|
210 |
|
211 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */ |
|
212 extern bool allow_ref_to_any; |
210 |
213 |
211 /* A pointer to the root of the parsing tree that will be generated |
214 /* A pointer to the root of the parsing tree that will be generated |
212 * by bison. |
215 * by bison. |
213 */ |
216 */ |
214 extern symbol_c *tree_root; |
217 extern symbol_c *tree_root; |
3221 REF_TO non_generic_type_name |
3224 REF_TO non_generic_type_name |
3222 {$$ = new ref_spec_c($2, locloc(@$));} |
3225 {$$ = new ref_spec_c($2, locloc(@$));} |
3223 | REF_TO function_block_type_name |
3226 | REF_TO function_block_type_name |
3224 {$$ = new ref_spec_c($2, locloc(@$));} |
3227 {$$ = new ref_spec_c($2, locloc(@$));} |
3225 | REF_TO ANY |
3228 | REF_TO ANY |
3226 {$$ = new ref_spec_c(new generic_type_any_c(locloc(@2)), locloc(@$));} |
3229 {$$ = new ref_spec_c(new generic_type_any_c(locloc(@2)), locloc(@$)); |
|
3230 if (!allow_ref_to_any) { |
|
3231 print_err_msg(locf(@$), locl(@$), "REF_TO ANY datatypes are not allowed (use -R option to activate support for this non-standard syntax)."); |
|
3232 yynerrs++; |
|
3233 } |
|
3234 } |
3227 /* The following line is actually not included in IEC 61131-3, but we add it anyway otherwise it will not be possible to |
3235 /* The following line is actually not included in IEC 61131-3, but we add it anyway otherwise it will not be possible to |
3228 * define a REF_TO datatype as an alias to an already previously declared REF_TO datatype. |
3236 * define a REF_TO datatype as an alias to an already previously declared REF_TO datatype. |
3229 * For example: |
3237 * For example: |
3230 * TYPE |
3238 * TYPE |
3231 * ref1: REF_TO INT; |
3239 * ref1: REF_TO INT; |
8154 /* A global flag used to tell the parser whether to include the full variable location |
8162 /* A global flag used to tell the parser whether to include the full variable location |
8155 * when printing out error messages... |
8163 * when printing out error messages... |
8156 */ |
8164 */ |
8157 bool full_token_loc; |
8165 bool full_token_loc; |
8158 |
8166 |
|
8167 /* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */ |
|
8168 bool allow_ref_to_any = false; |
|
8169 |
8159 /* A pointer to the root of the parsing tree that will be generated |
8170 /* A pointer to the root of the parsing tree that will be generated |
8160 * by bison. |
8171 * by bison. |
8161 */ |
8172 */ |
8162 symbol_c *tree_root; |
8173 symbol_c *tree_root; |
8163 |
8174 |
8381 |
8392 |
8382 |
8393 |
8383 int stage2__(const char *filename, |
8394 int stage2__(const char *filename, |
8384 const char *includedir, /* Include directory, where included files will be searched for... */ |
8395 const char *includedir, /* Include directory, where included files will be searched for... */ |
8385 symbol_c **tree_root_ref, |
8396 symbol_c **tree_root_ref, |
8386 bool full_token_loc_ /* error messages specify full token location */ |
8397 bool full_token_loc_, /* error messages specify full token location */ |
|
8398 bool ref_to_any_ /* allow use of non-standard REF_TO ANY datatypes */ |
8387 ) { |
8399 ) { |
8388 char *libfilename = NULL; |
8400 char *libfilename = NULL; |
8389 |
8401 |
8390 if (includedir != NULL) { |
8402 if (includedir != NULL) { |
8391 INCLUDE_DIRECTORIES[0] = includedir; |
8403 INCLUDE_DIRECTORIES[0] = includedir; |
8411 free(errmsg); |
8423 free(errmsg); |
8412 /* we give up... */ |
8424 /* we give up... */ |
8413 return -1; |
8425 return -1; |
8414 } |
8426 } |
8415 |
8427 |
8416 allow_function_overloading = true; |
8428 allow_function_overloading = true; |
8417 allow_extensible_function_parameters = true; |
8429 allow_extensible_function_parameters = true; |
8418 full_token_loc = full_token_loc_; |
8430 full_token_loc = full_token_loc_; |
|
8431 allow_ref_to_any = ref_to_any_; |
8419 if (yyparse() != 0) |
8432 if (yyparse() != 0) |
8420 ERROR; |
8433 ERROR; |
8421 fclose(libfile); |
8434 fclose(libfile); |
8422 |
8435 |
8423 if (yynerrs > 0) { |
8436 if (yynerrs > 0) { |
8444 perror(errmsg); |
8457 perror(errmsg); |
8445 free(errmsg); |
8458 free(errmsg); |
8446 return -1; |
8459 return -1; |
8447 } |
8460 } |
8448 |
8461 |
8449 allow_function_overloading = false; |
8462 allow_function_overloading = false; |
8450 allow_extensible_function_parameters = false; |
8463 allow_extensible_function_parameters = false; |
8451 full_token_loc = full_token_loc_; |
8464 full_token_loc = full_token_loc_; |
|
8465 allow_ref_to_any = ref_to_any_; |
|
8466 //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 */ |
8452 |
8467 |
8453 if (yyparse() != 0) { |
8468 if (yyparse() != 0) { |
8454 fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n"); |
8469 fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n"); |
8455 exit(EXIT_FAILURE); |
8470 exit(EXIT_FAILURE); |
8456 } |
8471 } |