Documentation

Regex.Syntax.Grammar.Loop

Parser utils for ReaderT and StateT

Instances For
    theorem Parser.advanced_of_lt (s : String.Slice) (p q : s.Pos) (h : p < q) :
    ParseIt.Advanced { internalState := { slice := s, pos := q } } { internalState := { slice := s, pos := p } }
    @[simp]
    @[irreducible]
    def Parser.loopTakeMany? {ρ σ β α : Type} (pre : ReaderT ρ (StateT σ SimpleCharParser) β) (post : β → Array α → ReaderT ρ (StateT σ SimpleCharParser) α) (alternative : ReaderT ρ (StateT σ SimpleCharParser) α) (hpre : ∀ (r : ρ) (st : σ) (it rest₁ : Std.Iter Char) (h₁ : ParseIt.Progress rest₁ it) (x : β × σ), pre r st it = ParseIt.Result.ok rest₁ h₁ x → ParseIt.Advanced rest₁ it) :

    loopTakeMany corresponds to the following parser:

      loop := (pre >>= fun x => StateT.takeMany loop >>= fun y => post x y) <|> alternative
    

    It return a value iff there is no termination failure.

    Instances For
      theorem Parser.loopTakeMany?_eq_some {ρ σ β α : Type} (pre : ReaderT ρ (StateT σ SimpleCharParser) β) (post : β → Array α → ReaderT ρ (StateT σ SimpleCharParser) α) (alternative : ReaderT ρ (StateT σ SimpleCharParser) α) (hpre : ∀ (r : ρ) (st : σ) (it rest₁ : Std.Iter Char) (h₁ : ParseIt.Progress rest₁ it) (x : β × σ), pre r st it = ParseIt.Result.ok rest₁ h₁ x → ParseIt.Advanced rest₁ it) {r : ρ} {st st' : σ} {it rest : Std.Iter Char} {h : ParseIt.Progress rest it} {a : Option α} (heq : loopTakeMany? pre post alternative hpre r st it = ParseIt.Result.ok rest h (a, st')) :

      A successful loopManyM? always returns some.

      def Parser.loopTakeMany {ρ σ β α : Type} (pre : ReaderT ρ (StateT σ SimpleCharParser) β) (post : β → Array α → ReaderT ρ (StateT σ SimpleCharParser) α) (alternative : ReaderT ρ (StateT σ SimpleCharParser) α) (hpre : ∀ (r : ρ) (st : σ) (it rest₁ : Std.Iter Char) (h₁ : ParseIt.Progress rest₁ it) (x : β × σ), pre r st it = ParseIt.Result.ok rest₁ h₁ x → ParseIt.Advanced rest₁ it) :

      loopTakeMany corresponds to the following mutual recursive parser:

        loop := (pre >>= fun x => StateT.takeMany loop >>= fun y => post x y) <|> alternative
      

      with the property ParseIt.Advanced for parser pre which excludes termination failures

      Instances For