{"id":13566051,"url":"https://github.com/stefano/wasm-forth","last_synced_at":"2025-04-03T23:30:59.892Z","repository":{"id":41233475,"uuid":"115422659","full_name":"stefano/wasm-forth","owner":"stefano","description":"A Forth implementation compiling to WebAssembly.","archived":false,"fork":false,"pushed_at":"2019-05-05T14:42:15.000Z","size":63,"stargazers_count":143,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-04T20:41:33.751Z","etag":null,"topics":["compiler","forth","forth-94","interpreter","wasm","webassembly"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefano.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-26T13:02:49.000Z","updated_at":"2024-10-22T05:30:03.000Z","dependencies_parsed_at":"2022-09-06T04:40:38.551Z","dependency_job_id":null,"html_url":"https://github.com/stefano/wasm-forth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefano%2Fwasm-forth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefano%2Fwasm-forth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefano%2Fwasm-forth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefano%2Fwasm-forth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefano","download_url":"https://codeload.github.com/stefano/wasm-forth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097662,"owners_count":20883122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","forth","forth-94","interpreter","wasm","webassembly"],"created_at":"2024-08-01T13:02:00.969Z","updated_at":"2025-04-03T23:30:58.815Z","avatar_url":"https://github.com/stefano.png","language":"Python","readme":"WASM Forth\n==========\n\nA Forth implementation compiling to WebAssembly.\n\nIt includes an ANS Forth standard environment containing all the CORE words.\nThe system has a fixed amount of memory available, currently 128 MB.\n\nInteraction with Javascript at the moment is limited to textual input (using `WasmForth.source`)\nand output (through the `write` configuration parameter passed to `WasmForth.boot`).\n\nUsing the included (optional) virtual DOM library it's possible to\nwrite interactive web apps. See the code in `examples/todomvc/` for an\nexample TODO list web app fully implemented in Forth.\n\nInstallation\n============\n\n    $ npm install wasm-forth\n\nUsage\n=====\n\nThe following code instantiates the interpreter and runs a program that prints \"Hello, World!\" to the console:\n\n    import * as WasmForth from 'wasm-forth';\n    import wasmURL from 'wasm-forth/dist/kernel.wasm';\n    import coreURL from 'wasm-forth/dist/core.f';\n    import vdomURL from 'wasm-forth/dist/vdom.f';\n\n    WasmForth.boot({\n        wasmURL,\n        sources: [coreURL, vdomURL],\n        write: (text) =\u003e {\n            console.log(text);\n        }\n    }).then(() =\u003e {\n        WasmForth.source(': HELLO S\" Hello, World!\" TYPE ; HELLO\\n');\n    });\n\n`WasmForth.boot({ ... })` initializes the system and returns a Promise. Once resolved, it's possible to\ninterpret forth code by passing it to `WasmForth.source(string)`. Note that the string passed must end with a newline.\n\n`WasmForth.boot` accepts a configuration object with 3 required parameters:\n\n- `wasmURL`: URL where to fetch the \"kernel.wasm\" included in the NPM package.\n- `sources`: a list of URLs where to fetch the forth \"core.f\" included in the NPM package.\n- `write`: a function that will be called when the forth code needs to output text.\n\nIf you're using webpack, you can use the file-loader (https://github.com/webpack-contrib/file-loader)\nplugin to distribute `kernel.wasm`, `core.f` and `vdom.f`.\n\nYou can also use this library without a module bundler by loading it in a \u003cscript\u003e tag.\n\nSee https://github.com/stefano/wasm-forth/tree/master/examples/webpack for an example usage with webpack,\nand https://github.com/stefano/wasm-forth/tree/master/examples/script for an example usage as a \u003cscript\u003e tag.\n\nSee https://github.com/stefano/wasm-forth/tree/master/examples/todomvc for an example of a full web app that interacts with the DOM.\n\nBuilding from source\n====================\n\nTo build the forth kernel distribution and the interactive environment (see below), you will\nfirst need to install binaryen (https://github.com/WebAssembly/binaryen)\nand ensure that `libbinaryen.so` is in the library path (LD_LIBRARY_PATH).\n\nThen build the kernel (Python 3.6 is required):\n\n    $ python3.6 -m venv env\n    $ source env/bin/activate\n    $ python setup.py build_ext -L path/to/binaryen/lib/\n    $ python setup.py develop\n    $ python kernel\n    $ npm install\n    $ npm run build # or 'npm run watch'\n\nInteractive Environment\n=======================\n\nThis repository also contains a REPL static page (see the `repl` directory).\nTo serve it locally, follow the instructions above and then run the following command:\n\n    $ python kernel --demo-repl\n\nThe REPL will be served at http://localhost:8080/\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefano%2Fwasm-forth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefano%2Fwasm-forth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefano%2Fwasm-forth/lists"}