1
2// Copyright 2018 Peter Dimov.
3//
4// Distributed under the Boost Software License, Version 1.0.
5//
6// See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt
8
9#include <boost/wave.hpp>
10#include <boost/wave/cpplexer/cpp_lex_token.hpp>
11#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
12#include <iostream>
13
14int main()
15{
16 std::string input(
17 "#if 0\n"
18 "6.28\n"
19 "#else\n"
20 "3.14\n"
21 "#endif\n"
22 );
23
24 try
25 {
26 typedef boost::wave::cpplexer::lex_token<> token_type;
27 typedef boost::wave::cpplexer::lex_iterator<token_type> lex_iterator_type;
28 typedef boost::wave::context<std::string::iterator, lex_iterator_type> context_type;
29
30 context_type ctx( input.begin(), input.end(), "input.cpp" );
31
32 for( context_type::iterator_type first = ctx.begin(), last = ctx.end(); first != last; ++first )
33 {
34 std::cout << first->get_value();
35 }
36
37 return 0;
38 }
39 catch( boost::wave::cpp_exception const & x )
40 {
41 std::cerr << x.file_name() << "(" << x.line_no() << "): " << x.description() << std::endl;
42 return 1;
43 }
44 catch( std::exception const & x )
45 {
46 std::cerr << "Exception: " << x.what() << std::endl;
47 return 2;
48 }
49}
50

source code of boost/libs/wave/test/testwave/quick.cpp