summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorCamil Staps2018-02-07 17:38:48 +0100
committerCamil Staps2018-02-07 17:38:48 +0100
commita58bf7e338b2ed7a42c1d33d7854eb59550a2ee8 (patch)
tree35b03c64ce5c7e94f97703e5d4bb68ced0151083 /src/Main.hs
parentCorrectly parsing the example (diff)
Integrate pretty printer
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 71734c4..15a97fa 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -8,15 +8,15 @@ 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"
- putStrLn $ (show . lex') contents
- putStrLn $ (show . result) contents
- where
- lex' :: String -> Maybe [Token]
- lex' = lex
-
- result :: String -> Maybe (Either ParseError Program)
- result c = parse <$> lex c
+ 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