LmCast :: Stay tuned in

A Compiler Writing Journey

Recorded: March 25, 2026, 3 a.m.

Original Summarized

GitHub - DoctorWkt/acwj: A Compiler Writing Journey · GitHub

Skip to content

Navigation Menu

Toggle navigation

Sign in

Appearance settings

PlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub SparkBuild and deploy intelligent appsGitHub ModelsManage and compare promptsMCP RegistryNewIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersView all resourcesOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityAcceleratorGitHub StarsArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricing

Search or jump to...

Search code, repositories, users, issues, pull requests...

Search

Clear

Search syntax tips

Provide feedback


We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

DoctorWkt

/

acwj

Public

Notifications
You must be signed in to change notification settings

Fork
1.2k

Star
12.9k

Code

Issues
22

Pull requests
3

Actions

Projects

Security
0

Insights

Additional navigation options

Code

Issues

Pull requests

Actions

Projects

Security

Insights


DoctorWkt/acwj

 masterBranchesTagsGo to fileCodeOpen more actions menuFolders and filesNameNameLast commit messageLast commit dateLatest commit History240 Commits240 Commits00_Introduction00_Introduction  01_Scanner01_Scanner  02_Parser02_Parser  03_Precedence03_Precedence  04_Assembly04_Assembly  05_Statements05_Statements  06_Variables06_Variables  07_Comparisons07_Comparisons  08_If_Statements08_If_Statements  09_While_Loops09_While_Loops  10_For_Loops10_For_Loops  11_Functions_pt111_Functions_pt1  12_Types_pt112_Types_pt1  13_Functions_pt213_Functions_pt2  14_ARM_Platform14_ARM_Platform  15_Pointers_pt115_Pointers_pt1  16_Global_Vars16_Global_Vars  17_Scaling_Offsets17_Scaling_Offsets  18_Lvalues_Revisited18_Lvalues_Revisited  19_Arrays_pt119_Arrays_pt1  20_Char_Str_Literals20_Char_Str_Literals  21_More_Operators21_More_Operators  22_Design_Locals22_Design_Locals  23_Local_Variables23_Local_Variables  24_Function_Params24_Function_Params  25_Function_Arguments25_Function_Arguments  26_Prototypes26_Prototypes  27_Testing_Errors27_Testing_Errors  28_Runtime_Flags28_Runtime_Flags  29_Refactoring29_Refactoring  30_Design_Composites30_Design_Composites  31_Struct_Declarations31_Struct_Declarations  32_Struct_Access_pt132_Struct_Access_pt1  33_Unions33_Unions  34_Enums_and_Typedefs34_Enums_and_Typedefs  35_Preprocessor35_Preprocessor  36_Break_Continue36_Break_Continue  37_Switch37_Switch  38_Dangling_Else38_Dangling_Else  39_Var_Initialisation_pt139_Var_Initialisation_pt1  40_Var_Initialisation_pt240_Var_Initialisation_pt2  41_Local_Var_Init41_Local_Var_Init  42_Casting42_Casting  43_More_Operators43_More_Operators  44_Fold_Optimisation44_Fold_Optimisation  45_Globals_Again45_Globals_Again  46_Void_Functions46_Void_Functions  47_Sizeof47_Sizeof  48_Static48_Static  49_Ternary49_Ternary  50_Mop_up_pt150_Mop_up_pt1  51_Arrays_pt251_Arrays_pt2  52_Pointers_pt252_Pointers_pt2  53_Mop_up_pt253_Mop_up_pt2  54_Reg_Spills54_Reg_Spills  55_Lazy_Evaluation55_Lazy_Evaluation  56_Local_Arrays56_Local_Arrays  57_Mop_up_pt357_Mop_up_pt3  58_Ptr_Increments58_Ptr_Increments  59_WDIW_pt159_WDIW_pt1  60_TripleTest60_TripleTest  61_What_Next61_What_Next  62_Cleanup62_Cleanup  63_QBE63_QBE  64_6809_Target64_6809_Target  LICENSELICENSE  Readme.mdReadme.md  View all filesRepository files navigationREADMEGPL-3.0 licenseA Compiler Writing Journey
In this Github repository, I'm documenting my journey to write a
self-compiling compiler for a subset of the C language.
I'm also writing out the details so that,
if you want to follow along, there will be an explanation of what
I did, why, and with some references back to the theory of compilers.
But not too much theory, I want this to be a practical journey.
Here are the steps I've taken so far:

Part 0: Introduction to the Journey
Part 1: Introduction to Lexical Scanning
Part 2: Introduction to Parsing
Part 3: Operator Precedence
Part 4: An Actual Compiler
Part 5: Statements
Part 6: Variables
Part 7: Comparison Operators
Part 8: If Statements
Part 9: While Loops
Part 10: For Loops
Part 11: Functions, part 1
Part 12: Types, part 1
Part 13: Functions, part 2
Part 14: Generating ARM Assembly Code
Part 15: Pointers, part 1
Part 16: Declaring Global Variables Properly
Part 17: Better Type Checking and Pointer Offsets
Part 18: Lvalues and Rvalues Revisited
Part 19: Arrays, part 1
Part 20: Character and String Literals
Part 21: More Operators
Part 22: Design Ideas for Local Variables and Function Calls
Part 23: Local Variables
Part 24: Function Parameters
Part 25: Function Calls and Arguments
Part 26: Function Prototypes
Part 27: Regression Testing and a Nice Surprise
Part 28: Adding More Run-time Flags
Part 29: A Bit of Refactoring
Part 30: Designing Structs, Unions and Enums
Part 31: Implementing Structs, Part 1
Part 32: Accessing Members in a Struct
Part 33: Implementing Unions and Member Access
Part 34: Enums and Typedefs
Part 35: The C Pre-Processor
Part 36: break and continue
Part 37: Switch Statements
Part 38: Dangling Else and More
Part 39: Variable Initialisation, part 1
Part 40: Global Variable Initialisation
Part 41: Local Variable Initialisation
Part 42: Type Casting and NULL
Part 43: Bugfixes and More Operators
Part 44: Constant Folding
Part 45: Global Variable Declarations, revisited
Part 46: Void Function Parameters and Scanning Changes
Part 47: A Subset of sizeof
Part 48: A Subset of static
Part 49: The Ternary Operator
Part 50: Mopping Up, part 1
Part 51: Arrays, part 2
Part 52: Pointers, part 2
Part 53: Mopping Up, part 2
Part 54: Spilling Registers
Part 55: Lazy Evaluation
Part 56: Local Arrays
Part 57: Mopping Up, part 3
Part 58: Fixing Pointer Increments/Decrements
Part 59: Why Doesn't It Work, part 1
Part 60: Passing the Triple Test
Part 61: What's Next?
Part 62: Code Cleanup
Part 63: A New Backend using QBE
Part 64: A Backend for the 6809 CPU

I've stopped work on acwj and now I'm writing a new language
called alic from scratch. Check it out!
Copyrights
I have borrowed some of the code, and lots of ideas, from the
SubC compiler written by Nils M Holm.
His code is in the public domain. I think that my code is substantially
different enough that I can apply a different license to my code.
Unless otherwise noted,

all source code and scripts are (c) Warren Toomey under
the GPL3 license.
all non-source code documents (e.g. English documents,
image files) are (c) Warren Toomey under the Creative
Commons BY-NC-SA 4.0 license.

About

A Compiler Writing Journey

Topics

c

parsing

compiler

lexical-analysis

Resources

Readme

License

GPL-3.0 license

Uh oh!

There was an error while loading. Please reload this page.


Activity
Stars

12.9k
stars
Watchers

225
watching
Forks

1.2k
forks

Report repository

Releases
No releases published

Packages
0

 

 

 

Uh oh!

There was an error while loading. Please reload this page.


Uh oh!

There was an error while loading. Please reload this page.


Contributors

Uh oh!

There was an error while loading. Please reload this page.


Languages

C
97.2%

Shell
1.9%

Other
0.9%

Footer

© 2026 GitHub, Inc.

Footer navigation

Terms

Privacy

Security

Status

Community

Docs

Contact

Manage cookies

Do not share my personal information

You can’t perform that action at this time.

Warren Toomey’s “acwj” GitHub repository documents a comprehensive, self-compiling compiler project, meticulously developed with a focus on practical learning and a detailed understanding of compiler construction. The project’s progression, outlined through 64 parts, demonstrates a systematic approach to building a compiler for a subset of the C language. It begins with foundational elements such as lexical scanning and parsing, progressing through operator precedence, statement structures, variable declarations, and type systems, eventually culminating in ARM assembly code generation. A significant portion of the work focuses on addressing challenges related to memory management, pointer manipulation, and optimization techniques like constant folding and lazy evaluation.

The repository’s structure emphasizes a pragmatic approach, incorporating refactoring efforts and a gradual refinement of the compiler’s capabilities. Toomey invests in regression testing and introduces runtime flags to improve predictability and debuggability. The compiler’s evolution is notably marked by the incorporation of complex data types, including structs, unions, and enums, alongside their respective access mechanisms. Furthermore, the documentation delves deeper into areas such as the C preprocessor, control flow statements (switch, break, continue), casting, and variable initialization.

Importantly, the project’s development acknowledges the influence of Nils M Holm’s “SubC” compiler, utilizing borrowed code under the public domain license. Toomey strategically applies a different license – the GPL-3.0 – to his own code, reflecting his intent to maintain a distinct codebase with its own educational and collaborative goals. The repository’s documentation not only details the core compiler logic but also includes elements like "What's Next?" and "Code Cleanup," indicative of a continuous refinement and expansion of the project. A notable addition towards the end showcases the integration of a QBE backend for the 6809 CPU, demonstrating a shift toward a more versatile and optimized architecture. The project’s organization and meticulous documentation serve as a valuable resource for aspiring compiler designers and anyone seeking a deep dive into the intricacies of compiler construction.