| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Welcome to the Autumn.cpp wiki! This repo contain a C++ implementation of Autumn interpreter. By writing in C++, the interpreter is compilable into a python module, and a web assembly module.
Please follow the README page for building instructions for both Python and Webassembly module. Both the CPP, Python, and Javascript implementation exposes the following interface:
Below is a sequence diagram on how to use the interpreter in general:
In the following sections, we describe how to use the interpreter module for python and javascript.
First, copy the interpreter_module*.so to the python import folder.
import interpreter_module
# Creating a new interpreter
interpreter = interpreter_module.Interpreter()
# Loading autumn program, all arguments are string, the 2nd is the extra library/alternative std library, ignore for the 3rd argument for now.
run_result = interpreter.run_script(script, "", "", 42) # 42 is the random seed, any other number is fine.
# Action
interpreter.left()
interpreter.right()
interpreter.up()
interpreter.down()
interpreter.click(x, y) # int, int
# Step
interpreter.step()
# Render
interpreter.render_all()Checkout the example implementation in python_test_mpl.py
First, copy the interpreter_web.wasm, interpreter_web.js, interpreter_web.wasm.map to your static serving folder, include it in your script with:
<script src="./static/js/interpreter_web.js"></script>Following this, use the interpreter as follow:
interpreter = await new interpreterModule.Interpreter();
interpreter.runScript(programContent, autumnstdlib, "", 42); // 42 is the random seed, any other number is fine.
interpreter.click(x, y);
interpreter.left();
interpreter.right();
interpreter.up();
interpreter.down();
interpreter.step();
interpreter.renderAll();Note that, the wasm cannot find the default Autumn STDlib file, so please store the autumnstdlib to a string. Checkout MARA repo for an example.
| Back | FazBrowse Home | New Git URL |