Documentation

Init.Data.String.Pattern.Basic

A step taken during the traversal of a Slice by a forward or backward searcher.

  • rejected {s : Slice} (startPos endPos : s.Pos) : SearchStep s

    The subslice starting at startPos and ending at endPos did not match the pattern.

  • matched {s : Slice} (startPos endPos : s.Pos) : SearchStep s

    The subslice starting at startPos and ending at endPos matches the pattern.

Instances For
    Equations
      Instances For
        class String.Slice.Pattern.ToForwardSearcher {ρ : Type} (pat : ρ) (σ : outParam (SliceType)) :

        Provides a conversion from a pattern to an iterator of SearchStep that searches for matches of the pattern from the start towards the end of a Slice.

        • toSearcher (s : Slice) : Std.Iter (SearchStep s)

          Builds an iterator of SearchStep corresponding to matches of pat along the slice s. The SearchSteps returned by this iterator must contain ranges that are adjacent, non-overlapping and cover all of s.

        Instances

          Provides simple pattern matching capabilities from the start of a Slice.

          While these operations can be implemented on top of ToForwardSearcher some patterns allow for more efficient implementations. This class can be used to specialize for them. If there is no need to specialize in this fashion, then ForwardPattern.defaultImplementation can be used to automatically derive an instance.

          • startsWith : SliceBool

            Checks whether the slice starts with the pattern.

          • dropPrefix? (s : Slice) : Option s.Pos

            Checks whether the slice starts with the pattern. If it does, the slice is returned with the prefix removed; otherwise the result is none.

          Instances
            @[extern lean_string_memcmp]
            def String.Slice.Pattern.Internal.memcmpStr (lhs rhs : String) (lstart rstart len : Pos.Raw) (h1 : len.offsetBy lstart lhs.rawEndPos) (h2 : len.offsetBy rstart rhs.rawEndPos) :
            Equations
              Instances For
                @[inline]
                def String.Slice.Pattern.Internal.memcmpSlice (lhs rhs : Slice) (lstart rstart len : Pos.Raw) (h1 : len.offsetBy lstart lhs.rawEndPos) (h2 : len.offsetBy rstart rhs.rawEndPos) :
                Equations
                  Instances For
                    @[specialize #[3]]
                    def String.Slice.Pattern.ForwardPattern.defaultStartsWith {ρ : Type} {σ : SliceType} [(s : Slice) → Std.Iterator (σ s) Id (SearchStep s)] (pat : ρ) [ToForwardSearcher pat σ] (s : Slice) :
                    Equations
                      Instances For
                        @[specialize #[3]]
                        def String.Slice.Pattern.ForwardPattern.defaultDropPrefix? {ρ : Type} {σ : SliceType} [(s : Slice) → Std.Iterator (σ s) Id (SearchStep s)] (pat : ρ) [ToForwardSearcher pat σ] (s : Slice) :
                        Equations
                          Instances For
                            @[inline]
                            Equations
                              Instances For
                                class String.Slice.Pattern.ToBackwardSearcher {ρ : Type} (pat : ρ) (σ : outParam (SliceType)) :

                                Provides a conversion from a pattern to an iterator of SearchStep searching for matches of the pattern from the end towards the start of a Slice.

                                • toSearcher (s : Slice) : Std.Iter (SearchStep s)

                                  Build an iterator of SearchStep corresponding to matches of pat along the slice s. The SearchSteps returned by this iterator must contain ranges that are adjacent, non-overlapping and cover all of s.

                                Instances

                                  Provides simple pattern matching capabilities from the end of a Slice.

                                  While these operations can be implemented on top of ToBackwardSearcher, some patterns allow for more efficient implementations. This class can be used to specialize for them. If there is no need to specialize in this fashion, then BackwardPattern.defaultImplementation can be used to automatically derive an instance.

                                  • endsWith : SliceBool

                                    Checks whether the slice ends with the pattern.

                                  • dropSuffix? (s : Slice) : Option s.Pos

                                    Checks whether the slice ends with the pattern. If it does, the slice is returned with the suffix removed; otherwise the result is none.

                                  Instances
                                    @[specialize #[3]]
                                    Equations
                                      Instances For
                                        @[specialize #[3]]
                                        Equations
                                          Instances For
                                            @[inline]
                                            Equations
                                              Instances For