Skip to content

playfairs/hcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HCC

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.

What It Does

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

How It Works (Simple Terms)

  1. Lexer - Reads your HolyC code character-by-character and breaks it into tokens (keywords, operators, variables, etc.)
  2. Parser - Takes those tokens and builds a tree structure representing your program
  3. Semantic Analysis - Checks that your code makes sense (variables are declared, types match, etc.)
  4. IR Generation - Converts your program into an intermediate representation
  5. C Code Generator - Translates everything into equivalent C23 code
  6. C Compiler - Standard compilers like clang/gcc turn that C into a runnable program

Quick Start

make

./build/hcc input.hc output.c

gcc -o input output.c

./program

Example

Input (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);
}

Currently Supported

  • 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 /* */)

Not Yet Implemented

  • Structs and enums
  • Pointers and arrays (parsing exists, code generation incomplete)
  • Strings with proper semantics
  • TempleOS compatibility layer
  • Optimization passes
  • Many HolyC-specific features

About

Cross-platform Holy-C Compiler allowing for compilation without using TempleOS

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages