Introduction
Forest Overview
Forest is a console application developed in C++ using Microsoft Developer Studio, without relying on third-party packages.
It operates on PPL.DLL, an implementation of the Parenthesis Programming Language (PPL).
Originally written in C#, the PPL code was translated into C++.
PPL is an interpreted programming language in which all elements (statements, parameters, blocks) are enclosed in parentheses,
resembling LISP syntax.
It includes a preprocessor to simplify code writing and reduce parentheses usage.
PPL source code (format: .scr) is converted into an intermediate representation (format: .ppl) for immediate execution.
Key features of PPL
1. Extensibility:
-Combines C++ functionalities with custom user libraries by creating DLLs via the CodeGen.exe utility.
-Enables adding full PPL functionality to any user application.
2. Modes:
-ppl (base) mode: Syntax similar to LISP, using prefix notation for mathematical and logical expressions.
Examples:
var (x [0]);
set(x) (+(1)(2));
set (x)( -(0)(+(3)(2))); // infix notation: x = -(3 + 2);
if(==(x) (1)) …
-scr (preprocessor) mode: Syntax similar to C, using infix notation for mathematical and logical expressions.
Examples:
var x = 0;
set x = 1 + 2; // or x = 1 + 2;
if (x == 1)…
Commands in format scr may be used on the left side of the expression(example).
3. Parsing:
-Code written in scr mode is translated into ppl mode before execution. Each parser level creates a syntax tree.
-Forest calls PPL API functions, which can also be used in other applications.
4. Execution Modes:
-The operating mode (scr or ppl) is determined by the file extension or a command in the code itself.
-scr mode simplifies coding by eliminating the need for enclosing statements in parentheses.
-Default mode is set in Configuration.Data: (Code [ppl])
Built-In Statements and Compound Blocks
Preprocessor includes the following statements: –
var, const, realloc,
storage statements,
array statements,
set, setkvp,cpc, sumdata,
savedata,readdata,array,
write#, writearray,call,
createstruct, insertstruct,
delegate, dlgtistant,dlgset,dlgtcall,callback,
setloopend,savedata,readdata
and following compound statements (blocks): –
definestruct,function, for, if, else, switch, case, default, finally,failure.
All ppl mode statements may be also added to scr code in format ppl if these
statements do not have scr mode.
Data Handling
Unicode Storage: All data is saved as Unicode symbols, while digital data is converted
into strings.
Examples:
set x = 5.2; saved as string "5.2"
Boolean values are saved as strings - "True" and "False":
set x = True;
Script Execution Stages
Script execution involves:
-Creating an array of statements (simple or compound).
-Generating a syntax tree for each statement.
-Traversing all nodes in the syntax tree and executing the associated procedures.
-Repeating the process recursively for each statement in compound blocks.
-Continuing the process for each statement in the array until completion.
-The dstree command allows users to visualize syntax trees for each script statement.
Debugging Features
Forest includes commands for debugging:
-dbg: Enables debugging mode.
-traceppl: Traces code execution.
-suspend and resume: Temporarily pauses script execution and resumes it.
-start and stop: Measures the execution duration and outputs results in milliseconds.