Ticket #6253: hackfix.patch
File hackfix.patch, 3.6 KB (added by , 11 years ago) |
---|
-
.hpp
old new 34 34 return os_.good(); 35 35 } 36 36 37 template <typename Char> 38 struct ProperCharTypeStrings {}; 39 40 template <> 41 struct ProperCharTypeStrings<char> 42 { 43 static char *CharTypeString; 44 static char *LiteralPrefix; 45 }; 46 //Not a good idea since this is a header and we don't want multiple definition complaints from the compiler 47 char * ProperCharTypeStrings<char>::CharTypeString = "char"; 48 char * ProperCharTypeStrings<char>::LiteralPrefix = ""; 49 50 template<> 51 struct ProperCharTypeStrings<wchar_t> 52 { 53 static char *CharTypeString; 54 static char *LiteralPrefix; 55 }; 56 //Not a good idea since this is a header and we don't want multiple definition complaints from the compiler 57 char * ProperCharTypeStrings<wchar_t>::CharTypeString = "wchar_t"; 58 char * ProperCharTypeStrings<wchar_t>::LiteralPrefix = "L"; 59 37 60 /////////////////////////////////////////////////////////////////////////// 38 61 // Generate a table of the names of the used lexer states, which is a bit 39 62 // tricky, because the table stored with the rules is sorted based on the … … 48 71 typedef typename 49 72 boost::lexer::basic_rules<Char>::string_size_t_map::const_iterator 50 73 state_iterator; 51 typedef std::map<std::size_t, char const*> reverse_state_map_type;74 typedef std::map<std::size_t, Char const*> reverse_state_map_type; 52 75 53 76 reverse_state_map_type reverse_state_map; 54 77 state_iterator send = rules_.statemap().end(); … … 60 83 61 84 generate_delimiter(os_); 62 85 os_ << "// this table defines the names of the lexer states\n"; 63 os_ << "charconst* const lexer_state_names"86 os_ << ProperCharTypeStrings<Char>::CharTypeString << " const* const lexer_state_names" 64 87 << (name_suffix[0] ? "_" : "") << name_suffix 65 88 << "[" << rules_.statemap().size() << "] = \n{\n"; 66 89 … … 73 96 { 74 97 os_ << " 0, // \"<undefined state>\"\n"; 75 98 } 76 os_ << " \"" << (*rit).second << "\"";99 os_ << " " << ProperCharTypeStrings<Char>::LiteralPrefix << "\"" << (*rit).second << "\""; 77 100 if (++rit != rend) 78 101 os_ << ",\n"; 79 102 else … … 89 112 return os_.good(); 90 113 } 91 114 115 template <typename Char> 92 116 inline bool 93 117 generate_cpp_state_table (std::ostream &os_, char const* name_suffix 94 118 , bool bol, bool eol) … … 110 134 os_ << " static std::size_t state_count()\n"; 111 135 os_ << " {\n return lexer_state_count" << suffix << "; \n }\n\n"; 112 136 os_ << " // return the name of the lexer state as given by 'idx'\n"; 113 os_ << " static charconst* state_name(std::size_t idx)\n";137 os_ << " static " << ProperCharTypeStrings<Char>::CharTypeString << " const* state_name(std::size_t idx)\n"; 114 138 os_ << " {\n return lexer_state_names" << suffix << "[idx]; \n }\n\n"; 115 139 os_ << " // return the next matched token\n"; 116 140 os_ << " template<typename Iterator>\n"; … … 896 920 return false; 897 921 os_ << "}\n\n"; 898 922 899 if (!generate_cpp_state_table (os_, name_suffix923 if (!generate_cpp_state_table<Char>(os_, name_suffix 900 924 , sm_.data()._seen_BOL_assertion, sm_.data()._seen_EOL_assertion)) 901 925 { 902 926 return false;