Parser utils for ReaderT and StateT
Equations
Instances For
@[reducible, inline]
Equations
Instances For
@[instance_reducible]
instance
Parser.Parser.coeSimpleParser
{α ρ σ : Type}
:
Coe (SimpleCharParser α) (ReaderT ρ (StateT σ SimpleCharParser) α)
Equations
- Parser.Parser.coeSimpleParser = { coe := fun (p : Parser.SimpleCharParser α) (x : ρ) (σ_1 : σ) => do let __do_lift ← p pure (__do_lift, σ_1) }
Equations
Instances For
Equations
- Parser.mkSimpleError it msg = ParseIt.Result.error ((ParseIt.Error.Simple.unexpected (ParseIt.HasPos.pos it) none).addMessage (ParseIt.HasPos.pos it) msg)
Instances For
@[irreducible]
def
Parser.loop
{ρ σ α : Type}
(f : ReaderT ρ (StateT σ SimpleCharParser) α → ReaderT ρ (StateT σ SimpleCharParser) α)
:
ReaderT ρ (StateT σ SimpleCharParser) α
The recursive function loop calls p with a parser that acts like p
except it fails if called from the same or lower string position
see https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/Advent.20of.20Code.3F/near/405471085
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Parser.StateT.efoldlP
{ε ι τ : Type u}
{m : Type u → Type v}
[Std.Iterator ι Id τ]
{β α σ : Type u}
[Std.Iterators.Finite ι Id]
[Monad m]
(f : β → α → StateT σ (ParseIt.ParserT ε ι τ m) β)
(init : β)
(p : StateT σ (ParseIt.ParserT ε ι τ m) α)
:
StateT σ (ParseIt.ParserT ε ι τ m) (β × Option ε)
Equations
- Parser.StateT.efoldlP f init p s it = Parser.StateT.efoldlP.loop f p s it init it (ParseIt.Progress.refl it)
Instances For
@[irreducible]
def
Parser.StateT.efoldlP.loop
{ε ι τ : Type u}
{m : Type u → Type v}
[Std.Iterator ι Id τ]
{β α σ : Type u}
[Monad m]
(f : β → α → StateT σ (ParseIt.ParserT ε ι τ m) β)
(p : StateT σ (ParseIt.ParserT ε ι τ m) α)
[Std.Iterators.Finite ι Id]
(s : σ)
(it : Std.Iter τ)
(y : β)
(cur : Std.Iter τ)
(hcur : ParseIt.Progress cur it)
:
m (ParseIt.Result ε it ((β × Option ε) × σ))
Fold from iterator cur, which it progressed to, with accumulator y.
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Parser.StateT.foldlP
{ε ι τ : Type u}
{m : Type u → Type v}
[Std.Iterator ι Id τ]
{β α σ : Type u}
[Std.Iterators.Finite ι Id]
[Monad m]
(f : β → α → StateT σ (ParseIt.ParserT ε ι τ m) β)
(init : β)
(p : StateT σ (ParseIt.ParserT ε ι τ m) α)
:
StateT σ (ParseIt.ParserT ε ι τ m) β
Equations
- Parser.StateT.foldlP f init p = Prod.fst <$> Parser.StateT.efoldlP f init p
Instances For
def
Parser.StateT.foldl
{ε ι τ : Type u}
{m : Type u → Type v}
[Std.Iterator ι Id τ]
{β α σ : Type u}
[Std.Iterators.Finite ι Id]
[Monad m]
(f : β → α → β)
(init : β)
(p : StateT σ (ParseIt.ParserT ε ι τ m) α)
:
StateT σ (ParseIt.ParserT ε ι τ m) β
Equations
- Parser.StateT.foldl f init p = Parser.StateT.foldlP (fun (y : β) (x : α) => pure (f y x)) init p
Instances For
def
Parser.manyM
{ρ σ α : Type}
(p : ReaderT ρ (StateT σ SimpleCharParser) α)
:
ReaderT ρ (StateT σ SimpleCharParser) (Array α)
Equations
- Parser.manyM p r = Parser.StateT.foldl (fun (acc : Array α) (a : α) => acc.push a) #[] (p r)
Instances For
Instances For
Instances For
def
Parser.withPosM
{ρ σ α : Type}
(p : ReaderT ρ (StateT σ SimpleCharParser) α)
:
ReaderT ρ (StateT σ SimpleCharParser) (String.Pos.Raw × String.Pos.Raw × α)
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- Parser.skipChar? c = tryCatch (Parser.skipChar c) fun (x : ParseIt.Error.Simple ParseIt.CharIterator) => pure ()
Instances For
Equations
- Parser.skipString tks = ParseIt.Char.string tks *> pure ()
Instances For
Equations
- Parser.skipString? tks = tryCatch (Parser.skipString tks) fun (x : ParseIt.Error.Simple ParseIt.CharIterator) => pure ()
Instances For
exec check on current char and consume char on success
Equations
- One or more equations did not get rendered due to their size.
Instances For
exec check on current char and skip char on success
Equations
- Parser.trySkipChar check = do let __do_lift ← Parser.tryChar check match __do_lift with | some val => pure true | x => pure false
Instances For
exec check on current char and then exec p on success
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Parser.tryCharThenPWithPosM
{ρ σ α : Type}
(check : Char → Bool)
(p : ReaderT ρ (StateT σ SimpleCharParser) α)
:
ReaderT ρ (StateT σ SimpleCharParser) (Option (String.Pos.Raw × String.Pos.Raw × α))
exec check on current char and then exec p on success
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Parser.tryCharWithPosMap
{α : Type}
(check : Char → Bool)
(f : Char → String.Pos.Raw → String.Pos.Raw → α)
:
Equations
Instances For
Equations
- Parser.manyChars p = do let chars ← ParseIt.foldl (fun (acc : Array Char) (a : Char) => acc.push a) #[] p pure (String.ofList chars.toList)
Instances For
Equations
- Parser.many1Chars p = do let __do_lift ← p let chars ← ParseIt.foldl (fun (acc : Array Char) (a : Char) => acc.push a) #[__do_lift] p pure (String.ofList chars.toList)