stage1_2/stage1_2.cc
changeset 175 dadda1b5401e
parent 139 668a54686827
child 177 697562a5da7c
equal deleted inserted replaced
174:f648065fb66e 175:dadda1b5401e
   132 /* A symbol table to store the declared variables of
   132 /* A symbol table to store the declared variables of
   133  * the function currently being parsed...
   133  * the function currently being parsed...
   134  */
   134  */
   135 /* static */ symtable_c<int, BOGUS_TOKEN_ID> variable_name_symtable;
   135 /* static */ symtable_c<int, BOGUS_TOKEN_ID> variable_name_symtable;
   136 
   136 
       
   137 /* A symbol table to store the declared direct variables of
       
   138  * the function currently being parsed...
       
   139  */
       
   140 /* static */ symtable_c<int, BOGUS_TOKEN_ID> direct_variable_symtable;
   137 
   141 
   138 /* Function only called from within flex!
   142 /* Function only called from within flex!
   139  *
   143  *
   140  * search for a symbol in either of the two symbol tables
   144  * search for a symbol in either of the two symbol tables
   141  * declared above, and return the token id of the first
   145  * declared above, and return the token id of the first
   151     if ((token_id = library_element_symtable.find_value(identifier_str)) == library_element_symtable.end_value())
   155     if ((token_id = library_element_symtable.find_value(identifier_str)) == library_element_symtable.end_value())
   152       return identifier_token;
   156       return identifier_token;
   153   return token_id;
   157   return token_id;
   154 }
   158 }
   155 
   159 
       
   160 /* Function only called from within flex!
       
   161  *
       
   162  * search for a symbol in direct variables symbol table
       
   163  * declared above, and return the token id of the first
       
   164  * symbol found.
       
   165  */
       
   166 int get_direct_variable_token(const char *direct_variable_str) {
       
   167   int token_id;
       
   168 
       
   169   if ((token_id = direct_variable_symtable.find_value(direct_variable_str)) == direct_variable_symtable.end_value())
       
   170     return direct_variable_token;
       
   171   return token_id;
       
   172 }
   156 
   173 
   157 /************************/
   174 /************************/
   158 /* Utility Functions... */
   175 /* Utility Functions... */
   159 /************************/
   176 /************************/
   160 
   177