stage1_2/stage1_2.cc
changeset 934 2a42a68f4b59
parent 924 9e824bb0c3d4
child 946 c012a64dc2fa
equal deleted inserted replaced
933:76324f461aed 934:2a42a68f4b59
    49 #include "create_enumtype_conversion_functions.hh"
    49 #include "create_enumtype_conversion_functions.hh"
    50 
    50 
    51 
    51 
    52 
    52 
    53 
    53 
    54 
    54 static stage1_2_options_t options_;
    55 
    55 
    56 /******************************************************/
    56 /******************************************************/
    57 /* whether we are supporting safe extensions          */
    57 /* whether we are supporting safe extensions          */
    58 /* as defined in PLCopen - Technical Committee 5      */
    58 /* as defined in PLCopen - Technical Committee 5      */
    59 /* Safety Software Technical Specification,           */
    59 /* Safety Software Technical Specification,           */
    60 /* Part 1: Concepts and Function Blocks,              */
    60 /* Part 1: Concepts and Function Blocks,              */
    61 /* Version 1.0 – Official Release                   */
    61 /* Version 1.0 – Official Release                   */
    62 /******************************************************/
    62 /******************************************************/
    63 bool safe_extensions_ = false;
    63 bool get_opt_safe_extensions() {return options_.safe_extensions;}
    64 bool get_opt_safe_extensions() {return safe_extensions_;}
       
    65 
    64 
    66 /************************************/
    65 /************************************/
    67 /* whether to allow nested comments */
    66 /* whether to allow nested comments */
    68 /************************************/
    67 /************************************/
    69 bool nested_comments_ = false;
    68 bool get_opt_nested_comments() {return options_.nested_comments;}
    70 bool get_opt_nested_comments() {return nested_comments_;}
    69 
    71 
    70 /**************************************************************************/
    72 /************************************/
    71 /* whether to allow REF(), DREF(), REF_TO, NULL and ^ operators/keywords  */
    73 /* whether to allow REF() operator  */
    72 /**************************************************************************/
    74 /************************************/
    73 bool get_opt_ref_standard_extensions() {return options_.ref_standard_extensions;}
    75 bool ref_operator_ = false;
    74 
    76 bool get_opt_ref_operator() {return ref_operator_;}
       
    77 
       
    78 
       
    79 /******************************************************/
       
    80 /* whether we are supporting conversion functions     */
       
    81 /* for enumerate data types                           */
       
    82 /******************************************************/
       
    83 bool conversion_functions_ = false;
       
    84 
    75 
    85 
    76 
    86 /****************************************************/
    77 /****************************************************/
    87 /* Controlling the entry to the body_state in flex. */
    78 /* Controlling the entry to the body_state in flex. */
    88 /****************************************************/
    79 /****************************************************/
   232 /***********************************************************************/
   223 /***********************************************************************/
   233 /***********************************************************************/
   224 /***********************************************************************/
   234 /***********************************************************************/
   225 /***********************************************************************/
   235 /***********************************************************************/
   226 /***********************************************************************/
   236 
   227 
   237 
       
   238 int stage2__(const char *filename, 
   228 int stage2__(const char *filename, 
   239              const char *includedir,     /* Include directory, where included files will be searched for... */
       
   240              symbol_c **tree_root_ref,
   229              symbol_c **tree_root_ref,
   241              bool full_token_loc,        /* error messages specify full token location */
   230              stage1_2_options_t options
   242              bool ref_to_any             /* allow use of non-standard REF_TO ANY datatypes */
       
   243             );
   231             );
   244 
   232 
   245 
   233 
   246 int stage1_2(const char *filename, symbol_c **tree_root_ref, stage1_2_options_t options) {
   234 int stage1_2(const char *filename, symbol_c **tree_root_ref, stage1_2_options_t options) {
   247       /* NOTE: we only call stage2 (bison - syntax analysis) directly, as stage 2 will itself call stage1 (flex - lexical analysis)
   235       /* NOTE: we only call stage2 (bison - syntax analysis) directly, as stage 2 will itself call stage1 (flex - lexical analysis)
   252        *       In this case, we use callback functions, i.e. stage1__ (i.e. flex) will call functions defined in this file
   240        *       In this case, we use callback functions, i.e. stage1__ (i.e. flex) will call functions defined in this file
   253        *       whenever it needs info/parameters coming from stage1_2().
   241        *       whenever it needs info/parameters coming from stage1_2().
   254        *       These callback functions will get their data from local (to this file) global variables...
   242        *       These callback functions will get their data from local (to this file) global variables...
   255        *       We now set those variables...
   243        *       We now set those variables...
   256        */
   244        */
   257 
   245   options_ = options;
   258   nested_comments_ = options.nested_comments;    
   246   return stage2__(filename, tree_root_ref, options);
   259   ref_operator_    = options.ref_operator;    
   247 }
   260   safe_extensions_ = options.safe_extensions;
   248 
   261   conversion_functions_ = options.conversion_functions;
       
   262   return stage2__(filename, options.includedir, tree_root_ref, options.full_token_loc, options.ref_to_any);
       
   263 }
       
   264