2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00
Files
spirit/example/qi/typeof.cpp
Nikita Kniazev f44479bcd3 Remove boost/config/warning_disable.hpp usage
It is better to manage warnings on our side to know what warnings we need to fix or suppress, and the only thing that header does is disabling deprecation warnings on MSVC and ICC which we would prefer to not show to users.
2021-08-24 03:14:12 +03:00

65 lines
2.0 KiB
C++

/*=============================================================================
Copyright (c) 2001-2010 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_copy.hpp>
#include <boost/spirit/include/support_auto.hpp>
#include <iostream>
#include <string>
///////////////////////////////////////////////////////////////////////////////
// Main program
///////////////////////////////////////////////////////////////////////////////
int
main()
{
using boost::spirit::ascii::space;
using boost::spirit::ascii::char_;
using boost::spirit::qi::parse;
typedef std::string::const_iterator iterator_type;
///////////////////////////////////////////////////////////////////////////////
// this works for non-c++11 compilers
#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
BOOST_SPIRIT_AUTO(qi, comment, "/*" >> *(char_ - "*/") >> "*/");
///////////////////////////////////////////////////////////////////////////////
// but this is better for c++11 compilers with auto
#else
using boost::spirit::qi::copy;
auto comment = copy("/*" >> *(char_ - "*/") >> "*/");
#endif
std::string str = "/*This is a comment*/";
std::string::const_iterator iter = str.begin();
std::string::const_iterator end = str.end();
bool r = parse(iter, end, comment);
if (r && iter == end)
{
std::cout << "-------------------------\n";
std::cout << "Parsing succeeded\n";
std::cout << "-------------------------\n";
}
else
{
std::string rest(iter, end);
std::cout << "-------------------------\n";
std::cout << "Parsing failed\n";
std::cout << "stopped at: \": " << rest << "\"\n";
std::cout << "-------------------------\n";
}
return 0;
}