inline lexer<IteratorT, PositionT>::lexer(IteratorT const &first, IteratorT const &last, PositionT const &pos, boost::wave::language_support language) : filename(pos.get_file()), at_eof(false), language(language) { using namespace std; // some systems have memset in std memset(&scanner, '\0', sizeof(Scanner)); scanner.fd = -1; scanner.eol_offsets = aq_create(); scanner.first = scanner.act = (uchar *)&(*first); scanner.last = scanner.first + std::distance(first, last); scanner.line = pos.get_line(); scanner.column = scanner.curr_column = pos.get_column(); scanner.error_proc = report_error; scanner.file_name = filename.c_str(); #if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0 scanner.enable_ms_extensions = 1; #else scanner.enable_ms_extensions = 0; #endif #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 scanner.act_in_c99_mode = boost::wave::need_c99(language); #endif }
inline typename ContainerT::value_type::string_type as_stringlit (std::vector<ContainerT> const &arguments, typename std::vector<ContainerT>::size_type i, PositionT const &pos) { using namespace boost::wave; typedef typename ContainerT::value_type::string_type string_type; BOOST_ASSERT(i < arguments.size()); string_type result("\""); bool was_whitespace = false; for (/**/; i < arguments.size(); ++i) { // stringize all remaining arguments typename ContainerT::const_iterator end = arguments[i].end(); for (typename ContainerT::const_iterator it = arguments[i].begin(); it != end; ++it) { token_id id = token_id(*it); if (IS_CATEGORY(*it, WhiteSpaceTokenType) || T_NEWLINE == id) { if (!was_whitespace) { // C++ standard 16.3.2.2 [cpp.stringize] // Each occurrence of white space between the argument's // preprocessing tokens becomes a single space character in the // character string literal. result += " "; was_whitespace = true; } } else if (T_STRINGLIT == id || T_CHARLIT == id) { // string literals and character literals have to be escaped result += impl::escape_lit((*it).get_value()); was_whitespace = false; } else if (T_PLACEMARKER != id) { // now append this token to the string result += (*it).get_value(); was_whitespace = false; } } // append comma, if not last argument if (i < arguments.size()-1) { result += ","; was_whitespace = false; } } result += "\""; // validate the resulting literal to contain no invalid universal character // value (throws if invalid chars found) boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(), pos.get_column(), pos.get_file()); return result; }
inline typename ContainerT::value_type::string_type as_stringlit (ContainerT const &token_sequence, PositionT const &pos) { using namespace boost::wave; typedef typename ContainerT::value_type::string_type string_type; string_type result("\""); bool was_whitespace = false; typename ContainerT::const_iterator end = token_sequence.end(); for (typename ContainerT::const_iterator it = token_sequence.begin(); it != end; ++it) { token_id id = token_id(*it); if (IS_CATEGORY(*it, WhiteSpaceTokenType) || T_NEWLINE == id) { if (!was_whitespace) { // C++ standard 16.3.2.2 [cpp.stringize] // Each occurrence of white space between the argument's // preprocessing tokens becomes a single space character in the // character string literal. result += " "; was_whitespace = true; } } else if (T_STRINGLIT == id || T_CHARLIT == id) { // string literals and character literals have to be escaped result += impl::escape_lit((*it).get_value()); was_whitespace = false; } else #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 if (T_PLACEMARKER != id) #endif { // now append this token to the string result += (*it).get_value(); was_whitespace = false; } } result += "\""; // validate the resulting literal to contain no invalid universal character // value (throws if invalid chars found) boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(), pos.get_column(), pos.get_file()); return result; }
inline lexer<IteratorT, PositionT, TokenT>::lexer(IteratorT const &first, IteratorT const &last, PositionT const &pos, boost::wave::language_support language_) : filename(pos.get_file()), at_eof(false), language(language_) #if BOOST_WAVE_SUPPORT_THREADING != 0 , cache() #endif { using namespace std; // some systems have memset in std memset(&scanner, '\0', sizeof(Scanner)); scanner.eol_offsets = aq_create(); if (first != last) { scanner.first = scanner.act = (uchar *)&(*first); scanner.last = scanner.first + std::distance(first, last); } scanner.line = pos.get_line(); scanner.column = scanner.curr_column = pos.get_column(); scanner.error_proc = report_error; scanner.file_name = filename.c_str(); #if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0 scanner.enable_ms_extensions = true; #else scanner.enable_ms_extensions = false; #endif #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 scanner.act_in_c99_mode = boost::wave::need_c99(language_); #endif #if BOOST_WAVE_SUPPORT_IMPORT_KEYWORD != 0 scanner.enable_import_keyword = !boost::wave::need_c99(language_); #else scanner.enable_import_keyword = false; #endif scanner.detect_pp_numbers = boost::wave::need_prefer_pp_numbers(language_); scanner.single_line_only = boost::wave::need_single_line(language_); #if BOOST_WAVE_SUPPORT_CPP0X != 0 scanner.act_in_cpp0x_mode = boost::wave::need_cpp0x(language_); #else scanner.act_in_cpp0x_mode = false; #endif }