As I alluded to at the end of my last post on the subject of the JOSS programming language, my goal is to revive the language and create a usable version of it. (Why, you ask? Why not)
By expressing the entire program and state of the simulator in JSON we gain the ability to easily have access to any part of the program or data. We also have the ability to save the current session using the browser’s local storage api or share the program by simply saving the serialized JSON to the server with a unique link. JSON is also the reason for storing the parse trees as objects rather than compiling them to an intermediary before use. By walking and evaluating a command by climbing through it’s parse tree we can use recursion to jump to other commands in the program tape. When we have fully climbed back up the tree to the root node or a command returns the Stop. token we know the program has finished executing.
Citation: "JOSS: Experience with an experimental computing service for users at remote typing consoles", J. C. Shaw, May 1965, Page: 10
Using the paper I found previously discussing the use of JOSS on JOHNNIAC over a 16 month period, I have been able to piece together a Context Free Grammar. While I am pretty happy with it, it’s not perfect. Every now and then I spot an error and fix it but for the most part I’m satisfied it’s solid.
There are however a couple of things intentionally in there which aren’t perfect but there is good reason for them. For instance, because JOSS lacks the ability to have user defined functions I have created a function token and within it an array of tokens, each representing a different standard math function available to the user. The reason for this is to allow parse time error checking of the number of variables.
Converting for PEG.js
So far I have gotten numbers and math expressions converted into a PEG.js parser. The current state of the parse can be seen on this Gist along with the BNF Grammar. Eventually I will move all of this into its own repo on Github but for now it’s all being developed in the browser; that is, I’m writing the PEG.js parse directly into their online compiler to test it as I go, so there is nothing local to save to a repo at the moment.
Below is the current BNF Grammar for the language.