tinyBigGAMES/BlaisePascal
Open-source Pascal-to-C++ transpiler with Pascal semantic compatibility. Self-contained distribution with bundled Zig compiler and runtime. Think in P...
Think in Pascal. Compile to C++.
An open-source Pascal-to-C++ transpiler with perfect Delphi semantic compatibility. Self-contained distribution with bundled Zig compiler and complete runtime library.
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 compile, 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.
Download the latest release and extract to any directory. Everything you need is included:
Blaise.exe - The transpilerbin/res/zig/ - Zig compiler with LLVMbin/res/runtime/ - C++ Pascal runtime library# Create a new program project
blaise.exe init MyProgram
# Or create a library project
blaise.exe init MyLib --template library
Edit the generated source file in src/MyProgram.pas:
program MyProgram;
begin
WriteLn('Hello from Blaise Pascal!');
end.
# Navigate to your project directory
cd MyProgram
# Build the project (transpile + compile)
blaise.exe build
# Run the compiled executable
blaise.exe run
blaise init <name> [--template <type>] # Create new project
blaise build # Build project
blaise run # Run executable
blaise clean # Clean build artifacts
blaise zig <args> # Pass args to Zig compiler
blaise version # Show version
blaise help # Show help
program - Executable program (default)library - Shared library (.dll on Windows, .so on Linux)unit - Static library (.lib on Windows, .a on Linux)Control your build settings using compiler directives in your Pascal source:
{$TARGET x86_64-linux}
program MyProgram;
begin
WriteLn('Cross-platform!');
end.
Supported targets:
{$TARGET x86_64-windows} - Windows 64-bit{$TARGET x86_64-linux} - Linux 64-bit{$TARGET aarch64-macos} - macOS ARM64{$TARGET native} - Current platform (default){$OPTIMIZATION Debug} // Debug build (default)
{$OPTIMIZATION ReleaseSafe} // Safe optimized build
{$OPTIMIZATION ReleaseFast} // Fast optimized build
{$OPTIMIZATION ReleaseSmall} // Size optimized build
{$APPTYPE GUI} // No console window
{$APPTYPE CONSOLE} // Console application (default)
{$INCLUDE_HEADER <raylib.h>}
{$LIBRARY_PATH .\lib}
{$LINK raylib.lib}
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β 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 Source (.pas)
β
DelphiAST (parsing)
β
Blaise Transpiler (token mapping)
β
Generated C++23 (.cpp)
β
Zig/LLVM (compilation)
β
Native Executable
The transpiler is a dumb token mapper - It walks the AST and maps Pascal tokens to C++ tokens with bp:: prefixes. That's it.
All semantic complexity lives in the C++23 runtime - The bp namespace contains wrapped types, operators, and Pascal RTL functions that preserve exact Pascal semantics.
if..then..elsewhile..do, repeat..untilfor..to..do, for..downto..docase..of..elsebreak, continue, exit+, -, *, /, div, mod=, <>, <, >, <=, >=and, or, not, xorshl, shrin@, ^try..except..endtry..finally..endWriteLn, Write, ReadLn, Read, File I/OLength, Pos, Copy, UpperCase, LowerCase, TrimIntToStr, StrToInt, FloatToStr, StrToFloatAbs, Sqrt, Sin, Cos, Tan, Round, TruncGetMem, FreeMem, New, DisposeParamCount, ParamStr, HaltPascal Source:
program Hello;
var
name: String;
age: Integer;
begin
name := 'World';
age := 42;
WriteLn('Hello, ', name, '!');
WriteLn('Age: ', age);
end.
Generated C++23:
#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;
}
Blaise Pascal works seamlessly with external libraries thanks to the isolated bp namespace:
program RaylibDemo;
{$INCLUDE_HEADER '<raylib.h>'}
{$LIBRARY_PATH .\lib}
{$LINK libraylib.a}
const
SCREEN_WIDTH = 800;
SCREEN_HEIGHT = 450;
begin
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, 'Blaise Pascal + raylib');
SetTargetFPS(60);
while not WindowShouldClose() do
begin
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText('Hello from Blaise Pascal!', 190, 200, 20, LIGHTGRAY);
EndDrawing();
end;
CloseWindow();
end.
Create a project-specific build configuration by using compiler directives:
program MyGame;
{$TARGET native}
{$OPTIMIZATION ReleaseFast}
{$APPTYPE GUI}
{$INCLUDE_HEADER <raylib.h>}
{$LIBRARY_PATH .\lib}
{$LINK raylib.lib}
begin
// Your game code here
end.
For comprehensive documentation, visit:
Contributions are welcome! Please feel free to submit a Pull Request.
The project is structured as follows:
src/compiler/ - Blaise Pascal compiler (Delphi source)bin/res/runtime/ - C++23 runtime librarybin/res/zig/ - Bundled Zig compilerexamples/ - Example projectsdocs/ - DocumentationBlaise Pascal is licensed under the BSD 3-Clause License. See LICENSE for details.
Copyright Β© 2025-present tinyBigGAMESβ’ LLC. All Rights Reserved.