An open API service indexing awesome lists of open source software.

https://github.com/insoft-uk/primeplus

PPL+ is a pre-processor that improves readability and maintainability of HP PPL code.
https://github.com/insoft-uk/primeplus

calculator code-maintance compression graphical-calculator hp hp-prime ppl prgm prime programming-language software-development

Last synced: 11 days ago
JSON representation

PPL+ is a pre-processor that improves readability and maintainability of HP PPL code.

Awesome Lists containing this project

README

          

## PPL+ for HP Prime Programming Language
**Command Line Tool**

**PPL+** is a pre-processor that improves readability and maintainability of HP PPL code. It supports custom regex rules, can extract PPL source from **.hpprgm** and **.hpappprgm** files, and can also **compress** PPL source into a compact, optimized form for the HP Prime. PPL+ supports add-ons that enable conversion of Adafruit resources into PPL.
Using these **add-ons**, **Adafruit** fonts and Adafruit_GFX **.h** files can be converted to PPL. In addition, the **GROB** add-on allows image files to be imported and converted as well.

**Compression** of your code results in it taking up less space, making it use less storage of your HP Prime's storage memory giving you more space for more programs.

**Reformating** your code enforce a consistent coding style throughout your project, making it easier for multiple developers to work on the same codebase. It helps maintain a uniform look and feel, which can enhance code readability. Readability: Well-formatted code is easier to read and understand.

Download links: macOS | Windows | Linux

`Usage: ppl+ [-o ] [-v]`



Options
Description




-o Specify the filename for generated code


-c or --compressSpecify if the PPL code should be compressed


-r or --reformatSpecify if the PPL code should be reformated


-v or --verboseDisplay detailed processing information


Additional Commands


--versionDisplays the version information


--buildDisplays the build information


--helpShow this help message

>[!WARNING]
PPL+ 26 (v5.x) will transition to using ICU. As a result, prebuilt Windows 11 binaries will no longer be provided. Users running Windows 11 who wish to use PPL+ 26 (v5.x) will need to install ICU for Windows and compile the command line tool from source.

### Regular Expressions
**Example: Extending PPL with Switch-Case Functionality Using Regex**

This example demonstrates how to use **regex** (regular expressions) to add **switch-case** control flow to the PPL language, similar to the switch statements found in other programming languages.

```
regex >`\bswitch +([a-z_.:]+)`i LOCAL sw__SCOPE__ := $1;\aCASE
regex >`\bcase +([^ ]+) +do\b`i IF sw\`__SCOPE__-1` == $1 THEN
switch X
case 0 do
end;
end;
```
**PPL+ Preprocessor: Switch-Case to PPL Conversion**

The PPL+ preprocessor generates valid PPL code by transforming switch-case statements into standard PPL case statements. This preprocessing step allows you to write more intuitive switch-case syntax while maintaining full compatibility with the PPL language, as the output is pure, valid PPL code.

```
LOCAL sw0 := X;
CASE
IF sw0 == 0 THEN
END;
END;
```

### Code Stack

A code stack provides a convenient way to store code snippets that can be retrieved and used later.

**Example: how code stack can be used for a regular expresion to bring a bit of C style to PPL**

```
regex >`\bfor *([^;]+); *([^;]+); *([^;]+) +do\b`i $1;\aWHILE $2 DO__PUSH__`\i$3;\a`
regex >`\bend;`i __POP__END;
function()
begin
for i=0; i<2; i=i+1 do
A := A+1;
end;
end;
```

**PPL+ Preprocessor: PPL Converstion**

```
function()
BEGIN
i := 0; WHILE i<2 DO
A := A + 1;
i := i + 1; END;
END;
```

### Implimenting Variable Aliases and Auto
```
regex >`\bauto\b`i v__COUNTER__
regex =`^ *\bauto *: *([a-z]\w*)` g__COUNTER__:$1
regex `\b([a-zA-Z_]\w*) *\: *([a-zA-Z]\w*(?:::[a-zA-Z]\w*)*)` alias $2:=$1;$1

auto : myGlobal := 1;
fnc1: My::Function(p1: argumentOne)
begin
local auto: i, a: Alpha;
for i=0; i<2; i=i+1 do
Alpha := Alpha + 1 * myGlobal * argumentOne;
end;

end;
auto: anotherGlobal := 2;

My::Function();
```

**PPL+ Preprocessor: PPL Converstion**
```
g0 := 1;
fnc1(p1)
BEGIN
LOCAL v0, a;
v0 := 0; WHILE v0<2 DO
a := a + 1 * g0 * p1;
v0 := v0 + 1; END;
END;

g1 := 2;
fnc1();
```

### Assignment Style

In PPL+, the = operator is treated as := (assignment) by default, whereas in standard PPL, = is interpreted as == (equality). This behavior in PPL+ can be explicitly controlled using the directive:

```#pragma mode( assignment(:=) )```

This will inform PPL+ that PPL assignment is to be used only, allowing you to use = as equality.

When = is used for assignment, the PPL := operator is still supported; however, using := is strongly recommended.

>[!IMPORTANT]
In PPL+ by default `=` is treated as `:=` were in PPL `=` is treated as `==`

## Alias
Added support for defining aliases that include a dot (e.g., alias hp::text := HP.Text).

>[!NOTE]
The PPL+ preprocessor is subject to change but aims to maintain some level of compatibility with previous versions.