vxml_pipeline/split_replacement

Literal and regular-expression rules for splitting text into VXML.

A split rule operates on text nodes only. Text outside a match remains text; each matched segment is interpreted according to a SplitReplacement. Rules can therefore introduce temporary VXML elements that a later desugarer pairs, folds, or otherwise interprets. Regular-expression fragments supplied to this module must not contain capturing groups unless a function explicitly documents otherwise.

Types

Associates one capture-group pattern with its replacement instruction.

pub type CaptureGroupReplacement {
  CaptureGroupReplacement(
    pattern: String,
    replacement: SplitReplacement,
  )
}

Constructors

A compiled regular expression whose capture groups have corresponding VXML replacement instructions.

pub type RegexpSplitRule {
  RegexpSplitRule(
    regexp: regexp.Regexp,
    capture_groups: List(CaptureGroupReplacement),
  )
}

Constructors

Determines how one matched regular-expression segment becomes VXML.

pub type SplitReplacement {
  Keep
  Discard
  DropLastCharacter
  Tag(String)
  TagWithSegmentAsValue(String, String)
  TagWithSegmentChild(String)
  TagThenText(String, String)
  TextThenTag(String, String)
}

Constructors

  • Keep
  • Discard
  • DropLastCharacter
  • Tag(String)
  • TagWithSegmentAsValue(String, String)
  • TagWithSegmentChild(String)
  • TagThenText(String, String)
  • TextThenTag(String, String)

Values

pub fn apply_regexp_split_rule(
  vxml: vxml.VXML,
  rule: RegexpSplitRule,
) -> List(vxml.VXML)

Applies one regular-expression split rule to a VXML node.

V-nodes are returned unchanged. Each line of a T-node is split separately, and the resulting text and element nodes retain blame advanced from the original line.

pub fn apply_regexp_split_rules(
  vxml: vxml.VXML,
  rules: List(RegexpSplitRule),
) -> List(vxml.VXML)

Applies several regular-expression split rules in order to one VXML node.

pub fn naive_unescaped_split_node(
  vxml: vxml.VXML,
  splitter: String,
  escaped_splitter_replacement: String,
  replacement: SplitReplacement,
) -> List(vxml.VXML)

Splits the lines of one text node on an unescaped literal delimiter.

V-nodes are returned unchanged. escaped_splitter_replacement specifies the text restored for escaped occurrences, while replacement determines how active occurrences become VXML.

pub fn parenthesize(s: String) -> String

Wraps a regular-expression fragment in a capturing group.

The fragment must not contain capturing groups of its own. Use noncapturing groups ((?:...)) inside the fragment instead.

pub const regex_prefix_to_make_unescaped: String

Regular-expression prefix that requires an even-length run of backslashes immediately before a delimiter.

pub fn regexp_split_rule(
  pattern pattern: String,
  replacement replacement: SplitReplacement,
) -> RegexpSplitRule

Constructs a single-group regular-expression split rule.

pattern must not contain capturing groups. Use noncapturing groups ((?:...)) inside it instead.

pub fn regexp_split_rule_for_groups(
  pairs: List(#(String, SplitReplacement)),
) -> RegexpSplitRule

Constructs a split rule from adjacent capture-group instructions.

The regular-expression fragment in each pair must not contain capturing groups. Use noncapturing groups ((?:...)) inside the fragments instead.

pub fn regexp_split_rule_to_string(
  rule: RegexpSplitRule,
) -> String

Returns a diagnostic representation of a regular-expression split rule.

pub fn remaining_unescaped_splits(
  splits: List(String),
  escaped_splitter_replacement: String,
) -> List(String)

Recombines literal split segments whose separators were escaped.

splits is the result of splitting on a literal delimiter and must be nonempty. A delimiter preceded by an odd-length backslash run is restored as escaped_splitter_replacement, consuming one escaping backslash. An even run leaves the delimiter active.

pub fn unescaped_regexp_split_rule(
  pattern pattern: String,
  replacement replacement: SplitReplacement,
) -> RegexpSplitRule

Constructs a split rule for an unescaped regular-expression suffix.

pattern must not contain capturing groups. Use noncapturing groups ((?:...)) inside it instead.

pub fn unescaped_suffix(suffix: String) -> String

Extends suffix so it matches only occurrences preceded by an even-length run of backslashes.

Search Document