| 16 | namespace vili::parser |
| 17 | { |
| 18 | template <class input_type> vili::node parse(input_type&& input, state parser_state) |
| 19 | { |
| 20 | try |
| 21 | { |
| 22 | peg::parse<vili::parser::rules::grammar, vili::parser::action, |
| 23 | vili::parser::control>(std::forward<input_type&&>(input), parser_state); |
| 24 | // std::cout << "Begin parsing" << std::endl; |
| 25 | /*peg::standard_trace<vili::parser::rules::grammar, vili::parser::action, |
| 26 | vili::parser::control>(std::forward<input_type&&>(input), parser_state);*/ |
| 27 | } |
| 28 | catch (peg::parse_error& e) |
| 29 | { |
| 30 | const auto p = e.positions.front(); |
| 31 | std::stringstream ss; |
| 32 | ss << e.what() << '\n' |
| 33 | << input.line_at(p) << '\n' |
| 34 | << std::setw(p.byte_in_line) << ' ' << '^' << std::endl; |
| 35 | throw exceptions::parsing_error( |
| 36 | input.source(), p.line, p.byte_in_line, VILI_EXC_INFO) |
| 37 | .nest(std::runtime_error(ss.str())); |
| 38 | } |
| 39 | /*catch (vili::exceptions::base_exception& e) |
| 40 | { |
| 41 | std::cerr << "vili::exception : " << e.what() << std::endl; |
| 42 | }*/ |
| 43 | |
| 44 | return parser_state.root; |
| 45 | } |
| 46 | |
| 47 | vili::node from_string(std::string_view data, state parser_state) |
| 48 | { |
no test coverage detected