-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelp.lhs
More file actions
82 lines (68 loc) · 2.66 KB
/
Copy pathHelp.lhs
File metadata and controls
82 lines (68 loc) · 2.66 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
81
82
\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 Help}
\\[0.75cm]
\end{center}
\section{Help with Topics}
%///////////////////////////////////////////////
\begin{code}
module Help (help) where
type HelpTopic = (String, [String])
help_topics :: [HelpTopic]
help_topics =
[ ("compile",
[ "Usage:"
, " $> atf compile T.atf_trans x1.atf_src ... xN.arf_src"
, "Description:"
, " This command transpiles each of xi.atf_src file into a"
, " xi.atf_tgt file, for which both the translated content and file"
, " type (atf_tgt) are specified by T.atf_trans."
, "Details:"
, " T.arg_lang is written in a language-specification format that"
, " is immediately compatible with atf. T, the compiled translator"
, " specification, which is then used to parse and transpile each"
, " xi.atf_src into a corresponding xi.atf_tgt file." ] )
, ("help",
[ "Usage:"
, " $> atf help <topic>"
, "Description:"
, " This command prints a helpful illustration description of the"
, " usage syntax and execution details about the given topic. For"
, " example, I would recommend running `atf help compile`." ] )
, ("all",
[ "ATF Commands:"
, " help <topic>"
, " compile <trans-spec> <source-1> ... <source-N>" ] )
]
print_help_topic :: HelpTopic -> IO ()
print_help_topic (topic, content)
= foldl (>>) (putStr "")
$ map putStrLn
$ ("help for \"" ++ topic ++ "\":\n") : content
extract_help_topic :: String -> Maybe HelpTopic
extract_help_topic topic =
let helper :: [HelpTopic] -> Maybe HelpTopic
helper [] = Nothing
helper (h:hs) = if topic == fst h
then Just h
else helper hs
in helper help_topics
help :: String -> IO ()
help topic = case extract_help_topic topic of
Nothing -> help "all"
Just ht -> print_help_topic ht
\end{code}
%\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
%-------------------------------------------------------------------------------
\end{document}
%-------------------------------------------------------------------------------