feat(frontend): Tomogram #220

Merged
aniva merged 9 commits from frontend/tomogram into dev 2025-07-02 15:18:19 -07:00
2 changed files with 26 additions and 2 deletions
Showing only changes of commit 53ea808c90 - Show all commits

View File

@ -10,7 +10,7 @@ namespace Lean.Elab
private def elaboratorToString : Name → String private def elaboratorToString : Name → String
| .anonymous => "" | .anonymous => ""
| n => s!"⟨{n}⟩ " | n => s!"⟨{n}⟩ "
private def indent (s : String) : String := "\n".intercalate $ s.splitOn "\n" |>.map ("\t" ++ .) private def indent (s : String) : String := "\n".intercalate $ s.splitOn "\n" |>.map (" " ++ .)
/-- The `Syntax` for a `Lean.Elab.Info`, if there is one. -/ /-- The `Syntax` for a `Lean.Elab.Info`, if there is one. -/
protected def Info.stx? : Info → Option Syntax protected def Info.stx? : Info → Option Syntax

View File

@ -1,5 +1,29 @@
import Pantograph.Frontend
open Lean
namespace Pantograph
def fail (s : String) : IO Unit := do
IO.eprintln s
def dissect (args: List String): IO Unit := do
let fileName :: _args := args | fail s!"Must supply a file name"
let file ← IO.FS.readFile fileName
let (context, state) ← do Frontend.createContextStateFromFile file fileName (env? := .none) {}
let frontendM: Elab.Frontend.FrontendM _ :=
Frontend.mapCompilationSteps λ step => do
for tree in step.trees do
IO.println s!"{← tree.toString}"
let (_, _) ← frontendM.run context |>.run state
return ()
end Pantograph
open Pantograph
def main (args : List String) : IO Unit := do def main (args : List String) : IO Unit := do
let command :: args := args | IO.eprintln "Must supply a command" let command :: args := args | IO.eprintln "Must supply a command"
IO.println s!"{command}" match command with
| "dissect" => dissect args
| _ => IO.eprintln s!"Unknown command {command}"