File: glsl-pprint.hs

package info (click to toggle)
haskell-language-glsl 0.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 144 kB
  • sloc: haskell: 1,593; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 607 bytes parent folder | download | duplicates (3)
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
module Main where

import System.Environment (getArgs)
import Text.PrettyPrint.HughesPJClass

import Language.GLSL

info :: [String]
info = 
  [ "This is glsl-pprint."
  ]

usage :: [String]
usage = info ++
  ["usage:\n  glsl-pprint [-p] filename"]

main :: IO ()
main = do
  args <- getArgs
  case args of
    [fn] -> do
      content <- readFile fn
      putStrLn . show . parse $ content
    ["-p", fn] -> do
      content <- readFile fn
      case parse content of
        Left err -> putStrLn $ "parse error:\n" ++ show err
        Right ast -> print . pPrint $ ast
    _ -> putStrLn $ unlines usage