Simple XML parser - error handling - line number
I see tutorial sample: https://www.boost.org/doc/libs/1_67_0/libs/spirit/example/qi/mini_xml3.cpp https://www.boost.org/doc/libs/1_67_0/libs/spirit/example/qi/mini_xml3.cpp on_error<fail> ( xml , std::cout << val("Error! Expecting ") << _4 // what failed? << val(" here: \"") << constructstd::string(_3, _2) // iterators to error-pos, end << val("\"") << std::endl ); How print line number, or how print _2 and _3 . If I write _2 instead _4, is compiler error. -- Sent from: http://boost.2283326.n4.nabble.com/Boost-Users-f2553780.html
AMDG On 06/29/2018 12:43 PM, AndrzejB via Boost-users wrote:
I see tutorial sample: https://www.boost.org/doc/libs/1_67_0/libs/spirit/example/qi/mini_xml3.cpp https://www.boost.org/doc/libs/1_67_0/libs/spirit/example/qi/mini_xml3.cpp on_error<fail> ( xml , std::cout << val("Error! Expecting ") << _4 // what failed? << val(" here: \"") << constructstd::string(_3, _2) // iterators to error-pos, end << val("\"") << std::endl ); How print line number,
The parser doesn't track line numbers at all. If you want to print it, you'll need to add something to count new lines.
or how print _2 and _3 . If I write _2 instead _4, is compiler error.
_2 and _3 are iterators. You can't print them directly. Hence why this code constructs a string from them. In Christ, Steven Watanabe
participants (2)
-
AndrzejB
-
Steven Watanabe