File: .lake/packages/lean4/src/lean/Lean/Language/Lean.lean

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Language.Lean.0.Lean.Language.Lean.pushOpt
code: private def pushOpt (a? : Option α) (as : Array α) : Array α 
goal: Array α

full_name: Lean.Language.Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Language.Lean._hyg.37
code: /-- Option for capturing output to stderr during elaboration. -/
register_builtin_option stderrAsMessages : Bool := {
  defValue := true
  group    := "server"
  descr    := "(server) capture output to the Lean stderr channel (such as from `dbg_trace`) during elaboration of a command as a diagnostic message"
}
goal: IO (Lean.Option Bool)

full_name: Lean.Language.Lean.stderrAsMessages
code: /-- Option for capturing output to stderr during elaboration. -/
register_builtin_option stderrAsMessages : Bool := {
  defValue := true
  group    := "server"
  descr    := "(server) capture output to the Lean stderr channel (such as from `dbg_trace`) during elaboration of a command as a diagnostic message"
}
goal: Lean.Option Bool

full_name: Lean.Language.Lean.CommandFinishedSnapshot.cmdState
code: /-- Snapshot after elaboration of the entire command. -/
structure CommandFinishedSnapshot extends Language.Snapshot where
  /-- Resulting elaboration state. -/
  cmdState : Command.State
deriving Nonempty
goal: Lean.Elab.Command.State

full_name: Lean.Language.Lean.instNonemptyCommandFinishedSnapshot
code: /-- Snapshot after elaboration of the entire command. -/
structure CommandFinishedSnapshot extends Language.Snapshot where
  /-- Resulting elaboration state. -/
  cmdState : Command.State
deriving Nonempty
goal: Nonempty Lean.Language.Lean.CommandFinishedSnapshot

full_name: Lean.Language.Lean.CommandFinishedSnapshot
code: /-- Snapshot after elaboration of the entire command. -/
structure CommandFinishedSnapshot extends Language.Snapshot where
  /-- Resulting elaboration state. -/
  cmdState : Command.State
deriving Nonempty
goal: Type

full_name: Lean.Language.Lean.instToSnapshotTreeCommandFinishedSnapshot
code: instance : ToSnapshotTree CommandFinishedSnapshot 
goal: Lean.Language.ToSnapshotTree Lean.Language.Lean.CommandFinishedSnapshot

full_name: Lean.Language.Lean.CommandParsedSnapshotData
code: /-- State after a command has been parsed. -/
structure CommandParsedSnapshotData extends Snapshot where
  /-- Syntax tree of the command. -/
  stx : Syntax
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /--
  Snapshot for incremental reporting and reuse during elaboration, type dependent on specific
  elaborator.
   -/
  elabSnap : SnapshotTask DynamicSnapshot
  /-- State after processing is finished. -/
  finishedSnap : SnapshotTask CommandFinishedSnapshot
  /-- Cache for `save`; to be replaced with incrementality. -/
  tacticCache : IO.Ref Tactic.Cache
deriving Nonempty
goal: Type

full_name: Lean.Language.Lean.instNonemptyCommandParsedSnapshotData
code: /-- State after a command has been parsed. -/
structure CommandParsedSnapshotData extends Snapshot where
  /-- Syntax tree of the command. -/
  stx : Syntax
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /--
  Snapshot for incremental reporting and reuse during elaboration, type dependent on specific
  elaborator.
   -/
  elabSnap : SnapshotTask DynamicSnapshot
  /-- State after processing is finished. -/
  finishedSnap : SnapshotTask CommandFinishedSnapshot
  /-- Cache for `save`; to be replaced with incrementality. -/
  tacticCache : IO.Ref Tactic.Cache
deriving Nonempty
goal: Nonempty Lean.Language.Lean.CommandParsedSnapshotData

full_name: Lean.Language.Lean.CommandParsedSnapshotData.elabSnap
code: /-- State after a command has been parsed. -/
structure CommandParsedSnapshotData extends Snapshot where
  /-- Syntax tree of the command. -/
  stx : Syntax
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /--
  Snapshot for incremental reporting and reuse during elaboration, type dependent on specific
  elaborator.
   -/
  elabSnap : SnapshotTask DynamicSnapshot
  /-- State after processing is finished. -/
  finishedSnap : SnapshotTask CommandFinishedSnapshot
  /-- Cache for `save`; to be replaced with incrementality. -/
  tacticCache : IO.Ref Tactic.Cache
deriving Nonempty
goal: Lean.Language.SnapshotTask Lean.Language.DynamicSnapshot

full_name: Lean.Language.Lean.CommandParsedSnapshotData.tacticCache
code: /-- State after a command has been parsed. -/
structure CommandParsedSnapshotData extends Snapshot where
  /-- Syntax tree of the command. -/
  stx : Syntax
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /--
  Snapshot for incremental reporting and reuse during elaboration, type dependent on specific
  elaborator.
   -/
  elabSnap : SnapshotTask DynamicSnapshot
  /-- State after processing is finished. -/
  finishedSnap : SnapshotTask CommandFinishedSnapshot
  /-- Cache for `save`; to be replaced with incrementality. -/
  tacticCache : IO.Ref Tactic.Cache
deriving Nonempty
goal: IO.Ref Lean.Elab.Tactic.Cache

full_name: Lean.Language.Lean.CommandParsedSnapshotData.finishedSnap
code: /-- State after a command has been parsed. -/
structure CommandParsedSnapshotData extends Snapshot where
  /-- Syntax tree of the command. -/
  stx : Syntax
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /--
  Snapshot for incremental reporting and reuse during elaboration, type dependent on specific
  elaborator.
   -/
  elabSnap : SnapshotTask DynamicSnapshot
  /-- State after processing is finished. -/
  finishedSnap : SnapshotTask CommandFinishedSnapshot
  /-- Cache for `save`; to be replaced with incrementality. -/
  tacticCache : IO.Ref Tactic.Cache
deriving Nonempty
goal: Lean.Language.SnapshotTask Lean.Language.Lean.CommandFinishedSnapshot

full_name: Lean.Language.Lean.CommandParsedSnapshotData.stx
code: /-- State after a command has been parsed. -/
structure CommandParsedSnapshotData extends Snapshot where
  /-- Syntax tree of the command. -/
  stx : Syntax
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /--
  Snapshot for incremental reporting and reuse during elaboration, type dependent on specific
  elaborator.
   -/
  elabSnap : SnapshotTask DynamicSnapshot
  /-- State after processing is finished. -/
  finishedSnap : SnapshotTask CommandFinishedSnapshot
  /-- Cache for `save`; to be replaced with incrementality. -/
  tacticCache : IO.Ref Tactic.Cache
deriving Nonempty
goal: Lean.Syntax

full_name: Lean.Language.Lean.CommandParsedSnapshotData.parserState
code: /-- State after a command has been parsed. -/
structure CommandParsedSnapshotData extends Snapshot where
  /-- Syntax tree of the command. -/
  stx : Syntax
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /--
  Snapshot for incremental reporting and reuse during elaboration, type dependent on specific
  elaborator.
   -/
  elabSnap : SnapshotTask DynamicSnapshot
  /-- State after processing is finished. -/
  finishedSnap : SnapshotTask CommandFinishedSnapshot
  /-- Cache for `save`; to be replaced with incrementality. -/
  tacticCache : IO.Ref Tactic.Cache
deriving Nonempty
goal: Lean.Parser.ModuleParserState

full_name: Lean.Language.Lean.CommandParsedSnapshot
code: /-- State after a command has been parsed. -/
-- workaround for lack of recursive structures
inductive CommandParsedSnapshot where
  /-- Creates a command parsed snapshot. -/
  | mk (data : CommandParsedSnapshotData)
    (nextCmdSnap? : Option (SnapshotTask CommandParsedSnapshot))
deriving Nonempty
goal: Type

full_name: Lean.Language.Lean.instNonemptyCommandParsedSnapshot
code: /-- State after a command has been parsed. -/
-- workaround for lack of recursive structures
inductive CommandParsedSnapshot where
  /-- Creates a command parsed snapshot. -/
  | mk (data : CommandParsedSnapshotData)
    (nextCmdSnap? : Option (SnapshotTask CommandParsedSnapshot))
deriving Nonempty
goal: Nonempty Lean.Language.Lean.CommandParsedSnapshot

full_name: Lean.Language.Lean.CommandParsedSnapshot.mk
code: /-- State after a command has been parsed. -/
-- workaround for lack of recursive structures
inductive CommandParsedSnapshot where
  /-- Creates a command parsed snapshot. -/
  | mk (data : CommandParsedSnapshotData)
    (nextCmdSnap? : Option (SnapshotTask CommandParsedSnapshot))
deriving Nonempty
goal: Lean.Language.Lean.CommandParsedSnapshot

full_name: Lean.Language.Lean.CommandParsedSnapshot.data
code: /-- The snapshot data. -/
abbrev CommandParsedSnapshot.data : CommandParsedSnapshot → CommandParsedSnapshotData
  
goal: Lean.Language.Lean.CommandParsedSnapshot → Lean.Language.Lean.CommandParsedSnapshotData

full_name: Lean.Language.Lean.CommandParsedSnapshot.nextCmdSnap?
code: /-- Next command, unless this is a terminal command. -/
abbrev CommandParsedSnapshot.nextCmdSnap? : CommandParsedSnapshot →
    Option (SnapshotTask CommandParsedSnapshot)
  
goal: Lean.Language.Lean.CommandParsedSnapshot → Option (Lean.Language.SnapshotTask Lean.Language.Lean.CommandParsedSnapshot)

full_name: Lean.Language.Lean.instToSnapshotTreeCommandParsedSnapshot.go
code: partial instance : ToSnapshotTree CommandParsedSnapshot 
goal: Lean.Language.SnapshotTree

full_name: Lean.Language.Lean.instToSnapshotTreeCommandParsedSnapshot
code: partial instance : ToSnapshotTree CommandParsedSnapshot 
goal: Lean.Language.ToSnapshotTree Lean.Language.Lean.CommandParsedSnapshot

full_name: Lean.Language.Lean.HeaderProcessedState
code: /-- State after successful importing. -/
structure HeaderProcessedState where
  /-- The resulting initial elaboration state. -/
  cmdState : Command.State
  /-- First command task (there is always at least a terminal command). -/
  firstCmdSnap : SnapshotTask CommandParsedSnapshot
goal: Type

full_name: Lean.Language.Lean.HeaderProcessedState.cmdState
code: /-- State after successful importing. -/
structure HeaderProcessedState where
  /-- The resulting initial elaboration state. -/
  cmdState : Command.State
  /-- First command task (there is always at least a terminal command). -/
  firstCmdSnap : SnapshotTask CommandParsedSnapshot
goal: Lean.Elab.Command.State

full_name: Lean.Language.Lean.HeaderProcessedState.firstCmdSnap
code: /-- State after successful importing. -/
structure HeaderProcessedState where
  /-- The resulting initial elaboration state. -/
  cmdState : Command.State
  /-- First command task (there is always at least a terminal command). -/
  firstCmdSnap : SnapshotTask CommandParsedSnapshot
goal: Lean.Language.SnapshotTask Lean.Language.Lean.CommandParsedSnapshot

full_name: Lean.Language.Lean.HeaderProcessedSnapshot.result?
code: /-- State after the module header has been processed including imports. -/
structure HeaderProcessedSnapshot extends Snapshot where
  /-- State after successful importing. -/
  result? : Option HeaderProcessedState
  isFatal := result?.isNone
goal: Option Lean.Language.Lean.HeaderProcessedState

full_name: Lean.Language.Lean.HeaderProcessedSnapshot
code: /-- State after the module header has been processed including imports. -/
structure HeaderProcessedSnapshot extends Snapshot where
  /-- State after successful importing. -/
  result? : Option HeaderProcessedState
  isFatal := result?.isNone
goal: Type

full_name: Lean.Language.Lean.instToSnapshotTreeHeaderProcessedSnapshot
code: instance : ToSnapshotTree HeaderProcessedSnapshot 
goal: Lean.Language.ToSnapshotTree Lean.Language.Lean.HeaderProcessedSnapshot

full_name: Lean.Language.Lean.HeaderParsedState
code: /-- State after successfully parsing the module header. -/
structure HeaderParsedState where
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /-- Header processing task. -/
  processedSnap : SnapshotTask HeaderProcessedSnapshot
goal: Type

full_name: Lean.Language.Lean.HeaderParsedState.processedSnap
code: /-- State after successfully parsing the module header. -/
structure HeaderParsedState where
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /-- Header processing task. -/
  processedSnap : SnapshotTask HeaderProcessedSnapshot
goal: Lean.Language.SnapshotTask Lean.Language.Lean.HeaderProcessedSnapshot

full_name: Lean.Language.Lean.HeaderParsedState.parserState
code: /-- State after successfully parsing the module header. -/
structure HeaderParsedState where
  /-- Resulting parser state. -/
  parserState : Parser.ModuleParserState
  /-- Header processing task. -/
  processedSnap : SnapshotTask HeaderProcessedSnapshot
goal: Lean.Parser.ModuleParserState

full_name: Lean.Language.Lean.HeaderParsedSnapshot.ictx
code: /-- State after the module header has been parsed. -/
structure HeaderParsedSnapshot extends Snapshot where
  /-- Parser input context supplied by the driver, stored here for incremental parsing. -/
  ictx : Parser.InputContext
  /-- Resulting syntax tree. -/
  stx : Syntax
  /-- State after successful parsing. -/
  result? : Option HeaderParsedState
  isFatal := result?.isNone
  /-- Cancellation token for interrupting processing of this run. -/
  cancelTk? : Option IO.CancelToken
goal: Lean.Parser.InputContext

full_name: Lean.Language.Lean.HeaderParsedSnapshot.stx
code: /-- State after the module header has been parsed. -/
structure HeaderParsedSnapshot extends Snapshot where
  /-- Parser input context supplied by the driver, stored here for incremental parsing. -/
  ictx : Parser.InputContext
  /-- Resulting syntax tree. -/
  stx : Syntax
  /-- State after successful parsing. -/
  result? : Option HeaderParsedState
  isFatal := result?.isNone
  /-- Cancellation token for interrupting processing of this run. -/
  cancelTk? : Option IO.CancelToken
goal: Lean.Syntax

full_name: Lean.Language.Lean.HeaderParsedSnapshot
code: /-- State after the module header has been parsed. -/
structure HeaderParsedSnapshot extends Snapshot where
  /-- Parser input context supplied by the driver, stored here for incremental parsing. -/
  ictx : Parser.InputContext
  /-- Resulting syntax tree. -/
  stx : Syntax
  /-- State after successful parsing. -/
  result? : Option HeaderParsedState
  isFatal := result?.isNone
  /-- Cancellation token for interrupting processing of this run. -/
  cancelTk? : Option IO.CancelToken
goal: Type

full_name: Lean.Language.Lean.HeaderParsedSnapshot.cancelTk?
code: /-- State after the module header has been parsed. -/
structure HeaderParsedSnapshot extends Snapshot where
  /-- Parser input context supplied by the driver, stored here for incremental parsing. -/
  ictx : Parser.InputContext
  /-- Resulting syntax tree. -/
  stx : Syntax
  /-- State after successful parsing. -/
  result? : Option HeaderParsedState
  isFatal := result?.isNone
  /-- Cancellation token for interrupting processing of this run. -/
  cancelTk? : Option IO.CancelToken
goal: Option IO.CancelToken

full_name: Lean.Language.Lean.HeaderParsedSnapshot.result?
code: /-- State after the module header has been parsed. -/
structure HeaderParsedSnapshot extends Snapshot where
  /-- Parser input context supplied by the driver, stored here for incremental parsing. -/
  ictx : Parser.InputContext
  /-- Resulting syntax tree. -/
  stx : Syntax
  /-- State after successful parsing. -/
  result? : Option HeaderParsedState
  isFatal := result?.isNone
  /-- Cancellation token for interrupting processing of this run. -/
  cancelTk? : Option IO.CancelToken
goal: Option Lean.Language.Lean.HeaderParsedState

full_name: Lean.Language.Lean.instToSnapshotTreeHeaderParsedSnapshot
code: instance : ToSnapshotTree HeaderParsedSnapshot 
goal: Lean.Language.ToSnapshotTree Lean.Language.Lean.HeaderParsedSnapshot

full_name: Lean.Language.Lean.HeaderParsedSnapshot.processedResult
code: /-- Shortcut accessor to the final header state, if successful. -/
def HeaderParsedSnapshot.processedResult (snap : HeaderParsedSnapshot) :
    SnapshotTask (Option HeaderProcessedState) 
goal: Lean.Language.SnapshotTask (Option Lean.Language.Lean.HeaderProcessedState)

full_name: Lean.Language.Lean.InitialSnapshot
code: /-- Initial snapshot of the Lean language processor: a "header parsed" snapshot. -/
abbrev InitialSnapshot 
goal: Type

full_name: Lean.Language.Lean.LeanProcessingContext.newCancelTk
code: /-- Lean-specific processing context. -/
structure LeanProcessingContext extends ProcessingContext where
  /-- Position of the first file difference if there was a previous invocation. -/
  firstDiffPos? : Option String.Pos
  /-- Cancellation token of the previous invocation, if any. -/
  oldCancelTk? : Option IO.CancelToken
  /-- Cancellation token of the current run. -/
  newCancelTk : IO.CancelToken
goal: IO.CancelToken

full_name: Lean.Language.Lean.LeanProcessingContext
code: /-- Lean-specific processing context. -/
structure LeanProcessingContext extends ProcessingContext where
  /-- Position of the first file difference if there was a previous invocation. -/
  firstDiffPos? : Option String.Pos
  /-- Cancellation token of the previous invocation, if any. -/
  oldCancelTk? : Option IO.CancelToken
  /-- Cancellation token of the current run. -/
  newCancelTk : IO.CancelToken
goal: Type

full_name: Lean.Language.Lean.LeanProcessingContext.oldCancelTk?
code: /-- Lean-specific processing context. -/
structure LeanProcessingContext extends ProcessingContext where
  /-- Position of the first file difference if there was a previous invocation. -/
  firstDiffPos? : Option String.Pos
  /-- Cancellation token of the previous invocation, if any. -/
  oldCancelTk? : Option IO.CancelToken
  /-- Cancellation token of the current run. -/
  newCancelTk : IO.CancelToken
goal: Option IO.CancelToken

full_name: Lean.Language.Lean.LeanProcessingContext.firstDiffPos?
code: /-- Lean-specific processing context. -/
structure LeanProcessingContext extends ProcessingContext where
  /-- Position of the first file difference if there was a previous invocation. -/
  firstDiffPos? : Option String.Pos
  /-- Cancellation token of the previous invocation, if any. -/
  oldCancelTk? : Option IO.CancelToken
  /-- Cancellation token of the current run. -/
  newCancelTk : IO.CancelToken
goal: Option String.Pos

full_name: Lean.Language.Lean.LeanProcessingT
code: /-- Monad transformer holding all relevant data for Lean processing. -/
abbrev LeanProcessingT m 
goal: Type u_1

full_name: Lean.Language.Lean.LeanProcessingM
code: /-- Monad holding all relevant data for Lean processing. -/
abbrev LeanProcessingM 
goal: Type

full_name: Lean.Language.Lean.instMonadLiftLeanProcessingMLeanProcessingTIO
code: instance : MonadLift LeanProcessingM (LeanProcessingT IO) 
goal: MonadLift Lean.Language.Lean.LeanProcessingM (Lean.Language.Lean.LeanProcessingT IO)

full_name: Lean.Language.Lean.instMonadLiftProcessingTLeanProcessingT
code: instance : MonadLift (ProcessingT m) (LeanProcessingT m) 
goal: MonadLift (Lean.Language.ProcessingT m) (Lean.Language.Lean.LeanProcessingT m)

full_name: Lean.Language.Lean.LeanProcessingM.run
code: /--
Embeds a `LeanProcessingM` action into `ProcessingM`, optionally using the old input string to speed
up reuse analysis and supplying a cancellation token that should be triggered as soon as reuse is
ruled out.
-/
def LeanProcessingM.run (act : LeanProcessingM α) (oldInputCtx? : Option InputContext)
    (oldCancelTk? : Option IO.CancelToken := none) : ProcessingM α 
goal: Lean.Language.ProcessingM α

full_name: Lean.Language.Lean.isBeforeEditPos
code: /--
Returns true if there was a previous run and the given position is before any textual change
compared to it.
-/
def isBeforeEditPos (pos : String.Pos) : LeanProcessingM Bool 
goal: Lean.Language.Lean.LeanProcessingM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Language.Lean.0.Lean.Language.Lean.withHeaderExceptions
code: /--
  Adds unexpected exceptions from header processing to the message log as a last resort; standard
  errors should already have been caught earlier. -/
private def withHeaderExceptions (ex : Snapshot → α) (act : LeanProcessingT IO α) :
    LeanProcessingM α 
goal: Lean.Language.Lean.LeanProcessingM α

full_name: Lean.Language.Lean.SetupImportsResult
code: /--
Result of retrieving additional metadata about the current file after parsing imports. In the
language server, these are derived from the `lake setup-file` result. On the cmdline and for similar
simple uses, these can be computed eagerly without looking at the imports.
-/
structure SetupImportsResult where
  /-- Module name of the file being processed. -/
  mainModuleName : Name
  /-- Options provided outside of the file content, e.g. on the cmdline or in the lakefile. -/
  opts : Options
  /-- Kernel trust level. -/
  trustLevel : UInt32 := 0
goal: Type

full_name: Lean.Language.Lean.SetupImportsResult.trustLevel
code: /--
Result of retrieving additional metadata about the current file after parsing imports. In the
language server, these are derived from the `lake setup-file` result. On the cmdline and for similar
simple uses, these can be computed eagerly without looking at the imports.
-/
structure SetupImportsResult where
  /-- Module name of the file being processed. -/
  mainModuleName : Name
  /-- Options provided outside of the file content, e.g. on the cmdline or in the lakefile. -/
  opts : Options
  /-- Kernel trust level. -/
  trustLevel : UInt32 := 0
goal: UInt32

full_name: Lean.Language.Lean.SetupImportsResult.mainModuleName
code: /--
Result of retrieving additional metadata about the current file after parsing imports. In the
language server, these are derived from the `lake setup-file` result. On the cmdline and for similar
simple uses, these can be computed eagerly without looking at the imports.
-/
structure SetupImportsResult where
  /-- Module name of the file being processed. -/
  mainModuleName : Name
  /-- Options provided outside of the file content, e.g. on the cmdline or in the lakefile. -/
  opts : Options
  /-- Kernel trust level. -/
  trustLevel : UInt32 := 0
goal: Lean.Name

full_name: Lean.Language.Lean.SetupImportsResult.opts
code: /--
Result of retrieving additional metadata about the current file after parsing imports. In the
language server, these are derived from the `lake setup-file` result. On the cmdline and for similar
simple uses, these can be computed eagerly without looking at the imports.
-/
structure SetupImportsResult where
  /-- Module name of the file being processed. -/
  mainModuleName : Name
  /-- Options provided outside of the file content, e.g. on the cmdline or in the lakefile. -/
  opts : Options
  /-- Kernel trust level. -/
  trustLevel : UInt32 := 0
goal: Lean.Options

full_name: Lean.Language.Lean.process.processHeader
code: /--
Entry point of the Lean language processor.

The `setupImports` function is called after the header has been parsed and before the first command
is parsed in order to supply additional file metadata (or abort with a given terminal snapshot); see
`SetupImportsResult`.

`old?` is a previous resulting snapshot, if any, to be reused for incremental processing.
-/
/-
General notes:
* For each processing function we pass in the previous state, if any, in order to reuse still-valid
  state. As there is no cheap way to check whether the `Environment` is unchanged, i.e. *semantic*
  change detection is currently not possible, we must make sure to pass `none` as all follow-up
  "previous states" from the first *syntactic* change onwards.
* We must make sure to trigger `oldCancelTk?` as soon as discarding `old?`.
* Control flow up to finding the last still-valid snapshot (which should be quick) is synchronous so
  as not to report this "fast forwarding" to the user as well as to make sure the next run sees all
  fast-forwarded snapshots without having to wait on tasks.
-/
partial def process
    (setupImports : Syntax → ProcessingT IO (Except HeaderProcessedSnapshot SetupImportsResult))
    (old? : Option InitialSnapshot) : ProcessingM InitialSnapshot 
goal: Lean.Language.Lean.LeanProcessingM (Lean.Language.SnapshotTask Lean.Language.Lean.HeaderProcessedSnapshot)

full_name: Lean.Language.Lean.process.parseCmd
code: /--
Entry point of the Lean language processor.

The `setupImports` function is called after the header has been parsed and before the first command
is parsed in order to supply additional file metadata (or abort with a given terminal snapshot); see
`SetupImportsResult`.

`old?` is a previous resulting snapshot, if any, to be reused for incremental processing.
-/
/-
General notes:
* For each processing function we pass in the previous state, if any, in order to reuse still-valid
  state. As there is no cheap way to check whether the `Environment` is unchanged, i.e. *semantic*
  change detection is currently not possible, we must make sure to pass `none` as all follow-up
  "previous states" from the first *syntactic* change onwards.
* We must make sure to trigger `oldCancelTk?` as soon as discarding `old?`.
* Control flow up to finding the last still-valid snapshot (which should be quick) is synchronous so
  as not to report this "fast forwarding" to the user as well as to make sure the next run sees all
  fast-forwarded snapshots without having to wait on tasks.
-/
partial def process
    (setupImports : Syntax → ProcessingT IO (Except HeaderProcessedSnapshot SetupImportsResult))
    (old? : Option InitialSnapshot) : ProcessingM InitialSnapshot 
goal: Lean.Language.Lean.LeanProcessingM (Lean.Language.SnapshotTask Lean.Language.Lean.CommandParsedSnapshot)

full_name: Lean.Language.Lean.process.doElab
code: /--
Entry point of the Lean language processor.

The `setupImports` function is called after the header has been parsed and before the first command
is parsed in order to supply additional file metadata (or abort with a given terminal snapshot); see
`SetupImportsResult`.

`old?` is a previous resulting snapshot, if any, to be reused for incremental processing.
-/
/-
General notes:
* For each processing function we pass in the previous state, if any, in order to reuse still-valid
  state. As there is no cheap way to check whether the `Environment` is unchanged, i.e. *semantic*
  change detection is currently not possible, we must make sure to pass `none` as all follow-up
  "previous states" from the first *syntactic* change onwards.
* We must make sure to trigger `oldCancelTk?` as soon as discarding `old?`.
* Control flow up to finding the last still-valid snapshot (which should be quick) is synchronous so
  as not to report this "fast forwarding" to the user as well as to make sure the next run sees all
  fast-forwarded snapshots without having to wait on tasks.
-/
partial def process
    (setupImports : Syntax → ProcessingT IO (Except HeaderProcessedSnapshot SetupImportsResult))
    (old? : Option InitialSnapshot) : ProcessingM InitialSnapshot 
goal: Lean.Language.Lean.LeanProcessingM (Lean.Language.SnapshotTask Lean.Language.Lean.CommandFinishedSnapshot)

full_name: Lean.Language.Lean.process
code: /--
Entry point of the Lean language processor.

The `setupImports` function is called after the header has been parsed and before the first command
is parsed in order to supply additional file metadata (or abort with a given terminal snapshot); see
`SetupImportsResult`.

`old?` is a previous resulting snapshot, if any, to be reused for incremental processing.
-/
/-
General notes:
* For each processing function we pass in the previous state, if any, in order to reuse still-valid
  state. As there is no cheap way to check whether the `Environment` is unchanged, i.e. *semantic*
  change detection is currently not possible, we must make sure to pass `none` as all follow-up
  "previous states" from the first *syntactic* change onwards.
* We must make sure to trigger `oldCancelTk?` as soon as discarding `old?`.
* Control flow up to finding the last still-valid snapshot (which should be quick) is synchronous so
  as not to report this "fast forwarding" to the user as well as to make sure the next run sees all
  fast-forwarded snapshots without having to wait on tasks.
-/
partial def process
    (setupImports : Syntax → ProcessingT IO (Except HeaderProcessedSnapshot SetupImportsResult))
    (old? : Option InitialSnapshot) : ProcessingM InitialSnapshot 
goal: Lean.Language.ProcessingM Lean.Language.Lean.InitialSnapshot

full_name: Lean.Language.Lean.process.parseHeader
code: /--
Entry point of the Lean language processor.

The `setupImports` function is called after the header has been parsed and before the first command
is parsed in order to supply additional file metadata (or abort with a given terminal snapshot); see
`SetupImportsResult`.

`old?` is a previous resulting snapshot, if any, to be reused for incremental processing.
-/
/-
General notes:
* For each processing function we pass in the previous state, if any, in order to reuse still-valid
  state. As there is no cheap way to check whether the `Environment` is unchanged, i.e. *semantic*
  change detection is currently not possible, we must make sure to pass `none` as all follow-up
  "previous states" from the first *syntactic* change onwards.
* We must make sure to trigger `oldCancelTk?` as soon as discarding `old?`.
* Control flow up to finding the last still-valid snapshot (which should be quick) is synchronous so
  as not to report this "fast forwarding" to the user as well as to make sure the next run sees all
  fast-forwarded snapshots without having to wait on tasks.
-/
partial def process
    (setupImports : Syntax → ProcessingT IO (Except HeaderProcessedSnapshot SetupImportsResult))
    (old? : Option InitialSnapshot) : ProcessingM InitialSnapshot 
goal: Lean.Language.Lean.LeanProcessingM Lean.Language.Lean.HeaderParsedSnapshot

full_name: Lean.Language.Lean.processCommands
code: /--
Convenience function for tool uses of the language processor that skips header handling.
-/
def processCommands (inputCtx : Parser.InputContext) (parserState : Parser.ModuleParserState)
    (commandState : Command.State)
    (old? : Option (Parser.InputContext × CommandParsedSnapshot) := none) :
    BaseIO (SnapshotTask CommandParsedSnapshot) 
goal: BaseIO (Lean.Language.SnapshotTask Lean.Language.Lean.CommandParsedSnapshot)

full_name: Lean.Language.Lean.waitForFinalEnv?.goCmd
code: /-- Waits for and returns final environment, if importing was successful. -/
partial def waitForFinalEnv? (snap : InitialSnapshot) : Option Environment 
goal: Option Lean.Environment

full_name: Lean.Language.Lean.waitForFinalEnv?
code: /-- Waits for and returns final environment, if importing was successful. -/
partial def waitForFinalEnv? (snap : InitialSnapshot) : Option Environment 
goal: Option Lean.Environment