diff options
author | Camil Staps | 2018-02-08 08:44:57 +0100 |
---|---|---|
committer | Camil Staps | 2018-02-08 08:44:57 +0100 |
commit | 62f50c52bd2234e5715474fa2aeb7fd36257d6db (patch) | |
tree | e129311f75e944858b2ce0e4f4140ab23751d13a /src/Main.hs | |
parent | Integrate pretty printer (diff) |
Add example programs; Main.hs using stdin
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs index 15a97fa..07733dd 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -2,6 +2,7 @@ module Main where import Prelude hiding(lex) +import System.Environment import Text.Parsec.Error (ParseError) @@ -12,10 +13,16 @@ import SPL.PrettyPrinter main :: IO () main = do - contents <- readFile "test/example1.spl" + args <- getArgs + contents <- getContents case lex contents of Nothing -> putStrLn "Failed to lex" - Just tks -> case parse tks of + Just tks -> if "--parse" `elem` args + then doParse tks + else return () + where + doParse :: [Token] -> IO () + doParse tks = case parse tks of Left e -> do putStrLn $ "Failed to parse (" ++ show e ++ "). Tokens were:" putStrLn $ show tks |