Boost logo

Boost Users :

Subject: Re: [Boost-users] Simple XML parser - error handling - line number
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2018-06-29 20:21:54


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: \"")
> << construct<std::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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net