Ethan Reece c0e77d22cf | ||
---|---|---|
app | ||
example | ||
.gitignore | ||
CHANGELOG.md | ||
README.md | ||
package.yaml | ||
really-bad-compiler-in-haskell.cabal | ||
stack.yaml | ||
stack.yaml.lock |
README.md
Really Bad Compiler in Haskell
A compiler written in Haskell which can currently perform basic arithmetic using the megaparsec and llvm-hs libraries (I do not know what language I am going to compile yet). 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
Build Instructions
- Install
ghcup
(for managing Haskell tools) andnix
(for managing external dependencies). - Clone the repo.
- Use
ghcup
to installstack 2.9.3
,HLS 2.2.0.0
,GHC 9.2.8
, andcabal 3.6.2.0
. - Use
stack run <file>
to run the program (for example,stack run example/1
).
Known bugs
Building
- If llvm_16 is in the nix store, stack will use it for some reason and the build will fail. Currently, you may need to run
nix-store --delete /nix/store/<llvm16devdirectory>
to build it.
File structure
app
- contains the compiler programexample
- contains example programs that can be compiled
Credits
Learning Resources Used
- Introduction to Compiler Design class at The University of Texas at Dallas, taught by Charles Averill
- learnyouahaskell.com (for learning Haskell basics)
- https://akashagrawal.me/2017/01/19/beginners-guide-to-megaparsec.html
- https://markkarpov.com/tutorial/megaparsec.html (for help writing a Haskell equation parser)
- https://www.forth.com/starting-forth/1-forth-stacks-dictionary/ (for learning Forth)
- https://blog.josephmorag.com/posts/mcc0/ (Haskell compiler tutorial with megaparsec, llvm-hs, and nix)
- https://gh.sudoer.ch/llvm-hs/llvm-hs-examples (for help writing an llvm code generator)
Tools
- Language: Haskell
- Haskell tools: GHCup, Stack, Cabal
- Libraries: megaparsec, parser-combinators, text, llvm-hs-pure
- Dependencies: llvm, clang
- IDE: VSCodium
- Git platform: Forgejo
- AI: Phind
- Search: Kagi, Stack Overflow