Re: IPv6 address parsing
Michael Powell <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <CAMEoF_FbMtjKR+6RVa3Te91cLcZ6Mj=4zjaWdJg27O=1kqvedw@mail.gmail.com> |
On Tue, Dec 19, 2017 at 4:25 AM, Seth <[email protected]> wrote: > On 17-12-17 16:42, Michael Powell wrote: > > i.e. repeat(1, 4)[hex] SHOULD reject "abcd1234" but it is not. > > Of course it SHOULD not. If you want that, program it. We've been over this > many times before: What are you talking about, "it SHOULD not"? I *DID* "program" it; I want from 1 to 4 hexadecimal characters. *THAT'S IT*! No fewer, no more. That's the whole point of repeat(1, 4)[...] isn't it? It's possible I am misunderstanding the nature of HEX, per se, which, after consulting again with the docs, probably I am. http://www.boost.org/doc/libs/1_66_0/libs/spirit/doc/html/spirit/qi/reference/numeric/uint.html That is to say, if *HEX* is excessively greedy, that's another matter, entirely. Perhaps then the PEG hex that is provided is ill suited to the task, and rather the uint_parser in the appropriate base-16 Radix is the better solution to the problem at hand. That's what I'm getting at here, the dynamics of repeating a specific number of hex characters. Same goes for bin and oct; I'm not sure how useful matching a general form value of that pattern, or a specific xyz(num) is, when what I want, at least in this instance, is a single "digit". But this does not appear to be the nature of these particular parsers. Sorry if that seems confusing; much of which seems to be mine. I'm just trying to sort out the nuts and bolts of Spirit/Qi in order to apply the best solution. > On 08-12-17 16:53, Seth wrote: > > On 04-12-17 23:09, Michael Powell wrote: > > I should think that if there were any remaining input that would be a > failure to match? > > You shouldn't. PEG grammars are left-to-right greedy. This is documented. > > I've said this before: > > On 30-11-17 00:40, Seth wrote: > > Bonus tip: consider adding `>> qi::eoi` at the end of the parse > expression so you don't need to check whether all of the input has been > consumed (it must). > > And also this warning about partially matching: > > On 27-11-17 13:51, Seth wrote: > > 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. > > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot