spirit/repository/example/qi/seek.cpp
2017-11-21 19:49:36 +03:00

49 lines
1.3 KiB
C++

/*//////////////////////////////////////////////////////////////////////////////
Copyright (c) 2011 Jamboree
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)
//////////////////////////////////////////////////////////////////////////////*/
// [ Jamboree Oct 27, 2011 ] new example.
#include <cstdlib>
#include <iostream>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/repository/include/qi_seek.hpp>
int main()
{
//[reference_qi_seek_namespace
namespace qi = boost::spirit::qi;
namespace repo = boost::spirit::repository;
//]
typedef std::string::const_iterator iterator;
//[reference_qi_seek_vars
std::string str("/*C-style comment*/");
iterator it = str.begin();
iterator end = str.end();
//]
//[reference_qi_seek_parse
if (qi::parse(it, end, "/*" >> repo::qi::seek["*/"]))
{
std::cout << "-------------------------------- \n";
std::cout << "Parsing succeeded.\n";
std::cout << "---------------------------------\n";
}
else
{
std::cout << "-------------------------------- \n";
std::cout << "Unterminated /* comment.\n";
std::cout << "-------------------------------- \n";
}//]
return EXIT_SUCCESS;
}