Re: Boost Spirit and VS2017
Michael Powell <[email protected]> Wed, 31 Oct 2018 09:48:25 -0400
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <CAMEoF_HTz7RTPkW1ebcyKY8tRKOkvjZj+sWJJ-=u_V+57C_4Ew@mail.gmail.com> |
On Tue, Oct 30, 2018 at 6:57 PM Michael Powell <[email protected]> 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, and is preserved only for > compatibility with workarounds for old versions of Visual C++. It will > be removed in a future release, and in this release always returns 0. > Please use standards-conforming mechanisms to manipulate fpos, such as > conversions to and from streamoff, or an integral type, instead. If > you are receiving this message while compiling Boost.IOStreams, a fix > has been submitted upstream to make Boost use standards-conforming > mechanisms, as it does for other compilers. You can define > _SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING to acknowledge that you have > received this warning, or define _REMOVE_FPOS_SEEKPOS to remove > std::fpos::seekpos entirely. > 1>c:\program files (x86)\microsoft visual > studio\2017\enterprise\vc\tools\msvc\14.15.26726\include\iosfwd(59): > note: see declaration of 'std::fpos<_Mbstatet>::seekpos' I got past this issue. Thanks go to Gavin on the Boost list! Still need to acknowledge with the definition however. > With my grammar: > > BOOST_FUSION_ADAPT_STRUCT(NS_VERSION_H::version, _major, _minor, > _patch, _build); > > template <typename It> > struct version_parser : qi::grammar<It, NS_VERSION_H::version()> { > > version_parser() : dot_('.'), version_parser::base_type(_start) { > using qi::lit; > using qi::hold; > using qi::short_; > _major_part = short_; > _minor_part = lit(dot_) >> short_; > _patch_part = lit(dot_) >> short_; > _build_part = lit(dot_) >> short_; > _start = hold[_major_part >> _minor_part >> -(_patch_part >> > -_build_part)]; > } > > private: > > qi::rule<It, NS_VERSION_H::version()> _start; > const char dot_; > qi::rule<It, short()> _major_part; > qi::rule<It, short()> _minor_part; > qi::rule<It, short()> _patch_part; > qi::rule<It, short()> _build_part; > }; > > bool try_parse_version(const std::string& s, NS_VERSION_H::version& v) { > using It = std::string::const_iterator; > using qi::parse; > > It first = s.begin(), last = s.end(); > > if (!parse(first, last, version_parser<It>{}, v)) { > std::cout << "Failed to parse: '" << s << "'" << std::endl; > return false; > } > > const auto dot_ = "."; > > std::cout << "version: " > << v._major > << dot_ << v._minor > << dot_ << v._patch > << dot_ << v._build << std::endl; > > return true; > } It seems to be parsing all but the last element. I think it's an EOI issue? But memory escapes me at the moment how Spirit Qi handles that use case... Something like this? using qi::lit; using qi::no_skip; using qi::short_; using qi::eoi; _major_part = short_; _minor_part = lit(dot_) >> short_; _patch_part = lit(dot_) >> short_; _build_part = lit(dot_) >> short_; _start = no_skip[_major_part >> _minor_part >> (_patch_part | (_patch_part >> _build_part))] >> eoi; Cheers! > At present I have not furnished any Spirit flags or anything of that > sort; pretty much taking the includes, grammar, building as-is. > > Secondary to the error, I want the parser to reject spaces, should > just be numeric (short) and the dot delimiter. > > Best regards, > > Michael Powell