Skip to content

A new version of the phoenix language compiler. This time everything gets compiled into machine code with the help of the LLVM Project.

Notifications You must be signed in to change notification settings

TomtheCoder2/phoenix_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phoenix Language

🔥 A modern, statically-typed programming language with LLVM-powered compilation

Overview

Phoenix is a programming language designed for clarity, performance, and ease of use. It compiles directly to optimized machine code using LLVM, combining the speed of low-level languages with a clean, modern syntax.

Example Code

fun fibonacci(n: int) : int {
    if (n <= 1) {
        return n;
    }
    return fibonacci(n - 1) + fibonacci(n - 2);
}

fun main() {
    println("Hello from Phoenix!");

    // Vector operations
    var numbers: vec<int> = [1, 2, 3];
    push(numbers, 4);
    numbers[0] = 10;

    println("The 10th Fibonacci number is:");
    println(fibonacci(10));

    // Control flow
    for (var i = 0; i < 5; i++) {
        if (i > 2) {
            println("Bigger than 2");
        } else {
            println("Smaller than or equal to 2");
        }
    }
}

main();

Key Features

  • Strong Static Typing: Catch errors at compile time
  • First-class Functions: Functions as values
  • Vector Support: Built-in arrays with dynamic operations
  • Rich Control Flow: If/else, while loops, for loops
  • Multiple Data Types: Integer, float, boolean, string
  • LLVM Optimization: Compiled to efficient machine code
  • Precise Error Reporting: Error messages with file and line information

Getting Started

# Build the compiler
cargo build -p phoenix_runtime -r
cargo build -r

# Compile a Phoenix file
./target/release/compiler --input program.px

# Run the compiled program
./output/output

(Currently only tested on mac)

Project Status

Phoenix is under active development. Recent additions include:

  • Vector support with push and indexing
  • Span-based error reporting
  • Return statements
  • Multiple print function variants

Roadmap

  • String as a first-class type
  • Multi-file support
  • Structs and classes
  • Logical operators (&& and ||)
    • a && b: If a evaluates to false, b is not evaluated, and the result is false.
    • a || b: If a evaluates to true, b is not evaluated, and the result is true.
  • Functions as variables
  • Package management
  • REPL

Built with ❤️ and Rust

About

A new version of the phoenix language compiler. This time everything gets compiled into machine code with the help of the LLVM Project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages