WASM Forth ========== A Forth implementation compiling to WebAssembly. It includes an ANS Forth standard environment containing all the CORE words. The system has a fixed amount of memory available, currently 128 MB. Interaction with Javascript at the moment is limited to textual input (using `WasmForth.source`) and output (through the `write` configuration parameter passed to `WasmForth.boot`). Using the included (optional) virtual DOM library it's possible to write interactive web apps. See the code in `examples/todomvc/` for an example TODO list web app fully implemented in Forth. Installation ============ $ npm install wasm-forth Usage ===== The following code instantiates the interpreter and runs a program that prints "Hello, World!" to the console: import * as WasmForth from 'wasm-forth'; import wasmURL from 'wasm-forth/dist/kernel.wasm'; import coreURL from 'wasm-forth/dist/core.f'; import vdomURL from 'wasm-forth/dist/vdom.f'; WasmForth.boot({ wasmURL, sources: [coreURL, vdomURL], write: (text) => { console.log(text); } }).then(() => { WasmForth.source(': HELLO S" Hello, World!" TYPE ; HELLO\n'); }); `WasmForth.boot({ ... })` initializes the system and returns a Promise. Once resolved, it's possible to interpret forth code by passing it to `WasmForth.source(string)`. Note that the string passed must end with a newline. `WasmForth.boot` accepts a configuration object with 3 required parameters: - `wasmURL`: URL where to fetch the "kernel.wasm" included in the NPM package. - `sources`: a list of URLs where to fetch the forth "core.f" included in the NPM package. - `write`: a function that will be called when the forth code needs to output text. If you're using webpack, you can use the file-loader (https://github.com/webpack-contrib/file-loader) plugin to distribute `kernel.wasm`, `core.f` and `vdom.f`. You can also use this library without a module bundler by loading it in a