Module Earley_core.Charset
Type
type t= charsetSynonym of
charset.
Charset construction
val empty : charsetThe empty character set.
val full : charsetThe full character set.
val singleton : char -> charsetsingleton creturns a charset containing onlyc.
val range : char -> char -> charsetrange cmin cmaxreturns the charset containing all the characters betweencminandcmax.
val from_string : string -> charsetfrom_string sreturns 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_argumentis raised in case of ill-formed description.
val union : charset -> charset -> charsetunion cs1 cs2builds a new charset that contins the union of the characters ofcs1andcs2.
val complement : charset -> charsetcomplement csreturns a new charset containing exactly characters that are not incs.
Membership test
val mem : charset -> char -> boolmem cs ctests whether the charsetcscontainsc.
Printing and string representation
val print : Stdlib.out_channel -> charset -> unitprint oc csprints the charsetcsto 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 -> unitprint_full oc csis the same asprint oc csbut it does not use abreviations (i.e. all characters are displayed).
val show : charset -> stringshow oc csbuilds a string representing the charsetcsusing the same compact format asprint.
val show_full : charset -> stringshow_full oc csis the same asshow oc csbut it does not use abreviations (i.e. all characters appear).
Manipulating charsets imperatively
val addq : charset -> char -> unitaddq cs cadds the charactercto the charsetcs. Users must be particularly careful when using this function. In particular, it should not be used directly onempty,fullor the result of thesingletonfunction as it would change their value permanently. It is advisable to prefer the use ofaddor to work on acopy.
val delq : charset -> char -> unitdelq cs cdeletes the charactercfrom the charsetcs. Similar recomendatiosn as foraddqapply.