https://github.com/thomscoder/luna Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + By Plan + Enterprise + Teams + Compare all + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} thomscoder / luna Public * Notifications * Fork 2 * Star 36 A really tiny WebAssembly compiler for demonstration and educational purposes. Written in Go and built as one of my quests to conquer the WebAssembly dungeon luna-demo.vercel.app 36 stars 2 forks Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights thomscoder/luna This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Clone HTTPS GitHub CLI [https://github.com/t] Use Git or checkout with SVN using the web URL. [gh repo clone thomsc] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @thomscoder thomscoder docs: changed image, updated docs (index.html) ... 1 62bfaef Nov 1, 2022 docs: changed image, updated docs (index.html) 62bfaef 1 Git stats * 10 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time compiler feat: regex for literals (freely rename the function) + docs: updated... Nov 1, 2022 defaults feat: regex for literals (freely rename the function) + docs: updated... Nov 1, 2022 example docs: changed image, updated docs (index.html) Nov 1, 2022 texts feat: luna Nov 1, 2022 types feat: luna Nov 1, 2022 .gitignore feat: luna Nov 1, 2022 Makefile feat: luna Nov 1, 2022 README.md docs: changed image, updated docs (index.html) Nov 1, 2022 go.mod feat: luna Nov 1, 2022 go.sum feat: luna Nov 1, 2022 index.js feat: luna Nov 1, 2022 main.go feat: luna Nov 1, 2022 package.json feat: tokenizer (log) Oct 29, 2022 pnpm-lock.yaml hali: initial commit Oct 27, 2022 View code [ ] Luna How it works Use it in the browser Requirements Roadmap More interactivity More arithmetics Expansion of Wat syntax README.md Luna Luna is a reeeaaally tiny, yet expanding, sample compiler for WebAssembly Text Format, written in Go and built as one of my quest to conquer the WebAssembly dungeon. (I just wanted to build something like wat2wasm) luna It is so tiny that can only make additions lol. I've built Luna because I wanted to learn how to build a compiler while learning WebAssembly. The goal of Luna is not to replace (in a long distant future) solid tools like wat2wasm, wasmer or others; nor to do fancy stuff, the goal of this project is to be useful for anyone approaching WebAssembly and/or as a blueprint for anyone that wants to develop a compiled-to-wasm programming language. I tried to document each section of the code as much as I could (I'm still doing it) with link to resources I've studied while building this, but if you want to improve it, feel free to open issues and pull requests. How it works Followed the amazing articles about the Chasm compiler (a WAT compiler written in Typescript for the Chasm language) and a guide to write a WAT compiler in Rust * Luna takes a .wat file (or string if used in the browser) * Splits it into tokens ./compiler/tokenizer.go * Creates a very simple AST of the tokens ./compiler/parser.go * Compiles ./compiler/compiler.go Use it in the browser Luna can also be used in the browsers Demo: https://luna-demo.vercel.app/ The make wasm or make update commands will build (or update) with TinyGo the ./example/main.wasm file to be imported in the browser In the ./example directory there's a working example of how to do that. Requirements * Go * Tinygo * Make * syscall/js set up (or simply comment out the startLuna function and the syscall/js import) Roadmap 1. More interactivity Currently Luna supports only the renaming of the exported function and some order scrumbling 2. More arithmetics Currently Luna supports only addition 3. Expansion of Wat syntax Luna is by no means finished there are a lot of things that can be implemented and A LOT of things that can be improved. Any suggestions, pull requests, issues or feedback is greatly welcomed!!! About A really tiny WebAssembly compiler for demonstration and educational purposes. Written in Go and built as one of my quests to conquer the WebAssembly dungeon luna-demo.vercel.app Topics javascript golang compiler webassembly personal-project learning-by-doing sample-code wat2wasm hacktoberfest2022 Resources Readme Stars 36 stars Watchers 1 watching Forks 2 forks Releases No releases published Packages 0 No packages published Languages * Go 50.7% * JavaScript 43.3% * HTML 4.3% * CSS 1.2% * Makefile 0.5% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.