packages feed

kaleidoscope (empty) → 0.1.0.0

raw patch · 9 files changed

+410/−0 lines, 9 filesdep +basedep +containersdep +haskelinesetup-changed

Dependencies added: base, containers, haskeline, llvm-general, llvm-general-pure, mtl, parsec, transformers

Files

+ LICENSE-MIT view
@@ -0,0 +1,19 @@+Copyright (c) 2013-2016, Stephen Diehl++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to+deal in the Software without restriction, including without limitation the+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or+sell copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS+IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ kaleidoscope.cabal view
@@ -0,0 +1,115 @@+name:                kaleidoscope+version:             0.1.0.0+synopsis:            Haskell Kaleidoscope tutorial+description:         Port of the Kaleidoscope tutorial for Haskell and LLVM+homepage:            https://github.com/sdiehl/kaleidoscope+license:             MIT+license-file:        LICENSE-MIT+author:              Stephen Diehl+maintainer:          stephen.m.diehl@gmail.com+copyright:           2012 Stephen Diehl+Category:            Compilers+build-type:          Simple+cabal-version:       >=1.10+Bug-Reports:         https://github.com/sdiehl/kaleidoscope/issues++Flag Tutorial+  Description: Compile with pandoc preprocessor+  Default:     False++Source-Repository head+    Type: git+    Location: git@github.com:sdiehl/kaleidoscope.git++executable chapter2+  default-language:    Haskell2010+  main-is:             Main.hs+  build-depends:+      base                 >= 4.6 && <4.10+    , haskeline            >= 0.7.1.2+    , llvm-general         >= 3.5.0.0+    , llvm-general-pure    >= 3.5.0+    , parsec               >= 3.1+    , mtl                  >= 2.1.3+    , transformers         >= 0.3.0.0 && < 0.5+  hs-source-dirs:      src/chapter2++executable chapter3+  default-language:    Haskell2010+  main-is:             Main.hs+  build-depends:+      base                 >= 4.6 && <4.10+    , haskeline            >= 0.7.1.2+    , llvm-general         >= 3.5.0.0+    , llvm-general-pure    >= 3.5.0+    , parsec               >= 3.1+    , mtl                  >= 2.1.3+    , transformers         >= 0.3.0.0 && < 0.5+    , containers           >= 0.4+  hs-source-dirs:      src/chapter3++executable chapter4+  default-language:    Haskell2010+  main-is:             Main.hs+  build-depends:+      base                 >= 4.6 && <4.10+    , haskeline            >= 0.7.1.2+    , llvm-general         >= 3.5.0.0+    , llvm-general-pure    >= 3.5.0+    , parsec               >= 3.1+    , containers           >= 0.4+    , mtl                  >= 2.1.3+    , transformers         >= 0.3.0.0 && < 0.5+  hs-source-dirs:      src/chapter4++executable chapter5+  default-language:    Haskell2010+  main-is:             Main.hs+  build-depends:+      base                 >= 4.6 && <4.10+    , haskeline            >= 0.7.1.2+    , llvm-general         >= 3.5.0.0+    , llvm-general-pure    >= 3.5.0+    , parsec               >= 3.1+    , containers           >= 0.4+    , mtl                  >= 2.1.3+    , transformers         >= 0.3.0.0 && < 0.5+  hs-source-dirs:      src/chapter5++executable chapter6+  default-language:    Haskell2010+  main-is:             Main.hs+  build-depends:+      base                 >= 4.6 && <4.10+    , haskeline            >= 0.7.1.2+    , llvm-general         >= 3.5.0.0+    , llvm-general-pure    >= 3.5.0+    , parsec               >= 3.1+    , containers           >= 0.4+    , mtl                  >= 2.1.3+    , transformers         >= 0.3.0.0 && < 0.5+  hs-source-dirs:      src/chapter6++executable chapter7+  default-language:    Haskell2010+  main-is:             Main.hs+  build-depends:+      base                 >= 4.6 && <4.10+    , haskeline            >= 0.7.1.2+    , llvm-general         >= 3.5.0.0+    , llvm-general-pure    >= 3.5.0+    , parsec               >= 3.1+    , containers           >= 0.4+    , mtl                  >= 2.1.3+    , transformers         >= 0.3.0.0 && < 0.5+  hs-source-dirs:      src/chapter7++library+  default-language:    Haskell2010+  build-depends:+      base                 >= 4.6 && <4.10+    , haskeline            >= 0.7.1.2+    , llvm-general         >= 3.5.0.0+    , llvm-general-pure    >= 3.5.0+    , mtl                  >= 2.1.3+    , transformers         >= 0.3.0.0 && < 0.5
+ src/chapter2/Main.hs view
@@ -0,0 +1,22 @@+module Main where++import Parser++import Control.Monad.Trans+import System.Console.Haskeline++process :: String -> IO ()+process line = do+  let res = parseToplevel line+  case res of+    Left err -> print err+    Right ex -> mapM_ print ex++main :: IO ()+main = runInputT defaultSettings loop+  where+  loop = do+    minput <- getInputLine "ready> "+    case minput of+      Nothing -> outputStrLn "Goodbye."+      Just input -> (liftIO $ process input) >> loop
+ src/chapter3/Main.hs view
@@ -0,0 +1,48 @@+module Main where++import Parser+import Codegen+import Emit++import Control.Monad.Trans++import System.IO+import System.Environment+import System.Console.Haskeline++import qualified LLVM.General.AST as AST++initModule :: AST.Module+initModule = emptyModule "my cool jit"++process :: AST.Module -> String -> IO (Maybe AST.Module)+process modo source = do+  let res = parseToplevel source+  case res of+    Left err -> print err >> return Nothing+    Right ex -> do+      ast <- codegen modo ex+      return $ Just ast++processFile :: String -> IO (Maybe AST.Module)+processFile fname = readFile fname >>= process initModule++repl :: IO ()+repl = runInputT defaultSettings (loop initModule)+  where+  loop mod = do+    minput <- getInputLine "ready> "+    case minput of+      Nothing -> outputStrLn "Goodbye."+      Just input -> do+        modn <- liftIO $ process mod input+        case modn of+          Just modn -> loop modn+          Nothing -> loop mod++main :: IO ()+main = do+  args <- getArgs+  case args of+    []      -> repl+    [fname] -> processFile fname >> return ()
+ src/chapter4/Main.hs view
@@ -0,0 +1,48 @@+module Main where++import Parser+import Codegen+import Emit++import Control.Monad.Trans++import System.IO+import System.Environment+import System.Console.Haskeline++import qualified LLVM.General.AST as AST++initModule :: AST.Module+initModule = emptyModule "my cool jit"++process :: AST.Module -> String -> IO (Maybe AST.Module)+process modo source = do+  let res = parseToplevel source+  case res of+    Left err -> print err >> return Nothing+    Right ex -> do+      ast <- codegen modo ex+      return $ Just ast++processFile :: String -> IO (Maybe AST.Module)+processFile fname = readFile fname >>= process initModule++repl :: IO ()+repl = runInputT defaultSettings (loop initModule)+  where+  loop mod = do+    minput <- getInputLine "ready> "+    case minput of+      Nothing -> outputStrLn "Goodbye."+      Just input -> do+        modn <- liftIO $ process mod input+        case modn of+          Just modn -> loop modn+          Nothing -> loop mod++main :: IO ()+main = do+  args <- getArgs+  case args of+    []      -> repl+    [fname] -> processFile fname >> return ()
+ src/chapter5/Main.hs view
@@ -0,0 +1,48 @@+module Main where++import Parser+import Codegen+import Emit++import Control.Monad.Trans++import System.IO+import System.Environment+import System.Console.Haskeline++import qualified LLVM.General.AST as AST++initModule :: AST.Module+initModule = emptyModule "my cool jit"++process :: AST.Module -> String -> IO (Maybe AST.Module)+process modo source = do+  let res = parseToplevel source+  case res of+    Left err -> print err >> return Nothing+    Right ex -> do+      ast <- codegen modo ex+      return $ Just ast++processFile :: String -> IO (Maybe AST.Module)+processFile fname = readFile fname >>= process initModule++repl :: IO ()+repl = runInputT defaultSettings (loop initModule)+  where+  loop mod = do+    minput <- getInputLine "ready> "+    case minput of+      Nothing -> outputStrLn "Goodbye."+      Just input -> do+        modn <- liftIO $ process mod input+        case modn of+          Just modn -> loop modn+          Nothing -> loop mod++main :: IO ()+main = do+  args <- getArgs+  case args of+    []      -> repl+    [fname] -> processFile fname >> return ()
+ src/chapter6/Main.hs view
@@ -0,0 +1,48 @@+module Main where++import Parser+import Codegen+import Emit++import Control.Monad.Trans++import System.IO+import System.Environment+import System.Console.Haskeline++import qualified LLVM.General.AST as AST++initModule :: AST.Module+initModule = emptyModule "my cool jit"++process :: AST.Module -> String -> IO (Maybe AST.Module)+process modo source = do+  let res = parseToplevel source+  case res of+    Left err -> print err >> return Nothing+    Right ex -> do+      ast <- codegen modo ex+      return $ Just ast++processFile :: String -> IO (Maybe AST.Module)+processFile fname = readFile fname >>= process initModule++repl :: IO ()+repl = runInputT defaultSettings (loop initModule)+  where+  loop mod = do+    minput <- getInputLine "ready> "+    case minput of+      Nothing -> outputStrLn "Goodbye."+      Just input -> do+        modn <- liftIO $ process mod input+        case modn of+          Just modn -> loop modn+          Nothing -> loop mod++main :: IO ()+main = do+  args <- getArgs+  case args of+    []      -> repl+    [fname] -> processFile fname >> return ()
+ src/chapter7/Main.hs view
@@ -0,0 +1,60 @@+--------------------------------------------------------------------+-- |+-- Module    :  Main+-- Copyright :  (c) Stephen Diehl 2013+-- License   :  MIT+-- Maintainer:  stephen.m.diehl@gmail.com+-- Stability :  experimental+-- Portability: non-portable+--+--------------------------------------------------------------------++module Main where++import Parser+import Codegen+import Emit++import Control.Monad.Trans++import System.IO+import System.Environment+import System.Console.Haskeline++import qualified LLVM.General.AST as AST++initModule :: AST.Module+initModule = emptyModule "my cool jit"++process :: AST.Module -> String -> IO (Maybe AST.Module)+process modo source = do+  let res = parseToplevel source+  case res of+    Left err -> print err >> return Nothing+    Right ex -> do+      ast <- codegen modo ex+      return $ Just ast++processFile :: String -> IO (Maybe AST.Module)+processFile fname = readFile fname >>= process initModule++repl :: IO ()+repl = runInputT defaultSettings (loop initModule)+  where+  loop :: AST.Module -> InputT IO ()+  loop mod = do+    minput <- getInputLine "ready> "+    case minput of+      Nothing -> outputStrLn "Goodbye."+      Just input -> do+        modn <- lift $ process mod input+        case modn of+          Just modn -> loop modn+          Nothing -> loop mod++main :: IO ()+main = do+  args <- getArgs+  case args of+    []      -> repl+    [fname] -> processFile fname >> return ()