stage1_2/iec_bison.yy
changeset 761 7b52623a2f37
parent 759 16050b4303a0
child 805 b737cfc92614
equal deleted inserted replaced
760:d736dc9e9e51 761:7b52623a2f37
  8263 
  8263 
  8264   if ((libfilename = strdup3(INCLUDE_DIRECTORIES[0], "/", LIBFILE)) == NULL) {
  8264   if ((libfilename = strdup3(INCLUDE_DIRECTORIES[0], "/", LIBFILE)) == NULL) {
  8265     fprintf (stderr, "Out of memory. Bailing out!\n");
  8265     fprintf (stderr, "Out of memory. Bailing out!\n");
  8266     return -1;
  8266     return -1;
  8267   }
  8267   }
  8268 
  8268   
  8269   if(parse_file(libfilename) < 0) {
  8269   FILE *libfile = NULL;
       
  8270   if((libfile = parse_file(libfilename)) == NULL) {
  8270     char *errmsg = strdup2("Error opening library file ", libfilename);
  8271     char *errmsg = strdup2("Error opening library file ", libfilename);
  8271     perror(errmsg);
  8272     perror(errmsg);
  8272     free(errmsg);
  8273     free(errmsg);
  8273     /* we give up... */
  8274     /* we give up... */
  8274     return -1;
  8275     return -1;
  8277   allow_function_overloading = true;
  8278   allow_function_overloading = true;
  8278   allow_extensible_function_parameters = true;
  8279   allow_extensible_function_parameters = true;
  8279   full_token_loc = full_token_loc_;
  8280   full_token_loc = full_token_loc_;
  8280   if (yyparse() != 0)
  8281   if (yyparse() != 0)
  8281       ERROR;
  8282       ERROR;
  8282 
  8283   fclose(libfile);
       
  8284       
  8283   if (yynerrs > 0) {
  8285   if (yynerrs > 0) {
  8284     fprintf (stderr, "\n%d error(s) found in %s. Bailing out!\n", yynerrs /* global variable */, libfilename);
  8286     fprintf (stderr, "\n%d error(s) found in %s. Bailing out!\n", yynerrs /* global variable */, libfilename);
  8285     ERROR;
  8287     ERROR;
  8286   }
  8288   }
  8287   free(libfilename);
  8289   free(libfilename);
  8297 
  8299 
  8298   /* now parse the input file... */
  8300   /* now parse the input file... */
  8299   #if YYDEBUG
  8301   #if YYDEBUG
  8300     yydebug = 1;
  8302     yydebug = 1;
  8301   #endif
  8303   #endif
  8302 
  8304   FILE *mainfile = NULL;
  8303   if(parse_file(filename) < 0) {
  8305   if ((mainfile = parse_file(filename)) == NULL) {
  8304     char *errmsg = strdup2("Error opening main file ", filename);
  8306     char *errmsg = strdup2("Error opening main file ", filename);
  8305     perror(errmsg);
  8307     perror(errmsg);
  8306     free(errmsg);
  8308     free(errmsg);
  8307     return -1;
  8309     return -1;
  8308   }
  8310   }
  8313 
  8315 
  8314   if (yyparse() != 0) {
  8316   if (yyparse() != 0) {
  8315     fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n");
  8317     fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n");
  8316     exit(EXIT_FAILURE);
  8318     exit(EXIT_FAILURE);
  8317   }
  8319   }
  8318 
  8320   fclose(mainfile);
       
  8321   
  8319   if (yynerrs > 0) {
  8322   if (yynerrs > 0) {
  8320     fprintf (stderr, "\n%d error(s) found. Bailing out!\n", yynerrs /* global variable */);
  8323     fprintf (stderr, "\n%d error(s) found. Bailing out!\n", yynerrs /* global variable */);
  8321     exit(EXIT_FAILURE);
  8324     exit(EXIT_FAILURE);
  8322   }
  8325   }
  8323   
  8326