Skip to content

Commit 7bdef3a

Browse files
committed
Codegen for some functions
1 parent 9b66c5a commit 7bdef3a

File tree

4 files changed

+268
-160
lines changed

4 files changed

+268
-160
lines changed

app/Main.hs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Control.Monad.Except
77
import qualified LLVM.AST as AST
88
import Parser
99
import Lexer
10+
import Emit
1011

1112
firstModule :: AST.Module
1213
firstModule = AST.defaultModule { AST.moduleName = "First Module" }
@@ -21,6 +22,7 @@ eval mod source = do
2122
Left err -> print err >> return Nothing
2223
Right ex -> do
2324
print ex
25+
ast <- codegen mod [ex]
2426
return $ Just mod
2527

2628
repl :: IO ()
@@ -35,14 +37,7 @@ repl = runInputT defaultSettings (loop firstModule)
3537
case wrappedMod of
3638
Just modn -> loop modn
3739
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
40+
4641

4742
liftError :: ExceptT String IO a -> IO a
4843
liftError = runExceptT >=> either fail return

src/AST.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ data Op
7878
| Minus
7979
| Mul
8080
| Divide
81-
deriving (Show,Eq,Ord)
81+
deriving (Show, Ord, Eq)
8282

8383
data Type
8484
= IntC

0 commit comments

Comments
 (0)