{"id":16563733,"url":"https://github.com/nathsou/elox","last_synced_at":"2025-03-21T11:32:49.992Z","repository":{"id":39470176,"uuid":"191258125","full_name":"nathsou/Elox","owner":"nathsou","description":"Interpreter for a superset of Crafting Interpreter's lox language","archived":false,"fork":false,"pushed_at":"2023-01-07T07:43:26.000Z","size":2148,"stargazers_count":18,"open_issues_count":22,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-11T20:42:55.729Z","etag":null,"topics":["craftinginterpreters","interpreter","lox","rust"],"latest_commit_sha":null,"homepage":"https://nathsou.github.io/Elox/web/dist/index.html","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/nathsou.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}},"created_at":"2019-06-10T23:12:21.000Z","updated_at":"2024-04-04T19:25:36.000Z","dependencies_parsed_at":"2023-02-06T15:01:36.276Z","dependency_job_id":null,"html_url":"https://github.com/nathsou/Elox","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/nathsou%2FElox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathsou%2FElox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathsou%2FElox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathsou%2FElox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathsou","download_url":"https://codeload.github.com/nathsou/Elox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221814961,"owners_count":16885086,"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":["craftinginterpreters","interpreter","lox","rust"],"created_at":"2024-10-11T20:42:10.159Z","updated_at":"2024-10-28T10:05:05.592Z","avatar_url":"https://github.com/nathsou.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elox\n\nElox for Extended-lox, is a superset of the lox toy language from Bob Nystrom's book [_Crafting Interpreters_](http://www.craftinginterpreters.com/).\n\nIt is an interpreted (both in a VM or directly by walking the AST) or compiled (to WASM), dynamically typed, objected oriented programming language.\n\nYou can test it [here](https://nathsou.github.io/Elox/web/dist/index.html)\n\nIts main additions to lox are :\n\n- Native Arrays\n- String concatenation of any variable types allowed\n- Modulo '%' operator available\n- Usual assignment shorthands: +=, -=, ++, --, *=, /=, %=\n- Default valued function parameters\n- Rest parameters\n- Anonymous functions allowed\n\n# Running\n\nElox is written in Rust and can thus target your computer's architecture and [WebAssembly](https://webassembly.org/).\n\nFurthermore, an Elox to wasm compiler is in development\n\n## Compiling and running\n\nIn the project folder: \n\n```bash\n$ cargo run --release --bin [elox | vm | wasm] [file.elox]\n```\n\n## Compiling to WebAssembly\n\n### Compiling an elox program to wasm\n\nElox can target wasm directly, it uses the VM compiled bytecode as \nan intermediate representation which is then translated to WebAssembly\n\n```bash\n$ cargo run --release --bin wasm [file.elox]\n```\n\nthis command produces a file named out.wasm which can be run with :\n\n```bash\n$ node run_wasm.js\n```\n\n### Compiling the project to wasm\n\nUsing [wasm-pack](https://rustwasm.github.io/wasm-pack/) in the project folder:\n\n```bash\n$ wasm-pack build\n```\n\nThe demo website using the compiled wasm module can be run using:\n\n```bash\n$ cd web\n$ npm run start\n```\n\n## Todo\n\n- [ ] Arrow functions\n- [ ] standard library\n - [ ] Implement [traits](https://www.wikiwand.com/en/Trait_(computer_programming))\n - [X] Write a compiler targetting wasm directly\n - [ ] Optional type annotations used by a static type checker\n - [ ] Function overloading\n - [ ] 'const' keyword\n- [ ] Replace 'nil' with Option\\\u003cT\u003e or other? =\u003e match and enums?\n- [ ] bundler to import other elox files\n- [ ] extern code execution (C or JS)\n\n## Examples\n\nDemos are available in the /demos folder and can be [run online](https://nathsou.github.io/Elox/web/dist/index.html).\n\n```javascript\n// Pseudo Random Number Generator\nclass PRNG {\n  init(seed = clock() * 1000) {\n    this.a = 25214903917;\n    this.c = 11;\n    this.m = 281474976710656;\n    this.seed = seed;\n  }\n\n  next() {\n    this.seed = (this.a * this.seed + this.c) % this.m;\n    return this.seed / this.m;\n  }\n}\n \nvar prng = PRNG();\nvar nums = [];\n\nfor (var i = 0; i \u003c 10; i++) {\n   nums.push(prng.next());\n}\n\nprint nums;\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathsou%2Felox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathsou%2Felox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathsou%2Felox/lists"}