Module Earley_core.Charset
Type
type t
= charset
Synonym of
charset
.
Charset construction
val empty : charset
The empty character set.
val full : charset
The full character set.
val singleton : char -> charset
singleton c
returns a charset containing onlyc
.
val range : char -> char -> charset
range cmin cmax
returns the charset containing all the characters betweencmin
andcmax
.
val from_string : string -> charset
from_string s
returns the charset corresponding to the description strings
, which may contain standalone characters (different from'-'
, which is only allowed as first character) or ranges. They are build of start and end characters, separated by'-'
. An example of a valid description is"-_a-zA-Z0-9"
. Note thatInvalid_argument
is raised in case of ill-formed description.
val union : charset -> charset -> charset
union cs1 cs2
builds a new charset that contins the union of the characters ofcs1
andcs2
.
val complement : charset -> charset
complement cs
returns a new charset containing exactly characters that are not incs
.
Membership test
val mem : charset -> char -> bool
mem cs c
tests whether the charsetcs
containsc
.
Printing and string representation
val print : Stdlib.out_channel -> charset -> unit
print oc cs
prints the charsetcs
to the output channeloc
. A compact format is used for printing: common ranges are used and full and empty charsets are abreviated.
val print_full : Stdlib.out_channel -> charset -> unit
print_full oc cs
is the same asprint oc cs
but it does not use abreviations (i.e. all characters are displayed).
val show : charset -> string
show oc cs
builds a string representing the charsetcs
using the same compact format asprint
.
val show_full : charset -> string
show_full oc cs
is the same asshow oc cs
but it does not use abreviations (i.e. all characters appear).
Manipulating charsets imperatively
val addq : charset -> char -> unit
addq cs c
adds the characterc
to the charsetcs
. Users must be particularly careful when using this function. In particular, it should not be used directly onempty
,full
or the result of thesingleton
function as it would change their value permanently. It is advisable to prefer the use ofadd
or to work on acopy
.
val delq : charset -> char -> unit
delq cs c
deletes the characterc
from the charsetcs
. Similar recomendatiosn as foraddq
apply.