ZenithEngine Jamie Balfour's ZPE Programming Environment
To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the user of functional cookies. For more information read this page.

ZPE Programming Environment

The ZPE Programming Environment or ZPE is a complete language parser, compiler and interpreter framework for Java. It interprets and compiles YASS (a custom language specific for this) into an abstract syntax tree (AST) and into other languages.

You can download the install package with the configuration script for Mac OS X and Linux here. To run this in your terminal type: sudo ./configure.sh (you need to run with elevated permissions to install it and you will need to be in the directory of the unzipped file) to install all the files including the manual page.

ZPE was originally known from May 2015 until July 2018 as the Zenith Parsing Engine but after a rename became known as the ZPE Programming Environment.

Feel free to leave comments in comments section below.

ZPE Banner

The core of the whole system is the Zenith Framework which can be extended further with more functions and functionalities. As well as this, the ZPE Programming Environment features a range of built-in functions. ZPE Programming Environment (ZPE) was also known by it's codename Shifting Sands before getting it's final name.

ZPE was pronounced originally as ZeePeeEee but as of late 2015 it was named after our hamster at the time, Henry, as Zippy (I name a lot of projects after my pets). It was designed specifically for my own fun but also for education purposes, with the main aim being to help introduce those who find programming difficult to a much easier language to learn.

This done using a very flexible compiler, one that will work in many ways, leaving not just one possible way to write a piece of code, but multiple. For example, take a for loop:

YASS
for($i = 3, $i < 10, 1)
	//Do something
end for
			

This loop can be modified to have an end loop instead of an end for ending:

YASS
for($i = 3, $i < 10, 1)
	//Do something
end loop
			

The same for loop can be written using braces rather than end for to terminate the loop and also using the $i++ increment feature rather than specifying just a number to increment by.

YASS
for($i = 3, $i < 10, $i++) {
	//Do something
}
			

It can also be written using semi colons to make the syntax of this identical to PHP:

YASS
for($i = 3; $i < 10; $i++) {
	//Do something
}
			

Actually, there are plenty more variations of this same loop. But crucially, all of them compile to the same thing underneath. The compiler does all of the work checking this. So feel free to write it as if it were using braces like C or just using keywords like VB.NET because remember, the compiler is efficient as it is and it can deal with having these extra checks.

How the ZenithEngine works with other languages

Zenith is a stand-alone interpreter as well as a middle-man interpreter. Commands that are specified to it are run as small Java based applications.

The following image shows how it works:

ZenithEngine

How ZPE works with other languages and libraries such as BRS

The ZenithEngine's core principle purpose is to develop intermediate code. This code is then transformed to C, Java, C#, VB.NET, Python and more or it is compiled.

You can see how the ZenithParser itself works with the language by looking at the ZenJSONParser file here.

Syntax

There are lots of functions:

Returns in Java are the YASS equivalent: return ( $v )

In Java maths is written like: int v = 1 + 1 and in ZPE as of version 1.3.5.60 it is written as $v = 1 + 1

Expressions can be nested: print ( floor (1.42) + 1)

You can read more about the syntax by clicking on Documentation at the top of this page.

Purpose

Prior to ZPE I had already developed a programming language that I begun to write when I turned 18 called BlackRabbit Script. The language was slow. But when I began writing a spell checker for Wonderword, I learned more about things like BNF and parsers I begun rewriting it. Further, BRS was limited to Windows.

I think it would be fair to say that I begun building this down to my own research and knowledge, but that my university course definitely was the push that made the performance almost double after learning about LL(1) parsers where I was converted to remove backtracking almost all over the parser.

ZPE and YASS were started in January 2015 as a programming project I decided to start for fun (as with all of my software). In March I could see it was really coming along as a programming syntax and thought I might as well continue with it. From there on, what was originally called only by it's codename, Shifting Sands and Stratosphere, became something else.

Just as BlackRabbit Script worked on .NET, ZPE works on Java. The two were fundamentally and syntactically different. Both were variations or dialects of my own BlackRabbit Script. YASS as it is known was fully based on the same syntax as BlackRabbit Script started on.

YASS and the ZPE Programming Environment are designed as a small compact programming language that can be used within other applications as scripting languages, but they also both feature stand-alone functionality as well. The core aim of the language was to improve the readability of code to make it easier to learn, therefore the language can also be seen as theoretical and educational languages too.

Technical stuff

ZPE is an LL(1) parser that will compile code from YASS to byte-code. The parser requires the use of backtracking and does this incredibly well. By doing things this way, it can assess mathematical expressions in one simple function rather than needing other methods.

Code is converted from byte-code to a FAST (Flat AST). The FAST is then run through an optimiser (only if being compiled to a file). The runtime will then run through the FAST and decide what to do based on the byte-code of each AST.

There are very few regular expression evaluations used in the language which is designed to keep the compile time down.

Compiled files will run faster than interpreted files, but interpeting code still runs relatively quickly.

Compared with BRS

BlackRabbit Script or BRS is my .NET Windows equivalent version of the same language. It serves the same purpose but on Windows.

A lot more time and effort went into the development of ZPE than BRS because I had a lot more of a plan when I developed it.

In terms of performance, ZPE is considerably better. In both languages I wrote the same for loop that does the same thing (loops 100,000 times):

YASS/BRS
for($i = 0, $i < 100000, 1)
	print($i)
end for
										

The newly designed ZPE performs nearly twice as fast as it did at the start of 2015, and considerably better than the .NET version of 2014 and the original version of 2011.

The following graph shows system times in milliseconds to perform a loop that prints each number up to 100, 000 times:

Latest version
Oldest version

Scores are calculated by determining time in milliseconds taken to do the same task with better results being the ones that takes less time as shown above. Note, the right two bars are versions of BRS and the left bars are versions of ZPE (with the second bar being ZPE 1.2).

Parser and language features

Many features have been suggested by testers and users of the language, although the majority are my own.

The following core language features have been implemented as of now:

  • LL(1) parser
  • Tree generation
  • Compiling and interpreting code
  • Line reading mode to take individual commands
  • Graphical user interface mode
  • Command line arguments
  • On-the-fly interpreting
  • Core functionalties such as print, arithmetic and string manipulation
  • Variable substitution
  • Variable assignment
  • Condition assessment
  • Bracketed logic and math
  • If statements
  • Loops
  • Functions and nested functions, function calling and nested function calls
  • YASS core function overwriting - write functions over core functionalities by defining a function or defining a custom function
  • Optional parameters
  • Finite sets/lists and functions
  • Associative arrays/maps
  • Methods that are multi-functional. Mean, mode, max and min are functions that work on lists and numeric parameters
  • Mathematical parser
  • Recursion has been available since version 1.3.5.60
  • 100 or more built in commands
  • Custom functions written in Java
  • Library support
  • Lambda (λ) expressions and anonymous functions
  • Built in sort algorithms
  • Full support for structures
  • A standard library, written itself in YASS, open and compiled and designed to showcase the power of the language.

The following core language features are being developed at the moment and will be available soon:

  • Export to Java

The following core language features are being considered and may come soon:

  • Export to C, C++, VB.NET, C# and Python

There is more in the changelog as to what has been added. You can find the changelog here.

I do regret to inform everyone that I no longer have access to the old versions due to them cluttering my system. I decided to stick to the current version of ZPE code and the three build versions back (so if was writing code for 1.5.0.1 I could still access back to 1.4.3) came to an end at the start of 2017.

Presentation

As I often create slideshows of projects, I have created a slideshow on my website about the ZPE. You can view it from here.

What's good about ZPE?

Really? Do I need to explain this to you again? Ok.

It's open for development

The ZPE is an open for development (closed source for the majority) parser that means you can develop your own functions in Java (one of the most popular programming languages in the world) for it as well as help me develop it.

I maintain the core of the engine, but suggestions are always welcome.

Byte-codes are also available so developing applications using them is easy.

It's one language for all

ZPE will soon allow you to write programs in it and then convert them straight to Java, and eventually other languages. This feature will prove incredibly useful.

It's a mathematical parser

ZPE also can act as a mathematical parser. A lot of my time and effort went into my RMM parser. I had for a long time thought of just running something like JavaScript to do this but I eventually got my RMM to do it's job perfectly.

It can be used for those quick mathematical evaluations from the command line using zpe -m '5+5*10'.

Version 1.4.3 replaced the RMM with the LAMP parser - a much better version that processes both logic and mathematical expressions at the same time.

It's also a learning language

YASS or Yet Another Simple Syntax is really simple and is designed to read that way too. I promise to listen to feedback and to never put in complicated structures where ever I can avoid doing so.

It's multi platform

Because the underlying Java programming language that powers the parser is Java, it is already platform independent. This means you can run it on a huge number of devices such as Windows PCs, Macs and Linux machines, as well as many others.

Build your own functions for it

Whilst it is possible to write programs with multiple functions, compile them into a library and run them as YASS code, it is also possible to write Java based plugins for the language and let them run as libraries. It works really fluidly and well too!

To get started, download the TestPlugin project and compile it to a JAR file. Place this in the plugins/ folder where the zpe.jar resides (if the folder does not exist, simply create it and call it "plugins") which you can find by typing zpe -h config.

The system is very similar to my .NET version but as a bit of a newcomer to the Java world at the time (compared with .NET) I did need the help of this tutorial.

Make sure you have the latest ZPE when you compile to ensure full compatibility! This also ensures that the byte-codes are up to date.

It has a remote mode

This remote mode allows you to setup a server machine that can run more complex tasks on a more powerful computer. Take for instance the limited power of the amazing little Raspberry Pi. Run a ZPE Server on a system with a more powerful Core i7 on it and then run a ZPE Client on the Raspberry Pi and pass all the complex calculations to the more powerful system. ZPE will soon also support sending files for processing and returning them when an operation is complete.

Remote mode can also be used for communication. Open two servers and two clients and pass messages to a graphical interface, creating a small internal instant messenger.

The following are example scripts. They are placed here from time to time and may not be fully functioning in the latest version of ZPE.

You can find more on my personal shared Dropbox folder here

FireFile listing

All files in this directory listed by FireFile

Files

If there are any faults within FireFile, please report them to me.

Contributions

The following software and/or components were used in the production of ZPE:

  • Java BECL (Balfour's Enterprise Class Library) - used for the image effects amongst many other helper functions.
  • Google's GSON library - used for parsing JSON to a Java HashMap which is then converted to a ZPEAssociativeArray. This was added in version 1.5.0 (10.12.2016) and replaced by JBSON which is my own JSON parser built on the Zenith Parser in version 1.5.3 (24.02.2017).

The following people are to thank for their contributions to the development of ZPE:

  • Julian Merlin Ertel - major contributor through major testing. Without any doubt the biggest external tester of ZPE, all the way from version 1.3.

Known bugs

The following list are known bugs in the latest version. Fixes are currently being looked at. The bugs with an exclamation mark (!) after the number are priority bugs. I will leave all bugs from version 1.5.3 in this list and update them as I or someone else manages to fix them. Most of these bugs are found by myself or my test group.

Bug number Description Fixed
#1! Modular arithmetic does not always give the correct result 2019-01-28
#2! Arithmetical evaluation on inner object values does not work 2017-03-28
#3 MySQL functions no longer work
#4 Concatenation with value access within object context (e.g. $x -> $y & $x -> $z) does not work 2018-08-31
#5 ZPE needs to handle errors in code better and not crash when the compiler finds a fault. 2017-09-20
#6 ZPE Parser needs to work on comments more flexibly, not binding itself to a single style of comments (// and /* */ are currently the only supported options) 2018-01-01
#7 Concatenation with function access within object context (e.g. $x -> func1() & $x -> func2()) does not work 2018-12-29
#8 Accessing an object value's index within object context (e.g. $x -> $v[0] = 10) does not work 2018-12-29