Re: IPv6 mapped phrase not parsing MSVC2015

Michael Powell <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <CAMEoF_GXnFCAFznZuo5fF8257+jma7nv9Hrg5R4oG8moqm4KsQ@mail.gmail.com>
Duh!

On Mon, Dec 25, 2017 at 3:11 PM, Michael Powell <[email protected]> wrote:
> Hello,
>
> Merry Christmas!
>
> The same phrases/grammar is working on GCC but does not appear to work
> across platforms on Microsoft Visual C++ 2015.
>
> https://wandbox.org/permlink/LDudwkvVa0M7J6z0

Helps when I actually include the grammar in question among the
candidate parsers:

void VerifyMappedAddress(const std::string& addr, bool expected_match
    , const std::function<void(const std::string&, const
Ast::IPv4MappedAddress)>& verify) {
    typedef std::string::const_iterator It;
    MappedAddrParser0<It> g0; MappedAddrParser1<It> g1;
    MappedAddrParser2<It> g2; MappedAddrParser3<It> g3;
    //                        ^^^^^^^^^^^^^^^^^^^^^^^^^
    Ast::IPv4MappedAddress y;
    INFO("Verifying address >>> " + addr + " <<<");
    // And with some variadic help, gets the job done.
    auto const actual_match = TryVerifyGrammars<It, Ast::IPv4MappedAddress
        , decltype(g0), decltype(g1), decltype(g2), decltype(g3)>(
            addr.begin(), addr.end(), y, expected_match, g0, g1, g2, g3);
    if (actual_match == expected_match) {
        verify(addr, y);
    }
    else {
        FAIL("Failed to identify the expected match");
    }
}


> The first couple of IPv4 mapped phrase grammars work, no problem. But
> when I jump into the third, all of a sudden there is a problem. I've
> tried different iterations how to compose the grammar, all are
> rejecting the test case:
>
> // Micro-grammar representing the phrase: / [*1(h16 ":") h16] "::"
> 3(h16 ":") ls32
> _ipv6_addr_base = lexeme[
>     _h16_col >> _h16 >> _col_x2 >> _h16_col >> _h16_col >> _h16
>         | /* */ _h16 >> _col_x2 >> _h16_col >> _h16_col >> _h16
>         | /*         */ _col_x2 >> _h16_col >> _h16_col >> _h16
> ];
>
> // or...
> _ipv6_addr_base = lexeme[
>     -(_h16_col >> _h16
>         | /*   */ _h16
>         ) >> _col_x2 >> _h16_col >> _h16_col >> _h16
> ];
>
> // or...
> _ipv6_addr_base = lexeme[(
>     _h16_col >> _h16 >> _col_x2
>     | _h16 >> /*     */ _col_x2
>     | /*             */ _col_x2
>     ) >> _h16_col >> _h16_col >> _h16
> ];
>
> // The bit with the ':' delimiter is the odd exception to including
> Colon in the address.
> _start = _ipv6_addr_base >> col_ >> _ls32 >> eoi;
>
> // The test case: "::c60:b132:f8e2:120.48.69.95"
>
> The same grammar/test case in GCC appears to pass without difficulties.
>
> Running with Boost version: '106501'
> Parsing '::1234:3456:5678:0.12.234.50' -> ::1234:3456:5678:0.12.234.50 (PASS)
>
> Phrase elements are composed in the same way across platforms using
> Integer parsers, etc.
>
> What is the cross platform issue with Boost.Spirit, then? Open to suggestions...
>
> Cheers,
>
> Michael Powell

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.