{"id":22300741,"url":"https://github.com/paladin-t/bitty.compiler_plugin","last_synced_at":"2025-09-25T12:35:36.978Z","repository":{"id":77919118,"uuid":"399470218","full_name":"paladin-t/bitty.compiler_plugin","owner":"paladin-t","description":"An example compiler plugin for Bitty Engine.","archived":false,"fork":false,"pushed_at":"2021-08-25T07:55:27.000Z","size":53,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-30T20:43:51.545Z","etag":null,"topics":["bitty","bitty-engine","brainfuck","compiler","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/paladin-t.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":"2021-08-24T13:11:03.000Z","updated_at":"2023-01-22T00:56:24.000Z","dependencies_parsed_at":"2023-02-27T22:00:30.108Z","dependency_job_id":null,"html_url":"https://github.com/paladin-t/bitty.compiler_plugin","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/paladin-t%2Fbitty.compiler_plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paladin-t%2Fbitty.compiler_plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paladin-t%2Fbitty.compiler_plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paladin-t%2Fbitty.compiler_plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paladin-t","download_url":"https://codeload.github.com/paladin-t/bitty.compiler_plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245559945,"owners_count":20635468,"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":["bitty","bitty-engine","brainfuck","compiler","lua"],"created_at":"2024-12-03T18:13:50.123Z","updated_at":"2025-09-25T12:35:36.902Z","avatar_url":"https://github.com/paladin-t.png","language":"Lua","readme":"# Compiler plugin for Bitty Engine\n\nThis repository demonstrates how to implement a custom compiler/transpiler plugin for [Bitty Engine](https://github.com/paladin-t/bitty) with a BF example.\n\n## Installing\n\n1. Clone or download this repository.\n\n2. Click \"Project\", \"Browse Data Directory...\" from the menu bar.\n\n![](imgs/browse.png)\n\n3. Ensure there is a \"plugins\" directory under that directory.\n\n4. Put the \"plugin.bit\" into the new created \"plugins\" directory. And name it properly.\n\n![](imgs/install.png)\n\n5. Reopen Bitty Engine.\n\n## Injecting\n\n1. Create a new asset, select the registered asset type.\n\n![](imgs/new_asset.png)\n\n2. Click \"Install\" to inject necessary assets to the target project.\n\n![](imgs/inject.png)\n\n![](imgs/injected.png)\n\n3. Write and run BF code.\n\n![](imgs/run.png)\n\n## Principles\n\n![](imgs/principles.png)\n\nBitty Engine loads plugin to extend its features once it's installed. It loads a BF compiler in this example which can inject the compiler to a target project. And the injected compiler/transpiler runs as regular Bitty code that translates BF code to runnable Lua chunk.\n\n```lua\nrequire 'bf/compiler'               -- Require the compiler.\n\nlocal f = compile('hello world.bf') -- Compile something.\nf()                                 -- Run the compiled chunk.\n```\n\n## Write your own compiler plugin\n\nA compiler plugin contains three parts.\n\n### 1. Meta info\n\nSimilar to regular Bitty projects, it has an \"info.json\", define it as you want.\n\n### 2. Main entry\n\nBitty Engine doesn't run a plugin project directly, it must be installed before running. The execution entry is also named as \"main.lua\".\n\nBut the entry functions are different from regular project. Eg.\n\n```lua\n-- Which assets are supposed to be injected from this plugin to target project.\nlocal assets = {\n  'bf/compiler.lua',\n  'bf/README.txt'\n}\n\n-- Tips and example code.\nlocal tips = 'Usage:\\n  require \\'bf/compiler\\'\\n  f = compile(\\'source.bf\\')\\n  f()'\nlocal code = 'require \\'bf/compiler\\'\\nf = compile(\\'source.bf\\')\\nf()\\n'\n\n-- Plugin entry, called to determine the usage of this plugin.\nfunction usage()\n  return { 'compiler' } -- This plugin is a compiler.\nend\n\n-- Plugin entry, called to determine the schema of this plugin.\nfunction schema()\n  return {\n    -- Common.\n    name = 'BF',      -- Asset name registered for this plugin.\n    extension = 'bf', -- Asset extension registered for this plugin.\n\n    -- List of string.\n    keywords = { },\n    identifiers = { },\n    quotes = { '\\'', '\"' },\n    -- String.\n    multiline_comment_start = nil,\n    multiline_comment_end = nil,\n    -- C++ regex.\n    comment_patterns = { '\\\\#.*' },\n    number_patterns = { },\n    identifier_patterns = { },\n    punctuation_patterns = { '[\\\\\u003c\\\\\u003e\\\\+\\\\-\\\\.\\\\,\\\\[\\\\]]' },\n    -- Boolean.\n    case_sensitive = true,\n    -- List of string.\n    assets = assets\n  }\nend\n\n-- Plugin entry, called to install necessary assets to your target project.\nfunction compiler()\n  print('Install BF compiler to the current project.')\n\n  waitbox('Installing')\n    :thus(function (rsp)\n      local install = function (name)\n        local data = Project.main:read(name)\n        data:poke(1)\n        Project.editing:write(name, data) -- Write into the target project.\n      end\n\n      for _, asset in ipairs(assets) do -- Install all necessary assets.\n        install(asset)\n      end\n\n      print('Done.')\n\n      msgbox(tips)\n        :thus(function ()\n          Platform.setClipboardText(code) -- Put example code to clipboard.\n        end)\n    end)\nend\n```\n\n### 3. Assets to be injected\n\nThe plugin project also contains assets to be injected. See the plugin in this repository for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaladin-t%2Fbitty.compiler_plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaladin-t%2Fbitty.compiler_plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaladin-t%2Fbitty.compiler_plugin/lists"}