Re: [boost] spirit: character set complement (for lexers)
by Joel de Guzman other posts by this author
Oct 23 2002 5:57AM messages near this date
RE: [boost] spirit: character set complement (for lexers)
|
Re:[boost] Serialization: problem with multi-inheritance
----- Original Message -----
From: "Petr Kocmid" <pkocmid@[...].cz>
> > Perhaps ~ch_p('x') and ~digit_p will both result to a chset as well.
> > However, there's a problem. Character sets can support 8/16/32
> > bits. While it is clear that ~ch_p('x') is chset<char> with everything
> > on except 'x', and ~ch_p(L'x') will be chset<wchar_t>, what will be
> > the type of ~digit_p? Shall it be hardcoded to chset<char>?
>
> Perhaps using a chset seems to be a little overkill in certain cases.
>
> I have this idea, resulted from closer look in primitives.hpp: for all single character pa
rsers
which are using locale-style check call in their test function, the most efficient way to ma
ke a
complementar parser would be to add a completely new little parser, such as not_digit_p, hav
ing
return !impl::isdigit_ in underlying test().
>
> Then ~digit_p could map to not_digit_p and vice versa, making such complement operation na
turally
symmetric. And honoring locale, too. More, no need to hardcode anything to chset<char> .
Hmmm. Nice idea. I think this is practical (and fast!)
If there are no objections, I think I like this :-)
Cheers,
--Joel
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Petr Kocmid
Joel de Guzman
Petr Kocmid
Joel de Guzman
|