Boost logo

Boost Users :

Subject: Re: [Boost-users] [Spirit] chset_p
From: Thomas Taylor (thomas.taylor_at_[hidden])
Date: 2009-07-03 10:32:43


Commander Pirx wrote:

> Hi all,
>
> I've detected a strange behavior of Spirit using (VC9SP1). I assume that
Spirit has its own mailing list, which is the best place to post for
questions about Spirit.

> chset_p( "-_!#$%&*+|~" ) and
> chset_p( "!#$%&*+-_|~" )
>
> are identical. I've only changed the order of the characters a little bit.
> But when i'm trying to parse a string like "abcd-edfg: " the parser eats
> the ':' sign but shouldn't. Examples here:
>
> token_ = alnum_p | chset_p( "-_!#$%&*+|~" );
>
> // the line above works fine
>
> token_ = alnum_p | chset_p( "!#$%&*+-_|~" );
>
> // here the ':' sign will be consumed!
Behaviour like that baffled me too at first, but is actually easy to
explain: In the first variant chset_p( "-_!#$%&*+|~" ) has the "-" as the
first character, so this is fine, it will be treated as "-". The second
variant chset_p( "!#$%&*+-_|~" ) has the "-" in the middle, so this is
treated as the range from "+" to "_", which assuming you use ascii
encompasses the ":" (and a lot of other character from #43 to #95).

HTH,
Thomas Taylor


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net