For the complete documentation index, see llms.txt. This page is also available as Markdown.

Ampliphi

Ampliphi is a high-level, imperative programming language designed to compile down to the Varphi architecture.

Ampliphi was originally developed by Hassan El-Sheikha, Kevin Thevara, and Youssef Abouzied as part of a compilers course at the University of Toronto. It provides a familiar C-like syntax with strong static typing, arrays, and procedures. It attempts to abstract away the complexities of writing raw Varphi assembly while utilizing an advanced compiler optimization pipeline to produce more efficient Varphi code.


Quick Look

Ampliphi programs consist of global variable declarations followed by procedures. The entry point of every program is the main procedure.

Because Ampliphi compiles directly to Varphi, each declared variable maps directly to a tape in the generated Varphi code. When running your program via the Ampliphi CLI, you will be automatically prompted to initialize the values of these variables/tapes before the program executes.

Here is a simple program that calculates the sum of an array:

// Global declarations
int[5] arr;
int sum;
int i;
bool cond;

// Entry point
procedure main {
    sum = 0;
    i = 0;
    
    // Note: Control flow conditions must be evaluated into a boolean variable first!
    cond = i < 5;
    
    while (cond) {
        sum = sum + arr[i];
        i = i + 1;
        
        // Re-evaluate condition for the next iteration
        cond = i < 5;
    }
}

Getting Started

Installation

You can install the Ampliphi toolchain directly via PyPI using uv or pip:

Alternatively, you can download the standalone executable for your operating system (Windows, macOS, or Linux) from our GitHub Releases.

Usage

To compile and run an Ampliphi source file, simply use the CLI:

If you use the --run flag, the CLI will interactively ask you to provide initial values for your global variables (tapes) before executing the compiled Varphi.

You can also inspect the compilation pipeline by emitting the AST, IR, or Tokens:


Language Guide

Variables and Types

All variables in Ampliphi are global and must be declared at the top of the file before any procedures. Ampliphi supports two primitive types: int and bool, as well as fixed-size arrays.

In the compiled Varphi output for the snippet above, x and flag will each become a standard tape, while arr will consist of 10 array tapes.

Procedures

Code is organized into procedures. A program must contain at least one procedure named main. Procedures can invoke other procedures using the invoke keyword.

Control Flow

Ampliphi supports if/else and while statements.

The condition for an if or while statement cannot be an inline expression (like x < 5). It must be a boolean identifier. You must evaluate your condition into a boolean variable first.


Formal Grammar

Ampliphi follows a strict, easy-to-parse grammar. Below is the formal EBNF specification:

Last updated

Was this helpful?