-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.hs
35 lines (31 loc) · 1.01 KB
/
graph.hs
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
module Main where
import NDGraph(executeByStepEx)
import System.Environment(getArgs,getProgName)
import System.Directory(doesFileExist)
import System.FilePath(takeExtension,takeFileName)
main::IO ()
main = do
args <- getArgs
name <- getProgName
if (length args < 1)
then error ("error: no input file specified!\nusage: " ++ name ++ " filename")
else return ()
filename <- return $ (!!) args 0
exists <- doesFileExist filename
if (not exists)
then error ("error: " ++ takeFileName filename ++": no such file or directory")
else return()
if (takeExtension filename /= ".9")
then error ("error: " ++ takeFileName filename ++": file format not recognized")
else return()
code <- readFile filename
putStrLn (fst (executeByStepEx code))
--import System.Process
--import System.Exit
--import Codec.Picture.Png
--import Data.ByteString.Char8(pack)
--runGraphViz graph = do
-- (exit,out,err) <- readProcessWithExitCode "dot" ["-Tsvg"] graph
-- writeFile "graph.svg" out
-- decodePng (pack out)
-- svgNewFromHandle svg