Prysma
Documentation / OverviewView source

Prysma Programming Language

Prysma is a system programming language compiled to the LLVM 18 infrastructure. The project focuses on deterministic resource control without a garbage collector, branchless compile-time lookup tables for tokenization, contiguous arena allocation, and parallel multi-file compilation.

Technical Capabilities

  • LLVM Backend: Intermediate Representation (IR) generation targeting LLVM 18 SSA form using opaque pointers.
  • Lexical Analysis: Tokenization powered by compile-time lookup tables (256-byte CharClass LUT) and Little-Endian 64-bit integer comparisons, eliminating dynamic hashing overhead.
  • Memory Management: Manual heap allocation via new and delete operators. AST node allocations backed by contiguous arenas (llvm::BumpPtrAllocator).
  • Multi-file Compilation: Parallel 2-pass compilation pipeline using llvm::ThreadPool, resolving include directives with circular dependency detection.
  • Object Model: Classes with public:, private:, and protected: access specifiers, single inheritance, and dynamic polymorphism via virtual method tables (vtables).
  • Static Analysis: Strict typing system with safe auto-casting, context stacks for lexical scopes, and fail-fast early syntax error detection.

Compiler Architecture

The compiler operates across a modular pipeline:

  1. Frontend: Branchless lexical tokenization (Lexer::tokenize) and recursive descent instruction parsing.
  2. Pass 1 (Analysis & Registration): AST construction and declaration registration via FillingVisitorRegistry and FillingVisitorBodyClass.
  3. Pass 2 (Environments & Emission): Symbol table resolution (BuilderEnvironmentRegistryFunction, BuilderEnvironmentRegistryVariable) and LLVM IR emission via GeneralVisitorGenCode.
  4. Backend: Optimizations and native binary generation by the LLVM infrastructure.

Syntax

fn int32 main() {
    dec string message = "Prysma system operational";
    call print(ref message);
    return 0;
}

Compilation with Docker

The official compilation toolchain (LLVM 18, Clang 18, LLD, CMake, ccache, Python) is encapsulated within a Docker container to ensure reproducible builds.

Docker Installation

Host OS Installation Guide
Arch Linux Arch Linux Guide
Debian Debian Guide
Ubuntu Ubuntu Guide
Windows (PowerShell) Windows Guide

Quick Start

  1. Build the compilation image:

    docker build --target debug -t prysma-debug -f docker/compiler/Dockerfile .
    
  2. Compile the project from the host:

    # Release mode (-O3, -march=native, -flto, lld)
    docker run --rm -v "$(pwd)":/workspace prysma-debug python3 build.py
    
    # Instrumented Debug mode (-g3, -O0, ASan, UBSan)
    docker run --rm -v "$(pwd)":/workspace prysma-debug python3 debug.py
    
  3. Interactive session:

    docker run --rm -it -v "$(pwd)":/workspace prysma-debug
    

The build.py / debug.py script automatically runs internal AST node, visitor, and parser generators before calling CMake and Clang.

VS Code Integration

The provided .vscode configuration interfaces directly with the container:

  • Compilation (Ctrl+Shift+B): Compiles the active .p source file via docker/environnement_dev/linux/docker-cli.sh (or docker/environnement_dev/windows/docker-cli.ps1 on Windows).
  • Debugging (F5): Debugger launch profiles for LLDB (C++ compiler, port 1234) and debugpy (Python generators, port 5678).
  • Clangd Code Intelligence: C++ code navigation and completion on the host without local LLVM dependencies.
  • Syntax Highlighting: Extension in .vscode/SyntaxeCouleurPrysma for .p files.

See the VS Code Environment Guide. For advanced options and benchmarks, see the Docker Compilation Guide.

Documentation

Technical documentation is available in docs/:

License

This project is distributed under the GPL v3 license. Consult the LICENSE file for legal details.

Official Maintainers