Pantograph/Pantograph/Serial.lean

24 lines
541 B
Plaintext
Raw Normal View History

2023-05-21 17:41:39 -07:00
import Lean
/-
Expression IO
-/
namespace Pantograph.Serial
/-- Read a theorem from the environment -/
def expr_from_const (env: Lean.Environment) (name: Lean.Name): Except String Lean.Expr :=
match env.find? name with
| none => throw s!"Symbol not found: {name}"
| some cInfo => return cInfo.type
def syntax_from_str (env: Lean.Environment) (s: String): Except String Lean.Syntax :=
Lean.Parser.runParserCategory
(env := env)
(catName := `term)
(input := s)
(fileName := "<stdin>")
end Pantograph.Serial