Skip to content

Commit 2da39e5

Browse files
committed
Some minor modifications
1 parent 1a478ca commit 2da39e5

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff 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

app/Main.hs

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
11
module 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
39
import Lexer
410

11+
firstModule :: AST.Module
12+
firstModule = AST.defaultModule { AST.moduleName = "First Module" }
13+
514
main :: 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+

0 commit comments

Comments
 (0)