The Portable Programming Language (PPL) is a work in progress (WIP), hobby project.
PPL aims to be a systems programming language, similar to C/C++.
Here is a small sample of PPL:
b :: int = 7; c :: int = 8;
main :: fn () -> int
{
D := 9u;
D ? ppl_console_print( "Hello: %d\n", b + c + D) :
ppl_console_print( "Hellohi: %d\n", c);
for the_iterator in 0 ..= 7 do
{
ppl_console_print("in the loop\n");
if the_iterator then continue;
ppl_console_print("the_iterator: %d\n", the_iterator);
}
}
NOTE: I had a little too much fun writing complex, garbage software. The ASTs generated by the compiler are deeply nested and the AST generation algorithm has poor performance.
- The compiler toolchain features an interactive command line system to control it.
- The toolchain includes a compiler to convert PPL source to a binary.
- The toolchain includes an assembler to convert a text representation of the PPL IR (pasm) to a binary.
- Preliminary compilation error message support.
Platform Support:
- Windows
- macOS
Language Features Supported:
- Single and multi-line comments.
- Global and function-local variable declaration, strongly typed (currently, only signed/unsigned integers supported).
- Arithmetic expressions via operators with proper precedence.
- Operators supported:
- Ternary conditional operator.
- +/-.
- type casting.
- Conditional branching (if statements, else if, and else).
- Loop statements:
- while loops (which use C for loop syntax).
- Span (compile-time constant)-based for Loops.
- Other statements:
- break and continue statements.
- return statements.
- Standard library:
- ppl_console_print.
Dependency: ld
must be available from the terminal.
Run build.sh
to build the compiler.
Run bin/ppl
to run the compiler. If the compiler is not run from the root repo directory,
the macro PSTDLIB_PATH within src/ppl.cpp may need to be changed.
Building the codebase can be done in a terminal which is equipped with the ability to call MSVC from the command line.
This is generally done by calling vcvarsall.bat x64
, which is included in the
Microsoft C/C++ Build Tools. This script is automatically called by the x64 Native Tools Command Prompt for VS <year>
variant of the vanilla cmd.exe
. If
you've installed the build tools, this command prompt may be easily located by
searching for Native
from the Windows Start Menu search.
You can ensure that the MSVC compiler is accessible from your command line by running:
cl
If everything is set up correctly, you should have output very similar to the following:
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30151 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
Run build.bat
to build the compiler.
Run bin\ppl.exe
to run the compiler. If the compiler is not run from the root repo directory,
the macro PSTDLIB_PATH within src/ppl.cpp may need to be changed.