-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.lhs
More file actions
80 lines (67 loc) · 2.76 KB
/
Copy pathMain.lhs
File metadata and controls
80 lines (67 loc) · 2.76 KB
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
71
72
73
74
75
76
77
78
79
80
\documentclass{article}
%-------------------------------------------------------------------------------
% SETUP
%-------------------------------------------------------------------------------
\usepackage{verbatim}
\newenvironment{code}{\verbatim}{\endverbatim\normalsize}
\usepackage[margin=1in]{geometry}
\newcommand{\tc}[1]{\texttt{#1}}
%-------------------------------------------------------------------------------
\begin{document}
%-------------------------------------------------------------------------------
\begin{center}
\Huge{ATF Main}
\\[0.75cm]
\end{center}
\section{The Main Method}
%///////////////////////////////////////////////
\begin{code}
module Main (main) where
import System.Environment
import Help
import Compile
main :: IO ()
main = do
clargs <- getArgs
case clargs of
-- main commands
"help" : [] -> help "all"
"help" : topic : [] -> help topic
"compile" : [] -> help "compile"
"compile" : fp_trans : fp_srcs -> do
putStrLn $ "-------------------------------------------------------"
putStrLn $ "compiling with:"
putStrLn $ "- translator: " ++ fp_trans
putStrLn $ "- sources: " ++ (list_to_string fp_srcs)
putStrLn $ "-------------------------------------------------------"
putStrLn $ "compilation status:"
compile fp_trans fp_srcs
"logo" : [] -> print_logo
-- other commands
command : _ -> error $ "unrecognized command: " ++ command
[] -> error "use `atf help <topic>` for help"
list_to_string :: [String] -> String
list_to_string ss = case ss of
[] -> ""
(x:[]) -> x
(x:y:xs) -> x ++ ", " ++ y ++ (list_to_string xs)
print_logo :: IO ()
print_logo = foldl (>>) (putStr "") $ map putStrLn
[ ""
, " ┐"
, " ╽ ╽ ╽ ╖"
, " ╓─╼╬───╬───╬───╼═╣"
, " ┐═╢ ╿ ╿ ╿"
, " ╽ ╽ ╽ ╽ ╖"
, " ╠╾──╼╣ ╢ ╠─╼═╣"
, " ╿ ╿ ╿ ╿"
, " ╽ ╽ ╽ ╽"
, " ─╬─ ─╬ ─╬─ ╬─┐"
, " ╿ ╿ ╿ ╿"
, " └"
, "" ]
\end{code}
%\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
%-------------------------------------------------------------------------------
\end{document}
%-------------------------------------------------------------------------------