-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.gr
41 lines (34 loc) · 1016 Bytes
/
Main.gr
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
import File
import GrParsec
data Entry = Entry
String -- id
String -- type signature
String -- documentation
-- Conver a list of characters into a primitive string
toString : List Char -> String
toString Empty = "";
toString (Next x xs) = stringCons x (toString xs)
-- Parsers any sequence into a string
str : Parser String
str = (many [mkMoveable anyChar])
`andThen` [\xs -> return (toString xs)]
-- Parse Granule comments
comment : Parser String
comment =
(char ['-'])
`andThen` [\c -> let () = drop @Char c in (char ['-'])
`andThen` [\c -> let () = drop @Char c in str]]
parse : String -> List Entry
parse = parse
entriesToHTML : List Entry -> String
entriesToHTML = entriesToHTML
-- Entry point
main : () <{Stdin, Open, IOExcept, Read, Write, Close}>
main =
let
fileName <- fromStdin;
[fileName] <- pure (moveString fileName);
fileData <- readFile fileName;
entries <- pure (parse fileData)
in
writeFile (fileName `stringAppend` ".html") (entriesToHTML entries)