{"id":20950227,"url":"https://github.com/bytexenon/the-tiny-lua-compiler","last_synced_at":"2025-10-28T23:16:40.983Z","repository":{"id":241028068,"uuid":"804069712","full_name":"ByteXenon/The-Tiny-Lua-Compiler","owner":"ByteXenon","description":"⛄ Possibly the smallest Lua compiler ever ","archived":false,"fork":false,"pushed_at":"2024-05-22T09:07:42.000Z","size":15,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-23T02:36:27.731Z","etag":null,"topics":["compiler","lexer","lua","lua-compiler","lua-the-tiny-compiler","lua-tiny-compiler","luau","tiny-compiler","tokenizer"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc-by-4.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ByteXenon.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-21T22:37:00.000Z","updated_at":"2024-05-28T02:22:54.703Z","dependencies_parsed_at":"2024-05-28T02:22:51.836Z","dependency_job_id":null,"html_url":"https://github.com/ByteXenon/The-Tiny-Lua-Compiler","commit_stats":null,"previous_names":["bytexenon/the-tiny-lua-compiler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteXenon%2FThe-Tiny-Lua-Compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteXenon%2FThe-Tiny-Lua-Compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteXenon%2FThe-Tiny-Lua-Compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteXenon%2FThe-Tiny-Lua-Compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ByteXenon","download_url":"https://codeload.github.com/ByteXenon/The-Tiny-Lua-Compiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225275706,"owners_count":17448387,"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":["compiler","lexer","lua","lua-compiler","lua-the-tiny-compiler","lua-tiny-compiler","luau","tiny-compiler","tokenizer"],"created_at":"2024-11-19T00:47:27.533Z","updated_at":"2025-10-28T23:16:40.635Z","avatar_url":"https://github.com/ByteXenon.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n![The Tiny Lua Compiler (TLC)](https://github.com/ByteXenon/TinyLua/assets/125568681/41cf5285-e31d-4b27-a8a8-ee83a7300f1f)\n\n**A minimal, educational Lua 5.1 compiler written in Lua**\n\n_Inspired by [Jamie Kyle's The Super Tiny Compiler](https://github.com/jamiebuilds/the-super-tiny-compiler) written in JavaScript_\n\n\u003c/div\u003e\n\n## Features\n\n- **Educational**: Reading through the guided code will help you learn about how _most_ compilers work from end to end.\n- [**Self-compiling**](\u003chttps://en.wikipedia.org/wiki/Self-hosting_(compilers)\u003e): This compiler can compile itself!\n- **Zero dependencies**: This compiler is written in pure Lua and has no dependencies.\n- **Speed**: Even though speed is not the main priority, the compiler is still pretty fast compared to other Lua compilers written in Lua.\n- **100% test coverage**: TLC has a test suite that covers 100% of the code. Want to see it in action? Run `sh tests/test.sh` in your terminal.\n\n### [Want to jump into the code? Click here](https://github.com/bytexenon/The-Tiny-Lua-Compiler/blob/main/the-tiny-lua-compiler.lua)\n\n---\n\n### Why should I care?\n\nThat's fair, most people don't really have to think about compilers in their day\njobs. However, compilers are all around you, tons of the tools you use are based\non concepts borrowed from compilers.\n\n### Why Lua?\n\nLua is a simple programming language that is easy to learn and use. It doesn't\nhave complex syntax or a lot of features, which makes it a great language to\nmake a compiler for.\n\n### But compilers are scary!\n\nYes, they are. But that's our fault (the people who write compilers), we've\ntaken something that is reasonably straightforward and made it so scary that\nmost think of it as this totally unapproachable thing that only the nerdiest of\nthe nerds are able to understand.\n\n### Example usage?\n\nThe compiler is written in a way that it can be used as a library.\nHere is an example of how you can use it:\n\n```lua\nlocal tlc = require(\"the-tiny-lua-compiler\")\n\nlocal code = [[\n  for i = 1, 3 do\n    print(\"Hello from TLC! \" .. i)\n  end\n]]\n\n-- Tokenize the code\nlocal tokens = tlc.Tokenizer.new(code):tokenize()\n\n-- Convert tokens into an Abstract Syntax Tree (AST)\nlocal abstractSyntaxTree = tlc.Parser.new(tokens):parse()\n\n-- Generate executable code\nlocal prototype = tlc.CodeGenerator.new(abstractSyntaxTree):generate()\nlocal bytecode = tlc.Compiler.new(prototype):compile()\n\n-- Load and execute the compiled function.\n-- Only works in Lua 5.1 (as it generates Lua 5.1 bytecode)\nlocal compiledFunction = loadstring(bytecode)\ncompiledFunction()\n```\n\n### Okay so where do I begin?\n\nAwesome! Head on over to the [the-tiny-lua-compiler.lua](https://github.com/bytexenon/The-Tiny-Lua-Compiler/blob/main/the-tiny-lua-compiler.lua) file.\n\n### Tests\n\nRun the test suite with:\n\n```bash\nsh tests/test.sh\n```\n\n### Support The Tiny Lua Compiler (TLC)\n\nI don't take donations, but you can support TLC by starring the repository and sharing it with others.\nIf you find a bug or have a feature request, feel free to open an issue or submit a pull request.\n\n---\n\n[![cc-by-4.0](https://licensebuttons.net/l/by/4.0/80x15.png)](http://creativecommons.org/licenses/by/4.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytexenon%2Fthe-tiny-lua-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytexenon%2Fthe-tiny-lua-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytexenon%2Fthe-tiny-lua-compiler/lists"}