Re: Boost Spirit and VS2017

Michael Powell <[email protected]> Wed, 31 Oct 2018 13:16:58 -0400
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <CAMEoF_F1ocQo5g-H8JDTsH6eHdEmFwewzWBg3ebD0K4WeASZyw@mail.gmail.com>
On Wed, Oct 31, 2018 at 12:15 PM Dan Bloomquist <[email protected]> wrote:
>
> Michael Powell wrote:
> > Hello,
> >
> > I am receiving the following error building against the latest VS2017 ...
> >
> > 1>Version_Parser.cpp
> > 1>d:\dev\boost.org\boost_1_68_0\boost\iostreams\positioning.hpp(96):
> > error C4996: 'std::fpos<_Mbstatet>::seekpos': warning STL4019: The
> > member std::fpos::seekpos() is non-Standard....
>
> building with v141, not the latest and
> _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
>
> I get no errors or warnings. on the other hand, I think you want your
> parser to look like:
> _major_part >> _minor_part >> -_patch_part >> -_build_par
>
> At that, if using v141, why not just use x3? It is so much easier on the
> eyes.
> Best, Dan.
>
> .....................................................................................
> using namespace boost::spirit::x3;
> struct version
> {
>      short _major= 0;
>      short _minor= 0;
>      short _patch= 0;
>      short _build= 0;
>
> };
> BOOST_FUSION_ADAPT_STRUCT(version, _major, _minor,  _patch, _build);
>
> auto const part = rule<struct _, short>("part") = int_ >> -lit(".");
> auto const ver = rule<struct ver_def, version>("ver") = part >> part >>
> -part >> -part;

That's curious. I think I more or less did that, but I had grouping
going on, i.e.:

auto const ver = rule<struct ver_def, version>("ver") = part >> part
>> -(part >> -part);

Or even:

auto const ver = rule<struct ver_def, version>("ver") = part >> part
>> -(part | part >> part);

And I was finding that all but the last element would get parsed.

> void test(const char* in)
> {
>      std::string str(in);
>      version vers;
>      auto begin = str.begin();
>      phrase_parse(begin, end(str), ver, space, vers);
>
>      std::cout << "end: " << begin
>          << "* " << vers._major
>          << " " << vers._minor
>          << " " << vers._patch
>          << " " << vers._build
>          << std::endl;
> }
>
> int main()
> {
>      test("1. 2.3. 4");
>      test("1 . 2");
>      return 0;
> }
>
> _______________________________________________
> Spirit-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spirit-general