Go back

Pasclang

Pasclang is a compiler for the educational language Pseudo-Pascal. It uses the LLVM infrastructure for code generation on different targets. The goal is to show how to implement a full compiler for a simple imperative language using CMake and the LLVM infrastructure and as few external libraries as possible.

The Pseudo-Pascal language

Pseudo-Pascal is a Pascal dialect which features similar syntax and semantics but has several limitations. For example, only single-file programs can be compiled. The supported types are integers and booleans. Only three built-in functions exist: readln(), which reads an integer from the standard input as well as write(x) and writeln(x), where x is an integer printed to the standard output (with or with no new line). The test directory features several examples of programs written in Pseudo-Pascal. More examples will be added as features get implemented.

Source code

The source code is hosted online at Gitlab and can be cloned or browsed from here.

Learn more

A short documentation file is available both in English and in French.

Future plans

The initial goal of providing a complete implementation of Pseudo-Pascal has been achieved. Some features could be added, such as automatic garbage collection or at least some way to manually free allocated memory blocks. However those weren't part of the initial desciption of the Pseudo-Pascal language and adding a delete keyword calling the C standard free function is rather trivial. See for reference the new keyword implementation in src/LLVMBackend/IRGenerator.cpp (search for the AST::EArrayAllocation overload).

Go top/Go back