2 | import Compiler.Common
4 | import Core.Directory
5 | import Core.InitPrimitives
7 | import Core.UnifyState
8 | import Libraries.Utils.Path
10 | import Idris.REPL.Opts
13 | import TTImp.ProcessDecls
22 | usage = "Usage: yaffle <input file> [--timing]"
24 | processArgs : List String -> Core (Maybe Nat)
25 | processArgs [] = pure Nothing
26 | processArgs ["--timing"] = pure (Just 10)
28 | = coreLift $
do ignore $
putStrLn usage
29 | exitWith (ExitFailure 1)
33 | resolved _ _ = pure ()
36 | yaffleMain : String -> List String -> Core ()
37 | yaffleMain sourceFileName args
38 | = do defs <- initDefs
39 | c <- newRef Ctxt defs
40 | t <- processArgs args
41 | modIdent <- ctxtPathToNS sourceFileName
42 | m <- newRef MD (initMetadata (PhysicalIdrSrc modIdent))
43 | u <- newRef UST initUState
44 | s <- newRef Syn initSyntax
45 | o <- newRef ROpts (defaultOpts (Just sourceFileName) (REPL ErrorLvl) [])
46 | whenJust t $
setLogTimings
48 | case extension sourceFileName of
49 | Just "ttc" => do coreLift_ $
putStrLn "Processing as TTC"
50 | ignore $
readFromTTC {extra = ()} True emptyFC True sourceFileName (nsAsModuleIdent emptyNS) emptyNS
51 | coreLift_ $
putStrLn "Read TTC"
52 | _ => do coreLift_ $
putStrLn "Processing as TTImp"
53 | ok <- processTTImpFile sourceFileName
55 | do makeBuildDirectory modIdent
56 | ttcFileName <- getTTCFileName sourceFileName "ttc"
57 | writeToTTC () sourceFileName ttcFileName
58 | coreLift_ $
putStrLn "Written TTC"
59 | repl {c} {u} {s} {o}
63 | = do (_ :: fname :: rest) <- getArgs
64 | | _ => do putStrLn usage
65 | exitWith (ExitFailure 1)
66 | coreRun (yaffleMain fname rest)
67 | (\err : Error => putStrLn ("Uncaught error: " ++ show err))