equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * matiec - a compiler for the programming languages defined in IEC 61131-3 |
2 * matiec - a compiler for the programming languages defined in IEC 61131-3 |
3 * |
3 * |
4 * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
4 * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
|
5 * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
5 * |
6 * |
6 * This program is free software: you can redistribute it and/or modify |
7 * This program is free software: you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by |
8 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation, either version 3 of the License, or |
9 * the Free Software Foundation, either version 3 of the License, or |
9 * (at your option) any later version. |
10 * (at your option) any later version. |
7969 ) { |
7970 ) { |
7970 |
7971 |
7971 FILE *in_file = NULL, *lib_file = NULL; |
7972 FILE *in_file = NULL, *lib_file = NULL; |
7972 char *libfilename = NULL; |
7973 char *libfilename = NULL; |
7973 |
7974 |
|
7975 for(int i = 0; standard_function_names[i] != NULL; i++) |
|
7976 if (library_element_symtable.find_value(standard_function_names[i]) == |
|
7977 library_element_symtable.end_value()) |
|
7978 library_element_symtable.insert(standard_function_names[i], standard_function_name_token); |
|
7979 |
7974 if((in_file = fopen(filename, "r")) == NULL) { |
7980 if((in_file = fopen(filename, "r")) == NULL) { |
7975 char *errmsg = strdup2("Error opening main file ", filename); |
7981 char *errmsg = strdup2("Error opening main file ", filename); |
7976 perror(errmsg); |
7982 perror(errmsg); |
7977 free(errmsg); |
7983 free(errmsg); |
7978 return -1; |
7984 return -1; |
8021 fclose(lib_file); |
8027 fclose(lib_file); |
8022 |
8028 |
8023 /* if by any chance the library is not complete, we |
8029 /* if by any chance the library is not complete, we |
8024 * now add the missing reserved keywords to the list!!! |
8030 * now add the missing reserved keywords to the list!!! |
8025 */ |
8031 */ |
8026 for(int i = 0; standard_function_names[i] != NULL; i++) |
|
8027 if (library_element_symtable.find_value(standard_function_names[i]) == |
|
8028 library_element_symtable.end_value()) |
|
8029 library_element_symtable.insert(standard_function_names[i], standard_function_name_token); |
|
8030 |
|
8031 for(int i = 0; standard_function_block_names[i] != NULL; i++) |
8032 for(int i = 0; standard_function_block_names[i] != NULL; i++) |
8032 if (library_element_symtable.find_value(standard_function_block_names[i]) == |
8033 if (library_element_symtable.find_value(standard_function_block_names[i]) == |
8033 library_element_symtable.end_value()) |
8034 library_element_symtable.end_value()) |
8034 library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token); |
8035 library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token); |
8035 |
8036 |