{"id":18989380,"url":"https://github.com/source-academy/sourceror","last_synced_at":"2025-04-16T08:54:34.781Z","repository":{"id":36965319,"uuid":"237257455","full_name":"source-academy/sourceror","owner":"source-academy","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-16T07:09:58.000Z","size":1147,"stargazers_count":8,"open_issues_count":12,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T03:14:11.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/source-academy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-30T16:42:31.000Z","updated_at":"2024-06-18T11:00:16.000Z","dependencies_parsed_at":"2024-04-23T09:20:29.529Z","dependency_job_id":"3e9217cc-d788-43b3-b07a-279fdfde0863","html_url":"https://github.com/source-academy/sourceror","commit_stats":{"total_commits":246,"total_committers":5,"mean_commits":49.2,"dds":"0.23983739837398377","last_synced_commit":"84d9dee2a2fec72428fd1b220e5c235cd2157637"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsourceror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsourceror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsourceror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-academy%2Fsourceror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/source-academy","download_url":"https://codeload.github.com/source-academy/sourceror/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249222139,"owners_count":21232437,"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":[],"created_at":"2024-11-08T17:06:24.107Z","updated_at":"2025-04-16T08:54:34.763Z","avatar_url":"https://github.com/source-academy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Sourceror\n\nSourceror is a compiler from Source to WebAssembly, written in Rust.  For deployment, the compiler is itself compiled to WebAssembly using the existing Rust toolchain.  It is also possible to compile the compiler to the native binary format and architecture (e.g. x86), which is useful for debugging.\n\nNote: If you just want to play with it and don't want to spend time building it on your own, you can go to [Source Academy](https://source-academy.github.io/) and switch the language to \"Source §1 WebAssembly\".  Your Source programs will be compiled and run in your browser.\n\n## Usage\n\nSourceror should be used with [Sourceror Driver](sourceror-driver). On its own, Sourceror only compiles a validated ESTree to WebAssembly.  Sourceror Driver invokes js-slang to convert Source to a validated ESTree, and then invokes Sourceror for the rest of the compilation process.  Sourceror Driver also includes functionality to run the compiled WebAssembly binary.\n\nSourceror Driver is packaged as an NPM package `sourceror` that bundles the compiled WebAssembly module.\n\n```\nyarn add sourceror\n```\n\nTo use in a web project, you need a bundler that can handle loading WebAssembly modules, such as Webpack 4 or above.\n\nTo use in a Node project, you will need a version of Node that supports loading WebAssembly as an ES module: `--experimental-wasm-modules`.\n\n```js\nimport { compile, run } from \"sourceror\";\nimport { createContext } from \"js-slang\";\n\nfunction compileAndRun(chapter = 1, code: string) {\n  let context = createContext(chapter);\n  compile(code, context)\n    .then((wasm_module) =\u003e run(wasm_module, context))\n    .then((result) =\u003e console.log(result))\n    .catch((err) =\u003e console.error(err));\n}\n```\n\n## Building\n\nAll the commands below assume that you have an up-to-date installation of the Rust compiler toolchain.\n\nTo build, navigate to the `sourceror-driver` directory of this repository, and do\n\n```\nyarn run build\n```\n\n`dist/` and `wasm/` will be created in `sourceror-driver`.\n\nYou can then use your locally-built `sourceror-driver` in another project (such as `cadet-frontend`) by running\n\n```\nyarn link\n```\n\nin the `sourceror-driver` directory, and then\n\n```\nyarn link sourceror\n```\n\nin the root of the other project.\n\n## Native binary\n\nSourceror can be compiled as a native binary for debugging purposes.  You can do\n\n```\ncargo run\n```\n\nwhich will build and run a native binary.  You can debug it with the usual debugging tools for C and C++.\n\nNote that this native binary will only accept ESTree input, and not Source source code.\n\n## Contributing\n\nFor minor bugs, you can make a pull request directly.  For larger things and debatable features, please file an issue before spending any substantial amount of time on your feature.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-academy%2Fsourceror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsource-academy%2Fsourceror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-academy%2Fsourceror/lists"}