stage1_2/iec_bison.yy
changeset 749 76c87fdb5fc8
parent 748 ad4265253528
child 756 634f476cb60f
equal deleted inserted replaced
748:ad4265253528 749:76c87fdb5fc8
  8352 
  8352 
  8353   fclose(in_file);
  8353   fclose(in_file);
  8354   return 0;
  8354   return 0;
  8355 }
  8355 }
  8356 
  8356 
       
  8357 /* Create a tmp file from a char buffer. */
  8357 FILE *ftmpopen (void *buf, size_t size, const char *opentype)
  8358 FILE *ftmpopen (void *buf, size_t size, const char *opentype)
  8358 {
  8359 {
  8359   FILE *f;
  8360   FILE *f;
  8360   f = tmpfile();
  8361   f = tmpfile();
  8361   fwrite(buf, 1, size, f);
  8362   fwrite(buf, 1, size, f);
  8362   rewind(f);
  8363   rewind(f);
  8363   return f;
  8364   return f;
  8364 }
  8365 }
  8365 
  8366 
  8366 
  8367 /*  sstage2__ function allow to parse a ST code inside a string.
       
  8368  *  We use this function to add into AST auto generated code like enum conversion functions.
       
  8369  *  This appoach allow us to write future changes code indipendetly and to check generate code
       
  8370  *  during developing.
       
  8371  */
  8367 int sstage2__(const char *text, 
  8372 int sstage2__(const char *text, 
  8368               symbol_c **tree_root_ref,
  8373               symbol_c **tree_root_ref,
  8369               bool full_token_loc_        /* error messages specify full token location */
  8374               bool full_token_loc_        /* error messages specify full token location */
  8370              ) {
  8375              ) {
  8371 
  8376 
  8372   FILE *in_file = NULL;
  8377   FILE *in_file = NULL;
  8373     
  8378     
  8374   if((in_file = ftmpopen((void *)text, strlen(text), "r")) == NULL) {
  8379   if((in_file = ftmpopen((void *)text, strlen(text), "r")) == NULL) {
  8375     perror("Error temp file.");
  8380     perror("Error creating temp file.");
  8376     return -1;
  8381     return -1;
  8377   }
  8382   }
  8378 
  8383 
  8379   /* now parse the input file... */
  8384   /* now parse the input file... */
  8380   #if YYDEBUG
  8385   #if YYDEBUG
  8381     yydebug = 1;
  8386     yydebug = 1;
  8382   #endif
  8387   #endif
  8383   yyin = in_file;
  8388   yyin = in_file;
       
  8389   
       
  8390   /* We turn on "allow_function_overloading" flag to disable some checks. 
       
  8391    * In detail when we add to symboltable a symbol already processed we
       
  8392    * don't want to get any error. 
       
  8393    */  
       
  8394    
  8384   allow_function_overloading = true;
  8395   allow_function_overloading = true;
  8385   allow_extensible_function_parameters = false;
  8396   allow_extensible_function_parameters = false;
  8386   full_token_loc = full_token_loc_;
  8397   full_token_loc = full_token_loc_;
  8387   current_filename = "built-in";
  8398   current_filename = "built-in";
  8388   current_tracking = GetNewTracking(yyin);
  8399   current_tracking = GetNewTracking(yyin);