Holy C Compiler
A cross-platform HolyC compiler written in pure C that allows HolyC programs to be compiled on Linux, macOS, and Windows without requiring TempleOS.
HCC takes HolyC source code (files ending in .hc) and compiles them into portable C23 code. You can then use any standard C compiler (clang, gcc, etc.) to turn that C code into an executable.
Compilation Pipeline:
input.hc → [HCC] → output.c → [clang/gcc] → executable
- Lexer - Reads your HolyC code character-by-character and breaks it into tokens (keywords, operators, variables, etc.)
- Parser - Takes those tokens and builds a tree structure representing your program
- Semantic Analysis - Checks that your code makes sense (variables are declared, types match, etc.)
- IR Generation - Converts your program into an intermediate representation
- C Code Generator - Translates everything into equivalent C23 code
- C Compiler - Standard compilers like clang/gcc turn that C into a runnable program
make
./build/hcc input.hc output.c
gcc -o input output.c
./programInput (HolyC):
U0 Main()
{
I64 x = 42;
I64 y = x + 8;
}Output (Generated C23):
#include <stdint.h>
#include <stdio.h>
void Main() {
int64_t x = 42;
int64_t y = (x + 8);
}- Basic types (I8, I16, I32, I64, U8, U16, U32, U64, F32, F64, U0)
- Variable declarations and assignments
- Function declarations and calls
- Arithmetic and logical operators
- Control flow (if/else, while, for)
- Comments (// and /* */)
- Structs and enums
- Pointers and arrays (parsing exists, code generation incomplete)
- Strings with proper semantics
- TempleOS compatibility layer
- Optimization passes
- Many HolyC-specific features