stage1_2/stage1_2.cc
changeset 745 26cb3fa00d29
parent 354 0f24db96b519
child 746 c7219a37cc39
equal deleted inserted replaced
734:49853bded539 745:26cb3fa00d29
    44 
    44 
    45 
    45 
    46 #include "stage1_2.hh"
    46 #include "stage1_2.hh"
    47 #include "iec_bison.h"
    47 #include "iec_bison.h"
    48 #include "stage1_2_priv.hh"
    48 #include "stage1_2_priv.hh"
    49 
    49 #include "derived_conversion_functions.hh"
    50 
    50 
    51 
    51 
    52 
    52 
    53 
    53 
    54 /**************************************/
    54 /**************************************/
   283              const char *includedir,     /* Include directory, where included files will be searched for... */
   283              const char *includedir,     /* Include directory, where included files will be searched for... */
   284              symbol_c **tree_root_ref,
   284              symbol_c **tree_root_ref,
   285              bool full_token_loc         /* error messages specify full token location */
   285              bool full_token_loc         /* error messages specify full token location */
   286             );
   286             );
   287 
   287 
       
   288 int sstage2__(const char *text,
       
   289               symbol_c **tree_root_ref,
       
   290               bool full_token_loc         /* error messages specify full token location */
       
   291              );
       
   292 
   288 
   293 
   289 int stage1_2(const char *filename, symbol_c **tree_root_ref, stage1_2_options_t options) {
   294 int stage1_2(const char *filename, symbol_c **tree_root_ref, stage1_2_options_t options) {
   290       /* NOTE: we only call stage2 (bison - syntax analysis) directly, as stage 2 will itself call stage1 (flex - lexical analysis)
   295       /* NOTE: we only call stage2 (bison - syntax analysis) directly, as stage 2 will itself call stage1 (flex - lexical analysis)
   291        *       automatically as needed
   296        *       automatically as needed
   292        */
   297        */
   295        *       In this case, we use callback functions, i.e. stage1__ (i.e. flex) will call functions defined in this file
   300        *       In this case, we use callback functions, i.e. stage1__ (i.e. flex) will call functions defined in this file
   296        *       whenever it needs info/parameters coming from stage1_2().
   301        *       whenever it needs info/parameters coming from stage1_2().
   297        *       These callback functions will get their data from local (to this file) global variables...
   302        *       These callback functions will get their data from local (to this file) global variables...
   298        *       We now set those variables...
   303        *       We now set those variables...
   299        */
   304        */
       
   305 
   300   safe_extensions_ = options.safe_extensions;
   306   safe_extensions_ = options.safe_extensions;
   301   
   307   int ret = stage2__(filename, options.includedir, tree_root_ref, options.full_token_loc);
   302   return stage2__(filename, options.includedir, tree_root_ref, options.full_token_loc);
   308   derived_conversion_functions_c derived_conversion_functions(*tree_root_ref);
   303 }
   309   std::string source_code = derived_conversion_functions.get_declaration(*tree_root_ref);
   304 
   310   ret = sstage2__(source_code.c_str(), tree_root_ref, false);
       
   311   return ret;
       
   312 }
       
   313