{"id":17825988,"url":"https://github.com/thefox6/luavenuscompiler","last_synced_at":"2025-03-18T21:31:53.831Z","repository":{"id":68588339,"uuid":"239817606","full_name":"theFox6/LuaVenusCompiler","owner":"theFox6","description":"a compiler that loads and runs lua Venus scripts","archived":false,"fork":false,"pushed_at":"2020-05-09T10:57:40.000Z","size":74,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T14:16:11.573Z","etag":null,"topics":["compiler","lua","programming-language","script","venus","venus-files"],"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/theFox6.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":"2020-02-11T17:04:14.000Z","updated_at":"2023-07-02T13:09:52.000Z","dependencies_parsed_at":"2023-02-26T11:16:17.754Z","dependency_job_id":null,"html_url":"https://github.com/theFox6/LuaVenusCompiler","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/theFox6%2FLuaVenusCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theFox6%2FLuaVenusCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theFox6%2FLuaVenusCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theFox6%2FLuaVenusCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theFox6","download_url":"https://codeload.github.com/theFox6/LuaVenusCompiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960664,"owners_count":20375104,"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","lua","programming-language","script","venus","venus-files"],"created_at":"2024-10-27T18:34:54.845Z","updated_at":"2025-03-18T21:31:53.822Z","avatar_url":"https://github.com/theFox6.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LuaVenusCompiler\n[![luacheck][luacheck badge]][luacheck workflow]  \nA compiler that translates Venus files into Lua. Written in Lua.  \nThe compiler reads a Venus file and replaces Venus syntax by Lua syntax.  \nIt can also load and run the result.\n\n## Features:\n### \"foreach\" loop\nThe `foreach` statement will geneate a `pairs` statement.\n```lua\nlocal table = {2,1,3,\"test\"}\n\nforeach el in table {\n  print(el)\n}\n```\nwill generate:\n```lua\nlocal table = {2,1,3,\"test\"}\n\nfor _, el in table do\n  print(el)\nend\n```\n\n### Comments\nFor comments `--` and `##` can be used\nIf something follows a `--` it will always be treated as comment\n\n\n### Functions\n`fn` can be used instead of `function`.\n```lua\nfn test() {\n\tprint(\"hi\")\n}\n```\nwill generate\n```lua\nfunction test()\n\tprint(\"hi\")\nend\n```\n\n### Curly braces based syntax\nThe `do`,`then` and `end` statements can be replaced by curly braces syntax.  \nThey can be used in functions, loops, conditions, etcetera.  \nFor example:\n```lua\ndo {\n\tlocal table = {2,1,3,\"test\",\"test2\",3}\n\n\tfn findTest(t) {\n\t\trepeat {\n\t\t\tlocal found = false\n\t\t\tlocal el = table.remove(t)\n\t\t\tif el == \"test\" {\n\t\t\t\tfound = true\n\t\t\t} else {\n\t\t\t\tprint(el)\n\t\t\t}\n\t\t} until found\n\t}\n}\n```\nwill generate:\n```lua\ndo\n\tlocal table = {2,1,3,\"test\",\"test2\",3}\n\n\tfunction findTest(t) \n\t\trepeat\n\t\t\tlocal found = false\n\t\t\tlocal el = table.remove(t)\n\t\t\tif el == \"test\" then\n\t\t\t\tfound = true\n\t\t\telse\n\t\t\t\tprint(el)\n\t\t\tend\n\t\tuntil found\n\tend\nend\n```\n\n### Lambdas / Anonymous functions\nLambda syntax `(args) =\u003e {...}` can be used to create anonymous functions.\n```lua\nlocal result\nfn store_it(f) {\n\tresult = f(10,6)\n}\n\nstore_it((a,b) =\u003e {\n\treturn (a - b) * 2\n})\n```\nwill generate:\n```lua\nlocal result\nfunction store_it(f)\n\tresult = f(10,6)\nend\n\nstore_it(function(a,b)\n\treturn (a - b) * 2\nend)\n```\n\n### Increment and Decrement\n`++` and `--` can be used to add/sub by 1\n```lua\nlocal i = 0\nlocal j = 0\n\ni++\nj--\n```\nwill generate:\n```lua\nlocal i = 0\nlocal j = 0\n\ni = i + 1\nj = j - 1\n```\n\n### assignments\nAssignment operators `+=`, `-=`, `*=`, `/=`, `^=` and `.=` can be used for math on variables.\n```lua\nlocal a = 0\n-- Increased by\na += 2\n## Decreased by\na -= 1\n## Multiplied by\na *= 8\n-- Divided by\na /= 2\n-- Powered by\na ^= 3\n## Concatenate string\na .= \" str\"\n```\nwill generate\n```lua\nlocal a = 0\n-- Increased by\na = a + 2\n-- Decreased by\na = a - 1\n-- Multiplied by\na = a * 8\n-- Divided by\na = a / 2\n-- Powered by\na = a ^ 3\n-- Concatenate string\na = a .. \" str\"\n```\n\n## Working with the compiler\n### Loading \nThe init.lua returns a function for loading the compiler.  \nYou have to call it with the path to the script itself as argument.  \nIn case you have the LuaVenusCompiler directory within your project's  \nways of loding it may be:\n```lua\n--in case your project is run within it's own folder\nlocal vc = dofile(\"LuaVenusCompiler/init.lua\")(\"LuaVenusCompiler/\")\n--in case you have a variable called project_loc containing the path to your projects folder\nlocal vc = dofile(project_loc..\"/LuaVenusCompiler/init.lua\")(project_loc..\"/LuaVenusCompiler/\")\n--using require\nlocal vc = require(\"LuaVenusCompiler\")(\"LuaVenusCompiler/\")\n```\nWhen it is loaded it can also be accessed with the global called \"LuaVenusCompiler\".\n\n### Running Venus files\n`vc.dovenus(file)` works like `dofile(file)`  \nIt's argument can be a relative or absolute path to the file that should be run.\n\n### Loading Venus files\n`vc.loadvenus(file)` works like `loadfile(file)`  \nIt's argument can be a relative or absolute path to the file that should be loaded.  \nIt returns a function that runs the generated lua.\n\n### Generating Lua code\n`vc.tl_venus_file(file)` returns the lua generated from the files contents  \nIt's argument can be a relative or absolute path to the file that should be translated.  \nIt returns the generated lua as string.\n\n`vc.tl_venus_string(str)` returns the lua generated from the given string  \nIt returns the generated lua as string.\n\n### Generating Lua files\n`vc.convert_venus_file(venus_file_in,lua_file_out)` generates a lua file  \nIt's arguments can be relative or absolute paths.  \nThe venus_file_in will be converted to lua and written to lua_file_out.\n\n[luacheck badge]: https://github.com/theFox6/LuaVenusCompiler/workflows/luacheck/badge.svg\n[luacheck workflow]: https://github.com/theFox6/LuaVenusCompiler/actions?query=workflow%3Aluacheck\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthefox6%2Fluavenuscompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthefox6%2Fluavenuscompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthefox6%2Fluavenuscompiler/lists"}