fix: repl build failure
This commit is contained in:
parent
fe8b259e4f
commit
bec84f857b
15
Main.lean
15
Main.lean
|
@ -1,16 +1,15 @@
|
||||||
import Lean.Data.Json
|
import Lean.Data.Json
|
||||||
import Lean.Environment
|
import Lean.Environment
|
||||||
|
|
||||||
import Pantograph.Version
|
|
||||||
import Pantograph.Library
|
|
||||||
import Pantograph
|
import Pantograph
|
||||||
import Repl
|
import Repl
|
||||||
|
|
||||||
-- Main IO functions
|
-- Main IO functions
|
||||||
open Pantograph.Repl
|
open Pantograph.Repl
|
||||||
|
open Pantograph.Protocol
|
||||||
|
|
||||||
/-- Parse a command either in `{ "cmd": ..., "payload": ... }` form or `cmd { ... }` form. -/
|
/-- Parse a command either in `{ "cmd": ..., "payload": ... }` form or `cmd { ... }` form. -/
|
||||||
def parseCommand (s: String): Except String Protocol.Command := do
|
def parseCommand (s: String): Except String Command := do
|
||||||
let s := s.trim
|
let s := s.trim
|
||||||
match s.get? 0 with
|
match s.get? 0 with
|
||||||
| .some '{' => -- Parse in Json mode
|
| .some '{' => -- Parse in Json mode
|
||||||
|
@ -30,7 +29,7 @@ partial def loop : MainM Unit := do
|
||||||
if command.trim.length = 0 then return ()
|
if command.trim.length = 0 then return ()
|
||||||
match parseCommand command with
|
match parseCommand command with
|
||||||
| .error error =>
|
| .error error =>
|
||||||
let error := Lean.toJson ({ error := "command", desc := error }: Protocol.InteractionError)
|
let error := Lean.toJson ({ error := "command", desc := error }: InteractionError)
|
||||||
-- Using `Lean.Json.compress` here to prevent newline
|
-- Using `Lean.Json.compress` here to prevent newline
|
||||||
IO.println error.compress
|
IO.println error.compress
|
||||||
| .ok command =>
|
| .ok command =>
|
||||||
|
@ -46,15 +45,15 @@ unsafe def main (args: List String): IO Unit := do
|
||||||
-- NOTE: A more sophisticated scheme of command line argument handling is needed.
|
-- NOTE: A more sophisticated scheme of command line argument handling is needed.
|
||||||
-- Separate imports and options
|
-- Separate imports and options
|
||||||
if args == ["--version"] then do
|
if args == ["--version"] then do
|
||||||
println! s!"{version}"
|
println! s!"{Pantograph.version}"
|
||||||
return
|
return
|
||||||
|
|
||||||
initSearch ""
|
Pantograph.initSearch ""
|
||||||
|
|
||||||
let coreContext ← args.filterMap (λ s => if s.startsWith "--" then .some <| s.drop 2 else .none)
|
let coreContext ← args.filterMap (λ s => if s.startsWith "--" then .some <| s.drop 2 else .none)
|
||||||
|>.toArray |> createCoreContext
|
|>.toArray |> Pantograph.createCoreContext
|
||||||
let imports:= args.filter (λ s => ¬ (s.startsWith "--"))
|
let imports:= args.filter (λ s => ¬ (s.startsWith "--"))
|
||||||
let coreState ← createCoreState imports.toArray
|
let coreState ← Pantograph.createCoreState imports.toArray
|
||||||
let context: Context := {
|
let context: Context := {
|
||||||
imports
|
imports
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue