diff -r 0ede7ca157e2 -r 8aee27d46208 stage1_2/stage1_2.cc --- a/stage1_2/stage1_2.cc Fri Dec 26 09:39:18 2014 +0000 +++ b/stage1_2/stage1_2.cc Fri Dec 26 09:57:02 2014 +0000 @@ -135,15 +135,6 @@ /* NOTE: only accessed indirectly by the lexical parser (flex) * through the function get_identifier_token() */ -/* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec_bison.hh. - * We need this constant defined before we can declare the symbol tables. - * However, we cannot #include "iec_bison.hh" in this file (stage1_2_priv.hh) directly - * because of the way bison ver. 3.2 is copying all declarations in the prologue - * of iec.y to the iec_bison.hh file (including an #include stage1_2_priv.hh). - * So, if we were to include "iec_bison.hh" here, we would get a circular include. - * All this means that whoever includes this file (stage1_2_priv.hh) will need - * to take care to first inlcude iec_bison.hh !! - */ /* A symbol table to store all the library elements */ /* e.g.: * @@ -151,17 +142,17 @@ * * */ -/* static */ symtable_c library_element_symtable; +/* static */ library_element_symtable_t library_element_symtable; /* A symbol table to store the declared variables of * the function currently being parsed... */ -/* static */ symtable_c variable_name_symtable; +/* static */ variable_name_symtable_t variable_name_symtable; /* A symbol table to store the declared direct variables of * the function currently being parsed... */ -/* static */ symtable_c direct_variable_symtable; +/* static */ direct_variable_symtable_t direct_variable_symtable; /* Function only called from within flex! * @@ -173,12 +164,16 @@ */ int get_identifier_token(const char *identifier_str) { // std::cout << "get_identifier_token(" << identifier_str << "): \n"; - int token_id; - - if ((token_id = variable_name_symtable.find_value(identifier_str)) == variable_name_symtable.end_value()) - if ((token_id = library_element_symtable.find_value(identifier_str)) == library_element_symtable.end_value()) - return identifier_token; - return token_id; + variable_name_symtable_t ::iterator iter1; + library_element_symtable_t::iterator iter2; + + if ((iter1 = variable_name_symtable.find(identifier_str)) != variable_name_symtable.end()) + return iter1->second; + + if ((iter2 = library_element_symtable.find(identifier_str)) != library_element_symtable.end()) + return iter2->second; + + return identifier_token; } /* Function only called from within flex! @@ -188,11 +183,12 @@ * symbol found. */ int get_direct_variable_token(const char *direct_variable_str) { - int token_id; - - if ((token_id = direct_variable_symtable.find_value(direct_variable_str)) == direct_variable_symtable.end_value()) - return direct_variable_token; - return token_id; + direct_variable_symtable_t::iterator iter; + + if ((iter = direct_variable_symtable.find(direct_variable_str)) != direct_variable_symtable.end()) + return iter->second; + + return direct_variable_token; } /************************/