GitXplorerGitXplorer
f

compiler

public
35 stars
4 forks
0 issues

Commits

List of commits on branch master.
Unverified
700f5d2956d2024764f4677fc733e9e7bef70167

Fix a couple more Linux build and execution issues

ffiniteloop committed 4 years ago
Unverified
c6fd7441be40ef1c2503f8f647f6a41290a1e3e8

Fix missing header on Linux

ffiniteloop committed 4 years ago
Verified
2bf1114d136daa3b3a602aa1ac681999f0d4568b

Document `ir` command

ffiniteloop committed 4 years ago
Unverified
b9b8c56c5fc8b49bd8caa79e034e310d2aadd97f

Remove obsolete references to toy language

ffiniteloop committed 4 years ago
Unverified
23cb9cbca34135822fcb79d3b94616e23c94df6f

Update to support UTF-8 properly in the scanner and use a modern version of Bison

ffiniteloop committed 4 years ago
Unverified
a95f2bcd15b4d8a427183ea0931fbcf834d14bf9

Initial commit of compiler scaffolding

ffiniteloop committed 4 years ago

README

The README file for this repository.

Generic Compiler Scaffolding

This repository is the scaffolding for an end-to-end compiler. It is a useful starting point when developing a new language — taking care of the workflow and wiring typical in most of my personal programming language projects.

To build, check out the repository and execute the following commands:

$ git submodule init
$ git submodule update
$ cmake -H. -Bbuild
$ cmake --build build --target compiler
$ ./build/compiler

We include LLVM as a submodule.

Features and Dependencies

The compiler is split into four primary directories representing the logical parts of the compiler workflow:

  1. parser/ - A parser based on Bison and Flex.
  2. checker/ - Placeholder module to check the program for semantic correctness.
  3. emitter/ - Backend code generation to LLVM IR.
  4. commands/ - A lightweight framework for supporting different compiler commands. Out of the box, the compiler supports the following commands:
    • compiler run - Execute a program using just-in-time compilation
    • compiler build - Generates a binary (optionally cross-compiling for different architectures)
    • compiler check - Checks a program for semantic correctness
    • compiler parse - Checks a program for syntactic correctness
    • compiler ir - Emits the LLVM IR code for a program

Starting Point

The project builds a compiler for a minimal languge that prints the results of simple integer expressions, e.g.,

1 * 3 + (12 % 5)
(2 << 3) / 2

prints

5
8

Author

This scaffolding is used exclusively for personal projects by Bret Taylor (btaylor@gmail.com).