Skip to content
Mike Miller edited this page Aug 20, 2025 · 1 revision

Pscal Project Wiki

Overview

Pscal began as a Pascal interpreter and has evolved into a stack-based virtual machine with multiple language front ends, all written in C with a hand-crafted lexer, parser, bytecode compiler, and optional SDL2 and libcurl integrations. The architecture follows a classic compiler pipeline—front end, bytecode compiler, and VM—while supporting a substantial subset of Pascal through enums, records, control flow, units, and more.

Requirements and Building

  • C11-compatible compiler
  • CMake 3.24 or newer
  • libcurl
  • Optional: SDL2, SDL2_image, SDL2_ttf, SDL2_mixer
git clone <repository>
cd pscal
mkdir build && cd build
cmake ..  # add -DSDL=ON to enable SDL support
make

Testing

After compilation, On Linux run

ctest --output-on-failure

for the regression suite, which covers both passing cases and expected failures.

On MacOS run,

cd Tests;make

Front Ends

  • '''Pascal''' – Core language with a hand-written lexer and parser.
  • '''tiny Language''' – Minimal educational compiler emitting Pscal bytecode; limited to integer arithmetic but useful for experiments.
  • '''C-like''' – Compact C-style compiler supporting declarations, control flow, loops, expressions, and a REPL; built-in VM functions can be invoked directly.

Runtime Library and Built-ins

Pscal expects etc and lib directories at runtime and provides built-in routines for math, strings, I/O, files, random numbers, and system utilities. Additional units ship for string utilities, Base64 encoding, geometry helpers, terminal control, DOS-style file operations, advanced math, and general system utilities.

Extensibility

Developers can extend the VM by adding C source files under src/ext_builtins, each registering new primitives via registerExtendedBuiltins.

License

Pscal is released into the public domain under The Unlicense.