Update Readme

pull/25/head
Ethan Reece 2023-09-30 03:57:03 -05:00
parent e7083c1c40
commit 01ff098530
Signed by: me
GPG Key ID: D3993665FF92E1C3
7 changed files with 16 additions and 14 deletions

View File

@ -1,6 +1,8 @@
# Really Bad Compiler in Haskell
A compiler written in Haskell which can currently perform basic arithmetic. Currently using the megaparsec and llvm-hs-\* libraries, but I may reimplement certain libraries myself. Built for the Introduction to Compiler Design class at The University of Texas at Dallas.
A compiler for Hear, a language for when you cannot C.
Written in Haskell, and currently using the megaparsec and llvm-hs-\* libraries, but I plan to eventually rewrite the lexar/parser from scratch. Built for the Introduction to Compiler Design class at The University of Texas at Dallas.
Main repo: https://git.sudoer.ch/me/really-bad-compiler-in-haskell
@ -12,7 +14,7 @@ Main repo: https://git.sudoer.ch/me/really-bad-compiler-in-haskell
## Run Instructions
- Use `stack run <file>` to run the program (for example, `stack run example/1`).
- Use `stack run <file>` to run the program (for example, `stack run example/1.hear`).
- The LLVM will be generated as `a.out.ll`, and the executable will be generated as `a.out`.
## To edit

View File

@ -7,9 +7,9 @@ module Main (main) where
import Data.ByteString.Char8 qualified as B
import Data.Text.Lazy.IO qualified as T
import Forth.LLVMGen
import Forth.Parser
import Forth.Types.Expr
import Main.LLVMGen
import Main.Parser.Megaparsec
import Main.Types.Expr
import System.Environment
import System.Process

View File

@ -4,10 +4,9 @@
-- see https://gh.sudoer.ch/danieljharvey/mimsa/blob/trunk/llvm-calc/src/Calc/Compile/ToLLVM.hs
module Forth.LLVMGen (llvmGen) where
module Main.LLVMGen (llvmGen) where
import Data.ByteString (ByteString)
import Forth.Types.Expr as Expr
import LLVM (moduleLLVMAssembly, withModuleFromAST)
import LLVM.AST hiding (function)
import LLVM.AST.Type
@ -16,6 +15,7 @@ import LLVM.IRBuilder.Constant
import LLVM.IRBuilder.Instruction
import LLVM.IRBuilder.Module
import LLVM.IRBuilder.Monad
import Main.Types.Expr as Expr
getLLVM :: Expr -> Module
getLLVM expr =

View File

@ -2,13 +2,13 @@
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedStrings #-}
module Forth.Parser (parseExpr, ParseResult) where
module Main.Parser.Megaparsec (parseExpr, ParseResult) where
import Control.Monad.Combinators.Expr
import Data.Functor.Identity qualified
import Data.Text.Lazy
import Data.Void (Void)
import Forth.Types.Expr
import Main.Types.Expr
import Text.Megaparsec as MP
import Text.Megaparsec.Char as C
import Text.Megaparsec.Char.Lexer as L
@ -41,11 +41,11 @@ table =
binaryOp :: Text -> (a -> a -> a) -> Operator (ParsecT Void Text Data.Functor.Identity.Identity) a
binaryOp name f = InfixL (f <$ symbolParser name)
-- prefixOp :: Text -> (a -> a) -> Operator (ParsecT Void Text Data.Functor.Identity.Identity) a
-- prefixOp name f = Prefix (f <$ symbolParser name)
prefixOp :: Text -> (a -> a) -> Operator (ParsecT Void Text Data.Functor.Identity.Identity) a
prefixOp name f = Prefix (f <$ symbolParser name)
-- postfixOp :: Text -> (a -> a) -> Operator (ParsecT Void Text Data.Functor.Identity.Identity) a
-- postfixOp name f = Postfix (f <$ symbolParser name)
postfixOp :: Text -> (a -> a) -> Operator (ParsecT Void Text Data.Functor.Identity.Identity) a
postfixOp name f = Postfix (f <$ symbolParser name)
expr :: Parser Expr
expr = makeExprParser term table

View File

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