Boost logo

Boost :

From: Noah Stein (Noah_at_[hidden])
Date: 2002-10-22 14:18:07


> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Thomas Wenisch
> Sent: Tuesday, October 22, 2002 12:05 PM
> To: Boost mailing list
> Subject: RE: [boost] Re: Formal Review: The Spirit Parser Framework.
>
>
> Hartmut,
>
> On Tue, 22 Oct 2002, Hartmut Kaiser wrote:
>
> > Peter Dimov wrote:
> >
> > > > After what your code looks like:
> > > >
> > > > nonctl_char = urange_p( '\x21', '\xFF' );
> > >
> > > The question is, would you ever want ['\x21', '\xFF'] to
> > > _not_ be a valid
> > > range?
> >
> > If this is what you want, you could write 'epsilon_p - urange_p( '\x21',
> > '\xFF' )', essentially this means 'match everything (epsilon_p) except
> > ('-') the given range :-)
> >
>
>
> Perhaps I misread Peter's post, but I understood his question to mean,
> why is the assertion error useful? Why would we want range_p to assert if
> the lower bound > upper bound? (Peter, correct me if I am misinterpreting
> your question).
>
> If this causes users headaches because of the signed-ness of char, why
> not simply reverse the bounds, since this almost certainly what was
> intended. Here, I think it would be better for the code to simply work,
> instead of issuing a runtime diagnostic of questionable usefulness.
>
> Thoughts?

But this is probably not what he wants. As a 16-bit integer, what he wants
is 0x0021 -> 0x00FF. If he's dealing with 8-bit signed characters, and a
flip of the range is performed, the unsigned range he'll check is 0xFF,
0x00 -> 0x21. This is the complement to his set. Although messy, right now
I think assertion is the best option. My $.02.

-- Noah


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk