use L then you can type forth-like syntax Virtual machine in scratch It is inspired by forth language it uses polish notation e.g. 1 :dup :+-2 duplicates 1 and adds it so the result is 2 it never throws errors it rather is going to an endless loop, when it has wrong input :) it's purpose is to compile real languages to this machine current version v4.07
this project is mostly meant for my purposes, but of course you can use it :), the important things are in the code RoadMap: v1 - basic concepts like functions, recursion, working with stacks will be done in this version, basic scratch functions will be implemented v2 - an in-scratch game engine will be done with bindings to the VM v3 - outside of scratch will be created a compiler to this simple language, which will have scheme-like syntax v4 - debugged on simple games Project Status - VM execution works correctly using two stacks - all necessary operators are now working on the VM - use like 3 4 :+-2 for adding two numbers (expected result 7) - code branches - use like true :if 5 :then 7 :else (expected result 5), works also with nested ifs - forth-like functions :dup, :drop, :swap, see forth language specification for details, there should be much more of them implemented - possibility to create in language functions e.g. :noexec %fact :{ :dup 0 := :if :drop 1 :then :dup 1 :--2 %fact :*-2 :else :} :bind - and its usage is 5 %fact - expected result (top of the result stack) 120 (for factorial) - now there is memory implemented as well so it will now be easily possible to create the desired compiler use with 5 4 :cons, and delete with #0 :delcons - first compiled function from low level lisp-like language - factorial, you can use :noexec %x 5 :bind %c-fact, same with fib that is computing the fibbonaci sequence - basic display server that works now just with sprites is now working - new compiled functions reduce, map, filter, new data structure plist and added possibility to use lambdas - basic garbage collection implemented using mark & sweep algorithm - memory is now shared with scratch, this is for handling events, and sharing display with display server - hope this will be super fast - everything now seems to work correctly, however it's super-slow for real-time games, event-driven games should be ok however - so it's final version 4.0 now :) --- newer versions that are for fun v4.01 - added forth computation for binomial coefficient (slow because made from pascals triangle without cache) v4.02 - some new calculations added - pythagoras theorem, power of anything to n, imaginary number addition v4.03 - added new words for do times usage: %do %inc-x 5 %times v4.04 - added new word for really simple static compilation (for optimisation) with some errors - however useful for core features - mostly for future purposes of other language optimisation v4.05 - added classic memory with low-level interface v4.06 - updated compiler in order to work with recursive functions (still quite naive though) v4.07 - added new possibility to create function in memory with faster access v4.08 - added new words %unless and %when