diff --git a/language.cabal b/language.cabal index caf05d9..7a9c2f8 100644 --- a/language.cabal +++ b/language.cabal @@ -32,6 +32,7 @@ executable language Grammar.Skel Compiler.Compiler Compiler.StandardLLVMLibrary + Compiler.TH Interpreter hs-source-dirs: src @@ -42,5 +43,6 @@ executable language , containers , either , array + , template-haskell default-language: GHC2021 diff --git a/src/Compiler/StandardLLVMLibrary.hs b/src/Compiler/StandardLLVMLibrary.hs index 4672f5c..1b8c2da 100644 --- a/src/Compiler/StandardLLVMLibrary.hs +++ b/src/Compiler/StandardLLVMLibrary.hs @@ -1,6 +1,10 @@ +{-# LANGUAGE TemplateHaskell #-} module Compiler.StandardLLVMLibrary where +import Control.Monad +import Language.Haskell.TH +import Compiler.TH + +-- $(genCurries 8) standardLLVMLibrary :: String -standardLLVMLibrary = " - -" \ No newline at end of file +standardLLVMLibrary = $(includeStr "src/Compiler/standard_library.ll") diff --git a/src/Compiler/TH.hs b/src/Compiler/TH.hs new file mode 100644 index 0000000..497cbc7 --- /dev/null +++ b/src/Compiler/TH.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TemplateHaskell #-} +module Compiler.TH where +import Control.Monad +import Language.Haskell.TH +import System.IO.Unsafe(unsafePerformIO) + +includeStr :: String -> Q Exp +includeStr file = do + let res = unsafePerformIO $ readFile file + [|res|] \ No newline at end of file diff --git a/test/standard_library.ll b/src/Compiler/standard_library.ll similarity index 100% rename from test/standard_library.ll rename to src/Compiler/standard_library.ll