No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
src/Language
test
wrapper
.gitignore
.gitlab-ci.yml
LICENSE
Makefile
README.md
nyanpasu.cabal
stack.yaml

README.md

Build Status

nyanpasu

Building a compiler from a simple expression oriented language to x86 by incrementally adding features and using a C wrapper. You might enjoy following through the commit history!

Following cs4410 and cs75 in Haskell.

"Current" Status: Implemented pairs

  • Build with stack
  • Sample code examples
  • Use stack exec nyanpasu -- sample-programs --escape-hard to print sample programs in a way that can be eaten by:
  • make run-program PROGRAM="" <- put your --escaped-hard program here

Example:

➜ make run-program PROGRAM="Program {progDefs = [Fun () \\\"factorial\\\" [\\\"n\\\"] (If () (PrimBinOp () (NumBinOp Eq) (Atom (Num () 0)) (Idn () \\\"n\\\")) (Atom (Num () 1)) (PrimBinOp () (NumBinOp Mul) (Idn () \\\"n\\\") (Call () \\\"factorial\\\" [PrimBinOp () (NumBinOp Sub) (Idn () \\\"n\\\") (Atom (Num () 1))])))], progMain = Call () \\\"factorial\\\" [Atom (Num () 5)]}"
stack build --fast &&\
mkdir -p output &&\
echo "Program {progDefs = [Fun () \"factorial\" [\"n\"] (If () (PrimBinOp () (NumBinOp Eq) (Atom (Num () 0)) (Idn () \"n\")) (Atom (Num () 1)) (PrimBinOp () (NumBinOp Mul) (Idn () \"n\") (Call () \"factorial\" [PrimBinOp () (NumBinOp Sub) (Idn () \"n\") (Atom (Num () 1))])))], progMain = Call () \"factorial\" [Atom (Num () 5)]}" | stack exec nyanpasu -- compile-program > output/code.asm &&\
cp wrapper/main.c output/main.c &&\
nasm -f elf32 -o output/code.o output/code.asm &&\
clang -g -m32 -o output/program output/main.c output/code.o &&\
output/program
[snip]
120

Yeah, it's weird and inconvenient, but it works for now.