summaryrefslogtreecommitdiff
path: root/src/Main.hs
blob: 15a97fa9503b5bd99f8a2148e2232ca767d624cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- vim: et ts=2 sw=2 ai:
module Main where

import Prelude hiding(lex)

import Text.Parsec.Error (ParseError)

import SPL.Syntax
import SPL.Lex
import SPL.Parse
import SPL.PrettyPrinter

main :: IO ()
main = do
  contents <- readFile "test/example1.spl"
  case lex contents of
    Nothing  -> putStrLn "Failed to lex"
    Just tks -> case parse tks of
      Left e -> do
        putStrLn $ "Failed to parse (" ++ show e ++ "). Tokens were:"
        putStrLn $ show tks
      Right pgm -> putStrLn $ prettyPrint pgm