// test_wave1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #include #include #include #define M else\ +1 int _tmain(int argc, _TCHAR* argv[]) { using namespace boost::wave::cpplexer; using namespace boost::wave; using namespace boost::wave::cpplexer::slex; std::ifstream ifs("test_wave1.cpp", std::ios::binary | std::ios::in); ifs.unsetf(std::ios::skipws); std::string s = std::string(std::istream_iterator(ifs), std::istream_iterator()); typedef slex_token<> token_type; typedef slex_iterator iter_type; token_type::position_type pos; iter_type iter(s.begin(), s.end(), pos, language_support(support_cpp | support_option_preserve_comments | support_option_emit_contnewlines )); iter_type end = iter_type(); while (iter != end) { const token_type &t = *iter++; std::string line = t.get_value().c_str(); token_id tid; if (boost::starts_with(line, "else\\")) { tid = t; std::cout << t.get_value(); // output "else\" } } return 0; }