feat(frontend): Tomogram #220
|
@ -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
|
||||
|
|
|
@ -0,0 +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"
|
||||
match command with
|
||||
| "dissect" => dissect args
|
||||
| _ => IO.eprintln s!"Unknown command {command}"
|
|
@ -10,6 +10,7 @@ lean_lib Pantograph {
|
|||
|
||||
lean_lib Repl {
|
||||
}
|
||||
|
||||
@[default_target]
|
||||
lean_exe repl {
|
||||
root := `Main
|
||||
|
@ -17,6 +18,13 @@ lean_exe repl {
|
|||
supportInterpreter := true
|
||||
}
|
||||
|
||||
@[default_target]
|
||||
lean_exe tomograph {
|
||||
root := `Tomograph
|
||||
-- Solves the native symbol not found problem
|
||||
supportInterpreter := true
|
||||
}
|
||||
|
||||
require LSpec from git
|
||||
"https://github.com/argumentcomputer/LSpec.git" @ "a6652a48b5c67b0d8dd3930fad6390a97d127e8d"
|
||||
lean_lib Test {
|
||||
|
|
Loading…
Reference in New Issue