moonrockz/diagrams/regex

Types

AnchorKind

pub(all) enum AnchorKind {
  LineStart
  LineEnd
  InputStart
  InputEndBeforeNewline
  InputEnd
  PreviousMatchEnd
  WordBoundary
  NonWordBoundary
} derive(Eq, @moonbitlang/core/debug.Debug)

A zero-width position test that consumes no input.

Source

AnchorKind::equal

fn AnchorKind::equal(AnchorKind, AnchorKind) -> Bool

Source

AnchorKind::not_equal

fn AnchorKind::not_equal(x : AnchorKind, y : AnchorKind) -> Bool

Source

AnchorKind::to_repr

fn AnchorKind::to_repr(AnchorKind) -> @moonbitlang/core/debug.Repr

Source

Bounds

pub struct Bounds {
  min : Int
  max : Int?
  reluctant : Bool
  spelling : String
} derive(Eq, @moonbitlang/core/debug.Debug)

Symbolic repetition bounds. A repeat is never expanded into copies.

Source

Bounds::equal

fn Bounds::equal(Bounds, Bounds) -> Bool

Source

Bounds::new

fn Bounds::new(min : Int, max? : Int, reluctant? : Bool, spelling? : String) -> Bounds

Make bounds. The spelling defaults to the canonical regex quantifier.

Source

Bounds::not_equal

fn Bounds::not_equal(x : Bounds, y : Bounds) -> Bool

Source

Bounds::to_repr

fn Bounds::to_repr(Bounds) -> @moonbitlang/core/debug.Repr

Source

ClassKind

pub(all) enum ClassKind {
  Any
  Shorthand(Char)
  Property(String)
  CodePoint(String)
  Posix(String)
} derive(Eq, @moonbitlang/core/debug.Debug)

A predefined character class. The spelling is kept for display.

Source

ClassKind::equal

fn ClassKind::equal(ClassKind, ClassKind) -> Bool

Source

ClassKind::not_equal

fn ClassKind::not_equal(x : ClassKind, y : ClassKind) -> Bool

Source

ClassKind::to_repr

fn ClassKind::to_repr(ClassKind) -> @moonbitlang/core/debug.Repr

Source

GroupKind

pub(all) enum GroupKind {
  Capturing
  NonCapturing
  Named(String)
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

GroupKind::equal

fn GroupKind::equal(GroupKind, GroupKind) -> Bool

Source

GroupKind::not_equal

fn GroupKind::not_equal(x : GroupKind, y : GroupKind) -> Bool

Source

GroupKind::to_repr

fn GroupKind::to_repr(GroupKind) -> @moonbitlang/core/debug.Repr

Source

Index

pub struct Index {
  regex : Regex
  order : ReadOnlyArray[String]
  // private fields
}

A validated view of a regex model with constant-time lookups. Every node except the root has exactly one parent, so the arena is a finite tree.

Source

Index::build

fn Index::build(regex : Regex, limits? : Limits) -> IndexResult

Validate identities, ownership, bounds and explicit limits without recursion.

Source

Index::depth

fn Index::depth(self : Index, id : String) -> Int?

Source

Index::node

fn Index::node(self : Index, id : String) -> Node?

Source

Index::parent

fn Index::parent(self : Index, id : String) -> String?

Source

IndexResult

pub struct IndexResult {
  index : Index?
  diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}

Source

Kind

pub(all) enum Kind {
  Literal(String)
  Class(ClassKind)
  Set(Bool, ReadOnlyArray[SetItem])
  Anchor(AnchorKind)
  Backreference(String)
  Sequence(ReadOnlyArray[String])
  Choice(ReadOnlyArray[String])
  Group(GroupKind, String)
  Repeat(Bounds, String)
  Assertion(Look, Bool, String)
} derive(Eq, @moonbitlang/core/debug.Debug)

The meaning of one expression node. Composite kinds name their children by node identity, so a model is a flat, bounded arena.

Source

Kind::equal

fn Kind::equal(Kind, Kind) -> Bool

Source

Kind::not_equal

fn Kind::not_equal(x : Kind, y : Kind) -> Bool

Source

Kind::to_repr

fn Kind::to_repr(Kind) -> @moonbitlang/core/debug.Repr

Source

Limits

pub struct Limits {
  nodes : Int
  depth : Int
  work : Int
} derive(Eq, @moonbitlang/core/debug.Debug)

Explicit bounds for model validation and indexing.

Source

Limits::equal

fn Limits::equal(Limits, Limits) -> Bool

Source

Limits::new

fn Limits::new(nodes? : Int, depth? : Int, work? : Int) -> Limits

Source

Limits::not_equal

fn Limits::not_equal(x : Limits, y : Limits) -> Bool

Source

Limits::to_repr

fn Limits::to_repr(Limits) -> @moonbitlang/core/debug.Repr

Source

Look

pub(all) enum Look {
  Ahead
  Behind
} derive(Eq, @moonbitlang/core/debug.Debug)

The direction of a lookaround assertion.

Source

Look::equal

fn Look::equal(Look, Look) -> Bool

Source

Look::not_equal

fn Look::not_equal(x : Look, y : Look) -> Bool

Source

Look::to_repr

fn Look::to_repr(Look) -> @moonbitlang/core/debug.Repr

Source

Node

pub struct Node {
  id : String
  kind : Kind
  source : @moonrockz/diagrams.Span?
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

Node::children

fn Node::children(self : Node) -> ReadOnlyArray[String]

The children of node in drawing order.

Source

Node::equal

fn Node::equal(Node, Node) -> Bool

Source

Node::is_leaf

fn Node::is_leaf(self : Node) -> Bool

Literal text, classes, sets and anchors are leaves of the railroad.

Source

Node::label

fn Node::label(self : Node) -> String

The visible label of a leaf, or the name of a composite construct.

Source

Node::new

fn Node::new(id : String, kind : Kind, source? : @moonrockz/diagrams.Span) -> Node

Source

Node::not_equal

fn Node::not_equal(x : Node, y : Node) -> Bool

Source

Node::to_repr

fn Node::to_repr(Node) -> @moonbitlang/core/debug.Repr

Source

Regex

pub struct Regex {
  id : String
  root : String
  nodes : ReadOnlyArray[Node]
  title : String?
  accessibility_title : String?
  accessibility_description : String?
  pattern : String?
} derive(Eq, @moonbitlang/core/debug.Debug)

One immutable regular-expression diagram. It describes the structure of a pattern; it does not match input.

Source

Regex::equal

fn Regex::equal(Regex, Regex) -> Bool

Source

Regex::new

fn Regex::new(id : String, root : String, nodes : ArrayView[Node], title? : String, accessibility_title? : String, accessibility_description? : String, pattern? : String) -> Regex

Make a regex model. pattern is the optional source spelling for display.

Source

Regex::node

fn Regex::node(self : Regex, id : String) -> Node?

Find a node by identity. The search is linear; use Index for repeated lookups.

Source

Regex::not_equal

fn Regex::not_equal(x : Regex, y : Regex) -> Bool

Source

Regex::to_repr

fn Regex::to_repr(Regex) -> @moonbitlang/core/debug.Repr

Source

SetItem

pub(all) enum SetItem {
  Char(String)
  Range(String, String)
  Escape(String)
} derive(Eq, @moonbitlang/core/debug.Debug)

One item of a bracketed character set.

Source

SetItem::equal

fn SetItem::equal(SetItem, SetItem) -> Bool

Source

SetItem::not_equal

fn SetItem::not_equal(x : SetItem, y : SetItem) -> Bool

Source

SetItem::to_repr

fn SetItem::to_repr(SetItem) -> @moonbitlang/core/debug.Repr

Source

Values

diagnostic_codes

let diagnostic_codes : ReadOnlyArray[String]

The stable diagnostic codes of model validation.

Source

validate

fn validate(regex : Regex, limits? : Limits) -> ReadOnlyArray[@moonrockz/diagrams.Diagnostic]

Validate a constructed model. An empty result means the model is valid.

Source