diff options
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 16 |
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 |