regression_static_wide_6253.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. // Copyright (c) 2011 Ryan Molden
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/config/warning_disable.hpp>
  8. #include <boost/spirit/include/lex_lexertl.hpp>
  9. #include <boost/spirit/include/lex_generate_static_lexertl.hpp>
  10. #include <boost/spirit/include/lex_static_lexertl.hpp>
  11. #include <fstream>
  12. using namespace std;
  13. using namespace boost::spirit;
  14. template <typename BaseLexer>
  15. struct my_lexer : boost::spirit::lex::lexer<BaseLexer>
  16. {
  17. my_lexer()
  18. {
  19. token = L"Yay winning!";
  20. this->self = token;
  21. }
  22. lex::token_def<lex::unused_type, wchar_t> token;
  23. };
  24. int main()
  25. {
  26. typedef lex::lexertl::token<wchar_t const*> token_type;
  27. typedef lex::lexertl::lexer<token_type> lexer_type;
  28. my_lexer<lexer_type> lexer;
  29. basic_ofstream<wchar_t> output_dfa("test_dfa.hpp");
  30. BOOST_TEST(lex::lexertl::generate_static_dfa(lexer, output_dfa, L"test_dfa"));
  31. basic_ofstream<wchar_t> output_switch("test_switch.hpp");
  32. BOOST_TEST(lex::lexertl::generate_static_switch(lexer, output_switch, L"test_switch"));
  33. return boost::report_errors();
  34. }