package earley
Install
Dune Dependency
Authors
Maintainers
Sources
md5=6b666c0392dc5b153f81c27d6ef49b12
sha512=a81d2bcf05088a3aaa5c3c0fb3a38306061a624ddf6d8bbefee1b4a17d7a5961ad1b12c0af9bd8dce86aa14b6f05f1956b3f7b5731f3c552bec7f4550182c398
doc/earley.core/Earley_core/Charset/index.html
Module Earley_core.Charset
Source
A module providing efficient character sets.
Type
The abstract type for a character set.
Charset construction
range cmin cmax
returns the charset containing all the characters between cmin
and cmax
.
from_string s
returns the charset corresponding to the description string s
, 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 that Invalid_argument
is raised in case of ill-formed description.
union cs1 cs2
builds a new charset that contins the union of the characters of cs1
and cs2
.
complement cs
returns a new charset containing exactly characters that are not in cs
.
add cs c
returns a new charset containing the characters of cs
and the character c
.
del cs c
returns a new charset containing the characters of cs
but not the character c
.
Membership test
Printing and string representation
print oc cs
prints the charset cs
to the output channel oc
. A compact format is used for printing: common ranges are used and full and empty charsets are abreviated.
print_full oc cs
is the same as print oc cs
but it does not use abreviations (i.e. all characters are displayed).
show oc cs
builds a string representing the charset cs
using the same compact format as print
.
show_full oc cs
is the same as show oc cs
but it does not use abreviations (i.e. all characters appear).
Manipulating charsets imperatively
addq cs c
adds the character c
to the charset cs
. Users must be particularly careful when using this function. In particular, it should not be used directly on empty
, full
or the result of the singleton
function as it would change their value permanently. It is advisable to prefer the use of add
or to work on a copy
.