- success: {α : Type} → String.Iterator → α → Lean.Parsec.ParseResult α
- error: {α : Type} → String.Iterator → String → Lean.Parsec.ParseResult α
instance
Lean.Parsec.instReprParseResult
:
{α : Type} → [inst : Repr α] → Repr (Lean.Parsec.ParseResult α)
Equations
- Lean.Parsec.instReprParseResult = { reprPrec := [anonymous] }
Equations
Equations
- Lean.Parsec.instInhabitedParsec α = { default := fun it => Lean.Parsec.ParseResult.error it "" }
@[inline]
Equations
- Lean.Parsec.pure a it = Lean.Parsec.ParseResult.success it a
@[inline]
Equations
- Lean.Parsec.bind f g it = match f it with | Lean.Parsec.ParseResult.success rem a => g a rem | Lean.Parsec.ParseResult.error pos msg => Lean.Parsec.ParseResult.error pos msg
Equations
- Lean.Parsec.instMonadParsec = Monad.mk
@[inline]
Equations
- Lean.Parsec.fail msg it = Lean.Parsec.ParseResult.error it msg
@[inline]
Equations
- Lean.Parsec.orElse p q it = match p it with | Lean.Parsec.ParseResult.success rem a => Lean.Parsec.ParseResult.success rem a | Lean.Parsec.ParseResult.error rem err => if it = rem then q () it else Lean.Parsec.ParseResult.error rem err
@[inline]
Equations
- Lean.Parsec.attempt p it = match p it with | Lean.Parsec.ParseResult.success rem res => Lean.Parsec.ParseResult.success rem res | Lean.Parsec.ParseResult.error x err => Lean.Parsec.ParseResult.error it err
Equations
- Lean.Parsec.instAlternativeParsec = Alternative.mk (fun {α} => Lean.Parsec.fail "") fun {α} => Lean.Parsec.orElse
Equations
- Lean.Parsec.expectedEndOfInput = "expected end of input"
@[inline]
Equations
@[inline]
partial def
Lean.Parsec.manyCore
{α : Type}
(p : Lean.Parsec α)
(acc : Array α)
:
Lean.Parsec (Array α)
@[inline]
Equations
- Lean.Parsec.many p = Lean.Parsec.manyCore p #[]
@[inline]
Equations
- Lean.Parsec.many1 p = do let a ← p Lean.Parsec.manyCore p #[a]
@[inline]
@[inline]
Equations
@[inline]
Equations
- Lean.Parsec.many1Chars p = do let a ← p Lean.Parsec.manyCharsCore p (Char.toString a)
Equations
- Lean.Parsec.pstring s it = let substr := String.Iterator.extract it (String.Iterator.forward it (String.length s)); if substr = s then Lean.Parsec.ParseResult.success (String.Iterator.forward it (String.length s)) substr else Lean.Parsec.ParseResult.error it (toString "expected: " ++ toString s ++ toString "")
@[inline]
Equations
- Lean.Parsec.skipString s = SeqRight.seqRight (Lean.Parsec.pstring s) fun x => pure ()
Equations
- Lean.Parsec.unexpectedEndOfInput = "unexpected end of input"
@[inline]
Equations
@[inline]
Equations
- Lean.Parsec.pchar c = Lean.Parsec.attempt do let a ← Lean.Parsec.anyChar if a = c then pure c else Lean.Parsec.fail (toString "expected: '" ++ toString c ++ toString "'")
@[inline]
Equations
- Lean.Parsec.skipChar c = SeqRight.seqRight (Lean.Parsec.pchar c) fun x => pure ()
@[inline]
Equations
- Lean.Parsec.digit = Lean.Parsec.attempt do let c ← Lean.Parsec.anyChar if Char.ofNat 48 ≤ c ∧ c ≤ Char.ofNat 57 then pure c else Lean.Parsec.fail (toString "digit expected")
@[inline]
Equations
- Lean.Parsec.hexDigit = Lean.Parsec.attempt do let c ← Lean.Parsec.anyChar if Char.ofNat 48 ≤ c ∧ c ≤ Char.ofNat 57 ∨ Char.ofNat 97 ≤ c ∧ c ≤ Char.ofNat 97 ∨ Char.ofNat 65 ≤ c ∧ c ≤ Char.ofNat 65 then pure c else Lean.Parsec.fail (toString "hex digit expected")
@[inline]
Equations
- Lean.Parsec.asciiLetter = Lean.Parsec.attempt do let c ← Lean.Parsec.anyChar if Char.ofNat 65 ≤ c ∧ c ≤ Char.ofNat 90 ∨ Char.ofNat 97 ≤ c ∧ c ≤ Char.ofNat 122 then pure c else Lean.Parsec.fail (toString "ASCII letter expected")
@[inline]
Equations
- Lean.Parsec.satisfy p = Lean.Parsec.attempt do let c ← Lean.Parsec.anyChar if p c = true then pure c else Lean.Parsec.fail "condition not satisfied"
@[inline]
Equations
- Lean.Parsec.notFollowedBy p it = match p it with | Lean.Parsec.ParseResult.success x x_1 => Lean.Parsec.ParseResult.error it "" | Lean.Parsec.ParseResult.error x x_1 => Lean.Parsec.ParseResult.success it ()
@[inline]
Equations
- Lean.Parsec.peek? it = if String.Iterator.hasNext it = true then Lean.Parsec.ParseResult.success it (some (String.Iterator.curr it)) else Lean.Parsec.ParseResult.success it none
@[inline]
Equations
- Lean.Parsec.peek! = do let discr ← Lean.Parsec.peek? match discr with | some c => pure c | x => Lean.Parsec.fail Lean.Parsec.unexpectedEndOfInput
@[inline]
Equations
@[inline]