blob: 7162a20c10fc8249d3b6874480fd608900a719a5 (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
module Obs.Main
import Data.DPair
import Obs.Abstract
import Obs.Logging
import Obs.NormalForm
import Obs.Parser
import Obs.Syntax
import Obs.Term
import Obs.Typing
import Obs.Universe
import System
import System.File
import Text.PrettyPrint.Prettyprinter.Render.Terminal
%default total
record Options where
constructor MkOptions
file : String
lvl : Level
usage : String -> IO a
usage prog = do
() <- putStrLn "usage: \{prog} <file>"
exitFailure
parseLevel : String -> Maybe Level
parseLevel "0" = Just Error
parseLevel "1" = Just Warn
parseLevel "2" = Just Debug
parseLevel "3" = Just Info
parseLevel "4" = Just Trace
parseLevel "error" = Just Error
parseLevel "warn" = Just Warn
parseLevel "debug" = Just Debug
parseLevel "info" = Just Info
parseLevel "trace" = Just Trace
parseLevel _ = Nothing
parseOptions : List1 String -> IO Options
parseOptions (prog ::: [file, "-v", lvl]) = do
let Just lvl = parseLevel lvl
| Nothing => usage prog
pure $ MkOptions file lvl
parseOptions (prog ::: [file, "-v"]) = pure $ MkOptions file Debug
parseOptions (prog ::: [file]) = pure $ MkOptions file Error
parseOptions (prog ::: _) = usage prog
partial
main' : (input: String) -> Logging AnsiStyle (Exists NormalForm.Context)
main' input = do
defs <- parse input
blk <- abstractBlock defs
(_ ** (ctx, _)) <- checkBlock blk
pure (Evidence _ ctx)
partial
main : IO ()
main = do
(prog :: args) <- getArgs
| _ => usage "obs"
opts <- parseOptions (prog ::: args)
Right input <- readFile opts.file
| Left err => do putStrLn "failed to open file: \{show err}"; exitFailure
ctx <- logToTerminal opts.lvl $ main' input
putStrLn "Everything type checks."
|