@[inline]
Equations
- Lean.Parser.mkAtom info val = Lean.Syntax.atom info val
@[inline]
Equations
- Lean.Parser.mkIdent info rawVal val = Lean.Syntax.ident info rawVal val []
Equations
- Lean.Parser.getNext input pos = String.get input (String.next input pos)
- startPos : String.Pos
- stopPos : String.Pos
- token : Lean.Syntax
Equations
- Lean.Parser.initCacheForInput input = { tokenCache := { startPos := String.bsize input + 1, stopPos := 0, token := Lean.Syntax.missing } }
@[inline]
@[inline]
- input : String
- fileName : String
- fileMap : Lean.FileMap
Equations
- Lean.Parser.instInhabitedInputContext = { default := { input := default, fileName := default, fileMap := default } }
- env : Lean.Environment
- options : Lean.Options
- currNamespace : Lean.Name
- openDecls : List Lean.OpenDecl
structure
Lean.Parser.ParserContext
extends
Lean.Parser.InputContext
,
Lean.Parser.ParserModuleContext
:
Type
- prec : Nat
- tokens : Lean.Parser.TokenTable
- quotDepth : Nat
- suppressInsideQuot : Bool
- savedPos? : Option String.Pos
- forbiddenTk? : Option Lean.Parser.Token
Equations
- Lean.Parser.ParserContext.resolveName ctx id = Lean.ResolveName.resolveGlobalName ctx.toParserModuleContext.env ctx.toParserModuleContext.currNamespace ctx.toParserModuleContext.openDecls id
Equations
- Lean.Parser.instInhabitedError = { default := { unexpected := default, expected := default } }
Equations
- Lean.Parser.instBEqError = { beq := [anonymous] }
Equations
- Lean.Parser.Error.toString e = let unexpected := if (e.unexpected == "") = true then [] else [e.unexpected]; let expected := if (e.expected == []) = true then [] else let expected := Array.qsort (List.toArray e.expected) (fun e e' => decide (e < e')) 0 (Array.size (List.toArray e.expected) - 1); let expected := List.eraseReps (Array.toList expected); ["expected " ++ Lean.Parser.Error.expectedToString expected]; String.intercalate "; " (unexpected ++ expected)
Equations
- Lean.Parser.Error.instToStringError = { toString := Lean.Parser.Error.toString }
- stxStack : Array Lean.Syntax
- lhsPrec : Nat
- pos : String.Pos
- cache : Lean.Parser.ParserCache
- errorMsg : Option Lean.Parser.Error
@[inline]
Equations
- Lean.Parser.ParserState.hasError s = (s.errorMsg != none)
@[inline]
Equations
- Lean.Parser.ParserState.stackSize s = Array.size s.stxStack
def
Lean.Parser.ParserState.restore
(s : Lean.Parser.ParserState)
(iniStackSz : Nat)
(iniPos : Nat)
:
Equations
- Lean.Parser.ParserState.restore s iniStackSz iniPos = { stxStack := Array.shrink s.stxStack iniStackSz, lhsPrec := s.lhsPrec, pos := iniPos, cache := s.cache, errorMsg := none }
Equations
- Lean.Parser.ParserState.setPos s pos = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := pos, cache := s.cache, errorMsg := s.errorMsg }
def
Lean.Parser.ParserState.setCache
(s : Lean.Parser.ParserState)
(cache : Lean.Parser.ParserCache)
:
Equations
- Lean.Parser.ParserState.setCache s cache = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := s.pos, cache := cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.pushSyntax s n = { stxStack := Array.push s.stxStack n, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.popSyntax s = { stxStack := Array.pop s.stxStack, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.shrinkStack s iniStackSz = { stxStack := Array.shrink s.stxStack iniStackSz, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.next s input pos = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := String.next input pos, cache := s.cache, errorMsg := s.errorMsg }
def
Lean.Parser.ParserState.toErrorMsg
(ctx : Lean.Parser.ParserContext)
(s : Lean.Parser.ParserState)
:
Equations
- Lean.Parser.ParserState.toErrorMsg ctx s = match s.errorMsg with | none => "" | some msg => let pos := Lean.FileMap.toPosition ctx.toInputContext.fileMap s.pos; Lean.mkErrorStringWithPos ctx.toInputContext.fileName pos (toString msg)
def
Lean.Parser.ParserState.mkNode
(s : Lean.Parser.ParserState)
(k : Lean.SyntaxNodeKind)
(iniStackSz : Nat)
:
Equations
- Lean.Parser.ParserState.mkNode s k iniStackSz = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := err } => if (err != none && Array.size stack == iniStackSz) = true then let stack := Array.push stack Lean.Syntax.missing; { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := err } else let newNode := Lean.Syntax.node Lean.SourceInfo.none k (Array.extract stack iniStackSz (Array.size stack)); let stack := Array.shrink stack iniStackSz; let stack := Array.push stack newNode; { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := err }
def
Lean.Parser.ParserState.mkTrailingNode
(s : Lean.Parser.ParserState)
(k : Lean.SyntaxNodeKind)
(iniStackSz : Nat)
:
Equations
- Lean.Parser.ParserState.mkTrailingNode s k iniStackSz = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := err } => let newNode := Lean.Syntax.node Lean.SourceInfo.none k (Array.extract stack (iniStackSz - 1) (Array.size stack)); let stack := Array.shrink stack (iniStackSz - 1); let stack := Array.push stack newNode; { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := err }
Equations
- Lean.Parser.ParserState.setError s msg = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := x } => { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := "", expected := [msg] } }
Equations
- Lean.Parser.ParserState.mkError s msg = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := x } => { stxStack := Array.push stack Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := "", expected := [msg] } }
def
Lean.Parser.ParserState.mkUnexpectedError
(s : Lean.Parser.ParserState)
(msg : String)
(expected : optParam (List String) [])
:
Equations
- Lean.Parser.ParserState.mkUnexpectedError s msg expected = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := x } => { stxStack := Array.push stack Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := msg, expected := expected } }
def
Lean.Parser.ParserState.mkEOIError
(s : Lean.Parser.ParserState)
(expected : optParam (List String) [])
:
Equations
- Lean.Parser.ParserState.mkEOIError s expected = Lean.Parser.ParserState.mkUnexpectedError s "unexpected end of input" expected
def
Lean.Parser.ParserState.mkErrorAt
(s : Lean.Parser.ParserState)
(msg : String)
(pos : String.Pos)
(initStackSz? : optParam (Option Nat) none)
:
Equations
- Lean.Parser.ParserState.mkErrorAt s msg pos initStackSz? = match s, initStackSz? with | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := x_1 }, none => { stxStack := Array.push stack Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := "", expected := [msg] } } | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := x_1 }, some sz => { stxStack := Array.push (Array.shrink stack sz) Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := "", expected := [msg] } }
def
Lean.Parser.ParserState.mkErrorsAt
(s : Lean.Parser.ParserState)
(ex : List String)
(pos : String.Pos)
(initStackSz? : optParam (Option Nat) none)
:
Equations
- Lean.Parser.ParserState.mkErrorsAt s ex pos initStackSz? = match s, initStackSz? with | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := x_1 }, none => { stxStack := Array.push stack Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := "", expected := ex } } | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := x_1 }, some sz => { stxStack := Array.push (Array.shrink stack sz) Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := "", expected := ex } }
def
Lean.Parser.ParserState.mkUnexpectedErrorAt
(s : Lean.Parser.ParserState)
(msg : String)
(pos : String.Pos)
:
Equations
- Lean.Parser.ParserState.mkUnexpectedErrorAt s msg pos = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := x_1 } => { stxStack := Array.push stack Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := msg, expected := [] } }
Equations
- Lean.Parser.instInhabitedParserFn = { default := fun ctx s => s }
- epsilon: Lean.Parser.FirstTokens
- unknown: Lean.Parser.FirstTokens
- tokens: List Lean.Parser.Token → Lean.Parser.FirstTokens
- optTokens: List Lean.Parser.Token → Lean.Parser.FirstTokens
Equations
- Lean.Parser.instInhabitedFirstTokens = { default := Lean.Parser.FirstTokens.epsilon }
Equations
- Lean.Parser.FirstTokens.seq x x = match x, x with | Lean.Parser.FirstTokens.epsilon, tks => tks | Lean.Parser.FirstTokens.optTokens s₁, Lean.Parser.FirstTokens.optTokens s₂ => Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂) | Lean.Parser.FirstTokens.optTokens s₁, Lean.Parser.FirstTokens.tokens s₂ => Lean.Parser.FirstTokens.tokens (s₁ ++ s₂) | tks, x => tks
Equations
- Lean.Parser.FirstTokens.toOptional x = match x with | Lean.Parser.FirstTokens.tokens tks => Lean.Parser.FirstTokens.optTokens tks | tks => tks
Equations
- Lean.Parser.FirstTokens.merge x x = match x, x with | Lean.Parser.FirstTokens.epsilon, tks => Lean.Parser.FirstTokens.toOptional tks | tks, Lean.Parser.FirstTokens.epsilon => Lean.Parser.FirstTokens.toOptional tks | Lean.Parser.FirstTokens.tokens s₁, Lean.Parser.FirstTokens.tokens s₂ => Lean.Parser.FirstTokens.tokens (s₁ ++ s₂) | Lean.Parser.FirstTokens.optTokens s₁, Lean.Parser.FirstTokens.optTokens s₂ => Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂) | Lean.Parser.FirstTokens.tokens s₁, Lean.Parser.FirstTokens.optTokens s₂ => Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂) | Lean.Parser.FirstTokens.optTokens s₁, Lean.Parser.FirstTokens.tokens s₂ => Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂) | x, x_1 => Lean.Parser.FirstTokens.unknown
Equations
- Lean.Parser.FirstTokens.toStr x = match x with | Lean.Parser.FirstTokens.epsilon => "epsilon" | Lean.Parser.FirstTokens.unknown => "unknown" | Lean.Parser.FirstTokens.tokens tks => toString tks | Lean.Parser.FirstTokens.optTokens tks => "?" ++ toString tks
Equations
- collectTokens : List Lean.Parser.Token → List Lean.Parser.Token
- collectKinds : Lean.Parser.SyntaxNodeKindSet → Lean.Parser.SyntaxNodeKindSet
- firstTokens : Lean.Parser.FirstTokens
Equations
- Lean.Parser.instInhabitedParserInfo = { default := { collectTokens := default, collectKinds := default, firstTokens := default } }
Equations
- Lean.Parser.instInhabitedParser = { default := { info := default, fn := default } }
@[inline]
Equations
Equations
- Lean.Parser.dbgTraceStateFn label p c s = let sz := Array.size s.stxStack; let s' := p c s; dbgTrace (toString "" ++ toString label ++ toString "\n pos: " ++ toString s'.pos ++ toString "\n err: " ++ toString s'.errorMsg ++ toString "\n out: " ++ toString (Array.extract s'.stxStack sz (Array.size s'.stxStack)) ++ toString "") fun x => s'
Equations
- Lean.Parser.dbgTraceState label p = { info := p.info, fn := Lean.Parser.dbgTraceStateFn label p.fn }
@[noinline]
Equations
- Lean.Parser.epsilonInfo = { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.epsilon }
@[inline]
Equations
- Lean.Parser.checkStackTopFn p msg c s = if p (Array.back s.stxStack) = true then s else Lean.Parser.ParserState.mkUnexpectedError s msg
@[inline]
Equations
- Lean.Parser.checkStackTop p msg = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkStackTopFn p msg }
@[inline]
Equations
- Lean.Parser.andthenFn p q c s = let s := p c s; if Lean.Parser.ParserState.hasError s = true then s else q c s
@[noinline]
Equations
- Lean.Parser.andthenInfo p q = { collectTokens := p.collectTokens ∘ q.collectTokens, collectKinds := p.collectKinds ∘ q.collectKinds, firstTokens := Lean.Parser.FirstTokens.seq p.firstTokens q.firstTokens }
@[inline]
Equations
- Lean.Parser.andthen p q = { info := Lean.Parser.andthenInfo p.info q.info, fn := Lean.Parser.andthenFn p.fn q.fn }
Equations
- Lean.Parser.instAndThenParser = { andThen := fun a b => Lean.Parser.andthen a (b ()) }
@[inline]
Equations
- Lean.Parser.nodeFn n p c s = let iniSz := Lean.Parser.ParserState.stackSize s; let s := p c s; Lean.Parser.ParserState.mkNode s n iniSz
@[inline]
Equations
- Lean.Parser.trailingNodeFn n p c s = let iniSz := Lean.Parser.ParserState.stackSize s; let s := p c s; Lean.Parser.ParserState.mkTrailingNode s n iniSz
@[noinline]
Equations
- Lean.Parser.nodeInfo n p = { collectTokens := p.collectTokens, collectKinds := fun s => Lean.Parser.SyntaxNodeKindSet.insert (Lean.Parser.ParserInfo.collectKinds p s) n, firstTokens := p.firstTokens }
@[inline]
Equations
- Lean.Parser.node n p = { info := Lean.Parser.nodeInfo n p.info, fn := Lean.Parser.nodeFn n p.fn }
Equations
- Lean.Parser.errorFn msg x s = Lean.Parser.ParserState.mkUnexpectedError s msg
@[inline]
Equations
- Lean.Parser.error msg = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.errorFn msg }
Equations
- Lean.Parser.errorAtSavedPosFn msg delta c s = match c.savedPos? with | none => s | some pos => let pos := if delta = true then String.next c.toInputContext.input pos else pos; match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := x_1 } => { stxStack := Array.push stack Lean.Syntax.missing, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some { unexpected := msg, expected := [] } }
@[inline]
Equations
- Lean.Parser.errorAtSavedPos msg delta = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.errorAtSavedPosFn msg delta }
Equations
- Lean.Parser.checkPrecFn prec c s = if c.prec ≤ prec then s else Lean.Parser.ParserState.mkUnexpectedError s "unexpected token at this precedence level; consider parenthesizing the term"
@[inline]
Equations
- Lean.Parser.checkPrec prec = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkPrecFn prec }
Equations
- Lean.Parser.checkLhsPrecFn prec c s = if s.lhsPrec ≥ prec then s else Lean.Parser.ParserState.mkUnexpectedError s "unexpected token at this precedence level; consider parenthesizing the term"
@[inline]
Equations
- Lean.Parser.checkLhsPrec prec = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkLhsPrecFn prec }
Equations
- Lean.Parser.setLhsPrecFn prec c s = if Lean.Parser.ParserState.hasError s = true then s else { stxStack := s.stxStack, lhsPrec := prec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }
@[inline]
Equations
- Lean.Parser.setLhsPrec prec = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.setLhsPrecFn prec }
Equations
- Lean.Parser.checkInsideQuotFn c s = if (decide (c.quotDepth > 0) && !c.suppressInsideQuot) = true then s else Lean.Parser.ParserState.mkUnexpectedError s "unexpected syntax outside syntax quotation"
@[inline]
Equations
- Lean.Parser.checkInsideQuot = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkInsideQuotFn }
Equations
- Lean.Parser.checkOutsideQuotFn c s = if (!c.quotDepth == 0 || c.suppressInsideQuot) = true then s else Lean.Parser.ParserState.mkUnexpectedError s "unexpected syntax inside syntax quotation"
@[inline]
Equations
- Lean.Parser.checkOutsideQuot = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkOutsideQuotFn }
Equations
- Lean.Parser.addQuotDepthFn i p c s = p { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := c.prec, tokens := c.tokens, quotDepth := Int.toNat (Int.ofNat c.quotDepth + i), suppressInsideQuot := c.suppressInsideQuot, savedPos? := c.savedPos?, forbiddenTk? := c.forbiddenTk? } s
@[inline]
Equations
- Lean.Parser.incQuotDepth p = { info := p.info, fn := Lean.Parser.addQuotDepthFn 1 p.fn }
@[inline]
Equations
- Lean.Parser.decQuotDepth p = { info := p.info, fn := Lean.Parser.addQuotDepthFn (-1) p.fn }
Equations
- Lean.Parser.suppressInsideQuotFn p c s = p { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := c.prec, tokens := c.tokens, quotDepth := c.quotDepth, suppressInsideQuot := true, savedPos? := c.savedPos?, forbiddenTk? := c.forbiddenTk? } s
@[inline]
Equations
- Lean.Parser.suppressInsideQuot p = { info := p.info, fn := Lean.Parser.suppressInsideQuotFn p.fn }
@[inline]
Equations
- Lean.Parser.leadingNode n prec p = HAndThen.hAndThen (Lean.Parser.checkPrec prec) fun x => HAndThen.hAndThen (Lean.Parser.node n p) fun x => Lean.Parser.setLhsPrec prec
@[inline]
Equations
- Lean.Parser.trailingNodeAux n p = { info := Lean.Parser.nodeInfo n p.info, fn := Lean.Parser.trailingNodeFn n p.fn }
@[inline]
def
Lean.Parser.trailingNode
(n : Lean.SyntaxNodeKind)
(prec : Nat)
(lhsPrec : Nat)
(p : Lean.Parser.Parser)
:
Equations
- Lean.Parser.trailingNode n prec lhsPrec p = HAndThen.hAndThen (Lean.Parser.checkPrec prec) fun x => HAndThen.hAndThen (Lean.Parser.checkLhsPrec lhsPrec) fun x => HAndThen.hAndThen (Lean.Parser.trailingNodeAux n p) fun x => Lean.Parser.setLhsPrec prec
def
Lean.Parser.mergeOrElseErrors
(s : Lean.Parser.ParserState)
(error1 : Lean.Parser.Error)
(iniPos : Nat)
(mergeErrors : Bool)
:
Equations
- Lean.Parser.mergeOrElseErrors s error1 iniPos mergeErrors = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some error2 } => if (pos == iniPos) = true then { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some (if mergeErrors = true then Lean.Parser.Error.merge error1 error2 else error2) } else s | other => other
def
Lean.Parser.orelseFnCore
(p : Lean.Parser.ParserFn)
(q : Lean.Parser.ParserFn)
(mergeErrors : Bool)
:
Equations
- Lean.Parser.orelseFnCore p q mergeErrors c s = let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := p c s; match s.errorMsg with | some errorMsg => if (s.pos == iniPos) = true then Lean.Parser.mergeOrElseErrors (q c (Lean.Parser.ParserState.restore s iniSz iniPos)) errorMsg iniPos mergeErrors else s | none => s
@[inline]
Equations
@[noinline]
Equations
- Lean.Parser.orelseInfo p q = { collectTokens := p.collectTokens ∘ q.collectTokens, collectKinds := p.collectKinds ∘ q.collectKinds, firstTokens := Lean.Parser.FirstTokens.merge p.firstTokens q.firstTokens }
@[inline]
Equations
- Lean.Parser.orelse p q = { info := Lean.Parser.orelseInfo p.info q.info, fn := Lean.Parser.orelseFn p.fn q.fn }
Equations
- Lean.Parser.instOrElseParser = { orElse := fun a b => Lean.Parser.orelse a (b ()) }
@[noinline]
Equations
- Lean.Parser.noFirstTokenInfo info = { collectTokens := info.collectTokens, collectKinds := info.collectKinds, firstTokens := Lean.Parser.FirstTokens.unknown }
Equations
- Lean.Parser.atomicFn p c s = let iniPos := s.pos; match p c s with | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := some msg } => { stxStack := stack, lhsPrec := lhsPrec, pos := iniPos, cache := cache, errorMsg := some msg } | other => other
@[inline]
Equations
- Lean.Parser.atomic p = { info := p.info, fn := Lean.Parser.atomicFn p.fn }
Equations
- Lean.Parser.optionalFn p c s = let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := p c s; let s := if (Lean.Parser.ParserState.hasError s && s.pos == iniPos) = true then Lean.Parser.ParserState.restore s iniSz iniPos else s; Lean.Parser.ParserState.mkNode s Lean.nullKind iniSz
@[noinline]
Equations
- Lean.Parser.optionaInfo p = { collectTokens := p.collectTokens, collectKinds := p.collectKinds, firstTokens := Lean.Parser.FirstTokens.toOptional p.firstTokens }
@[inline]
Equations
- Lean.Parser.optionalNoAntiquot p = { info := Lean.Parser.optionaInfo p.info, fn := Lean.Parser.optionalFn p.fn }
Equations
- Lean.Parser.lookaheadFn p c s = let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := p c s; if Lean.Parser.ParserState.hasError s = true then s else Lean.Parser.ParserState.restore s iniSz iniPos
@[inline]
Equations
- Lean.Parser.lookahead p = { info := p.info, fn := Lean.Parser.lookaheadFn p.fn }
Equations
- Lean.Parser.notFollowedByFn p msg c s = let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := p c s; if Lean.Parser.ParserState.hasError s = true then Lean.Parser.ParserState.restore s iniSz iniPos else let s := Lean.Parser.ParserState.restore s iniSz iniPos; Lean.Parser.ParserState.mkUnexpectedError s (toString "unexpected " ++ toString msg ++ toString "")
@[inline]
Equations
- Lean.Parser.notFollowedBy p msg = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.notFollowedByFn p.fn msg }
@[inline]
Equations
- Lean.Parser.manyFn p c s = let iniSz := Lean.Parser.ParserState.stackSize s; let s := Lean.Parser.manyAux p c s; Lean.Parser.ParserState.mkNode s Lean.nullKind iniSz
@[inline]
Equations
- Lean.Parser.manyNoAntiquot p = { info := Lean.Parser.noFirstTokenInfo p.info, fn := Lean.Parser.manyFn p.fn }
@[inline]
Equations
- Lean.Parser.many1Fn p c s = let iniSz := Lean.Parser.ParserState.stackSize s; let s := Lean.Parser.andthenFn p (Lean.Parser.manyAux p) c s; Lean.Parser.ParserState.mkNode s Lean.nullKind iniSz
@[inline]
Equations
- Lean.Parser.many1NoAntiquot p = { info := p.info, fn := Lean.Parser.many1Fn p.fn }
def
Lean.Parser.sepByFn
(allowTrailingSep : Bool)
(p : Lean.Parser.ParserFn)
(sep : Lean.Parser.ParserFn)
:
Equations
- Lean.Parser.sepByFn allowTrailingSep p sep c s = let iniSz := Lean.Parser.ParserState.stackSize s; Lean.Parser.sepByFnAux p sep allowTrailingSep iniSz true c s
def
Lean.Parser.sepBy1Fn
(allowTrailingSep : Bool)
(p : Lean.Parser.ParserFn)
(sep : Lean.Parser.ParserFn)
:
Equations
- Lean.Parser.sepBy1Fn allowTrailingSep p sep c s = let iniSz := Lean.Parser.ParserState.stackSize s; Lean.Parser.sepByFnAux p sep allowTrailingSep iniSz false c s
@[noinline]
Equations
- Lean.Parser.sepByInfo p sep = { collectTokens := p.collectTokens ∘ sep.collectTokens, collectKinds := p.collectKinds ∘ sep.collectKinds, firstTokens := Lean.Parser.FirstTokens.unknown }
@[noinline]
Equations
- Lean.Parser.sepBy1Info p sep = { collectTokens := p.collectTokens ∘ sep.collectTokens, collectKinds := p.collectKinds ∘ sep.collectKinds, firstTokens := p.firstTokens }
@[inline]
def
Lean.Parser.sepByNoAntiquot
(p : Lean.Parser.Parser)
(sep : Lean.Parser.Parser)
(allowTrailingSep : optParam Bool false)
:
Equations
- Lean.Parser.sepByNoAntiquot p sep allowTrailingSep = { info := Lean.Parser.sepByInfo p.info sep.info, fn := Lean.Parser.sepByFn allowTrailingSep p.fn sep.fn }
@[inline]
def
Lean.Parser.sepBy1NoAntiquot
(p : Lean.Parser.Parser)
(sep : Lean.Parser.Parser)
(allowTrailingSep : optParam Bool false)
:
Equations
- Lean.Parser.sepBy1NoAntiquot p sep allowTrailingSep = { info := Lean.Parser.sepBy1Info p.info sep.info, fn := Lean.Parser.sepBy1Fn allowTrailingSep p.fn sep.fn }
Equations
- Lean.Parser.withResultOfFn p f c s = let s := p c s; if Lean.Parser.ParserState.hasError s = true then s else let stx := Array.back s.stxStack; Lean.Parser.ParserState.pushSyntax (Lean.Parser.ParserState.popSyntax s) (f stx)
@[noinline]
Equations
- Lean.Parser.withResultOfInfo p = { collectTokens := p.collectTokens, collectKinds := p.collectKinds, firstTokens := Lean.Parser.FirstTokens.unknown }
@[inline]
Equations
- Lean.Parser.withResultOf p f = { info := Lean.Parser.withResultOfInfo p.info, fn := Lean.Parser.withResultOfFn p.fn f }
@[inline]
Equations
- Lean.Parser.many1Unbox p = Lean.Parser.withResultOf (Lean.Parser.many1NoAntiquot p) fun stx => if (Lean.Syntax.getNumArgs stx == 1) = true then Lean.Syntax.getArg stx 0 else stx
Equations
- Lean.Parser.satisfyFn p errorMsg c s = let i := s.pos; if String.atEnd c.toInputContext.input i = true then Lean.Parser.ParserState.mkEOIError s else if p (String.get c.toInputContext.input i) = true then Lean.Parser.ParserState.next s c.toInputContext.input i else Lean.Parser.ParserState.mkUnexpectedError s errorMsg
Equations
- Lean.Parser.takeWhileFn p = Lean.Parser.takeUntilFn fun c => !p c
@[inline]
Equations
- Lean.Parser.takeWhile1Fn p errorMsg = Lean.Parser.andthenFn (Lean.Parser.satisfyFn p errorMsg) (Lean.Parser.takeWhileFn p)
Equations
- Lean.Parser.finishCommentBlock.eoi s = Lean.Parser.ParserState.mkUnexpectedError s "unterminated comment"
Equations
- Lean.Parser.mkEmptySubstringAt s p = { str := s, startPos := p, stopPos := p }
@[inline]
Equations
- Lean.Parser.rawFn p trailingWs c s = let startPos := s.pos; let s := p c s; if Lean.Parser.ParserState.hasError s = true then s else Lean.Parser.rawAux startPos trailingWs c s
@[inline]
Equations
- Lean.Parser.chFn c trailingWs = Lean.Parser.rawFn (Lean.Parser.satisfyFn (fun d => c == d) ("'" ++ toString c ++ "'")) trailingWs
Equations
- Lean.Parser.rawCh c trailingWs = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.chFn c trailingWs }
Equations
- Lean.Parser.hexDigitFn c s = let input := c.toInputContext.input; let i := s.pos; if String.atEnd input i = true then Lean.Parser.ParserState.mkEOIError s else let curr := String.get input i; let i := String.next input i; if (Char.isDigit curr || decide (Char.ofNat 97 ≤ curr) && decide (curr ≤ Char.ofNat 102) || decide (Char.ofNat 65 ≤ curr) && decide (curr ≤ Char.ofNat 70)) = true then Lean.Parser.ParserState.setPos s i else Lean.Parser.ParserState.mkUnexpectedError s "invalid hexadecimal numeral"
Equations
- Lean.Parser.quotedCharCoreFn isQuotable c s = let input := c.toInputContext.input; let i := s.pos; if String.atEnd input i = true then Lean.Parser.ParserState.mkEOIError s else let curr := String.get input i; if isQuotable curr = true then Lean.Parser.ParserState.next s input i else if (curr == Char.ofNat 120) = true then Lean.Parser.andthenFn Lean.Parser.hexDigitFn Lean.Parser.hexDigitFn c (Lean.Parser.ParserState.next s input i) else if (curr == Char.ofNat 117) = true then Lean.Parser.andthenFn Lean.Parser.hexDigitFn (Lean.Parser.andthenFn Lean.Parser.hexDigitFn (Lean.Parser.andthenFn Lean.Parser.hexDigitFn Lean.Parser.hexDigitFn)) c (Lean.Parser.ParserState.next s input i) else Lean.Parser.ParserState.mkUnexpectedError s "invalid escape sequence"
Equations
- Lean.Parser.isQuotableCharDefault c = (c == Char.ofNat 92 || c == Char.ofNat 34 || c == Char.ofNat 39 || c == Char.ofNat 114 || c == Char.ofNat 110 || c == Char.ofNat 116)
Equations
- Lean.Parser.mkNodeToken n startPos c s = let input := c.toInputContext.input; let stopPos := s.pos; let leading := Lean.Parser.mkEmptySubstringAt input startPos; let val := String.extract input startPos stopPos; let s := Lean.Parser.whitespace c s; let wsStopPos := s.pos; let trailing := { str := input, startPos := stopPos, stopPos := wsStopPos }; let info := Lean.SourceInfo.original leading startPos trailing stopPos; Lean.Parser.ParserState.pushSyntax s (Lean.Syntax.mkLit n val info)
Equations
- Lean.Parser.charLitFnAux startPos c s = let input := c.toInputContext.input; let i := s.pos; if String.atEnd input i = true then Lean.Parser.ParserState.mkEOIError s else let curr := String.get input i; let s := Lean.Parser.ParserState.setPos s (String.next input i); let s := if (curr == Char.ofNat 92) = true then Lean.Parser.quotedCharFn c s else s; if Lean.Parser.ParserState.hasError s = true then s else let i := s.pos; let curr := String.get input i; let s := Lean.Parser.ParserState.setPos s (String.next input i); if (curr == Char.ofNat 39) = true then Lean.Parser.mkNodeToken Lean.charLitKind startPos c s else Lean.Parser.ParserState.mkUnexpectedError s "missing end of character literal"
Equations
- Lean.Parser.decimalNumberFn startPos c = (fun parseOptExp s => let s := Lean.Parser.takeWhileFn (fun c => Char.isDigit c) c s; let input := c.toInputContext.input; let i := s.pos; let curr := String.get input i; if (curr == Char.ofNat 46 || curr == Char.ofNat 101 || curr == Char.ofNat 69) = true then let s := parseOptDot s; let s := parseOptExp s; Lean.Parser.mkNodeToken Lean.scientificLitKind startPos c s else Lean.Parser.mkNodeToken Lean.numLitKind startPos c s) (Lean.Parser.decimalNumberFn.parseOptDot c) (Lean.Parser.decimalNumberFn.parseOptExp c)
def
Lean.Parser.decimalNumberFn.parseOptDot
(c : Lean.Parser.ParserContext)
(s : Lean.Parser.ParserState)
:
Equations
- Lean.Parser.decimalNumberFn.parseOptDot c s = let input := c.toInputContext.input; let i := s.pos; let curr := String.get input i; if (curr == Char.ofNat 46) = true then let i := String.next input i; let curr := String.get input i; if Char.isDigit curr = true then Lean.Parser.takeWhileFn (fun c => Char.isDigit c) c (Lean.Parser.ParserState.setPos s i) else Lean.Parser.ParserState.setPos s i else s
def
Lean.Parser.decimalNumberFn.parseOptExp
(c : Lean.Parser.ParserContext)
(s : Lean.Parser.ParserState)
:
Equations
- Lean.Parser.decimalNumberFn.parseOptExp c s = let input := c.toInputContext.input; let i := s.pos; let curr := String.get input i; if (curr == Char.ofNat 101 || curr == Char.ofNat 69) = true then let i := String.next input i; let i := if (String.get input i == Char.ofNat 45) = true then String.next input i else i; let curr := String.get input i; if Char.isDigit curr = true then Lean.Parser.takeWhileFn (fun c => Char.isDigit c) c (Lean.Parser.ParserState.setPos s i) else Lean.Parser.ParserState.setPos s i else s
Equations
- Lean.Parser.binNumberFn startPos c s = let s := Lean.Parser.takeWhile1Fn (fun c => c == Char.ofNat 48 || c == Char.ofNat 49) "binary number" c s; Lean.Parser.mkNodeToken Lean.numLitKind startPos c s
Equations
- Lean.Parser.octalNumberFn startPos c s = let s := Lean.Parser.takeWhile1Fn (fun c => decide (Char.ofNat 48 ≤ c) && decide (c ≤ Char.ofNat 55)) "octal number" c s; Lean.Parser.mkNodeToken Lean.numLitKind startPos c s
Equations
- Lean.Parser.hexNumberFn startPos c s = let s := Lean.Parser.takeWhile1Fn (fun c => decide (Char.ofNat 48 ≤ c) && decide (c ≤ Char.ofNat 57) || decide (Char.ofNat 97 ≤ c) && decide (c ≤ Char.ofNat 102) || decide (Char.ofNat 65 ≤ c) && decide (c ≤ Char.ofNat 70)) "hexadecimal number" c s; Lean.Parser.mkNodeToken Lean.numLitKind startPos c s
Equations
- Lean.Parser.numberFnAux c s = let input := c.toInputContext.input; let startPos := s.pos; if String.atEnd input startPos = true then Lean.Parser.ParserState.mkEOIError s else let curr := String.get input startPos; if (curr == Char.ofNat 48) = true then let i := String.next input startPos; let curr := String.get input i; if (curr == Char.ofNat 98 || curr == Char.ofNat 66) = true then Lean.Parser.binNumberFn startPos c (Lean.Parser.ParserState.next s input i) else if (curr == Char.ofNat 111 || curr == Char.ofNat 79) = true then Lean.Parser.octalNumberFn startPos c (Lean.Parser.ParserState.next s input i) else if (curr == Char.ofNat 120 || curr == Char.ofNat 88) = true then Lean.Parser.hexNumberFn startPos c (Lean.Parser.ParserState.next s input i) else Lean.Parser.decimalNumberFn startPos c (Lean.Parser.ParserState.setPos s i) else if Char.isDigit curr = true then Lean.Parser.decimalNumberFn startPos c (Lean.Parser.ParserState.next s input startPos) else Lean.Parser.ParserState.mkError s "numeral"
Equations
- Lean.Parser.isIdCont input s = let i := s.pos; let curr := String.get input i; if (curr == Char.ofNat 46) = true then let i := String.next input i; if String.atEnd input i = true then false else let curr := String.get input i; Lean.isIdFirst curr || Lean.isIdBeginEscape curr else false
Equations
- Lean.Parser.mkTokenAndFixPos startPos tk c s = match tk with | none => Lean.Parser.ParserState.mkErrorAt s "token" startPos | some tk => if (c.forbiddenTk? == some tk) = true then Lean.Parser.ParserState.mkErrorAt s "forbidden token" startPos else let input := c.toInputContext.input; let leading := Lean.Parser.mkEmptySubstringAt input startPos; let stopPos := startPos + String.bsize tk; let s := Lean.Parser.ParserState.setPos s stopPos; let s := Lean.Parser.whitespace c s; let wsStopPos := s.pos; let trailing := { str := input, startPos := stopPos, stopPos := wsStopPos }; let atom := Lean.Parser.mkAtom (Lean.SourceInfo.original leading startPos trailing stopPos) tk; Lean.Parser.ParserState.pushSyntax s atom
Equations
- Lean.Parser.mkIdResult startPos tk val c s = let stopPos := s.pos; if Lean.Parser.isToken startPos stopPos tk = true then Lean.Parser.mkTokenAndFixPos startPos tk c s else let input := c.toInputContext.input; let rawVal := { str := input, startPos := startPos, stopPos := stopPos }; let s := Lean.Parser.whitespace c s; let trailingStopPos := s.pos; let leading := Lean.Parser.mkEmptySubstringAt input startPos; let trailing := { str := input, startPos := stopPos, stopPos := trailingStopPos }; let info := Lean.SourceInfo.original leading startPos trailing stopPos; let atom := Lean.Parser.mkIdent info rawVal val; Lean.Parser.ParserState.pushSyntax s atom
Equations
- Lean.Parser.identFnAux startPos tk r = (fun parse => parse r) (Lean.Parser.identFnAux.parse startPos tk)
partial def
Lean.Parser.identFnAux.parse
(startPos : Nat)
(tk : Option Lean.Parser.Token)
(r : Lean.Name)
(c : Lean.Parser.ParserContext)
(s : Lean.Parser.ParserState)
:
Equations
- Lean.Parser.tokenFn expected c s = let input := c.toInputContext.input; let i := s.pos; if String.atEnd input i = true then Lean.Parser.ParserState.mkEOIError s expected else let tkc := s.cache.tokenCache; if (tkc.startPos == i) = true then let s := Lean.Parser.ParserState.pushSyntax s tkc.token; Lean.Parser.ParserState.setPos s tkc.stopPos else let s := Lean.Parser.tokenFnAux c s; Lean.Parser.updateCache i s
Equations
- Lean.Parser.peekTokenAux c s = let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn [] c s; match s.errorMsg with | some e => (Lean.Parser.ParserState.restore s iniSz iniPos, Except.error s) | x => let stx := Array.back s.stxStack; (Lean.Parser.ParserState.restore s iniSz iniPos, Except.ok stx)
Equations
- Lean.Parser.peekToken c s = let tkc := s.cache.tokenCache; if (tkc.startPos == s.pos) = true then (s, Except.ok tkc.token) else Lean.Parser.peekTokenAux c s
Equations
- Lean.Parser.rawIdentFn c s = let input := c.toInputContext.input; let i := s.pos; if String.atEnd input i = true then Lean.Parser.ParserState.mkEOIError s else Lean.Parser.identFnAux i none Lean.Name.anonymous c s
@[inline]
Equations
- Lean.Parser.satisfySymbolFn p expected c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let startPos := s.pos; let s := Lean.Parser.tokenFn expected c s; if Lean.Parser.ParserState.hasError s = true then s else match Array.back s.stxStack with | Lean.Syntax.atom x sym => if p sym = true then s else Lean.Parser.ParserState.mkErrorsAt s expected startPos (some initStackSz) | x => Lean.Parser.ParserState.mkErrorsAt s expected startPos (some initStackSz)
Equations
- Lean.Parser.symbolFnAux sym errorMsg = Lean.Parser.satisfySymbolFn (fun s => s == sym) [errorMsg]
Equations
- Lean.Parser.symbolInfo sym = { collectTokens := fun tks => sym :: tks, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.tokens [sym] }
@[inline]
Equations
- Lean.Parser.symbolFn sym = Lean.Parser.symbolFnAux sym ("'" ++ sym ++ "'")
@[inline]
Equations
- Lean.Parser.symbolNoAntiquot sym = let sym := String.trim sym; { info := Lean.Parser.symbolInfo sym, fn := Lean.Parser.symbolFn sym }
Equations
- Lean.Parser.checkTailNoWs prev = match Lean.Syntax.getTailInfo prev with | Lean.SourceInfo.original x x_1 trailing x_2 => trailing.stopPos == trailing.startPos | x => false
Equations
- Lean.Parser.nonReservedSymbolFnAux sym errorMsg c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let startPos := s.pos; let s := Lean.Parser.tokenFn [errorMsg] c s; if Lean.Parser.ParserState.hasError s = true then s else match Array.back s.stxStack with | Lean.Syntax.atom x sym' => if (sym == sym') = true then s else Lean.Parser.ParserState.mkErrorAt s errorMsg startPos (some initStackSz) | Lean.Syntax.ident info rawVal x x_1 => if (sym == Substring.toString rawVal) = true then let s := Lean.Parser.ParserState.popSyntax s; Lean.Parser.ParserState.pushSyntax s (Lean.Syntax.atom info sym) else Lean.Parser.ParserState.mkErrorAt s errorMsg startPos (some initStackSz) | x => Lean.Parser.ParserState.mkErrorAt s errorMsg startPos (some initStackSz)
@[inline]
Equations
- Lean.Parser.nonReservedSymbolFn sym = Lean.Parser.nonReservedSymbolFnAux sym ("'" ++ sym ++ "'")
Equations
- Lean.Parser.nonReservedSymbolInfo sym includeIdent = { collectTokens := id, collectKinds := id, firstTokens := if includeIdent = true then Lean.Parser.FirstTokens.tokens [sym, "ident"] else Lean.Parser.FirstTokens.tokens [sym] }
@[inline]
Equations
- Lean.Parser.nonReservedSymbolNoAntiquot sym includeIdent = let sym := String.trim sym; { info := Lean.Parser.nonReservedSymbolInfo sym includeIdent, fn := Lean.Parser.nonReservedSymbolFn sym }
Equations
- Lean.Parser.strAux sym errorMsg j = (fun parse => parse j) (Lean.Parser.strAux.parse sym errorMsg)
partial def
Lean.Parser.strAux.parse
(sym : String)
(errorMsg : String)
(j : String.Pos)
(c : Lean.Parser.ParserContext)
(s : Lean.Parser.ParserState)
:
Equations
- Lean.Parser.checkTailWs prev = match Lean.Syntax.getTailInfo prev with | Lean.SourceInfo.original x x_1 trailing x_2 => decide (trailing.stopPos > trailing.startPos) | x => false
Equations
- Lean.Parser.checkWsBeforeFn errorMsg c s = let prev := Array.back s.stxStack; if Lean.Parser.checkTailWs prev = true then s else Lean.Parser.ParserState.mkError s errorMsg
Equations
- Lean.Parser.checkWsBefore errorMsg = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkWsBeforeFn errorMsg }
Equations
- Lean.Parser.checkTailLinebreak prev = match Lean.Syntax.getTailInfo prev with | Lean.SourceInfo.original x x_1 trailing x_2 => Substring.contains trailing (Char.ofNat 10) | x => false
Equations
- Lean.Parser.checkLinebreakBeforeFn errorMsg c s = let prev := Array.back s.stxStack; if Lean.Parser.checkTailLinebreak prev = true then s else Lean.Parser.ParserState.mkError s errorMsg
Equations
- Lean.Parser.checkLinebreakBefore errorMsg = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkLinebreakBeforeFn errorMsg }
Equations
- Lean.Parser.checkNoWsBeforeFn errorMsg c s = let prev := Lean.Parser.pickNonNone s.stxStack; if Lean.Parser.checkTailNoWs prev = true then s else Lean.Parser.ParserState.mkError s errorMsg
Equations
- Lean.Parser.checkNoWsBefore errorMsg = { info := Lean.Parser.epsilonInfo, fn := Lean.Parser.checkNoWsBeforeFn errorMsg }
Equations
- Lean.Parser.unicodeSymbolFnAux sym asciiSym expected = Lean.Parser.satisfySymbolFn (fun s => s == sym || s == asciiSym) expected
Equations
- Lean.Parser.unicodeSymbolInfo sym asciiSym = { collectTokens := fun tks => sym :: asciiSym :: tks, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.tokens [sym, asciiSym] }
@[inline]
Equations
- Lean.Parser.unicodeSymbolFn sym asciiSym = Lean.Parser.unicodeSymbolFnAux sym asciiSym ["'" ++ sym ++ "', '" ++ asciiSym ++ "'"]
@[inline]
Equations
- Lean.Parser.unicodeSymbolNoAntiquot sym asciiSym = let sym := String.trim sym; let asciiSym := String.trim asciiSym; { info := Lean.Parser.unicodeSymbolInfo sym asciiSym, fn := Lean.Parser.unicodeSymbolFn sym asciiSym }
Equations
- Lean.Parser.mkAtomicInfo k = { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.tokens [k] }
Equations
- Lean.Parser.numLitFn c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn ["numeral"] c s; if (!Lean.Parser.ParserState.hasError s && !Lean.Syntax.isOfKind (Array.back s.stxStack) Lean.numLitKind) = true then Lean.Parser.ParserState.mkErrorAt s "numeral" iniPos (some initStackSz) else s
@[inline]
Equations
- Lean.Parser.numLitNoAntiquot = { info := Lean.Parser.mkAtomicInfo "numLit", fn := Lean.Parser.numLitFn }
Equations
- Lean.Parser.scientificLitFn c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn ["scientific number"] c s; if (!Lean.Parser.ParserState.hasError s && !Lean.Syntax.isOfKind (Array.back s.stxStack) Lean.scientificLitKind) = true then Lean.Parser.ParserState.mkErrorAt s "scientific number" iniPos (some initStackSz) else s
@[inline]
Equations
- Lean.Parser.scientificLitNoAntiquot = { info := Lean.Parser.mkAtomicInfo "scientificLit", fn := Lean.Parser.scientificLitFn }
Equations
- Lean.Parser.strLitFn c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn ["string literal"] c s; if (!Lean.Parser.ParserState.hasError s && !Lean.Syntax.isOfKind (Array.back s.stxStack) Lean.strLitKind) = true then Lean.Parser.ParserState.mkErrorAt s "string literal" iniPos (some initStackSz) else s
@[inline]
Equations
- Lean.Parser.strLitNoAntiquot = { info := Lean.Parser.mkAtomicInfo "strLit", fn := Lean.Parser.strLitFn }
Equations
- Lean.Parser.charLitFn c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn ["char literal"] c s; if (!Lean.Parser.ParserState.hasError s && !Lean.Syntax.isOfKind (Array.back s.stxStack) Lean.charLitKind) = true then Lean.Parser.ParserState.mkErrorAt s "character literal" iniPos (some initStackSz) else s
@[inline]
Equations
- Lean.Parser.charLitNoAntiquot = { info := Lean.Parser.mkAtomicInfo "charLit", fn := Lean.Parser.charLitFn }
Equations
- Lean.Parser.nameLitFn c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn ["Name literal"] c s; if (!Lean.Parser.ParserState.hasError s && !Lean.Syntax.isOfKind (Array.back s.stxStack) Lean.nameLitKind) = true then Lean.Parser.ParserState.mkErrorAt s "Name literal" iniPos (some initStackSz) else s
@[inline]
Equations
- Lean.Parser.nameLitNoAntiquot = { info := Lean.Parser.mkAtomicInfo "nameLit", fn := Lean.Parser.nameLitFn }
Equations
- Lean.Parser.identFn c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn ["identifier"] c s; if (!Lean.Parser.ParserState.hasError s && !Lean.Syntax.isIdent (Array.back s.stxStack)) = true then Lean.Parser.ParserState.mkErrorAt s "identifier" iniPos (some initStackSz) else s
@[inline]
Equations
- Lean.Parser.identNoAntiquot = { info := Lean.Parser.mkAtomicInfo "ident", fn := Lean.Parser.identFn }
@[inline]
Equations
- Lean.Parser.rawIdentNoAntiquot = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.rawIdentFn }
Equations
- Lean.Parser.identEqFn id c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.tokenFn ["identifier"] c s; if Lean.Parser.ParserState.hasError s = true then s else match Array.back s.stxStack with | Lean.Syntax.ident x x_1 val x_2 => if (val != id) = true then Lean.Parser.ParserState.mkErrorAt s ("expected identifier '" ++ toString id ++ "'") iniPos (some initStackSz) else s | x => Lean.Parser.ParserState.mkErrorAt s "identifier" iniPos (some initStackSz)
@[inline]
Equations
- Lean.Parser.identEq id = { info := Lean.Parser.mkAtomicInfo "ident", fn := Lean.Parser.identEqFn id }
Equations
- Lean.Parser.ParserState.keepTop s startStackSize = let node := Array.back s; Array.push (Array.shrink s startStackSize) node
Equations
- Lean.Parser.ParserState.keepNewError s oldStackSize = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := err } => { stxStack := Lean.Parser.ParserState.keepTop stack oldStackSize, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := err }
def
Lean.Parser.ParserState.keepPrevError
(s : Lean.Parser.ParserState)
(oldStackSize : Nat)
(oldStopPos : String.Pos)
(oldError : Option Lean.Parser.Error)
:
Equations
- Lean.Parser.ParserState.keepPrevError s oldStackSize oldStopPos oldError = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := x, cache := cache, errorMsg := x_1 } => { stxStack := Array.shrink stack oldStackSize, lhsPrec := lhsPrec, pos := oldStopPos, cache := cache, errorMsg := oldError }
def
Lean.Parser.ParserState.mergeErrors
(s : Lean.Parser.ParserState)
(oldStackSize : Nat)
(oldError : Lean.Parser.Error)
:
Equations
- Lean.Parser.ParserState.mergeErrors s oldStackSize oldError = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some err } => if (oldError == err) = true then s else { stxStack := Array.shrink stack oldStackSize, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := some (Lean.Parser.Error.merge oldError err) } | other => other
Equations
- Lean.Parser.ParserState.keepLatest s startStackSize = match s with | { stxStack := stack, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := x } => { stxStack := Lean.Parser.ParserState.keepTop stack startStackSize, lhsPrec := lhsPrec, pos := pos, cache := cache, errorMsg := none }
Equations
- Lean.Parser.ParserState.replaceLongest s startStackSize = Lean.Parser.ParserState.keepLatest s startStackSize
Equations
- Lean.Parser.invalidLongestMatchParser s = Lean.Parser.ParserState.mkError s "longestMatch parsers must generate exactly one Syntax node"
def
Lean.Parser.runLongestMatchParser
(left? : Option Lean.Syntax)
(startLhsPrec : Nat)
(p : Lean.Parser.ParserFn)
:
Equations
- Lean.Parser.runLongestMatchParser left? startLhsPrec p c s = Id.run (let s := { stxStack := s.stxStack, lhsPrec := if Option.isSome left? = true then startLhsPrec else Lean.Parser.maxPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }; let startSize := Lean.Parser.ParserState.stackSize s; let _do_jp := fun s y => let s := p c s; if (Lean.Parser.ParserState.stackSize s == startSize + 1) = true then s else if Lean.Parser.ParserState.hasError s = true then Lean.Parser.ParserState.pushSyntax (Lean.Parser.ParserState.shrinkStack s startSize) Lean.Syntax.missing else Lean.Parser.invalidLongestMatchParser s; match left? with | some left => let s := Lean.Parser.ParserState.pushSyntax s left; do let y ← pure PUnit.unit _do_jp s y | x => do let y ← pure PUnit.unit _do_jp s y)
def
Lean.Parser.longestMatchStep
(left? : Option Lean.Syntax)
(startSize : Nat)
(startLhsPrec : Nat)
(startPos : String.Pos)
(prevPrio : Nat)
(prio : Nat)
(p : Lean.Parser.ParserFn)
:
Equations
- Lean.Parser.longestMatchStep left? startSize startLhsPrec startPos prevPrio prio p c s = let prevErrorMsg := s.errorMsg; let prevStopPos := s.pos; let prevSize := Lean.Parser.ParserState.stackSize s; let prevLhsPrec := s.lhsPrec; let s := Lean.Parser.ParserState.restore s prevSize startPos; let s := Lean.Parser.runLongestMatchParser left? startLhsPrec p c s; match prevErrorMsg, s.errorMsg with | none, none => if (decide (s.pos > prevStopPos) || s.pos == prevStopPos && decide (prio > prevPrio)) = true then (Lean.Parser.ParserState.replaceLongest s startSize, prio) else if (decide (s.pos < prevStopPos) || s.pos == prevStopPos && decide (prio < prevPrio)) = true then (let src := Lean.Parser.ParserState.restore s prevSize prevStopPos; { stxStack := src.stxStack, lhsPrec := prevLhsPrec, pos := src.pos, cache := src.cache, errorMsg := src.errorMsg }, prevPrio) else ({ stxStack := s.stxStack, lhsPrec := Nat.min s.lhsPrec prevLhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }, prio) | none, some x => (let src := Lean.Parser.ParserState.restore s prevSize prevStopPos; { stxStack := src.stxStack, lhsPrec := prevLhsPrec, pos := src.pos, cache := src.cache, errorMsg := src.errorMsg }, prevPrio) | some oldError, some x => if (decide (s.pos > prevStopPos) || s.pos == prevStopPos && decide (prio > prevPrio)) = true then (Lean.Parser.ParserState.keepNewError s startSize, prio) else if (decide (s.pos < prevStopPos) || s.pos == prevStopPos && decide (prio < prevPrio)) = true then (Lean.Parser.ParserState.keepPrevError s prevSize prevStopPos prevErrorMsg, prevPrio) else (Lean.Parser.ParserState.mergeErrors s prevSize oldError, prio) | some x, none => let successNode := Array.back s.stxStack; let s := Lean.Parser.ParserState.shrinkStack s startSize; (Lean.Parser.ParserState.pushSyntax s successNode, prio)
Equations
- Lean.Parser.longestMatchMkResult startSize s = if Lean.Parser.ParserState.stackSize s > startSize + 1 then Lean.Parser.ParserState.mkNode s Lean.choiceKind startSize else s
def
Lean.Parser.longestMatchFnAux
(left? : Option Lean.Syntax)
(startSize : Nat)
(startLhsPrec : Nat)
(startPos : String.Pos)
(prevPrio : Nat)
(ps : List (Lean.Parser.Parser × Nat))
:
Equations
- Lean.Parser.longestMatchFnAux left? startSize startLhsPrec startPos prevPrio ps = (fun parse => parse prevPrio ps) (Lean.Parser.longestMatchFnAux.parse left? startSize startLhsPrec startPos)
def
Lean.Parser.longestMatchFnAux.parse
(left? : Option Lean.Syntax)
(startSize : Nat)
(startLhsPrec : Nat)
(startPos : String.Pos)
(prevPrio : Nat)
(ps : List (Lean.Parser.Parser × Nat))
:
Equations
- Lean.Parser.longestMatchFnAux.parse left? startSize startLhsPrec startPos prevPrio [] = fun x s => Lean.Parser.longestMatchMkResult startSize s
- Lean.Parser.longestMatchFnAux.parse left? startSize startLhsPrec startPos prevPrio (p :: ps_2) x x_1 = Lean.Parser.longestMatchFnAux.parse left? startSize startLhsPrec startPos (Lean.Parser.longestMatchStep left? startSize startLhsPrec startPos prevPrio p.snd p.fst.fn x x_1).2 ps_2 x (Lean.Parser.longestMatchStep left? startSize startLhsPrec startPos prevPrio p.snd p.fst.fn x x_1).1
Equations
- Lean.Parser.longestMatchFn left? x = match x with | [] => fun x s => Lean.Parser.ParserState.mkError s "longestMatch: empty list" | [p] => fun c s => Lean.Parser.runLongestMatchParser left? s.lhsPrec p.fst.fn c s | p :: ps => fun c s => let startSize := Lean.Parser.ParserState.stackSize s; let startLhsPrec := s.lhsPrec; let startPos := s.pos; let s := Lean.Parser.runLongestMatchParser left? s.lhsPrec p.fst.fn c s; Lean.Parser.longestMatchFnAux left? startSize startLhsPrec startPos p.snd ps c s
Equations
- Lean.Parser.anyOfFn [] x x = Lean.Parser.ParserState.mkError x "anyOf: empty list"
- Lean.Parser.anyOfFn [p] x x = Lean.Parser.Parser.fn p x x
- Lean.Parser.anyOfFn (p :: ps) x x = Lean.Parser.orelseFn p.fn (Lean.Parser.anyOfFn ps) x x
@[inline]
Equations
- Lean.Parser.checkColGeFn errorMsg c s = match c.savedPos? with | none => s | some savedPos => let savedPos := Lean.FileMap.toPosition c.toInputContext.fileMap savedPos; let pos := Lean.FileMap.toPosition c.toInputContext.fileMap s.pos; if pos.column ≥ savedPos.column then s else Lean.Parser.ParserState.mkError s errorMsg
@[inline]
Equations
- Lean.Parser.checkColGe errorMsg = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.checkColGeFn errorMsg }
@[inline]
Equations
- Lean.Parser.checkColGtFn errorMsg c s = match c.savedPos? with | none => s | some savedPos => let savedPos := Lean.FileMap.toPosition c.toInputContext.fileMap savedPos; let pos := Lean.FileMap.toPosition c.toInputContext.fileMap s.pos; if pos.column > savedPos.column then s else Lean.Parser.ParserState.mkError s errorMsg
@[inline]
Equations
- Lean.Parser.checkColGt errorMsg = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.checkColGtFn errorMsg }
@[inline]
Equations
- Lean.Parser.checkLineEqFn errorMsg c s = match c.savedPos? with | none => s | some savedPos => let savedPos := Lean.FileMap.toPosition c.toInputContext.fileMap savedPos; let pos := Lean.FileMap.toPosition c.toInputContext.fileMap s.pos; if (pos.line == savedPos.line) = true then s else Lean.Parser.ParserState.mkError s errorMsg
@[inline]
Equations
- Lean.Parser.checkLineEq errorMsg = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.checkLineEqFn errorMsg }
@[inline]
Equations
- Lean.Parser.withPosition p = { info := p.info, fn := fun c s => Lean.Parser.Parser.fn p { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := c.prec, tokens := c.tokens, quotDepth := c.quotDepth, suppressInsideQuot := c.suppressInsideQuot, savedPos? := some s.pos, forbiddenTk? := c.forbiddenTk? } s }
@[inline]
Equations
- Lean.Parser.withoutPosition p = { info := p.info, fn := fun c s => let pos := Lean.FileMap.toPosition c.toInputContext.fileMap s.pos; Lean.Parser.Parser.fn p { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := c.prec, tokens := c.tokens, quotDepth := c.quotDepth, suppressInsideQuot := c.suppressInsideQuot, savedPos? := none, forbiddenTk? := c.forbiddenTk? } s }
@[inline]
Equations
- Lean.Parser.withForbidden tk p = { info := p.info, fn := fun c s => Lean.Parser.Parser.fn p { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := c.prec, tokens := c.tokens, quotDepth := c.quotDepth, suppressInsideQuot := c.suppressInsideQuot, savedPos? := c.savedPos?, forbiddenTk? := some tk } s }
@[inline]
Equations
- Lean.Parser.withoutForbidden p = { info := p.info, fn := fun c s => Lean.Parser.Parser.fn p { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := c.prec, tokens := c.tokens, quotDepth := c.quotDepth, suppressInsideQuot := c.suppressInsideQuot, savedPos? := c.savedPos?, forbiddenTk? := none } s }
Equations
- Lean.Parser.eoiFn c s = let i := s.pos; if String.atEnd c.toInputContext.input i = true then s else Lean.Parser.ParserState.mkError s "expected end of file"
@[inline]
Equations
- Lean.Parser.eoi = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := Lean.Parser.eoiFn }
Equations
Equations
- Lean.Parser.TokenMap.insert map k v = match Std.RBMap.find? map k with | none => Std.RBMap.insert map k [v] | some vs => Std.RBMap.insert map k (v :: vs)
Equations
- Lean.Parser.TokenMap.instInhabitedTokenMap = { default := Std.RBMap.empty }
Equations
- Lean.Parser.TokenMap.instEmptyCollectionTokenMap = { emptyCollection := Std.RBMap.empty }
- leadingTable : Lean.Parser.TokenMap (Lean.Parser.Parser × Nat)
- leadingParsers : List (Lean.Parser.Parser × Nat)
- trailingTable : Lean.Parser.TokenMap (Lean.Parser.Parser × Nat)
- trailingParsers : List (Lean.Parser.Parser × Nat)
Equations
- Lean.Parser.instInhabitedPrattParsingTables = { default := { leadingTable := ∅, leadingParsers := [], trailingTable := ∅, trailingParsers := [] } }
- default: Lean.Parser.LeadingIdentBehavior
- symbol: Lean.Parser.LeadingIdentBehavior
- both: Lean.Parser.LeadingIdentBehavior
Equations
- Lean.Parser.instBEqLeadingIdentBehavior = { beq := [anonymous] }
Equations
- Lean.Parser.instReprLeadingIdentBehavior = { reprPrec := [anonymous] }
- tables : Lean.Parser.PrattParsingTables
- behavior : Lean.Parser.LeadingIdentBehavior
Equations
- Lean.Parser.instInhabitedParserCategory = { default := { tables := default, behavior := default } }
@[inline]
def
Lean.Parser.indexed
{α : Type}
(map : Lean.Parser.TokenMap α)
(c : Lean.Parser.ParserContext)
(s : Lean.Parser.ParserState)
(behavior : Lean.Parser.LeadingIdentBehavior)
:
Equations
- Lean.Parser.indexed map c s behavior = let x := Lean.Parser.peekToken c s; match x with | (s, stx) => let find := fun n => match Std.RBMap.find? map n with | some as => (s, as) | x => (s, []); match stx with | Except.ok (Lean.Syntax.atom x sym) => find (Lean.Name.mkSimple sym) | Except.ok (Lean.Syntax.ident x x_1 val x_2) => match behavior with | Lean.Parser.LeadingIdentBehavior.default => find Lean.identKind | Lean.Parser.LeadingIdentBehavior.symbol => match Std.RBMap.find? map val with | some as => (s, as) | none => find Lean.identKind | Lean.Parser.LeadingIdentBehavior.both => match Std.RBMap.find? map val with | some as => match Std.RBMap.find? map Lean.identKind with | some as' => (s, as ++ as') | x => (s, as) | none => find Lean.identKind | Except.ok (Lean.Syntax.node x k x_1) => find k | Except.ok x => (s, []) | Except.error s' => (s', [])
@[inline]
Equations
Equations
- Lean.Parser.categoryParserFn catName ctx s = Lean.EnvExtension.getState Lean.Parser.categoryParserFnExtension ctx.toParserModuleContext.env catName ctx s
Equations
- Lean.Parser.categoryParser catName prec = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := fun c s => Lean.Parser.categoryParserFn catName { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := prec, tokens := c.tokens, quotDepth := c.quotDepth, suppressInsideQuot := c.suppressInsideQuot, savedPos? := c.savedPos?, forbiddenTk? := c.forbiddenTk? } s }
@[inline]
Equations
- Lean.Parser.termParser prec = Lean.Parser.categoryParser `term prec
Equations
- Lean.Parser.checkNoImmediateColon = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := fun c s => let prev := Array.back s.stxStack; if Lean.Parser.checkTailNoWs prev = true then let input := c.toInputContext.input; let i := s.pos; if String.atEnd input i = true then s else let curr := String.get input i; if (curr == Char.ofNat 58) = true then Lean.Parser.ParserState.mkUnexpectedError s "unexpected ':'" else s else s }
Equations
- Lean.Parser.setExpectedFn expected p c s = match p c s with | s'@h:{ stxStack := x, lhsPrec := x_1, pos := x_2, cache := x_3, errorMsg := some msg } => { stxStack := s'.stxStack, lhsPrec := s'.lhsPrec, pos := s'.pos, cache := s'.cache, errorMsg := some { unexpected := msg.unexpected, expected := [] } } | s' => s'
Equations
- Lean.Parser.setExpected expected p = { info := p.info, fn := Lean.Parser.setExpectedFn expected p.fn }
Equations
- Lean.Parser.pushNone = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := fun c s => Lean.Parser.ParserState.pushSyntax s Lean.mkNullNode }
Equations
- Lean.Parser.antiquotNestedExpr = Lean.Parser.node `antiquotNestedExpr (HAndThen.hAndThen (Lean.Parser.symbolNoAntiquot "(") fun x => HAndThen.hAndThen (Lean.Parser.decQuotDepth Lean.Parser.termParser) fun x => Lean.Parser.symbolNoAntiquot ")")
@[inline]
Equations
- Lean.Parser.tokenWithAntiquotFn p c s = Id.run (let s := p c s; let _do_jp := fun y => let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.Parser.fn (HAndThen.hAndThen Lean.Parser.checkNoWsBefore fun x => HAndThen.hAndThen (Lean.Parser.symbolNoAntiquot "%") fun x => HAndThen.hAndThen (Lean.Parser.symbolNoAntiquot "$") fun x => HAndThen.hAndThen Lean.Parser.checkNoWsBefore fun x => Lean.Parser.antiquotExpr) c s; let _do_jp := fun y => Lean.Parser.ParserState.mkNode s `token_antiquot (iniSz - 1); if Lean.Parser.ParserState.hasError s = true then pure (Lean.Parser.ParserState.restore s iniSz iniPos) else do let y ← pure PUnit.unit _do_jp y; if (Lean.Parser.ParserState.hasError s || c.quotDepth == 0) = true then pure s else do let y ← pure PUnit.unit _do_jp y)
@[inline]
Equations
- Lean.Parser.tokenWithAntiquot p = { info := p.info, fn := Lean.Parser.tokenWithAntiquotFn p.fn }
@[inline]
Equations
Equations
- Lean.Parser.instCoeStringParser = { coe := fun s => Lean.Parser.symbol s }
@[inline]
Equations
- Lean.Parser.nonReservedSymbol sym includeIdent = Lean.Parser.tokenWithAntiquot (Lean.Parser.nonReservedSymbolNoAntiquot sym includeIdent)
@[inline]
Equations
- Lean.Parser.unicodeSymbol sym asciiSym = Lean.Parser.tokenWithAntiquot (Lean.Parser.unicodeSymbolNoAntiquot sym asciiSym)
def
Lean.Parser.mkAntiquot
(name : String)
(kind : Option Lean.SyntaxNodeKind)
(anonymous : optParam Bool true)
:
Equations
- Lean.Parser.mkAntiquot name kind anonymous = let kind := Option.getD kind Lean.Name.anonymous ++ `antiquot; let nameP := Lean.Parser.node `antiquotName (HAndThen.hAndThen (Lean.Parser.checkNoWsBefore ("no space before ':" ++ name ++ "'")) fun x => HAndThen.hAndThen (Lean.Parser.symbol ":") fun x => Lean.Parser.nonReservedSymbol name); let nameP := if anonymous = true then HOrElse.hOrElse nameP fun x => HAndThen.hAndThen Lean.Parser.checkNoImmediateColon fun x => Lean.Parser.pushNone else nameP; Lean.Parser.leadingNode kind Lean.Parser.maxPrec (Lean.Parser.atomic (HAndThen.hAndThen (Lean.Parser.setExpected [] (Lean.Parser.symbol "$")) fun x => HAndThen.hAndThen (Lean.Parser.manyNoAntiquot (HAndThen.hAndThen (Lean.Parser.checkNoWsBefore "") fun x => Lean.Parser.symbol "$")) fun x => HAndThen.hAndThen (Lean.Parser.checkNoWsBefore "no space before spliced term") fun x => HAndThen.hAndThen Lean.Parser.antiquotExpr fun x => nameP))
Equations
- Lean.Parser.tryAnti c s = Id.run (let _do_jp := fun y => let x := Lean.Parser.peekToken c s; match x with | (s, stx) => match stx with | Except.ok stx@h:(Lean.Syntax.atom x sym) => sym == "$" | x => false; if (c.quotDepth == 0) = true then pure false else do let y ← pure PUnit.unit _do_jp y)
@[inline]
Equations
- Lean.Parser.withAntiquotFn antiquotP p c s = if Lean.Parser.tryAnti c s = true then Lean.Parser.orelseFn antiquotP p c s else p c s
@[inline]
Equations
- Lean.Parser.withAntiquot antiquotP p = { info := Lean.Parser.orelseInfo antiquotP.info p.info, fn := Lean.Parser.withAntiquotFn antiquotP.fn p.fn }
Equations
- Lean.Parser.withoutInfo p = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := p.fn }
def
Lean.Parser.mkAntiquotSplice
(kind : Lean.SyntaxNodeKind)
(p : Lean.Parser.Parser)
(suffix : Lean.Parser.Parser)
:
Equations
- Lean.Parser.mkAntiquotSplice kind p suffix = let kind := kind ++ `antiquot_scope; Lean.Parser.leadingNode kind Lean.Parser.maxPrec (Lean.Parser.atomic (HAndThen.hAndThen (Lean.Parser.setExpected [] (Lean.Parser.symbol "$")) fun x => HAndThen.hAndThen (Lean.Parser.manyNoAntiquot (HAndThen.hAndThen (Lean.Parser.checkNoWsBefore "") fun x => Lean.Parser.symbol "$")) fun x => HAndThen.hAndThen (Lean.Parser.checkNoWsBefore "no space before spliced term") fun x => HAndThen.hAndThen (Lean.Parser.symbol "[") fun x => HAndThen.hAndThen (Lean.Parser.node Lean.nullKind p) fun x => HAndThen.hAndThen (Lean.Parser.symbol "]") fun x => suffix))
@[inline]
def
Lean.Parser.withAntiquotSuffixSpliceFn
(kind : Lean.SyntaxNodeKind)
(p : Lean.Parser.ParserFn)
(suffix : Lean.Parser.ParserFn)
:
Equations
- Lean.Parser.withAntiquotSuffixSpliceFn kind p suffix c s = Id.run (let s := p c s; let _do_jp := fun y => let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := suffix c s; let _do_jp := fun y => Lean.Parser.ParserState.mkNode s (kind ++ `antiquot_suffix_splice) (Array.size s.stxStack - 2); if Lean.Parser.ParserState.hasError s = true then pure (Lean.Parser.ParserState.restore s iniSz iniPos) else do let y ← pure PUnit.unit _do_jp y; if (Lean.Parser.ParserState.hasError s || c.quotDepth == 0 || !Lean.Syntax.isAntiquot (Array.back s.stxStack)) = true then pure s else do let y ← pure PUnit.unit _do_jp y)
@[inline]
def
Lean.Parser.withAntiquotSuffixSplice
(kind : Lean.SyntaxNodeKind)
(p : Lean.Parser.Parser)
(suffix : Lean.Parser.Parser)
:
Equations
- Lean.Parser.withAntiquotSuffixSplice kind p suffix = { info := Lean.Parser.andthenInfo p.info suffix.info, fn := Lean.Parser.withAntiquotSuffixSpliceFn kind p.fn suffix.fn }
def
Lean.Parser.withAntiquotSpliceAndSuffix
(kind : Lean.SyntaxNodeKind)
(p : Lean.Parser.Parser)
(suffix : Lean.Parser.Parser)
:
Equations
- Lean.Parser.withAntiquotSpliceAndSuffix kind p suffix = Lean.Parser.withAntiquot (Lean.Parser.mkAntiquotSplice kind (Lean.Parser.withoutInfo p) suffix) (Lean.Parser.withAntiquotSuffixSplice kind p suffix)
def
Lean.Parser.nodeWithAntiquot
(name : String)
(kind : Lean.SyntaxNodeKind)
(p : Lean.Parser.Parser)
(anonymous : optParam Bool false)
:
Equations
- Lean.Parser.nodeWithAntiquot name kind p anonymous = Lean.Parser.withAntiquot (Lean.Parser.mkAntiquot name (some kind) anonymous) (Lean.Parser.node kind p)
Equations
- Lean.Parser.sepByElemParser p sep = Lean.Parser.withAntiquotSpliceAndSuffix `sepBy p (Lean.Parser.symbol (String.trim sep ++ "*"))
def
Lean.Parser.sepBy
(p : Lean.Parser.Parser)
(sep : String)
(psep : optParam Lean.Parser.Parser (Lean.Parser.symbol sep))
(allowTrailingSep : optParam Bool false)
:
Equations
- Lean.Parser.sepBy p sep psep allowTrailingSep = Lean.Parser.sepByNoAntiquot (Lean.Parser.sepByElemParser p sep) psep allowTrailingSep
def
Lean.Parser.sepBy1
(p : Lean.Parser.Parser)
(sep : String)
(psep : optParam Lean.Parser.Parser (Lean.Parser.symbol sep))
(allowTrailingSep : optParam Bool false)
:
Equations
- Lean.Parser.sepBy1 p sep psep allowTrailingSep = Lean.Parser.sepBy1NoAntiquot (Lean.Parser.sepByElemParser p sep) psep allowTrailingSep
Equations
- Lean.Parser.categoryParserOfStackFn offset ctx s = let stack := s.stxStack; if Array.size stack < offset + 1 then Lean.Parser.ParserState.mkUnexpectedError s "failed to determine parser category using syntax stack, stack is too small" else match Array.get! stack (Array.size stack - offset - 1) with | Lean.Syntax.ident x x_1 catName x_2 => Lean.Parser.categoryParserFn catName ctx s | x => Lean.Parser.ParserState.mkUnexpectedError s "failed to determine parser category using syntax stack, the specified element on the stack is not an identifier"
Equations
- Lean.Parser.categoryParserOfStack offset prec = { info := { collectTokens := id, collectKinds := id, firstTokens := Lean.Parser.FirstTokens.unknown }, fn := fun c s => Lean.Parser.categoryParserOfStackFn offset { toInputContext := c.toInputContext, toParserModuleContext := c.toParserModuleContext, prec := prec, tokens := c.tokens, quotDepth := c.quotDepth, suppressInsideQuot := c.suppressInsideQuot, savedPos? := c.savedPos?, forbiddenTk? := c.forbiddenTk? } s }
def
Lean.Parser.leadingParserAux
(kind : Lean.Name)
(tables : Lean.Parser.PrattParsingTables)
(behavior : Lean.Parser.LeadingIdentBehavior)
:
Equations
- Lean.Parser.leadingParserAux kind tables behavior c s = Id.run (let iniSz := Lean.Parser.ParserState.stackSize s; let x := Lean.Parser.indexed tables.leadingTable c s behavior; match x with | (s, ps) => let _do_jp := fun y => let ps := tables.leadingParsers ++ ps; let _do_jp := fun y => let s := Lean.Parser.longestMatchFn none ps c s; Lean.Parser.mkResult s iniSz; if List.isEmpty ps = true then pure (Lean.Parser.ParserState.mkError s (toString kind)) else do let y ← pure PUnit.unit _do_jp y; if Lean.Parser.ParserState.hasError s = true then pure s else do let y ← pure PUnit.unit _do_jp y)
@[inline]
def
Lean.Parser.leadingParser
(kind : Lean.Name)
(tables : Lean.Parser.PrattParsingTables)
(behavior : Lean.Parser.LeadingIdentBehavior)
(antiquotParser : Lean.Parser.ParserFn)
:
Equations
- Lean.Parser.leadingParser kind tables behavior antiquotParser = Lean.Parser.withAntiquotFn antiquotParser (Lean.Parser.leadingParserAux kind tables behavior)
def
Lean.Parser.trailingLoopStep
(tables : Lean.Parser.PrattParsingTables)
(left : Lean.Syntax)
(ps : List (Lean.Parser.Parser × Nat))
:
Equations
- Lean.Parser.trailingLoopStep tables left ps c s = Lean.Parser.longestMatchFn (some left) (ps ++ tables.trailingParsers) c s
partial def
Lean.Parser.trailingLoop
(tables : Lean.Parser.PrattParsingTables)
(c : Lean.Parser.ParserContext)
(s : Lean.Parser.ParserState)
:
@[inline]
def
Lean.Parser.prattParser
(kind : Lean.Name)
(tables : Lean.Parser.PrattParsingTables)
(behavior : Lean.Parser.LeadingIdentBehavior)
(antiquotParser : Lean.Parser.ParserFn)
:
Equations
- Lean.Parser.prattParser kind tables behavior antiquotParser c s = let iniSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let s := Lean.Parser.leadingParser kind tables behavior antiquotParser c s; if Lean.Parser.ParserState.hasError s = true then s else Lean.Parser.trailingLoop tables c s
Equations
- Lean.Parser.fieldIdxFn c s = let initStackSz := Lean.Parser.ParserState.stackSize s; let iniPos := s.pos; let curr := String.get c.toInputContext.input iniPos; if (Char.isDigit curr && curr != Char.ofNat 48) = true then let s := Lean.Parser.takeWhileFn (fun c => Char.isDigit c) c s; Lean.Parser.mkNodeToken Lean.fieldIdxKind iniPos c s else Lean.Parser.ParserState.mkErrorAt s "field index" iniPos (some initStackSz)
@[inline]
Equations
- Lean.Parser.fieldIdx = Lean.Parser.withAntiquot (Lean.Parser.mkAntiquot "fieldIdx" (some `fieldIdx)) { info := Lean.Parser.mkAtomicInfo "fieldIdx", fn := Lean.Parser.fieldIdxFn }
@[inline]
Equations
- Lean.Parser.skip = { info := Lean.Parser.epsilonInfo, fn := fun c s => s }
@[inline]
def
Lean.Syntax.foldArgsM
{β : Type}
{m : Type → Type}
[inst : Monad m]
(s : Lean.Syntax)
(f : Lean.Syntax → β → m β)
(b : β)
:
m β
Equations
- Lean.Syntax.foldArgsM s f b = Array.foldlM (flip f) b (Lean.Syntax.getArgs s) 0 (Array.size (Lean.Syntax.getArgs s))
@[inline]
Equations
- Lean.Syntax.foldArgs s f b = Id.run (Lean.Syntax.foldArgsM s f b)
@[inline]
def
Lean.Syntax.forArgsM
{m : Type → Type}
[inst : Monad m]
(s : Lean.Syntax)
(f : Lean.Syntax → m Unit)
:
m Unit
Equations
- Lean.Syntax.forArgsM s f = Lean.Syntax.foldArgsM s (fun s x => f s) ()