{"id":18824286,"url":"https://github.com/ndbaker1/koala","last_synced_at":"2026-02-07T16:02:24.466Z","repository":{"id":127435627,"uuid":"407759740","full_name":"ndbaker1/koala","owner":"ndbaker1","description":"ʕ •ᴥ•ʔ A Toy Programming Language that compiles to its own ISA and runs on a Virtual Machine","archived":false,"fork":false,"pushed_at":"2022-08-27T21:07:20.000Z","size":1157,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T01:51:05.217Z","etag":null,"topics":["abstract-syntax-tree","compiler-design","operating-system-learning","programming-language","rust","stack-machine","virtual-machine","webassembly"],"latest_commit_sha":null,"homepage":"https://ndbaker1.github.io/koala/","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/ndbaker1.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":"2021-09-18T04:55:41.000Z","updated_at":"2024-08-08T19:24:45.000Z","dependencies_parsed_at":"2023-03-13T11:34:01.367Z","dependency_job_id":null,"html_url":"https://github.com/ndbaker1/koala","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ndbaker1/koala","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndbaker1%2Fkoala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndbaker1%2Fkoala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndbaker1%2Fkoala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndbaker1%2Fkoala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ndbaker1","download_url":"https://codeload.github.com/ndbaker1/koala/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndbaker1%2Fkoala/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29199519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T14:35:27.868Z","status":"ssl_error","status_checked_at":"2026-02-07T14:25:51.081Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["abstract-syntax-tree","compiler-design","operating-system-learning","programming-language","rust","stack-machine","virtual-machine","webassembly"],"created_at":"2024-11-08T00:56:03.454Z","updated_at":"2026-02-07T16:02:24.459Z","avatar_url":"https://github.com/ndbaker1.png","language":"Rust","readme":"# Koala ʕ •ᴥ•ʔ\nA simple programming language packaged with a virtual machine created for learning purposes.  \nTry out the demo site [here 🌍](https://ndbaker1.github.io/koala/)\n\n\n###### *THIS LANGUAGE IS NOT MEANT TO BE USABLE, IT IS JUST FOR GIVING MYSELF AND OTHERS A FLEXIBLE VIEW OF HOW A MACHINE RUNS HIGH-LEVEL CODE*\n\n## Inspiration\n**Koala** was created as a programming/design exercise while attending the University of Texas at Dallas.\n\nIn order to get a better understanding of how a high level programming language executes on a machine I decided to make a small and portable language. \n\nKoala is written in `Rust`, making it a great candidate for cross-platform deployment, and also gets the benefit of being able to compile to `WebAssembly` by using `wasm-pack`  \n\nThe VM Runtime principle was inspired by languages like `Java` and `C#`.\nThe **Java Virtual Machine (JVM)**, and **.NET Core** are stack machines, which often end up executing many more instructions than register-based machine, but are much simpler to generate code for. \n\nPhases of the Project:\n  1. Implement a simple Virtual Machine (stack-based)\n  2. Design a small yet capable language grammar (procedural, arrays, recursion)\n  3. Parse source code into an Abstract Sytax Tree\n  4. Perform Code Generation for an AST, targetting our Virtual Machine platform\n  5. Create regression tests so that it is clear when changes to any of the previous components is a breaking change (Testing is Important!)\n\n## Development\nBuild everything in the Rust project before testing the binaries `koala` and `koalac`\n```sh\ncargo build\n...\ncargo run --bin koala\ncargo run --bin koalac\n```\nWhen testing the browser UI, package the wasm using `wasm-pack` or use the provided `koala-build.sh` script\n```sh\n# root project directory\n./koala-build.sh\n```\nStartup the browser UI using\n```sh\nnpm run dev\n```\n\n### Extended Work\n- [ ] add some QoL language features\n- [ ] demostrate compiling to LLVM IR\n- [ ] cleanup VM architecture, decide if call stack frame separation is necesary\n\n# Extra info\n\n## Compiler Architecture\nA typical Compiler architecture consists of 3 core analyzers:  \n1. Lexical Analyzer\n2. Syntactic Analyzer\n\u003e Koala uses the PEG parser in order to parse source code into `Rust` objects, which is performing lexical and syntactic analysis for us. Parsing Expression Grammars (PEGs) are much simpler to write rules for than convenional LL(k) grammars because recursive descent parsing approaches simulate infinite lookahead\n3. Semantic Analyzer\n\n\u003e Koala does not contain a semantic anaylzer portion, since it would have taken more development time than I wanted for a short project. If I was able to implement the semantic analyzer then I would have been able to provided type checking at compile time, syntax suggestions/error catching, and more features\n\nand is split into 3 groups:\n1. Front End\n\u003e Essentially consists of all the tasks involved to transform source code into an easily manipulatable form.  \n2. Middle End\n\u003e May be in an Intermediate Representation (IR) such as Kotlin IR or LLVM, which can undergo several cycles of optimization.  \n3. Back End\n\u003e Code Generation takes place in this step, which is a platform specific process and can consist of modules for many different targets\n\n## Self Hosted Compilers\nThe concept of a self-hosted compiler is interesting; that is, a compiler which can compile the compiler for its own language.\nThe bootstrapping process is used to characterize the stages needed to reach a self-hosted compiler.\n\n#### Stage 1\nYou must begin with a compiler in another start language.  \n#### Stage 2\nOnce the language is stable enough to write implement its own compiler, write and compile the compiler.\n#### Stage 3\nUsing the newely generated compiler, compile the source code for the compiler once again. If this compiler binary is no different than the compiler from the previous stage, then the compiler is self-sufficient.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndbaker1%2Fkoala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndbaker1%2Fkoala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndbaker1%2Fkoala/lists"}