Documentation

Regex.Nfa

NFA #

A byte oriented Thompson non-deterministic finite automaton (Checked.NFA), see also Tagged NFA.

@[reducible, inline]

The identifier of a regex pattern, represented by a Nat

Equations
Instances For
    inductive NFA.Look :

    The high-level intermediate representation for a look-around assertion.

    • Start: NFA.Look

      Match the beginning of text.

    • End: NFA.Look

      Match the end of text.

    • EndWithOptionalLF: NFA.Look

      Match the end of text (before optional newline).

    • StartLF: NFA.Look

      Match the beginning of a line or the beginning of text.

    • EndLF: NFA.Look

      Match of a line or the end of text.

    • StartCRLF: NFA.Look

      Match the beginning of a line or the beginning of text.

    • EndCRLF: NFA.Look

      Match of a line or the end of text.

    • WordUnicode: NFA.Look

      Match a Unicode-aware word boundary.

    • WordUnicodeNegate: NFA.Look

      Match a Unicode-aware negation of a word boundary.

    • WordStartUnicode: NFA.Look

      Match the start of a Unicode word boundary.

    • WordEndUnicode: NFA.Look

      Match the end of a Unicode word boundary.

    • WordStartHalfUnicode: NFA.Look

      Match the start half of a Unicode word boundary.

    • WordEndHalfUnicode: NFA.Look

      Match the end half of a Unicode word boundary.

    • PreviousMatch: NFA.Look

      Match the end of the previous match or start of string

    • ClearMatches: NFA.Look

      Clear matches

    Instances For
      Equations
      Instances For
        @[reducible, inline]

        The identifier of a finite automaton state, represented by a Nat. The identifier may refer to a non existing state.

        Equations
        Instances For
          Instances For

            A single transition to another state. This transition may only be followed if the current char in the haystack falls in the inclusive range of chars specified.

            • start : UInt32

              The inclusive start of the char range.

            • end : UInt32

              The inclusive end of the char range.

            • The identifier of the state to transition to.

            Instances For

              check if c falls in the inclusive range of chars specified in Transition trans

              Equations
              Instances For

                A state in an NFA.

                Instances For
                  Equations
                  Instances For

                    A char oriented Thompson non-deterministic finite automaton (NFA).

                    Instances For
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        inductive NFA.Checked.EatMode (n : Nat) :
                        Instances For
                          Equations
                          Instances For
                            Equations
                            • NFA.Checked.instToStringEatMode = { toString := NFA.Checked.EatMode.toString }

                            A single transition to another state. This transition may only be followed if the current char in the haystack falls in the inclusive range of chars specified.

                            • start : Nat

                              The inclusive start of the char range.

                            • end : Nat

                              The inclusive end of the char range.

                            • next : Fin n

                              The identifier of the state to transition to.

                            Instances For

                              check if c falls in the inclusive range of chars specified in Transition trans

                              Equations
                              Instances For
                                inductive NFA.Checked.State (n : Nat) :

                                A state in an NFA, the elements of Fin n refer to existing states in the NFA.

                                • Empty: {n : Nat} → Fin nNFA.Checked.State n

                                  An empty state whose only purpose is to forward the automaton to another state via an unconditional epsilon transition.

                                • NextChar: {n : Nat} → NatFin nNFA.Checked.State n

                                  use netx char

                                • Fail: {n : Nat} → NFA.Checked.State n

                                  Fail, force backtracking

                                • Eat: {n : Nat} → NFA.Checked.EatMode nFin nNFA.Checked.State n

                                  remove Frame.Step in stack

                                • ChangeFrameStep: {n : Nat} → Fin nFin nNFA.Checked.State n

                                  change Frame.Step in stack and force backtracking

                                • RemoveFrameStep: {n : Nat} → Fin nNFA.Checked.State n

                                  remove Frame.Step in stack and force backtrack

                                • BackRef: {n : Nat} → NatBoolFin nNFA.Checked.State n

                                  A state with a single transition may only be followed if the currunt chars match the backrefence to the capturung group.

                                • ByteRange: {n : Nat} → NFA.Checked.Transition nNFA.Checked.State n

                                  A state with a single transition that can only be taken if the current input symbol is in a particular range of chars.

                                • SparseTransitions: {n : Nat} → Array (NFA.Checked.Transition n)NFA.Checked.State n

                                  A sequence of transitions used to represent a sparse state.

                                • Look: {n : Nat} → NFA.LookFin nNFA.Checked.State n

                                  A conditional epsilon transition satisfied via some sort of look-around.

                                • Union: {n : Nat} → Array (Fin n)NFA.Checked.State n

                                  An alternation such that there exists an epsilon transition to all states in alternates, where matches found via earlier transitions are preferred over later transitions.

                                • UnionReverse: {n : Nat} → Array (Fin n)NFA.Checked.State n

                                  An alternation such that there exists an epsilon transition to all states in alternates, where matches found via later transitions are preferred over earlier transitions.

                                • BinaryUnion: {n : Nat} → Fin nFin nNFA.Checked.State n

                                  An alternation such that there exists precisely two unconditional epsilon transitions

                                • Capture: {n : Nat} → NFA.Capture.RoleFin nNFA.PatternIDNatNatNFA.Checked.State n

                                  An empty state that records a capture location. slot in this context refers to the specific capture group slot offset that is being recorded. Each capturing group has two slots corresponding to the start and end of the matching portion of that group.

                                • Match: {n : Nat} → NFA.PatternIDNFA.Checked.State n

                                  A match state. There is at least one such occurrence of this state for each regex that can match that is in this NFA.

                                Instances For
                                  Equations
                                  • NFA.Checked.instBEqState = { beq := NFA.Checked.beq' }
                                  Equations
                                  Instances For
                                    Equations
                                    • NFA.Checked.instToStringState = { toString := fun (s : NFA.Checked.State n) => s.toString }

                                    A char oriented Thompson non-deterministic finite automaton (NFA) with n states

                                    • n : Nat

                                      number of states

                                    • states : Array (NFA.Checked.State self.n)

                                      states of the NFA

                                    • unanchored_prefix_in_backtrack : Bool

                                      simulate a unanchored prefix by the backtracker

                                    • isEq : self.n = self.states.size

                                      assertion that n equals size of states

                                    Instances For
                                      Equations
                                      instance NFA.Checked.instCoeFinNSizeStateStates {nfa : NFA.Checked.NFA} :
                                      Coe (Fin nfa.n) (Fin nfa.states.size)
                                      Equations
                                      • NFA.Checked.instCoeFinNSizeStateStates = { coe := fun (n : Fin nfa.n) => Fin.castLE n }
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For

                                        transform Unchecked.NFA to Checked.NFA

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