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

Equations
Instances For

    get array of reference

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

      modify array, try to perform the update destructively

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Char position in a slice of some underlying string.

        Instances For

          create a CharPos from s and position «at»

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            to next position of cp

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Represents a stack frame on the heap while doing backtracking.

              Instances For
                @[implicit_reducible]
                Equations
                • One or more equations did not get rendered due to their size.
                @[reducible, inline]

                The stack of frames

                Equations
                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

                  Equations
                  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

                    Equations
                    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.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For