2022-04-27 14:04:03 -04:00
|
|
|
|
module Main
|
2021-07-07 07:11:39 -04:00
|
|
|
|
|
2023-03-31 13:31:29 -04:00
|
|
|
|
import Quox.Syntax
|
|
|
|
|
import Quox.Parser
|
|
|
|
|
import Quox.Definition
|
|
|
|
|
import Quox.Pretty
|
2021-07-20 16:05:19 -04:00
|
|
|
|
|
2023-03-31 13:31:29 -04:00
|
|
|
|
import System
|
|
|
|
|
import Data.IORef
|
|
|
|
|
import Data.SortedSet
|
|
|
|
|
import Control.Eff
|
|
|
|
|
import Text.PrettyPrint.Prettyprinter.Render.Terminal
|
2021-07-20 16:05:19 -04:00
|
|
|
|
|
2023-03-31 13:31:29 -04:00
|
|
|
|
export
|
|
|
|
|
die : Doc HL -> IO a
|
|
|
|
|
die err = do putDoc $ termHL <$> err; exitFailure
|
|
|
|
|
|
|
|
|
|
export
|
|
|
|
|
main : IO ()
|
|
|
|
|
main = do
|
|
|
|
|
seen <- newIORef SortedSet.empty
|
|
|
|
|
defs <- newIORef SortedMap.empty
|
|
|
|
|
for_ (drop 1 !getArgs) $ \file => do
|
|
|
|
|
putStrLn "checking \{file}"
|
|
|
|
|
Right res <- fromParserIO ["."] seen defs $ loadProcessFile file
|
|
|
|
|
| Left err => die $ prettyError True True err
|
|
|
|
|
for_ res $ \(name, def) => do
|
2023-04-03 10:08:10 -04:00
|
|
|
|
putDoc $ map termHL $ nest 2 $
|
2023-04-17 15:43:53 -04:00
|
|
|
|
sep [hsep [hcat [pretty0 True def.qty.fst, dotD,
|
|
|
|
|
hl Free (pretty0 True name)],
|
|
|
|
|
colonD],
|
2023-03-31 13:31:29 -04:00
|
|
|
|
prettyTerm True [<] [<] def.type]
|
|
|
|
|
|
|
|
|
|
-----------------------------------
|
2021-07-20 16:05:19 -04:00
|
|
|
|
|
2022-04-11 08:09:37 -04:00
|
|
|
|
private
|
2022-04-11 15:58:33 -04:00
|
|
|
|
text : PrettyOpts -> List String
|
2022-04-11 08:09:37 -04:00
|
|
|
|
text _ =
|
|
|
|
|
["",
|
|
|
|
|
#" ___ ___ _____ __ __"#,
|
|
|
|
|
#"/ _ `/ // / _ \\ \ /"#,
|
|
|
|
|
#"\_, /\_,_/\___/_\_\"#,
|
|
|
|
|
#" /_/"#,
|
|
|
|
|
""]
|
2022-03-06 19:19:26 -05:00
|
|
|
|
|
2022-04-11 08:09:37 -04:00
|
|
|
|
private
|
2022-04-11 15:58:33 -04:00
|
|
|
|
qtuwu : PrettyOpts -> List String
|
2022-04-11 08:09:37 -04:00
|
|
|
|
qtuwu opts =
|
|
|
|
|
if opts.unicode then
|
|
|
|
|
[#" ___,-´⎠ "#,
|
|
|
|
|
#"(·`──´ ◡ -´⎠"#,
|
2023-02-26 04:58:47 -05:00
|
|
|
|
#" \/\/──´⎞/`──´ "#,
|
|
|
|
|
#" ⎜⎟───,-₎ ⎞ "#,
|
|
|
|
|
#" ⎝⎠ (‾‾) ⎟ "#,
|
2022-04-11 08:09:37 -04:00
|
|
|
|
#" (‾‾‾) ⎟ "#]
|
|
|
|
|
else
|
|
|
|
|
[#" ___,-´/ "#,
|
|
|
|
|
#"(.`--´ u -´/"#,
|
|
|
|
|
#" \/\/--´|/`--´ "#,
|
2023-02-26 04:58:47 -05:00
|
|
|
|
#" ||---,-, \ "#,
|
|
|
|
|
#" `´ (--) | "#,
|
2022-04-11 08:09:37 -04:00
|
|
|
|
#" (---) | "#]
|
|
|
|
|
|
|
|
|
|
private
|
2022-04-11 15:58:33 -04:00
|
|
|
|
join1 : PrettyOpts -> String -> String -> String
|
2022-04-11 08:09:37 -04:00
|
|
|
|
join1 opts l r =
|
|
|
|
|
if opts.color then
|
|
|
|
|
" " <+> show (colored Green l) <+> " " <+> show (colored Magenta r)
|
|
|
|
|
else
|
|
|
|
|
" " <+> l <+> " " <+> r
|
|
|
|
|
|
|
|
|
|
export
|
2022-04-11 15:58:33 -04:00
|
|
|
|
banner : PrettyOpts -> String
|
2022-04-11 08:09:37 -04:00
|
|
|
|
banner opts = unlines $ zipWith (join1 opts) (qtuwu opts) (text opts)
|