silk.text.regex_unicode.
Unicode 17.0.0 case folding, property and range tables for silk.text.regex.
When to use#
Use silk.text.regex in application code. This module is the regular-expression engine's
Unicode support: ECMAScript case folding, the property sets \p{...} names, and the range
arithmetic that builds character classes.
Details#
The tables are compact range encodings, generated from the Unicode 17.0.0 Character Database
(Unicode License v3) by SilkJS's scripts/generate_unicode.py. The encoding started from
QuickJS, Copyright (c) 2017-2021 Fabrice Bellard and Charlie Gordon, under the MIT license in
licenses/quickjs.txt.
Public declarations: 6.
CaseMapping#
pub struct CaseMappingThe full Unicode case-fold mapping of one scalar, with at most three scalar values.
Only the first length entries of points are part of the result.
Field points#
pub points: [u32; 3]The mapped scalars, followed by zero entries that are not part of the result.
Field length#
pub length: usizeThe number of mapped scalars, from one through three.
UnicodeCase#
pub struct UnicodeCaseECMAScript case canonicalization and character classes over Unicode scalars.
Implementation UnicodeCase#
impl UnicodeCaseAssociated function fold#
pub fn fold(c: u32) -> CaseMappingReturns the full, locale-independent Unicode 17.0.0 case fold of c.
Details#
The result contains one through three scalars. An unmapped value is returned unchanged. Use this mapping for caseless text comparison; it can expand one scalar into several scalars.
Associated function canonicalize#
pub fn canonicalize(c: u32, isUnicode: bool) -> u32Applies ECMAScript RegExp canonicalization, which never expands a code point.
Associated function isSpace#
pub fn isSpace(code: u32) -> boolTests ECMAScript whitespace, including BOM but excluding NEXT LINE.
Associated function isWordByte#
pub fn isWordByte(code: u32) -> boolTests the ASCII word characters \w matches: letters, digits and _.
Associated function isIdentifierStart#
pub fn isIdentifierStart(code: u32) -> boolTests whether code can start an ECMAScript identifier, as a capture name requires.
Associated function isIdentifierContinue#
pub fn isIdentifierContinue(code: u32) -> boolTests whether code can continue an ECMAScript identifier, including ZWNJ and ZWJ.
UnknownProperty#
pub struct UnknownPropertyThe failure for a property name or value that is not an exact supported alias.
UnicodeProperties#
pub struct UnicodePropertiesThe character sets that \p{...} and \P{...} name.
Implementation UnicodeProperties#
impl UnicodePropertiesAssociated function isScriptName#
pub static fn isScriptName(name: string) -> boolReturns whether name is a script name or alias that \p{Script=name} accepts.
Details#
A static function, for checking a pattern while it compiles. It reads the name table the engine's own script lookup reads.
Associated function isCategoryName#
pub static fn isCategoryName(name: string) -> boolReturns whether name is a general category name or alias that \p{gc=name} accepts.
Details#
A static function, for checking a pattern while it compiles. It reads the name table the engine's own category lookup reads.
Associated function isBinaryName#
pub static fn isBinaryName(name: string) -> boolReturns whether name is a binary property name or alias that \p{name} accepts.
Details#
A static function, for checking a pattern while it compiles. It reads the name table the engine's own property lookup reads, and admits only the properties it can build.
Associated function script#
pub effect fn script(name: string, extensions: bool) -> CharRange
! OutOfMemoryError | UnknownProperty
? &mut AllocatorResolves exact Unicode script names and aliases; optionally applies Script_Extensions.
Errors#
UnknownPropertyifnameis not an exact supported alias.OutOfMemoryErrorif the allocator cannot supply the set.
Associated function generalCategory#
pub effect fn generalCategory(name: string) -> CharRange
! OutOfMemoryError | UnknownProperty
? &mut AllocatorResolves exact short/long category aliases and aggregate categories.
Errors#
UnknownPropertyifnameis not an exact supported alias.OutOfMemoryErrorif the allocator cannot supply the set.
Associated function property#
pub effect fn property(name: string) -> CharRange
! OutOfMemoryError | UnknownProperty
? &mut AllocatorResolves the supported binary property names and aliases.
Errors#
UnknownPropertyifnameis not an exact supported alias.OutOfMemoryErrorif the allocator cannot supply the set.
Associated function sequences#
pub effect fn sequences<'env, E, ? R>(
name: string,
mut visit: for<use 'call> mut fn<'env>(&[u32]) -> once Effect<'call & 'env; () ! E ? R>,
) -> ()
! OutOfMemoryError | UnknownProperty | E
? &mut Allocator | RVisits all sequences in upstream order. The borrowed stack buffer lasts only for the call.
Errors#
UnknownPropertyifnameis not an exact supported alias.Any failure of
visit.OutOfMemoryErrorif the allocator cannot supply the set.
RangeOperation#
pub enum RangeOperationHow CharRange.apply combines two sets.
Union#
UnionCharacters in either set.
Intersection#
IntersectionCharacters in both sets.
Xor#
XorCharacters in exactly one set.
Subtract#
SubtractCharacters in the first set and not the second.
CharRange#
pub struct CharRangeSorted, disjoint half-open intervals over u32 character values. Inversion uses an exclusive UINT32_MAX sentinel, not 0x110000.
Implementation CharRange#
impl CharRangeAssociated function make#
pub fn make() -> CharRangeReturns an empty set.
Method points#
pub fn points(self: &Self) -> &[u32]Returns the interval boundaries: each even index starts an interval, each odd index ends one.
Method clear#
pub fn clear(self: &mut Self) -> ()Removes every interval and keeps the storage.
Method reserve#
pub effect fn reserve(self: &mut Self, additional: usize) -> ()
! OutOfMemoryError
? &mut AllocatorReserves room for additional more boundaries.
Errors#
OutOfMemoryErrorif the allocator cannot grow the storage.
Method addInterval#
pub effect fn addInterval(self: &mut Self, start: u32, end: u32) -> ()
! OutOfMemoryError
? &mut AllocatorUnions a half-open interval, merging overlaps and adjacent intervals.
Errors#
OutOfMemoryErrorif the allocator cannot supply the set.
Method unionInterval#
pub effect fn unionInterval(self: &mut Self, first: u32, last: u32) -> ()
! OutOfMemoryError
? &mut AllocatorInterval union uses inclusive endpoints and unsigned wrapping.
Errors#
OutOfMemoryErrorif the allocator cannot supply the set.
Method apply#
pub effect fn apply(self: &mut Self, other: &CharRange, operation: RangeOperation) -> ()
! OutOfMemoryError
? &mut AllocatorReplaces this set with its combination with other.
Errors#
OutOfMemoryErrorif the allocator cannot supply the result.
Method invert#
pub effect fn invert(self: &mut Self) -> ()
! OutOfMemoryError
? &mut AllocatorReplaces this set with its complement over all u32 values.
Errors#
OutOfMemoryErrorif the allocator cannot grow the storage.
Method canonicalize#
pub effect fn canonicalize(self: &mut Self, isUnicode: bool) -> ()
! OutOfMemoryError
? &mut AllocatorCanonicalizes only case-changing table runs, never the whole character domain.
Errors#
OutOfMemoryErrorif the allocator cannot supply the set.
Category: Text.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.