Parser utils for ReaderT and StateT
instance
Parser.Parser.coeSimpleParser
{α ρ σ : Type}
:
Coe (SimpleParser Substring Char α) (ReaderT ρ (StateT σ (SimpleParser Substring Char)) α)
def
Parser.attemptM
{ρ σ α : Type}
(p : ReaderT ρ (StateT σ (SimpleParser Substring Char)) α)
:
ReaderT ρ (StateT σ (SimpleParser Substring Char)) α
extends Lean.Parser.attempt
Equations
- Parser.attemptM p f = do let __do_lift ← get let __discr ← liftM (Parser.withBacktracking (p f __do_lift)) match __discr with | (a, s) => do set s pure a
Instances For
Equations
Instances For
instance
Parser.instHOrElseSimpleParserSubstringCharReaderTStateT_regex
{α ρ σ : Type}
:
HOrElse (SimpleParser Substring Char α) (ReaderT ρ (StateT σ (SimpleParser Substring Char)) α)
(ReaderT ρ (StateT σ (SimpleParser Substring Char)) α)
Equations
Equations
- Parser.manyCore p acc = do let r ← Parser.efoldl (fun (arr : Array α) (x : α) => arr.push x) acc (Parser.withBacktracking p) pure r.fst
Instances For
extends Lean.Parser.many
Equations
- Parser.manyM p = do let __do_lift ← read liftM (Parser.manyCoreT✝ (p __do_lift) #[])
Instances For
Equations
- Parser.peekChar? = do let __do_lift ← Parser.eoption Parser.peek match __do_lift with | Sum.inl x => pure (some x) | Sum.inr val => pure none
Instances For
Equations
Instances For
def
Parser.withPosM
{ρ σ α : Type}
(p : ReaderT ρ (StateT σ (SimpleParser Substring Char)) α)
:
ReaderT ρ (StateT σ (SimpleParser Substring Char)) (String.Pos.Raw × String.Pos.Raw × α)
Equations
Instances For
Equations
- Parser.withPosSkip = do let __discr ← Parser.withPos Parser.anyToken match __discr with | (fst, t, snd) => pure t
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 : Parser.Error.Simple Substring Char) => pure ()
Instances For
Equations
- Parser.skipString tks = Parser.Char.string tks *> pure ()
Instances For
Equations
- Parser.skipString? tks = tryCatch (Parser.withBacktracking (Parser.skipString tks)) fun (x : Parser.Error.Simple Substring Char) => 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
def
Parser.tryCharThenPWithPos
{α : Type}
(check : Char → Bool)
(p : SimpleParser Substring Char α)
:
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 σ (SimpleParser Substring Char)) α)
:
ReaderT ρ (StateT σ (SimpleParser Substring Char)) (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 ← Parser.manyCore p #[] pure chars.toList.asString
Instances For
Equations
- Parser.many1Chars p = do let __do_lift ← p let chars ← Parser.manyCore p #[__do_lift] pure chars.toList.asString