Blaise Pascal™

Think in Pascal. Compile to C++.

Open-source Pascal-to-C++ transpiler with Pascal semantic compatibility. Self-contained distribution with bundled Zig compiler and runtime.

🎩 Why Blaise Pascal?

Named after the 17th-century French polymath Blaise Pascal—mathematician, physicist, and inventor of one of the first mechanical calculators—and the programming language that bears his name. Like its namesakes, Blaise Pascal™ embodies clarity, elegance, and the marriage of theoretical beauty with practical innovation. We honor Pascal's legacy by keeping the Pascal language alive and thriving in the modern age.

🎯

Pascal Dialect

A modern Pascal dialect compatible with Delphi where possible. Transpiles fundamental Pascal syntax with clean, predictable C++ output. Best thought of as its own flavor of Pascal optimized for C++ compilation.

Modern C++23

Generates clean C++23 code with modern LLVM backend. Leverages spaceship operator, std::format, and std::println for optimal performance.

🏗️

Smart Architecture

Dumb transpiler, smart runtime. Simple token mapping keeps the transpiler maintainable while a sophisticated runtime preserves exact Pascal semantics.

📦

Self-Contained

Everything included - Blaise transpiler, Zig compiler, and complete runtime library. Just unzip and go, no additional downloads needed.

🌍

Cross-Platform

Compile for Windows, Linux, and macOS from any platform using bundled Zig build system with consistent behavior everywhere.

🔒

Zero Conflicts

All runtime code in bp namespace with fully-qualified names. Perfect isolation from external libraries like raylib, SDL, OpenGL.

The Architecture

Simple design, powerful results

THE LAW

Wrap everything that can be wrapped in the C++ runtime

Make the transpiler DUMB.
Make the runtime SMART.

All runtime lives in namespace bp { ... }
ALWAYS use fully-qualified names: bp::Integer, bp::WriteLn
NEVER use 'using namespace bp;'

Pascal

.pas files

DelphiAST

Parse

Transpiler

Token map

C++23

Generate

Zig/LLVM

Compile

Binary

Execute

See It In Action

Write Pascal, get optimized C++

Pascal Source Code
program Hello;
var
  name: String;
  age: Integer;
begin
  name := 'World';
  age := 42;
  
  WriteLn('Hello, ', name, '!');
  WriteLn('Age: ', age);
end.
C++23 Generated Code
#include "runtime.h"

void ProgramMain() {
    bp::String name;
    bp::Integer age;
    
    name = "World";
    age = 42;
    
    bp::WriteLn("Hello, ", name, "!");
    bp::WriteLn("Age: ", age);
}

int main() {
    ProgramMain();
    return 0;
}

Language Coverage

Comprehensive Pascal language support

Core Types

  • Integer, Cardinal, Int64
  • Boolean, Char
  • String (UTF-16, 1-based)
  • Single, Double, Extended
  • Records, Enumerations
  • Arrays (static & dynamic)
  • Sets, Pointers

Control Flow

  • if..then..else
  • while..do
  • repeat..until
  • for..to..do
  • for..downto..do
  • case..of..else
  • break, continue, exit

Operators

  • Arithmetic: +, -, *, /, div, mod
  • Comparison: =, <>, <, >
  • Logical: and, or, not, xor
  • Bitwise: shl, shr
  • Set operations: in
  • Pointers: @, ^

Procedures & Functions

  • Declarations & parameters
  • const, var, out modifiers
  • Forward declarations
  • External functions
  • Result variable
  • Overloading support

Exception Handling

  • try..except..end
  • try..finally..end
  • Exception types
  • Raise exceptions
  • Exception messages

Program Types

  • Programs (executables)
  • Units (modules)
  • Libraries (DLLs)
  • Uses clause
  • Exports clause
  • Initialization/Finalization

I/O Functions

  • WriteLn, Write
  • ReadLn, Read
  • File I/O operations
  • Text files
  • Binary files
  • Directory operations

Runtime Library

  • String functions
  • Type conversions
  • Math operations
  • Memory management
  • System functions
  • And much more...

Getting Started

Self-contained distribution - just unzip and go!

1. Download & Extract

Blaise Pascal is completely self-contained. No external dependencies needed!

# Download Blaise Pascal package from GitHub
# Extract to any directory
# Everything included:
#   - Blaise.exe (transpiler)
#   - Zig 0.15.2 compiler (in bin/res/zig/)
#   - Complete runtime library (in bin/res/runtime/)

2. Create a New Project

Initialize a new Blaise Pascal project

# Create a new program project
bin\Blaise.exe init MyProgram

# Or create a library project
bin\Blaise.exe init MyLib --template library

3. Write Your Pascal Code

Edit the generated source file in src/main.pas

program MyProgram;
begin
  WriteLn('Hello from Blaise Pascal!');
end.

4. Build & Run

Use simple commands to build and execute your program

# Navigate to your project directory
cd MyProgram

# Build the project (transpile + compile)
..\bin\Blaise.exe build

# Run the compiled executable
..\bin\Blaise.exe run

5. Cross-Platform Compilation

Use the {$TARGET} compiler directive to target different platforms

// Target Linux 64-bit
{$TARGET x86_64-linux}
program MyProgram;
begin
  WriteLn('Cross-platform!');
end.

// Other target examples:
// {$TARGET x86_64-windows}  - Windows 64-bit
// {$TARGET aarch64-macos}   - macOS ARM64
// {$TARGET x86_64-linux}    - Linux 64-bit
// {$TARGET native}          - Current platform (default)

6. Additional Compiler Directives

Control build settings with compiler directives

// Optimization levels
{$OPTIMIZATION Debug}        // Debug build (default)
{$OPTIMIZATION ReleaseFast}  // Fast optimized build

// Application type (Windows)
{$APPTYPE GUI}              // No console window
{$APPTYPE CONSOLE}          // Console application (default)

// Link external libraries
{$LINK raylib.lib}
{$LIBRARY_PATH .\lib}