Equations
- Lean.SourceInfo.updateTrailing trailing x = match x with | Lean.SourceInfo.original leading pos x endPos => Lean.SourceInfo.original leading pos trailing endPos | info => info
- mk: ∀ (info : Lean.SourceInfo) (kind : Lean.SyntaxNodeKind) (args : Array Lean.Syntax), Lean.IsNode (Lean.Syntax.node info kind args)
Equations
- Lean.unreachIsNodeMissing h = False.elim (_ : False)
def
Lean.unreachIsNodeAtom
{β : Sort u_1}
{info : Lean.SourceInfo}
{val : String}
(h : Lean.IsNode (Lean.Syntax.atom info val))
:
β
Equations
- Lean.unreachIsNodeAtom h = False.elim (_ : False)
def
Lean.unreachIsNodeIdent
{β : Sort u_1}
{info : Lean.SourceInfo}
{rawVal : Substring}
{val : Lean.Name}
{preresolved : List (Lean.Name × List String)}
(h : Lean.IsNode (Lean.Syntax.ident info rawVal val preresolved))
:
β
Equations
- Lean.unreachIsNodeIdent h = False.elim (_ : False)
Equations
@[inline]
Equations
- Lean.SyntaxNode.getKind n = match n with | { val := Lean.Syntax.node x k x_1, property := x_2 } => k | { val := Lean.Syntax.missing, property := h } => Lean.unreachIsNodeMissing h | { val := Lean.Syntax.atom x x_1, property := h } => Lean.unreachIsNodeAtom h | { val := Lean.Syntax.ident x x_1 x_2 x_3, property := h } => Lean.unreachIsNodeIdent h
@[inline]
Equations
- Lean.SyntaxNode.withArgs n fn = match n with | { val := Lean.Syntax.node x x_1 args, property := x_2 } => fn args | { val := Lean.Syntax.missing, property := h } => Lean.unreachIsNodeMissing h | { val := Lean.Syntax.atom x x_1, property := h } => Lean.unreachIsNodeAtom h | { val := Lean.Syntax.ident x x_1 x_2 x_3, property := h } => Lean.unreachIsNodeIdent h
@[inline]
Equations
- Lean.SyntaxNode.getNumArgs n = Lean.SyntaxNode.withArgs n fun args => Array.size args
@[inline]
Equations
- Lean.SyntaxNode.getArg n i = Lean.SyntaxNode.withArgs n fun args => Array.get! args i
@[inline]
Equations
- Lean.SyntaxNode.getArgs n = Lean.SyntaxNode.withArgs n fun args => args
@[inline]
Equations
- Lean.SyntaxNode.modifyArgs n fn = match n with | { val := Lean.Syntax.node i k args, property := x } => Lean.Syntax.node i k (fn args) | { val := Lean.Syntax.missing, property := h } => Lean.unreachIsNodeMissing h | { val := Lean.Syntax.atom x x_1, property := h } => Lean.unreachIsNodeAtom h | { val := Lean.Syntax.ident x x_1 x_2 x_3, property := h } => Lean.unreachIsNodeIdent h
Equations
- Lean.Syntax.getAtomVal! x = match x with | Lean.Syntax.atom x val => val | x => panicWithPosWithDecl "Lean.Syntax" "Lean.Syntax.getAtomVal!" 67 18 "getAtomVal!: not an atom"
Equations
- Lean.Syntax.setAtomVal x x = match x, x with | Lean.Syntax.atom info x, v => Lean.Syntax.atom info v | stx, x => stx
@[inline]
def
Lean.Syntax.ifNode
{β : Sort u_1}
(stx : Lean.Syntax)
(hyes : Lean.SyntaxNode → β)
(hno : Unit → β)
:
β
Equations
- Lean.Syntax.ifNode stx hyes hno = match stx with | Lean.Syntax.node i k args => hyes { val := Lean.Syntax.node i k args, property := (_ : Lean.IsNode (Lean.Syntax.node i k args)) } | x => hno ()
@[inline]
def
Lean.Syntax.ifNodeKind
{β : Sort u_1}
(stx : Lean.Syntax)
(kind : Lean.SyntaxNodeKind)
(hyes : Lean.SyntaxNode → β)
(hno : Unit → β)
:
β
Equations
- Lean.Syntax.ifNodeKind stx kind hyes hno = match stx with | Lean.Syntax.node i k args => if (k == kind) = true then hyes { val := Lean.Syntax.node i k args, property := (_ : Lean.IsNode (Lean.Syntax.node i k args)) } else hno () | x => hno ()
Equations
- Lean.Syntax.asNode x = match x with | Lean.Syntax.node info kind args => { val := Lean.Syntax.node info kind args, property := (_ : Lean.IsNode (Lean.Syntax.node info kind args)) } | x => { val := Lean.mkNullNode, property := Lean.Syntax.asNode.proof_1 }
Equations
- Lean.Syntax.getIdAt stx i = Lean.Syntax.getId (Lean.Syntax.getArg stx i)
@[inline]
Equations
- Lean.Syntax.modifyArgs stx fn = match stx with | Lean.Syntax.node i k args => Lean.Syntax.node i k (fn args) | stx => stx
@[inline]
Equations
- Lean.Syntax.modifyArg stx i fn = match stx with | Lean.Syntax.node info k args => Lean.Syntax.node info k (Array.modify args i fn) | stx => stx
@[specialize]
partial def
Lean.Syntax.replaceM
{m : Type → Type}
[inst : Monad m]
(fn : Lean.Syntax → m (Option Lean.Syntax))
:
@[specialize]
partial def
Lean.Syntax.rewriteBottomUpM
{m : Type → Type}
[inst : Monad m]
(fn : Lean.Syntax → m Lean.Syntax)
:
@[inline]
Equations
- Lean.Syntax.rewriteBottomUp fn stx = Id.run (Lean.Syntax.rewriteBottomUpM fn stx)
Equations
Equations
- Lean.Syntax.identComponents stx nFields? = (fun nameComps => match stx with | Lean.Syntax.ident (Lean.SourceInfo.original lead pos trail x) rawStr val x_1 => let val := Lean.Name.eraseMacroScopes val; let nameComps := nameComps val nFields?; let rawComps := Lean.Syntax.splitNameLit rawStr; let rawComps := match nFields? with | some nFields => let nPrefix := List.length rawComps - nFields; let prefixSz := List.foldl (fun acc ss => acc + Substring.bsize ss + 1) 0 (List.take nPrefix rawComps); let prefixSz := prefixSz - 1; Substring.extract rawStr 0 prefixSz :: List.drop nPrefix rawComps | x => rawComps; if (List.length nameComps == List.length rawComps) = true then List.map (fun x => match x with | (id, ss) => let off := ss.startPos - rawStr.startPos; let lead := if (off == 0) = true then lead else String.toSubstring ""; let trail := if (ss.stopPos == rawStr.stopPos) = true then trail else String.toSubstring ""; let info := Lean.SourceInfo.original lead (pos + off) trail (pos + off + Substring.bsize ss); Lean.Syntax.ident info ss id []) (List.zip nameComps rawComps) else panicWithPosWithDecl "Lean.Syntax" "Lean.Syntax.identComponents" 199 4 ("assertion violation: " ++ "nameComps.length == rawComps.length\n ") | Lean.Syntax.ident si x val x_1 => let val := Lean.Name.eraseMacroScopes val; List.map (fun n => Lean.Syntax.ident si (String.toSubstring (Lean.Name.toString n)) n []) (nameComps val nFields?) | x => panicWithPosWithDecl "Lean.Syntax" "Lean.Syntax.identComponents" 212 9 "unreachable code has been reached") Lean.Syntax.identComponents.nameComps
Equations
- Lean.Syntax.identComponents.nameComps n nFields? = match nFields? with | some nFields => let nameComps := Lean.Name.components n; let nPrefix := List.length nameComps - nFields; let namePrefix := List.foldl (fun acc n => acc ++ n) Lean.Name.anonymous (List.take nPrefix nameComps); namePrefix :: List.drop nPrefix nameComps | x => Lean.Name.components n
Equations
- Lean.Syntax.topDown stx firstChoiceOnly = { firstChoiceOnly := firstChoiceOnly, stx := stx }
Equations
- Lean.Syntax.instForInTopDownSyntax = { forIn := fun {β} [Monad m] x init f => match x with | { firstChoiceOnly := firstChoiceOnly, stx := stx } => (fun loop => do let a ← loop stx init { default := init } match a with | ForInStep.yield b => pure b | ForInStep.done b => pure b) (Lean.Syntax.instForInTopDownSyntax.loop f firstChoiceOnly) }
@[specialize]
partial def
Lean.Syntax.instForInTopDownSyntax.loop
{m : Type u_1 → Type u_2}
:
{β : Type u_1} →
[inst : Monad m] →
(Lean.Syntax → β → m (ForInStep β)) → Bool → Lean.Syntax → β → [inst : Inhabited β] → m (ForInStep β)
Equations
- Lean.Syntax.hasMissing stx = Id.run do let r ← let col := Lean.Syntax.topDown stx; forIn col { fst := none, snd := PUnit.unit } fun stx r => let r := r.snd; if Lean.Syntax.isMissing stx = true then pure (ForInStep.done { fst := some true, snd := PUnit.unit }) else do pure PUnit.unit pure (ForInStep.yield { fst := none, snd := PUnit.unit }) let x : PUnit := r.snd let _do_jp : PUnit → Id Bool := fun y => pure false match r.fst with | none => do let y ← pure PUnit.unit _do_jp y | some a => pure a
- cur : Lean.Syntax
- parents : Array Lean.Syntax
- idxs : Array Nat
Equations
- Lean.Syntax.Traverser.fromSyntax stx = { cur := stx, parents := #[], idxs := #[] }
Equations
- Lean.Syntax.Traverser.setCur t stx = { cur := stx, parents := t.parents, idxs := t.idxs }
Equations
- Lean.Syntax.Traverser.down t idx = if idx < Lean.Syntax.getNumArgs t.cur then { cur := Lean.Syntax.getArg t.cur idx, parents := Array.push t.parents (Lean.Syntax.setArg t.cur idx default), idxs := Array.push t.idxs idx } else { cur := Lean.Syntax.missing, parents := Array.push t.parents t.cur, idxs := Array.push t.idxs idx }
Equations
- Lean.Syntax.Traverser.up t = if Array.size t.parents > 0 then let cur := if Array.back t.idxs < Lean.Syntax.getNumArgs (Array.back t.parents) then Lean.Syntax.setArg (Array.back t.parents) (Array.back t.idxs) t.cur else Array.back t.parents; { cur := cur, parents := Array.pop t.parents, idxs := Array.pop t.idxs } else t
Equations
- Lean.Syntax.Traverser.left t = if Array.size t.parents > 0 then Lean.Syntax.Traverser.down (Lean.Syntax.Traverser.up t) (Array.back t.idxs - 1) else t
Equations
- Lean.Syntax.Traverser.right t = if Array.size t.parents > 0 then Lean.Syntax.Traverser.down (Lean.Syntax.Traverser.up t) (Array.back t.idxs + 1) else t
- st : MonadState Lean.Syntax.Traverser m
def
Lean.Syntax.MonadTraverser.getCur
{m : Type → Type}
[inst : Monad m]
[t : Lean.Syntax.MonadTraverser m]
:
Equations
- Lean.Syntax.MonadTraverser.getCur = Lean.Syntax.Traverser.cur <$> get
def
Lean.Syntax.MonadTraverser.setCur
{m : Type → Type}
[t : Lean.Syntax.MonadTraverser m]
(stx : Lean.Syntax)
:
m Unit
Equations
- Lean.Syntax.MonadTraverser.setCur stx = modify fun t => Lean.Syntax.Traverser.setCur t stx
def
Lean.Syntax.MonadTraverser.goDown
{m : Type → Type}
[t : Lean.Syntax.MonadTraverser m]
(idx : Nat)
:
m Unit
Equations
- Lean.Syntax.MonadTraverser.goDown idx = modify fun t => Lean.Syntax.Traverser.down t idx
Equations
- Lean.Syntax.MonadTraverser.goUp = modify fun t => Lean.Syntax.Traverser.up t
Equations
- Lean.Syntax.MonadTraverser.goLeft = modify fun t => Lean.Syntax.Traverser.left t
def
Lean.Syntax.MonadTraverser.goRight
{m : Type → Type}
[t : Lean.Syntax.MonadTraverser m]
:
m Unit
Equations
- Lean.Syntax.MonadTraverser.goRight = modify fun t => Lean.Syntax.Traverser.right t
def
Lean.Syntax.MonadTraverser.getIdx
{m : Type → Type}
[inst : Monad m]
[t : Lean.Syntax.MonadTraverser m]
:
m Nat
Equations
- Lean.Syntax.MonadTraverser.getIdx = do let st ← get pure (Option.getD (Array.back? st.idxs) 0)
@[inline]
Equations
Equations
- Lean.mkListNode args = Lean.mkNullNode args
Equations
- Lean.Syntax.isQuot x = match x with | Lean.Syntax.node x (Lean.Name.str x_1 "quot" x_2) x_3 => true | Lean.Syntax.node x (Lean.Name.str (Lean.Name.str (Lean.Name.str (Lean.Name.str Lean.Name.anonymous "Lean" x_2) "Parser" x_3) "Term" x_4) "dynamicQuot" x_5) x_1 => true | x => false
Equations
- Lean.Syntax.getQuotContent stx = if Lean.Syntax.isOfKind stx `Lean.Parser.Term.dynamicQuot = true then Lean.Syntax.getOp stx 3 else Lean.Syntax.getOp stx 1
Equations
- Lean.Syntax.isAntiquot x = match x with | Lean.Syntax.node x (Lean.Name.str x_1 "antiquot" x_2) x_3 => true | x => false
def
Lean.Syntax.mkAntiquotNode
(term : Lean.Syntax)
(nesting : optParam Nat 0)
(name : optParam (Option String) none)
(kind : optParam Lean.Name Lean.Name.anonymous)
:
Equations
- Lean.Syntax.mkAntiquotNode term nesting name kind = let nesting := Lean.mkNullNode (mkArray nesting (Lean.mkAtom "$")); let term := match Lean.Syntax.isIdent term with | true => term | false => Lean.mkNode `antiquotNestedExpr #[Lean.mkAtom "(", term, Lean.mkAtom ")"]; let name := match name with | some name => Lean.mkNode `antiquotName #[Lean.mkAtom ":", Lean.mkAtom name] | none => Lean.mkNullNode; Lean.mkNode (kind ++ `antiquot) #[Lean.mkAtom "$", nesting, term, name]
Equations
Equations
- Lean.Syntax.unescapeAntiquot stx = if Lean.Syntax.isAntiquot stx = true then Lean.Syntax.setArg stx 1 (Lean.mkNullNode (Array.pop (Lean.Syntax.getArgs (Lean.Syntax.getOp stx 1)))) else stx
Equations
- Lean.Syntax.getAntiquotTerm stx = let e := if Lean.Syntax.isAntiquot stx = true then Lean.Syntax.getOp stx 2 else Lean.Syntax.getOp stx 3; if Lean.Syntax.isIdent e = true then e else Lean.Syntax.getOp e 1
Equations
- Lean.Syntax.antiquotKind? x = match x with | Lean.Syntax.node x (Lean.Name.str k "antiquot" x_1) args => if Lean.Syntax.isOfKind (Array.getOp args 3) `antiquotName = true then some k else some Lean.Name.anonymous | x => none
Equations
- Lean.Syntax.antiquotSpliceKind? x = match x with | Lean.Syntax.node x (Lean.Name.str k "antiquot_scope" x_1) args => some k | x => none
Equations
Equations
Equations
- Lean.Syntax.getAntiquotSpliceSuffix stx = if Lean.Syntax.isAntiquotSplice stx = true then Lean.Syntax.getOp stx 5 else Lean.Syntax.getOp stx 1
def
Lean.Syntax.mkAntiquotSpliceNode
(kind : Lean.SyntaxNodeKind)
(contents : Array Lean.Syntax)
(suffix : String)
(nesting : optParam Nat 0)
:
Equations
- Lean.Syntax.mkAntiquotSpliceNode kind contents suffix nesting = let nesting := Lean.mkNullNode (mkArray nesting (Lean.mkAtom "$")); Lean.mkNode (kind ++ `antiquot_splice) #[Lean.mkAtom "$", nesting, Lean.mkAtom "[", Lean.mkNullNode contents, Lean.mkAtom "]", Lean.mkAtom suffix]
Equations
- Lean.Syntax.antiquotSuffixSplice? x = match x with | Lean.Syntax.node x (Lean.Name.str k "antiquot_suffix_splice" x_1) args => some k | x => none
Equations
Equations
def
Lean.Syntax.mkAntiquotSuffixSpliceNode
(kind : Lean.SyntaxNodeKind)
(inner : Lean.Syntax)
(suffix : String)
:
Equations
- Lean.Syntax.mkAntiquotSuffixSpliceNode kind inner suffix = Lean.mkNode (kind ++ `antiquot_suffix_splice) #[inner, Lean.mkAtom suffix]
Equations
- Lean.Syntax.isTokenAntiquot stx = Lean.Syntax.isOfKind stx `token_antiquot