File tree Expand file tree Collapse file tree 2 files changed +46
-11
lines changed
Expand file tree Collapse file tree 2 files changed +46
-11
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,11 @@ On Linux
1010
1111### Documentation
1212
13- This project is documented under [ DOXYGEN ] ( http ://www.doxygen.nl/ ) Documentation
13+ This project is documented under [ Haddock ] ( https ://www.haskell.org/haddock/#Documentation ) Documentation
1414
1515### Authors
1616
17- * [ ** Vijay Tadikamalla** ] ( https://github.com/vijayphoenix )
18- * [ ** Anjani Kumar** ] ( https://github.com/anjani-1 )
19- * [ ** Anupam Saini** ] ( https://github.com/anupamsaini98 )
20- * [ ** Yogesh Singh** ] ( https://github.com/yo5sh )
17+ * [ ** Vijay Tadikamalla** ] ( https://github.com/vijayphoenix )
2118
2219#### License
2320
Original file line number Diff line number Diff line change 11module Main where
22
3+
4+ import System.Console.Haskeline
5+ import Control.Monad.Except
6+
7+ import qualified LLVM.AST as AST
8+ import Parser
39import Lexer
410
11+ firstModule :: AST. Module
12+ firstModule = AST. defaultModule { AST. moduleName = " First Module" }
13+
514main :: IO ()
6- main = do
7- str <- getLine
8- putStrLn (" Input:" ++ str)
9- print $ parse ident " File1" str
10- main
11- -- print $ parse ident "File1" str
15+ main = repl
16+
17+ eval :: AST. Module -> String -> IO (Maybe AST. Module )
18+ eval mod source = do
19+ let res = (parse moduleParser " Term" source)
20+ case res of
21+ Left err -> print err >> return Nothing
22+ Right ex -> do
23+ print ex
24+ return $ Just mod
25+
26+ repl :: IO ()
27+ repl = runInputT defaultSettings (loop firstModule)
28+ where
29+ loop mod = do
30+ inputCode <- getInputLine " Haskull> "
31+ case inputCode of
32+ Nothing -> outputStrLn " Exiting Haskull."
33+ Just input -> do
34+ wrappedMod <- liftIO $ eval mod input
35+ case wrappedMod of
36+ Just modn -> loop modn
37+ Nothing -> loop mod
38+ -- Just input -> do
39+ -- let tree = (parse commandParser "Term" input) in
40+ -- loop mod
41+ -- case (parse commandParser "sdf" inputCode) of
42+ -- Left mess -> outputStrLn mess
43+ -- Right out -> outputStrLn out
44+ -- outputStrLn (parse commandParser "sdf" inputCode)
45+ -- repl
46+
47+ liftError :: ExceptT String IO a -> IO a
48+ liftError = runExceptT >=> either fail return
49+
You can’t perform that action at this time.
0 commit comments