{"id":22389268,"url":"https://github.com/berzanorg/bytecode-compiler","last_synced_at":"2025-10-15T13:31:39.145Z","repository":{"id":201199576,"uuid":"707192281","full_name":"berzanorg/bytecode-compiler","owner":"berzanorg","description":"A bytecode compiler written in Rust.","archived":false,"fork":false,"pushed_at":"2023-10-19T20:19:23.000Z","size":18,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-05T03:09:56.456Z","etag":null,"topics":["bytecode","compiler","lexer","parser","virtual-machine"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/berzanorg.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-10-19T12:03:56.000Z","updated_at":"2024-09-05T06:24:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"cae00510-3268-4752-a13f-c3e568e6b775","html_url":"https://github.com/berzanorg/bytecode-compiler","commit_stats":null,"previous_names":["berzanxyz/virtual-machine","berzanorg/bytecode-compiler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berzanorg%2Fbytecode-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berzanorg%2Fbytecode-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berzanorg%2Fbytecode-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berzanorg%2Fbytecode-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berzanorg","download_url":"https://codeload.github.com/berzanorg/bytecode-compiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236612640,"owners_count":19177124,"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":["bytecode","compiler","lexer","parser","virtual-machine"],"created_at":"2024-12-05T03:10:03.966Z","updated_at":"2025-10-15T13:31:33.786Z","avatar_url":"https://github.com/berzanorg.png","language":"Rust","readme":"# bytecode-compiler\n\nThis project is built to explore how lexers, parsers, compilers and virtual machines work.\n\nThis project doesn't have any dependency and is built from scratch.\n\nThis project has unit tests for many of its modules.\n\n# Virtual Machine Overview\nVirtual machine implementation is like below.\n```rust\npub struct VirtualMachine {\n    stack: Vec\u003cValue\u003e,\n    register: [Value; REGISTER_SIZE],\n    bytecode: Vec\u003cu8\u003e,\n    program_counter: usize,\n}\n```\n\n# Language Overview\nA sample program is below.\n```js\nPUSH 10 \nPUSH 40\nADD\nRET\n```\n\n# Opcodes\nOpcode: **PUSH**\n\nPushes a value to the stack of the virtual machine.\n```js\nPUSH \u003cvalue\u003e // type of value is `i64` \n```\n\n\u003cbr\u003e\n\nOpcode: **POP**\n\nRemoves the last value from the stack.\n```js\nPOP \n```\n\n\u003cbr\u003e\n\nOpcode: **STORE**\n\nStores the last value from the stack at specified index in the register of the virtual machine.\n```js\nSTORE \u003cindex\u003e // type of index is `u8` \n```\n\n\u003cbr\u003e\n\nOpcode: **LOAD**\n\nPushes the value at the specified index in the register to the stack.\n```js\nLOAD \u003cindex\u003e // type of index is `u8` \n```\n\n\u003cbr\u003e\n\nOpcode: **ADD**\n\nRemoves the last 2 values from the stack. And pushes the sum of them back.\n```js\nADD\n```\n\n\u003cbr\u003e\n\nOpcode: **SUB**\n\nRemoves the last 2 values from the stack. And pushes the subtraction of them back.\n```js\nSUB\n```\n\n\u003cbr\u003e\n\nOpcode: **MUL**\n\nRemoves the last 2 values from the stack. And pushes the multiplication of them back.\n```js\nMUL\n```\n\n\u003cbr\u003e\n\nOpcode: **DIV**\n\nRemoves the last 2 values from the stack. And pushes the division of them back.\n```js\nDIV\n```\n\n\u003cbr\u003e\n\nOpcode: **MOD**\n\nRemoves the last 2 values from the stack. And pushes the modulo of them back.\n```js\nMOD\n```\n\n\u003cbr\u003e\n\nOpcode: **RET**\n\nStops the execution of the program. And returns the values in the stack.\n```js\nRET\n```\n\n\n\n\n\n# Development\n\n### Setup A Development Environment\nYou need [Rust Language](https://www.rust-lang.org/) installed.\n\nOr you can use [Dev Containers](https://containers.dev/) to easily setup a development environment.\n\n### Clone The Repo\nRun the command below to clone the repository.\n```sh\ngit clone https://github.com/BerzanXYZ/bytecode-compiler.git\n```\n\n### Set Your Working Directory\nRun the command below to set your working directory to `bytecode-compiler/`.\n```sh\ncd bytecode-compiler/\n```\n\n### Build The Program\nRun the command below to build the program.\n```sh\ncargo build --release\n```\n\n### Run The Examples\nRun the command below to run the examples.\n```sh\n./target/release/bytecode-compiler examples/adding.code # or examples/complex.code\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberzanorg%2Fbytecode-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberzanorg%2Fbytecode-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberzanorg%2Fbytecode-compiler/lists"}