--- generate_static.hpp Sun Dec 11 11:25:13 2011 +++ HackFix_generate_static.hpp Sun Dec 11 11:20:50 2011 @@ -34,6 +34,29 @@ return os_.good(); } + template + struct ProperCharTypeStrings {}; + + template <> + struct ProperCharTypeStrings + { + static char *CharTypeString; + static char *LiteralPrefix; + }; + //Not a good idea since this is a header and we don't want multiple definition complaints from the compiler + char * ProperCharTypeStrings::CharTypeString = "char"; + char * ProperCharTypeStrings::LiteralPrefix = ""; + + template<> + struct ProperCharTypeStrings + { + static char *CharTypeString; + static char *LiteralPrefix; + }; + //Not a good idea since this is a header and we don't want multiple definition complaints from the compiler + char * ProperCharTypeStrings::CharTypeString = "wchar_t"; + char * ProperCharTypeStrings::LiteralPrefix = "L"; + /////////////////////////////////////////////////////////////////////////// // Generate a table of the names of the used lexer states, which is a bit // tricky, because the table stored with the rules is sorted based on the @@ -48,7 +71,7 @@ typedef typename boost::lexer::basic_rules::string_size_t_map::const_iterator state_iterator; - typedef std::map reverse_state_map_type; + typedef std::map reverse_state_map_type; reverse_state_map_type reverse_state_map; state_iterator send = rules_.statemap().end(); @@ -60,7 +83,7 @@ generate_delimiter(os_); os_ << "// this table defines the names of the lexer states\n"; - os_ << "char const* const lexer_state_names" + os_ << ProperCharTypeStrings::CharTypeString << " const* const lexer_state_names" << (name_suffix[0] ? "_" : "") << name_suffix << "[" << rules_.statemap().size() << "] = \n{\n"; @@ -73,7 +96,7 @@ { os_ << " 0, // \"\"\n"; } - os_ << " \"" << (*rit).second << "\""; + os_ << " " << ProperCharTypeStrings::LiteralPrefix << "\"" << (*rit).second << "\""; if (++rit != rend) os_ << ",\n"; else @@ -89,6 +112,7 @@ return os_.good(); } + template inline bool generate_cpp_state_table (std::ostream &os_, char const* name_suffix , bool bol, bool eol) @@ -110,7 +134,7 @@ os_ << " static std::size_t state_count()\n"; os_ << " {\n return lexer_state_count" << suffix << "; \n }\n\n"; os_ << " // return the name of the lexer state as given by 'idx'\n"; - os_ << " static char const* state_name(std::size_t idx)\n"; + os_ << " static " << ProperCharTypeStrings::CharTypeString << " const* state_name(std::size_t idx)\n"; os_ << " {\n return lexer_state_names" << suffix << "[idx]; \n }\n\n"; os_ << " // return the next matched token\n"; os_ << " template\n"; @@ -896,7 +920,7 @@ return false; os_ << "}\n\n"; - if (!generate_cpp_state_table(os_, name_suffix + if (!generate_cpp_state_table(os_, name_suffix , sm_.data()._seen_BOL_assertion, sm_.data()._seen_EOL_assertion)) { return false;