Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
r28765@phanatique: nelhage | 2007-12-21 10:59:10 -0800
add a 'repl' that isn't git-svn-id: svn+ssh://lunatique.mit.edu/data/svn/flnv/trunk@33 e7f7c2cb-1e20-0410-8c26-a6ba679ee1f5
- Loading branch information
nelhage
committed
Jul 25, 2008
1 parent
553abfb
commit 3198820
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import FLNV.Expression | ||
import FLNV.Parser | ||
import FLNV.AST | ||
import FLNV.Error | ||
import System.IO | ||
import System.Exit | ||
|
||
runParser :: String -> IO Expression | ||
runParser str = case (readExpr str :: Either Error Expression) of | ||
Right expr -> return expr | ||
Left err -> do putStrLn (show err) | ||
exitWith $ ExitFailure 1 | ||
|
||
doDesugar :: Expression -> IO AST | ||
doDesugar exp = do case (runDesugar $ desugar exp) of | ||
(Left err) -> do putStrLn (show err) | ||
exitWith $ ExitFailure 2 | ||
(Right ast) -> return ast | ||
|
||
main :: IO () | ||
main = do prog <- getContents | ||
expr <- runParser prog | ||
ast <- doDesugar expr | ||
putStrLn $ show ast | ||
exitWith ExitSuccess |