MCPcopy Create free account
hub / github.com/boostorg/parser / main

Function main

example/semantic_actions.cpp:15–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace bp = boost::parser;
14
15int main()
16{
17 std::cout << "Enter a list of doubles, separated by commas. ";
18 std::string input;
19 std::getline(std::cin, input);
20
21 std::vector<double> result;
22//[ semantic_action_example_lambda
23 auto const action = [&result](auto & ctx) {
24 std::cout << "Got one!\n";
25 result.push_back(_attr(ctx));
26 };
27//]
28 auto const action_parser = bp::double_[action];
29 auto const success = bp::parse(input, action_parser % ',', bp::ws);
30
31 if (success) {
32 std::cout << "You entered:\n";
33 for (double x : result) {
34 std::cout << x << "\n";
35 }
36 } else {
37 std::cout << "Parse failure.\n";
38 }
39}
40//]

Callers

nothing calls this directly

Calls 2

_attrFunction · 0.85
parseFunction · 0.70

Tested by

no test coverage detected