--- a/stage1_2/iec_bison.yy Tue Nov 27 14:49:08 2012 +0000
+++ b/stage1_2/iec_bison.yy Tue Nov 27 15:49:05 2012 +0000
@@ -7971,11 +7971,6 @@
#include <errno.h>
#include "../util/symtable.hh"
-/* variables defined in code generated by flex... */
-extern FILE *yyin;
-extern int yylineno;
-extern tracking_t* current_tracking;
-
@@ -8102,7 +8097,6 @@
}
//fprintf(stderr, "error %d: %s\n", yynerrs /* a global variable */, additional_error_msg);
print_include_stack();
- //fprintf(stderr, "%s(%d-%d): %s\n", current_filename, first_line, last_line, current_error_msg);
}
@@ -8253,36 +8247,11 @@
bool full_token_loc_ /* error messages specify full token location */
) {
- FILE *in_file = NULL, *lib_file = NULL;
char *libfilename = NULL;
-
- if((in_file = fopen(filename, "r")) == NULL) {
- char *errmsg = strdup2("Error opening main file ", filename);
- perror(errmsg);
- free(errmsg);
- return -1;
- }
if (includedir != NULL) {
INCLUDE_DIRECTORIES[0] = includedir;
}
- if ((libfilename = strdup3(INCLUDE_DIRECTORIES[0], "/", LIBFILE)) == NULL) {
- fprintf (stderr, "Out of memory. Bailing out!\n");
- return -1;
- }
-
- if((lib_file = fopen(libfilename, "r")) == NULL) {
- char *errmsg = strdup2("Error opening library file ", libfilename);
- perror(errmsg);
- free(errmsg);
- }
-
- if (lib_file == NULL) {
- /* we give up... */
- free(libfilename);
- fclose(in_file);
- return -1;
- }
/* first parse the standard library file... */
/* Do not debug the standard library, even if debug flag is set! */
@@ -8291,12 +8260,23 @@
yydebug = 1;
#endif
*/
- yyin = lib_file;
+
+ if ((libfilename = strdup3(INCLUDE_DIRECTORIES[0], "/", LIBFILE)) == NULL) {
+ fprintf (stderr, "Out of memory. Bailing out!\n");
+ return -1;
+ }
+
+ if(parse_file(libfilename) < 0) {
+ char *errmsg = strdup2("Error opening library file ", libfilename);
+ perror(errmsg);
+ free(errmsg);
+ /* we give up... */
+ return -1;
+ }
+
allow_function_overloading = true;
allow_extensible_function_parameters = true;
full_token_loc = full_token_loc_;
- current_filename = libfilename;
- current_tracking = GetNewTracking(yyin);
if (yyparse() != 0)
ERROR;
@@ -8305,7 +8285,6 @@
ERROR;
}
free(libfilename);
- fclose(lib_file);
/* if by any chance the library is not complete, we
* now add the missing reserved keywords to the list!!!
@@ -8320,17 +8299,21 @@
#if YYDEBUG
yydebug = 1;
#endif
- yyin = in_file;
+
+ if(parse_file(filename) < 0) {
+ char *errmsg = strdup2("Error opening main file ", filename);
+ perror(errmsg);
+ free(errmsg);
+ return -1;
+ }
+
allow_function_overloading = false;
allow_extensible_function_parameters = false;
full_token_loc = full_token_loc_;
- current_filename = filename;
- current_tracking = GetNewTracking(yyin);
- {int res;
- if ((res = yyparse()) != 0) {
- fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n");
- exit(EXIT_FAILURE);
- }
+
+ if (yyparse() != 0) {
+ fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n");
+ exit(EXIT_FAILURE);
}
if (yynerrs > 0) {
@@ -8341,7 +8324,6 @@
if (tree_root_ref != NULL)
*tree_root_ref = tree_root;
- fclose(in_file);
return 0;
}