Re: [Qi] Phrase parsed but iterator did not reach end

Michael Powell <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <CAMEoF_FH=g=bBquxc4HpK8UWCzibJvBVrnT=SwSNzRxyD6f3sg@mail.gmail.com>
On Mon, Nov 27, 2017 at 9:11 AM, Michael Powell <[email protected]> wrote:
> On Mon, Nov 27, 2017 at 7:51 AM, Seth <[email protected]> wrote:
>> On 25-11-17 00:42, Michael Powell wrote:
>>
>> Basically to validate all the patterns from 0-65535 (valid port range).
>>
>> If that's the goal, see
>>
>> https://stackoverflow.com/questions/44156112/boost-spirit-qi-changing-tag-of-specialized-uint-parser/44158086#44158086
>>
>>      uint_parser<uint16_t, 10, 2, 5>();
>>
>> which correctly parses 0..65535.
>
> uint_parser accepts MinDigits and MaxDigits. If that's the case,
> wouldn't that be matching things like "00" through "99999"? At least
> at self-documenting face value.
>
> Now, if that were bit-width, that would be another story, I think,
> i.e. masking values within the mask 0x...ffff, I'd buy that.
>
>> A more complete example:
>>
>> https://stackoverflow.com/questions/47243884/boost-spirit-qi-validating-input-parser/47244585#47244585
>>
>> Which makes the point that you might want to `lexeme [ uint_parser<uint16_t,
>> 10, 2, 5>() >> !(digit|'.') ]` to avoid partially matching longer numbers.

So, an interesting corollary is that the same seems to work for octets
as it does for port numbers.

lexeme[uint_parser<uint8_t, 10, 1, 3>() >> !(digit | '.')];

After further consideration, perhaps it is the T that is constraining
the range, not the digits. However, that isn't obviously clear, even
after diving deeper through the inheritance chain.

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.