5287 free(il_operator); |
5287 free(il_operator); |
5288 return new identifier_c(strdup(name)); |
5288 return new identifier_c(strdup(name)); |
5289 } |
5289 } |
5290 |
5290 |
5291 |
5291 |
5292 |
5292 #include "standard_function_names.c" |
5293 |
|
5294 const char *standard_function_names[] = { |
|
5295 // 2.5.1.5.1 Type conversion functions |
|
5296 /* |
|
5297 *_TO_** |
|
5298 TRUNC |
|
5299 *_BCD_TO_** |
|
5300 **_TO_BCD_* |
|
5301 (REAL or LREAL to SINT, INT, DINT or LINT) |
|
5302 */ |
|
5303 "TRUNC", |
|
5304 "TIME_TO_REAL", |
|
5305 // 2.5.1.5.2 Numerical functions |
|
5306 // Table 23 - Standard functions of one numeric variable |
|
5307 "ABS","SQRT","LN","LOG","EXP","SIN","COS","TAN","ASIN","ACOS","ATAN", |
|
5308 // Table 24 - Standard arithmetic functions |
|
5309 "ADD","MUL","SUB","DIV","MOD"/* See note (a) */,"EXPT","MOVE", |
|
5310 // 2.5.1.5.3 Bit string functions |
|
5311 // Table 25 - Standard bit shift functions |
|
5312 "SHL","SHR","ROR","ROL", |
|
5313 // 2.5.1.5.4 Selection and comparison functions |
|
5314 // Table 26 - Standard bitwise Boolean functions |
|
5315 "AND","OR","XOR","NOT", |
|
5316 // Table 27 - Standard selection functions |
|
5317 "SEL","MAX","MIN","LIMIT","MUX", |
|
5318 // Table 28 - Standard comparison functions |
|
5319 "GT","GE","EQ","LE","LT","NE", |
|
5320 // 2.5.1.5.5 Character string functions |
|
5321 // Table 29 - Standard character string functions |
|
5322 "LEN","LEFT","RIGHT","MID","CONCAT","INSERT","DELETE","REPLACE","FIND", |
|
5323 // 2.5.1.5.6 Functions of time data types |
|
5324 // Table 30 - Functions of time data types |
|
5325 "ADD_TIME","ADD_TOD_TIME","ADD_DT_TIME","SUB_TIME","SUB_DATE_DATE", |
|
5326 "SUB_TOD_TIME","SUB_TOD_TOD","SUB_DT_TIME","SUB_DT_DT","MULTIME", |
|
5327 "DIVTIME","CONCAT_DATE_TOD", |
|
5328 // 2.5.1.5.7 Functions of enumerated data types |
|
5329 // Table 31 - Functions of enumerated data types |
|
5330 // "SEL", /* already above! We cannot have duplicates! */ |
|
5331 // "MUX", /* already above! We cannot have duplicates! */ |
|
5332 // "EQ", /* already above! We cannot have duplicates! */ |
|
5333 // "NE", /* already above! We cannot have duplicates! */ |
|
5334 |
|
5335 /* end of array marker! Do not remove! */ |
|
5336 NULL |
|
5337 |
|
5338 /* Note (a): |
|
5339 * This function has a name equal to a reserved keyword. |
|
5340 * This means that adding it here is irrelevant because the |
|
5341 * lexical parser will consider it the XXX token before |
|
5342 * it interprets it as an identifier and looks it up |
|
5343 * in the library elements symbol table. |
|
5344 */ |
|
5345 }; |
|
5346 |
|
5347 |
|
5348 |
|
5349 |
5293 |
5350 const char *standard_function_block_names[] = { |
5294 const char *standard_function_block_names[] = { |
5351 // 2.5.2.3.1 Bistable elements |
5295 // 2.5.2.3.1 Bistable elements |
5352 // Table 34 - Standard bistable function blocks |
5296 // Table 34 - Standard bistable function blocks |
5353 //"SR","RS", |
5297 //"SR","RS", |
5368 |
5312 |
5369 |
5313 |
5370 #define LIBFILE "ieclib.txt" |
5314 #define LIBFILE "ieclib.txt" |
5371 #define DEF_LIBFILENAME LIBDIRECTORY "/" LIBFILE |
5315 #define DEF_LIBFILENAME LIBDIRECTORY "/" LIBFILE |
5372 |
5316 |
|
5317 extern const char *INCLUDE_DIRECTORIES[]; |
|
5318 |
5373 int stage1_2__(const char *filename, const char *includedir, symbol_c **tree_root_ref) { |
5319 int stage1_2__(const char *filename, const char *includedir, symbol_c **tree_root_ref) { |
5374 FILE *in_file = NULL, *lib_file = NULL; |
5320 FILE *in_file = NULL, *lib_file = NULL; |
5375 char *libfilename = NULL; |
5321 char *libfilename = NULL; |
5376 |
5322 |
5377 if((in_file = fopen(filename, "r")) == NULL) { |
5323 if((in_file = fopen(filename, "r")) == NULL) { |
5380 free(errmsg); |
5326 free(errmsg); |
5381 return -1; |
5327 return -1; |
5382 } |
5328 } |
5383 |
5329 |
5384 if (includedir != NULL) { |
5330 if (includedir != NULL) { |
5385 if ((libfilename = strdup3(includedir, "/", LIBFILE)) == NULL) { |
5331 INCLUDE_DIRECTORIES[0] = includedir; |
5386 fprintf (stderr, "Out of memory. Bailing out!\n"); |
|
5387 return -1; |
|
5388 } |
|
5389 |
|
5390 if((lib_file = fopen(libfilename, "r")) == NULL) { |
|
5391 char *errmsg = strdup2("Error opening library file ", libfilename); |
|
5392 perror(errmsg); |
|
5393 free(errmsg); |
|
5394 } |
|
5395 } |
5332 } |
5396 |
5333 if ((libfilename = strdup3(INCLUDE_DIRECTORIES[0], "/", LIBFILE)) == NULL) { |
5397 if (lib_file == NULL) { |
5334 fprintf (stderr, "Out of memory. Bailing out!\n"); |
5398 /* we try again... */ |
5335 return -1; |
5399 if ((libfilename = strdup(DEF_LIBFILENAME)) == NULL) { |
5336 } |
5400 fprintf (stderr, "Out of memory. Bailing out!\n"); |
5337 |
5401 return -1; |
5338 if((lib_file = fopen(libfilename, "r")) == NULL) { |
5402 } |
5339 char *errmsg = strdup2("Error opening library file ", libfilename); |
5403 |
5340 perror(errmsg); |
5404 if((lib_file = fopen(libfilename, "r")) == NULL) { |
5341 free(errmsg); |
5405 char *errmsg = strdup2("Error opening library file ", libfilename); |
|
5406 perror(errmsg); |
|
5407 free(errmsg); |
|
5408 } |
|
5409 } |
5342 } |
5410 |
5343 |
5411 if (lib_file == NULL) { |
5344 if (lib_file == NULL) { |
5412 /* we give up... */ |
5345 /* we give up... */ |
5413 free(libfilename); |
5346 free(libfilename); |