symbols_find_null.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*=============================================================================
  2. Copyright (c) 2004 Joao Abecasis
  3. http://spirit.sourceforge.net/
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #include <boost/spirit/include/classic_scanner.hpp>
  9. #include <boost/spirit/home/classic/symbols/impl/tst.ipp>
  10. #include <boost/utility/addressof.hpp>
  11. typedef char char_type;
  12. typedef char const * iterator;
  13. char_type data_[] = "whatever";
  14. iterator begin = data_;
  15. iterator end = data_
  16. + sizeof(data_)/sizeof(char_type); // Yes, this is an intencional bug ;)
  17. int main()
  18. {
  19. typedef BOOST_SPIRIT_CLASSIC_NS::scanner<> scanner;
  20. typedef BOOST_SPIRIT_CLASSIC_NS::impl::tst<void *, char_type> symbols;
  21. symbols symbols_;
  22. symbols_.add(begin, end - 1, (void*) boost::addressof(symbols_));
  23. // The symbol table parser should not choke on input containing the null
  24. // character.
  25. symbols_.find(scanner(begin, end));
  26. }