Std.Regex.Syntax.Flags (Cure Standard Library v0.37.2)

View Source

Parser helpers for regex literal modifiers such as i, m, and u.

Examples

use Std.Regex.Syntax.Model
use Std.Regex.Syntax.Flags

parse_literal_flags(['i', 'm'], literal_default_options())
literal_extended_space(' ')             # => true

Summary

Functions

Return true if char is an ASCII whitespace character ignored in extended (x) mode.

Pair each character of input with its sequential source position starting from position.

Parse regex literal modifier characters into a LiteralFlags result, updating options for each recognized flag (i, m, s, x, u, f, U, E).

Prepare a raw regex literal character list for parsing, stripping extended whitespace and comments when ExtendedModifier is enabled while recording original source positions.

Prepend a character and its original source offset onto a LiteralSourceMap.

Strip unescaped whitespace and #-to-newline comments under extended (x) mode while preserving character classes and source positions.

Preserve characters verbatim inside a [...] character class under extended (x) mode until the closing ].

Preserve the character immediately following a backslash inside a character class under extended (x) mode.

Discard characters in an extended (x) mode # comment up to and including the terminating newline.

Preserve the character immediately following a backslash in extended (x) mode and resume stripping the remainder.

Functions

literal_extended_space(char: Char) -> Bool

 fn literal_extended_space(char: Char) -> Bool

Return true if char is an ASCII whitespace character ignored in extended (x) mode.

map_literal_source(input: List(Char), position: Nat) -> LiteralSourceMap

 fn map_literal_source(input: List(Char), position: Nat) -> LiteralSourceMap

Pair each character of input with its sequential source position starting from position.

parse_literal_flags(flags: List(Char), options: LiteralRegexOptions) -> LiteralFlags

 fn parse_literal_flags(flags: List(Char), options: LiteralRegexOptions) -> LiteralFlags

Parse regex literal modifier characters into a LiteralFlags result, updating options for each recognized flag (i, m, s, x, u, f, U, E).

prepare_literal(pattern: List(Char), options: LiteralRegexOptions) -> LiteralPrepared

 fn prepare_literal(pattern: List(Char), options: LiteralRegexOptions) -> LiteralPrepared

Prepare a raw regex literal character list for parsing, stripping extended whitespace and comments when ExtendedModifier is enabled while recording original source positions.

prepend_literal_source(char: Char, position: Nat, mapped: LiteralSourceMap) -> LiteralSourceMap

 fn prepend_literal_source(char: Char, position: Nat, mapped: LiteralSourceMap) -> LiteralSourceMap

Prepend a character and its original source offset onto a LiteralSourceMap.

strip_extended(input: List(Char), position: Nat) -> LiteralSourceMap

 fn strip_extended(input: List(Char), position: Nat) -> LiteralSourceMap

Strip unescaped whitespace and #-to-newline comments under extended (x) mode while preserving character classes and source positions.

strip_extended_class(input: List(Char), position: Nat) -> LiteralSourceMap

 fn strip_extended_class(input: List(Char), position: Nat) -> LiteralSourceMap

Preserve characters verbatim inside a [...] character class under extended (x) mode until the closing ].

strip_extended_class_escaped(input: List(Char), position: Nat) -> LiteralSourceMap

 fn strip_extended_class_escaped(input: List(Char), position: Nat) -> LiteralSourceMap

Preserve the character immediately following a backslash inside a character class under extended (x) mode.

strip_extended_comment(input: List(Char), position: Nat) -> LiteralSourceMap

 fn strip_extended_comment(input: List(Char), position: Nat) -> LiteralSourceMap

Discard characters in an extended (x) mode # comment up to and including the terminating newline.

strip_extended_escaped(input: List(Char), position: Nat) -> LiteralSourceMap

 fn strip_extended_escaped(input: List(Char), position: Nat) -> LiteralSourceMap

Preserve the character immediately following a backslash in extended (x) mode and resume stripping the remainder.