by vmorgulis · 11y ago · 0 comments
Do you know this interpreter ? (in D)
https://github.com/higgsjs/Higgs
It's one of the most advanced I found (outside browsers).
If you want to get rid of the "switch/case", you can look at threaded code interpreters.
http://www.complang.tuwien.ac.at/forth/threaded-code.html
You can find useful ressources in Forth about it.
I write a stack-based language in javascript. Each statement is a closure around the arguments of the expression stored in a flat array. The instruction pointer is an index in that array. It is partially compiled.
I also use function object constructor for a kind of FFI.
There is also good potential with asm.js to reach near-native performances.
Where's your language's website?
It is far less advanced than yours. It's inspired by Forth (a mixture of interpret and compile "word"s).
I'm doing that right now:
let print foreign console.log
print "hello"
Every "word" is a function receiving a stack and returning a stack. Whitespace can be replace by a "|".Each line is evaluated from right to left. Some words are used to change the state of the compiler and the compiler is a state machine (words are events).
The game is to find a minimal set of words to express high-level features like lambdas (from a word "jump", "until" or "instruction-pointer" for example).
It's cool to program :-)