namespace parser = boost::parser;
auto result = parser::parse(input,
parser, skip);
#include <boost/parser/parser.hpp> namespace parser = boost::parser; int main() { std::string input = "1.2,2.3, 3.4 ,4.5 , 8.7 , 2.4"; auto result = parser::parse( input, parser::double_ >> *(',' >> parser::double_), parser::ws ); static_assert(std::same_as<decltype(result), std::optional<std::vector<double>>>); if (result) { for (auto & x: *result) { std::cout << "=> " << x << std::endl; } } else { std::cout << "parse error" << std::endl; } }
output:
=> 1.2 => 2.3 => 3.4 => 4.5 => 8.7 => 2.4
#include <boost/parser/parser.hpp> #include <iostream> namespace parser = boost::parser; int main() { const std::string input = "1.2, 2.3 ,3.4 , 4.5 , , ,, , 7,8,9.2"; auto result = parser::parse( input, +parser::double_, parser::ws | parser::char_(',') ); static_assert(std::same_as<decltype(result), std::optional<std::vector<double>>>); if (result) for (auto & x: *result) std::cout << "=> " << x << std::endl; else std::cout << "parse error" << std::endl; }
output:
=> 1.2 => 2.3 => 3.4 => 4.5 => 7 => 8 => 9.2
namespace parser = boost::parser;
bool r = parser::parse(input, -parser-, attr, trace-mode=-off-);
auto result = parser::parse(input, -parser-, trace-mode=-off-);
bool r = parser::parse(input, -parser-, -skip-, -atr-, trace-mode=-off-);
auto result = parser::parse(input, -parser-, -skip, trace-mode=-off-);
Jan 21, 2025
c++ std::exception:
std::cout.write(err.data(), err.size());
std::cout << std::endl;
caught:
=================================== # The c++ programming language. # # # # Join c++ # # Deck # ===================================