diff --git a/Pantograph/Frontend/InfoTree.lean b/Pantograph/Frontend/InfoTree.lean index 6fe9370..cf3f7eb 100644 --- a/Pantograph/Frontend/InfoTree.lean +++ b/Pantograph/Frontend/InfoTree.lean @@ -10,7 +10,7 @@ namespace Lean.Elab private def elaboratorToString : Name → String | .anonymous => "" | 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. -/ protected def Info.stx? : Info → Option Syntax diff --git a/Tomograph.lean b/Tomograph.lean index 0878b36..ca0c21b 100644 --- a/Tomograph.lean +++ b/Tomograph.lean @@ -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 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}"