Skip to content
PaskalCPP
Start

PaskalCPP

Write Pascal-style code, use any C and C++ library. PaskalCPP is a Pascal and Oberon inspired systems language that compiles to C++23 and mixes freely with C++ in the same source file.

What PaskalCPP is

PaskalCPP is a minimal, general-purpose systems programming language. Its syntax follows Pascal and Oberon: blocks open and close with words, assignment is := and equality is =, every control-flow construct closes with its own word (end, or until for repeat), and names are declared before they are used.

The compiler writes a C++23 header and source for each module and builds them with the bundled Zig toolchain (clang). One source builds an executable, a shared library or a static library, for x86_64-windows-gnu and x86_64-linux-gnu, from one Windows machine.

What sets it apart is that C and C++ are part of the language. A library is used by #include-ing its header and calling it: there is no import, binding or wrapper layer to write or keep in sync.

hello.pcpp
module exe hello;

begin
  println("Hello from PaskalCPP!");
end.
output on x86_64-windows-gnu and x86_64-linux-gnu
Hello from PaskalCPP!
[Heap] Allocs: 0, Frees: 0, Leaked: 0

The last line is the heap report of a debug build, the default optimize level: see Optimize levels.

Five ideas

  • Readable by design. Pascal and Oberon blocks, := for assignment, ; after every statement, each construct closed by its own word (end, or until for repeat).
  • C++ is the surface. A C++ type can be the type of a PaskalCPP variable, a C++ expression can sit inside a PaskalCPP expression, and a C++ declaration can stand at module level. See C++ mixing.
  • C++23 is the machine code. PaskalCPP is a transpiler: C++23 plays the part machine code plays for a traditional compiler. See Building.
  • Errors speak PaskalCPP. A mistake in PaskalCPP code is reported in PaskalCPP's words and types; a problem the C++ compiler or the linker finds is mapped back to the file, line and column in your .pcpp source. See Diagnostics.
  • The toolchain is in the box. Zig and clang ship with PaskalCPP: one pcpp command turns a source file into a native binary. See The pcpp command.

How these docs are laid out

  • New to PaskalCPP? Start with the Tour: a first program, how to build and run it, and a taste of each part of the language.
  • Coming from Pascal or Delphi? The language pages, from Modules to Unit testing, describe each construct and the rules the compiler checks. The words are familiar; the differences are called out where they matter.
  • Coming from C++? Read C++ mixing first, then Building and The runtime: what PaskalCPP writes, how it builds, and what the runtime adds.
  • Looking something up? The Grammar gives the shape of every construct; the Reference lists every word, directive, intrinsic and diagnostic code, read from the compiler's own tables.

Every example on these pages is a file built on both official targets by its check and, when it is a program, run there; the output shown is the output it must print.

Getting PaskalCPP

PaskalCPP is open source under the Mozilla Public License 2.0. Releases, issues and discussion live on GitHub; the project's site is paskalcpp.org.