MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / parse

Function parse

extlibs/vili/src/parser/parser.cpp:18–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16namespace 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 {

Callers 2

from_stringFunction · 0.70
from_fileFunction · 0.70

Calls 5

parsing_errorClass · 0.85
line_atMethod · 0.80
nestMethod · 0.80
whatMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected