undermining the concept of pseudocode
SCSA, the authority that writes my school's curriculum, has their own flavour of pseudocode. They teach this to avoid teaching a real programming language. But the joke's on them, because their pseudocode is now a real language.
There's no spec for it, and their information conflicts at times, but this implementation is capable of running a decent amount of the examples I can find.
This repo has a lexer and a recursive descent parser with backtracking, and a stack bytecode compiler and virtual machine. It also has a vscode extension for syntax highlighting.
npm install
npm run build
./bin/scsa.js examples/small.scsacd vscode
npx vsce package
# now right click on scsa-pseudocode-*.vsix in vscode and installObjects with a negative ID are dynamically allocated. On occasion, when Interpreter.prototype.alloc is called, all positive objects on the heap, as well as anything on the stack, should be recursively marked. Then, any negative objects not marked as reachable can be removed.
All variables are global right now, and while technically all examples run fine, this is problematic. Function scopes should contain the variables they declare. I need to add stack frames to the interpreter so that variables can be local to functions.
All binary operators are currently parsed left to right.