Reorganize program
parent
5f1b5ce65c
commit
7f588ec561
|
@ -19,7 +19,7 @@ ghc-options: -threaded -Wall -j8 +RTS -A64M -RTS -fllvm
|
||||||
# source-dirs: src
|
# source-dirs: src
|
||||||
|
|
||||||
executable:
|
executable:
|
||||||
source-dirs: main
|
source-dirs: src
|
||||||
main: Main.hs
|
main: Main.hs
|
||||||
# tests:
|
# tests:
|
||||||
# testall:
|
# testall:
|
||||||
|
|
|
@ -16,12 +16,12 @@ tested-with:
|
||||||
executable really-bad-compiler-in-haskell
|
executable really-bad-compiler-in-haskell
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
other-modules:
|
other-modules:
|
||||||
Compiler.LLVMGen
|
Forth.LLVMGen
|
||||||
Parser.Expr
|
Forth.Parser
|
||||||
Types.Expr
|
Forth.Types.Expr
|
||||||
Paths_really_bad_compiler_in_haskell
|
Paths_really_bad_compiler_in_haskell
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
main
|
src
|
||||||
default-extensions:
|
default-extensions:
|
||||||
OverloadedStrings, LambdaCase
|
OverloadedStrings, LambdaCase
|
||||||
ghc-options: -threaded -Wall -j8 +RTS -A64M -RTS -fllvm
|
ghc-options: -threaded -Wall -j8 +RTS -A64M -RTS -fllvm
|
||||||
|
|
|
@ -4,13 +4,11 @@
|
||||||
|
|
||||||
-- see https://gh.sudoer.ch/danieljharvey/mimsa/blob/trunk/llvm-calc/src/Calc/Compile/ToLLVM.hs
|
-- see https://gh.sudoer.ch/danieljharvey/mimsa/blob/trunk/llvm-calc/src/Calc/Compile/ToLLVM.hs
|
||||||
|
|
||||||
module Compiler.LLVMGen (llvmGen) where
|
module Forth.LLVMGen (llvmGen) where
|
||||||
|
|
||||||
-- import LLVM.Pretty
|
|
||||||
|
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Debug.Trace
|
import Forth.Types.Expr as Expr
|
||||||
import LLVM (moduleLLVMAssembly, withModuleFromAST, writeLLVMAssemblyToFile)
|
import LLVM (moduleLLVMAssembly, withModuleFromAST)
|
||||||
import LLVM.AST hiding (function)
|
import LLVM.AST hiding (function)
|
||||||
import LLVM.AST.Type
|
import LLVM.AST.Type
|
||||||
import LLVM.Context
|
import LLVM.Context
|
||||||
|
@ -18,7 +16,6 @@ import LLVM.IRBuilder.Constant
|
||||||
import LLVM.IRBuilder.Instruction
|
import LLVM.IRBuilder.Instruction
|
||||||
import LLVM.IRBuilder.Module
|
import LLVM.IRBuilder.Module
|
||||||
import LLVM.IRBuilder.Monad
|
import LLVM.IRBuilder.Monad
|
||||||
import Types.Expr as Expr
|
|
||||||
|
|
||||||
getLLVM :: Expr -> Module
|
getLLVM :: Expr -> Module
|
||||||
getLLVM expr =
|
getLLVM expr =
|
|
@ -1,15 +1,15 @@
|
||||||
-- see https://markkarpov.com/tutorial/megaparsec.html
|
-- see https://markkarpov.com/tutorial/megaparsec.html
|
||||||
{-# LANGUAGE ImportQualifiedPost #-}
|
{-# LANGUAGE ImportQualifiedPost #-}
|
||||||
|
|
||||||
module Parser.Expr (parseExpr, ParseResult) where
|
module Forth.Parser (parseExpr, ParseResult) where
|
||||||
|
|
||||||
import Control.Monad.Combinators.Expr
|
import Control.Monad.Combinators.Expr
|
||||||
import Data.Functor.Identity qualified
|
import Data.Functor.Identity qualified
|
||||||
import Data.Void (Void)
|
import Data.Void (Void)
|
||||||
|
import Forth.Types.Expr
|
||||||
import Text.Megaparsec as MP
|
import Text.Megaparsec as MP
|
||||||
import Text.Megaparsec.Char as C
|
import Text.Megaparsec.Char as C
|
||||||
import Text.Megaparsec.Char.Lexer as L
|
import Text.Megaparsec.Char.Lexer as L
|
||||||
import Types.Expr
|
|
||||||
|
|
||||||
type Parser = Parsec Void String
|
type Parser = Parsec Void String
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module Types.Expr (Expr (..)) where
|
module Forth.Types.Expr (Expr (..)) where
|
||||||
|
|
||||||
data Expr
|
data Expr
|
||||||
= Lit Int
|
= Lit Int
|
|
@ -4,13 +4,14 @@
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
-- import Compiler.ExeGen
|
-- import Compiler.ExeGen
|
||||||
import Compiler.LLVMGen
|
|
||||||
import Data.ByteString.Char8 qualified as B
|
import Data.ByteString.Char8 qualified as B
|
||||||
import Data.Text.Lazy.IO qualified as T
|
import Data.Text.Lazy.IO qualified as T
|
||||||
import Parser.Expr
|
import Forth.LLVMGen
|
||||||
|
import Forth.Parser
|
||||||
|
import Forth.Types.Expr
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.Process
|
import System.Process
|
||||||
import Types.Expr
|
|
||||||
|
|
||||||
getRight :: ParseResult -> Expr
|
getRight :: ParseResult -> Expr
|
||||||
getRight (Right r) = r
|
getRight (Right r) = r
|
Reference in New Issue