Reorganize program

archive/forth
Ethan Reece 2023-09-29 18:01:47 -05:00
parent 5f1b5ce65c
commit 7f588ec561
Signed by: me
GPG Key ID: D3993665FF92E1C3
6 changed files with 15 additions and 17 deletions

View File

@ -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:

View File

@ -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

View File

@ -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 =

View File

@ -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

View File

@ -1,4 +1,4 @@
module Types.Expr (Expr (..)) where
module Forth.Types.Expr (Expr (..)) where
data Expr
= Lit Int

View File

@ -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