Created
October 30, 2013 09:50
-
-
Save gintenlabo/7229846 to your computer and use it in GitHub Desktop.
Boost version: 1.54.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/spirit/include/qi.hpp> | |
namespace qi = boost::spirit::qi; | |
int main() { | |
auto word = qi::raw[+qi::graph]; | |
auto rule = qi::omit[*qi::space] >> word >> qi::omit[+qi::space]; | |
std::string s = " hoge fuga"; | |
auto iter = s.begin(); | |
std::vector<std::string> results; | |
bool success = qi::parse(iter, s.end(), rule, results); | |
if (success) { | |
for (auto const& result : results) { | |
std::cout << result << std::endl; | |
} | |
} else { | |
std::cout << "parse error\n"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/spirit/include/qi.hpp> | |
namespace qi = boost::spirit::qi; | |
int main() { | |
auto word = qi::raw[+qi::graph]; | |
auto rule = qi::omit[*qi::space] >> word >> qi::omit[+qi::space] >> word; | |
std::string s = " hoge fuga"; | |
auto iter = s.begin(); | |
std::vector<std::string> results; | |
bool success = qi::parse(iter, s.end(), rule, results); | |
if (success) { | |
for (auto const& result : results) { | |
std::cout << result << std::endl; | |
} | |
} else { | |
std::cout << "parse error\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment