3 ms·
Great job. Do you know this interpreter ? (in D) https://github.com/higgsjs/Higgs https://github.com/higgsjs/Higgs It's one of the most advanced I found (out
by vmorgulis 11y ago
Great job.
Do you know this interpreter ? (in D)
https://github.com/higgsjs/Higgs 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 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.
- bartqk 11y agoThanks. Didn't heard of Higgs, but looks interesting. You could use JITting in MetaES as well, you have all information about execution during runtime, so why not? That was one of my ideas for demo, but this one is quite heavy ;) Where's your language's website?
- vmorgulis 11y agohttps://github.com/vmorgulys/crabble/tree/master/js/object/machine https://github.com/vmorgulys/crabble/tree/master/js/object/m... 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 :-)