Documentation

Regex.Backtrack

BoundedBacktracker #

An NFA backed bounded backtracker for executing regex searches with capturing groups (BoundedBacktracker.slots).

This regex engine only implements leftmost-first match semantics and only supports leftmost searches. By design, this backtracking regex engine is bounded. This bound is implemented by not visiting any combination of NFA state ID and position in a haystack more than once.

All searches execute in linear time with respect to the size of the regular expression and search text.

def BoundedBacktracker.Array.Ref.mkRef {α β : Type} [Inhabited β] (arr : Array α) :
ST.Ref β (Array α)

make reference of array

Instances For

    get array of reference

    Instances For
      def BoundedBacktracker.Array.Ref.modifyRefValue {α β : Type} [Inhabited β] (ref : ST.Ref β (Array α)) (index : Nat) (value : α) (f : ST.Out β Unit → Bool := fun (x : ST.Out β Unit) => decide True) :
      ST.Ref β (Array α)

      modify array, try to perform the update destructively

      Instances For

        Char position in a slice of some underlying string.

        Instances For

          create a CharPos from s and position «at»

          Instances For

            to next position of cp

            Instances For

              Represents a stack frame on the heap while doing backtracking.

              Instances For
                @[instance_reducible]
                @[reducible, inline]

                The stack of frames

                Instances For
                  @[inline]
                  def BoundedBacktracker.Stack.push {n : Nat} {s : String.Slice} (stack : Stack n s) (v : Frame n s) :
                  Stack n s

                  Push frame to stack

                  Instances For
                    @[inline]
                    def BoundedBacktracker.Stack.pop? {n : Nat} {s : String.Slice} (stack : Stack n s) :
                    Option (Frame n s × Stack n s)

                    pop head frame from stack

                    Instances For

                      Search for the first match of this regex in the haystack given and return log msgs and the matches of each capture group.

                      Instances For