scratchnative/scratchnative

Use a library to parse projects

adazem009 opened this issue · 4 comments

Hi, this is a really interesting project.

I've been working on a C++ library since April and I was wondering if it could be used in this project. It can already parse Scratch 3 projects, create ASTs, compile them into bytecode and run them.

I'm not sure whether it can be used to compile projects to C++ code (maybe I'll add an option to disable the default implementation of Scratch blocks so you can implement your own). Or maybe the bytecode generated by the built-in compiler could be used to output C++ code.

I don't know if a C++ library can be used in Rust or how difficult it is, but I think it'd make sense to use the library to avoid reinventing the wheel. And I'll add support for Scratch 2 and 1.4 projects in the future.

Here's the link to the library: https://github.com/scratchcpp/libscratchcpp
It's still missing a lot of things, but the core parts are implemented.

Just had a look at your project and it seems very complete, now I wonder whether or not I should archive scratchnative and link to your project.

Just had a look at your project and it seems very complete, now I wonder whether or not I should archive scratchnative and link to your project.

I've implemented a lot of things since August, so it should be possible to use it now, but I can't imagine how it can be used to compile projects to C++ code. libscratchcpp compiles scripts to bytecode which is then interpreted by a virtual machine (docs: https://scratchcpp.github.io/libscratchcpp-docs/virtualMachine.html). Maybe going through the generated bytecode and generating C++ code would be possible.

I should also mention that libscratchcpp hasn't reached version 1.0.0 yet, so keep in mind there might be incompatible API changes in any minor release.

By the way, you may also be interested in scratchcpp-gui which is a renderer for projects running under the libscratchcpp runtime.

I was talking about deprecating scratchnative in favour of your project. I was also thinking that maybe I could work on a JIT compiler for your VM and other utilities, would you accept these kinds of contributions?

I was talking about deprecating scratchnative in favour of your project. I was also thinking that maybe I could work on a JIT compiler for your VM and other utilities, would you accept these kinds of contributions?

Sure, that was actually my initial plan but I gave up because I wanted it to run on multiple CPU architectures.