Future Oriented Rapid Execution Smart Tools · Parenthesis Programming Language

Forest(PPL)

Write it like C, run it like LISP. Every program is a tree you can display, save, rebuild and change while it runs.

for.scr — what you write
var begin = 0;
var end = 3;
for(i, begin + 1, end + 1, 1)
{
  write(i);
}
preprocessor →
ppl — what runs
var (begin[0]);
var (end[3]);
loop (i)( + ( begin )( 1 ) )( + ( end )( 1 ) )( 1 )
(
  do
  (
    (write(i))
  )
);
run →
output
1
2
3

Infix .scr code is translated into parenthesized .ppl, then a syntax tree is built and traversed. Run showcode yes to see this translation for any of your own files.

Two notationsC-like scr and prefix ppl, freely mixed in one file
No dependenciesPlain C++ console app, core engine in PPL.DLL
16 librariesFrom Math and String to StorageLib, Requests and NumPPL
MITOpen source, VS Code extension included
Your first ten minutes

From download to your first program

  1. Download and unpack

    Download ForestPPL_SFX.exe from the repository and run it; it is a self-extracting archive. You get ForestPPL.exe, the library DLLs, Configuration.data and the folders Data, Examples, Functions and CodeGen.

  2. Start the interactive console

    With no arguments the interpreter waits for commands at the > prompt. Switch to the C-like notation with code scr.

    console
    >ForestPPL.exe
    >code scr;
    >write("Hello World!");
    Hello World!
    >help            // or ?, lists all commands
    >? d             // help for a single command
  3. Run a bundled example

    readcode (short form rc) reads and runs a file. Start with the cowsay series: each file adds one language feature to the previous one. Values after the file name replace $1$, $2$, $3$ in the script.

    console
    >rc examples\cowsay\cowsay1.scr
    >rc examples\cowsay\cowsay4.scr 1 1 10
  4. Write your own file

    Save this as lines.scr and run it outside the console. The notation is chosen by the file extension.

    lines.scr
    var n = $1$;
    for(i, 0, n)
    {
        write#("line {0} of {1}", i + 1, n);
    }
    terminal
    ForestPPL.exe lines.scr 3
  5. Turn on checking and highlighting

    checksyntax yes reports syntax errors before anything runs. The VS Code extension ships in the repository and installs with one command.

    terminal
    code --install-extension forestppl-vscode-0.3.0.vsix
A short tour

The essentials on one page

Examples come from the tutorial. Where the difference helps, the ppl form of the same construct sits next to the scr form.

Variables, constants, arrays

Every value is stored as a Unicode string: 5.2 is kept as "5.2", booleans as "True" and "False". A leading underscore makes a name private. The names result and all are reserved.

scr
var x = 0;
x = 1 + 2;              // "set" may be omitted
const PI2 = 6.28;
array y[3];
y[x - 1] = 2 + 3;
array colors[] = {"Red", "Green"};
writearray colors row;
ppl
var (x [0]);
set (x) (+(1)(2));
array (y[3]);
set (y[+(1)(2)]) (0);
set (x) ( -(0)(+(3)(2)) );  // x = -(3+2)

Declaring a name twice fails with name [x] already exists. Delete it with del x, or allow redeclaration with recreate yes.

Why Forest

Code and data live in trees

The d (display) command shows what is in memory at any moment: nodes N and leaves L. It is the main tool for understanding the language.

  • GlobalPublic variables, arrays, storage and nodes, shared by all code.
  • LocalVariables of the running function, removed when it returns.
  • FunctionsFunctions only, no data. Loaded by default from Functions\CommonFunctions.ppl.
  • ConfigurationSettings from Configuration.data: code mode, logging, debugging, auto-loaded libraries.
  • Scope ManagerTracks scopes: block variables disappear with their block, so nothing leaks.
>d
>code scr
>array y[] = {1,2,3};
>var x = 0;
>d
-N2     NS
---N3   Global
-----L0 empty     (const)
-----N4 y                  [Array 3]
-------L0       #       [1]
-------L1       #       [2]
-------L2       #       [3]
-----L1 x                  [0]
---N3   Local
Standard libraries

What ships in the box

The number on each card is how many functions the reference documents. Highlighted libraries load by default with the shipped Configuration.data.

Cheat sheet

Console commands

The service and special commands you will use in your first week. The reference has the full list with examples.

CommandGroupWhat it does
Project status

Platforms and recent changes

readyWindows — primary platform, built with MS Developer Studio
verifyingLinux — port complete, being verified against the test scripts
0.5.0VS Code — extension for .scr and .ppl files

New in ForestPPL

  • Scope Manager for variables in functions, loops and blocks
  • Producer–consumer pipeline for commands from the console and files
  • Much faster AST traversal
  • New Storage with jagged arrays, plus the StorageLib library
  • Syntax checking before execution with checksyntax
  • No more limits on index calculation and parameter passing
  • New API for external libraries and an HTML reference
  • New libraries: Requests (HTTP client) and NumPPL (NumPy-style arrays)
Community

Questions, ideas, collaboration

All conversation about ForestPPL happens in GitHub Discussions. Post there when you get stuck, want to build something together, or have an idea for the language.

Q&AHow do I do X? Why does this script behave this way? Include the code and the output you see.
IdeasNew commands, libraries or syntax you would like in PPL, and the problem they solve.
CollaborationPorting, writing libraries with CodeGen, examples, documentation, or using PPL.DLL in your own application.
Show and tellShare scripts and libraries you have built with ForestPPL.
Open GitHub Discussions

Found a reproducible bug? File it under Issues with the script, the command you ran and the error text.