| 1 | // This testcase demonstrates an issue with Wave's processing of raw string literals
|
|---|
| 2 |
|
|---|
| 3 | #include <iostream>
|
|---|
| 4 | #include <iomanip>
|
|---|
| 5 |
|
|---|
| 6 | #include <boost/wave.hpp>
|
|---|
| 7 | #include <boost/wave/token_ids.hpp>
|
|---|
| 8 | #include <boost/wave/cpplexer/cpp_lex_token.hpp>
|
|---|
| 9 | #include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
|
|---|
| 10 |
|
|---|
| 11 | #include <boost/spirit/include/support_istream_iterator.hpp>
|
|---|
| 12 | #include <boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp>
|
|---|
| 13 |
|
|---|
| 14 | typedef boost::wave::cpplexer::lex_token<> cpplexer_token_t;
|
|---|
| 15 | typedef boost::wave::cpplexer::lex_iterator<cpplexer_token_t> cpplexer_iterator_t;
|
|---|
| 16 |
|
|---|
| 17 | int main() {
|
|---|
| 18 |
|
|---|
| 19 | // This input produces an unterminated raw string literal followed by
|
|---|
| 20 | // a bunch of independent tokens. It should produce a single raw string
|
|---|
| 21 | // literal of three characters - "A", backslash, and plus
|
|---|
| 22 | std::string cppstr("R\"(A\\+)\"");
|
|---|
| 23 | // This input simply removes the backslash character. It correctly produces
|
|---|
| 24 | // a single literal of two characters - "A" followed by "+"
|
|---|
| 25 | // std::string cppstr("R\"(A+)\"");
|
|---|
| 26 |
|
|---|
| 27 | auto cbeg = cppstr.begin();
|
|---|
| 28 | auto cend = cppstr.end();
|
|---|
| 29 | using namespace boost::wave;
|
|---|
| 30 |
|
|---|
| 31 | // works
|
|---|
| 32 | cpplexer_iterator_t beg(cbeg, cend,
|
|---|
| 33 | cpplexer_token_t::position_type("fake.cpp"),
|
|---|
| 34 | language_support(support_cpp0x));
|
|---|
| 35 | cpplexer_iterator_t end;
|
|---|
| 36 |
|
|---|
| 37 | std::cout << "source string: |" << cppstr << "|\n";
|
|---|
| 38 | for (auto tok = beg; tok != end; ++tok) {
|
|---|
| 39 | std::cout << ID_FROM_TOKEN(*tok) << " |" << tok->get_value() << "| ";
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | std::cout << "\n";
|
|---|
| 43 |
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|