Introduction to the ACWJ Project
The ACWJ (A Compiler Writing Journey) project is an ambitious venture documented on GitHub, where the author shares their experiences and insights while creating a self-compiling compiler for a subset of the C language. Designed to be a practical exploration rather than a theoretical dissertation, this project provides a step-by-step account, making it accessible for those who wish to join in on the journey. Below is an overview of this engaging and educational project.
Project Overview
The ACWJ project is presented in various sections, each addressing a different aspect of compiler development. Here is a breakdown of the sections covered so far:
-
Part 0: Introduction to the Journey
An overarching introduction that sets the stage for what’s to come in this compiler writing journey. -
Part 1: Introduction to Lexical Scanning
Covers the fundamentals of breaking down source code into tokens through lexical analysis. -
Part 2: Introduction to Parsing
Discusses the process of parsing tokens to understand the syntactic structure of the source code. -
Part 3: Operator Precedence
Examines how different operators are prioritized during parsing. -
Part 4: An Actual Compiler
Presents the basics of building a functioning compiler. -
Parts 5-8: Statements and Control Structures
Explores the concepts of statements, variables, comparison operators,if
statements, andwhile
loops. -
Parts 9-13: Advanced Features
Delves into topics such as for loops, functions, types, and generating ARM assembly code. -
Parts 14-20: Complex Data Types
Covers pointers, global variables, arrays, character and string literals, and more operators. -
Parts 21-30: Designing and Implementing Data Structures
Focuses on the design and implementation of local variables, function calls, arrays, pointers, enums, structs, and unions. -
Parts 31-42: Further Enhancements and Bugfixes
Includes enhancements like constant folding, refinements to local and global variables, type casting, and bug fixes. -
Parts 43-50: Optimization and Refactoring
Discusses optimizations, void functions,sizeof
,static
, ternary operators, and ongoing refactoring efforts. -
Parts 51-64: Future Directions
Expands on new challenges and developments with discussions on lazy evaluation, register spilling, adding new backend targets, and the incorporation of QBE for code generation.
Licensing and Contributions
The ACWJ project acknowledges the work of Nils M Holm for some underlying code ideas, drawn from the SubC compiler, which is public domain. However, the ACWJ implementation is sufficiently unique to warrant a distinct license. The source code and scripts by Warren Toomey fall under the GPL3 license, while all non-source code documents are licensed under Creative Commons BY-NC-SA 4.0.
Conclusion
The ACWJ project is a remarkable resource for anyone interested in the art of compiler construction. By peeling back the layers of complexity in a structured manner, it invites learners, hobbyists, and engineers alike to delve into the inner workings of compiler design. The series remains ongoing, with plans for future installments, inviting curious minds to stay engaged for further insights and updates.