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