Skip to content

stage 1: a simple compiler #1

@glaebhoerl

Description

@glaebhoerl
  • Make a Stack project w/ the chosen dependencies
  • Make sure they all resolve & build etc.
  • Figure out what the initial minimal language will be?
  • Make sure LLVM still works w/ the OrcJIT example
  • Figure out what a concrete syntax tree should look like as a Haskell type

  • Write some types?
  • Lex something
  • Parse something
  • Resolve names
  • Typecheck something
  • Translate to an IR (ANF w/ basic blocks & basic block args?)
    • BBs or EBBs? probably BBs for now to simplify translation to LLVM
  • Generate some code
  • Output a binary
  • Make sure it actually runs & works

  • Write tests for everything! http://teh.id.au/posts/2017/06/07/round-trip-property/index.html
    • Write pretty printers
      • AST
      • IR
      • Error messages
    • Write well-formedness validators
    • Write a typechecker for the IR as well
    • Write an evaluator
    • Write fizzbuzz
  • Write a usable CLI
  • Make it JIT
  • Go back and fix the fixable FIXMEs and TODOs
  • Write a README w/ overview

two types: Int, Bool
arithmetic and comparison operators
if, while; forever/break?
let, var
read(), write()
mutation (assignment)
no functions yet

Example program:

 var n = 0
 forever {
     write(n)
     let m = read()
     if m == 0 {
         return
     }
     n = n + m
 }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions