forked from leanprover/lean4export
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.lean
33 lines (27 loc) · 1.1 KB
/
Main.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import Lean2Agda
import Lean.Util.Path
import Lean.Environment
structure Options extends Config where
imports: List String := []
constants: List String := []
def parseOptions (o: Options) (args: List String): Options :=
match args with
| "--erase-lambda-types" :: rest =>
parseOptions { o with eraseLambdaTypes := true } rest
| "--omit-implicits" :: rest =>
parseOptions { o with omitImplicits := true } rest
| _ =>
let (imports, constants) := args.span (· != "--")
{ o with imports, constants }
open Lean in
def main (args : List String) : IO Unit := do
initSearchPath (← findSysroot)
let options := parseOptions {} args
let imports := options.imports.toArray.map fun mod => { module := Syntax.decodeNameLit ("`" ++ mod) |>.get! }
let env ← importModules imports {}
let constants := match options.constants.tail? with
| some cs => cs.map fun c => Syntax.decodeNameLit ("`" ++ c) |>.get!
| none => env.constants.toList.map Prod.fst |>.filter (!·.isInternal)
TranslateM.run options.toConfig env do
for c in constants do
let _ ← translateConstantVariants c