Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2002-10-21 18:10:06

----- Original Message -----
From: "Petr Kocmid" <pkocmid_at_[hidden]>

> I digged in spirit 1.5.1 last night. Impressive stuff, really.


> Well, I sugest to reconsider about parser operator~ (with set complement semantics) for somewhat
limited usage. While it is problematic at large (as noted in operators.html), it could be quite
useful in lexers if applied on single character parsers, such as:
> ~ch_p('x') matches a single character, any other than x
> ~digit_p matches any non-digit character
> and so on with any other single character parser primitives.
> On contrary, it's usage for any string consuming parser or sequence should generate a compile time
warning or error.
> AFAIK, ANTLR uses such complement for characters, and even unicode intervals, which comes to be
very handy.

Oh, the chset (see character_sets.html) do support set inverse.
And you are right. Perhaps it should be extended to support
single character parsers selectively. For instance, ~anychar_p
is supported already ~anychar_p => nothing_p

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>?

Many thanks,

Boost list run by bdawes at, gregod at, cpdaniel at, john at