{"id":18257969,"url":"https://github.com/linkdd/airscript","last_synced_at":"2025-04-04T18:31:27.325Z","repository":{"id":40897650,"uuid":"508066827","full_name":"linkdd/airscript","owner":"linkdd","description":"Like Lua, but in Rust, and different","archived":false,"fork":false,"pushed_at":"2022-07-19T20:54:57.000Z","size":47,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T17:05:21.870Z","etag":null,"topics":["interpreter","lua","programming-language","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/linkdd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-27T21:27:03.000Z","updated_at":"2024-01-10T12:55:00.000Z","dependencies_parsed_at":"2022-07-14T06:40:30.808Z","dependency_job_id":null,"html_url":"https://github.com/linkdd/airscript","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/linkdd%2Fairscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Fairscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Fairscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Fairscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkdd","download_url":"https://codeload.github.com/linkdd/airscript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247229382,"owners_count":20905040,"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":["interpreter","lua","programming-language","rust"],"created_at":"2024-11-05T10:28:22.712Z","updated_at":"2025-04-04T18:31:26.532Z","avatar_url":"https://github.com/linkdd.png","language":"Rust","readme":"# AirScript\n\nIt's like [Lua](https://lua.org), but in [Rust](https://rust-lang.org), and\ndifferent.\n\n## Introduction\n\nAirScript is a dynamically typed, interpreted language inspired by **Lua** and\nwritten in **Rust**.\n\nJust like **Lua**, the interpreter is a stack-based virtual machine. The VM\nprovides an API to manipulate this stack, allowing you to:\n\n - push/pop primitive values\n - push/pop custom Rust types\n - push/pop (and call) Rust functions\n - ...\n\nExample:\n\n```rust\nuse airscript::prelude::*;\nuse airscript::interpreter::{VM, FuncReturns};\n\nfn square(vm: \u0026mut VM\u003c()\u003e) -\u003e Result\u003cusize\u003e {\n  let a = vm.pop_integer()?;\n  vm.push_integer(a * a);\n  Ok(1)\n}\n\nfn main() {\n  let mut vm: VM\u003c()\u003e = VM::new();\n\n  vm.push_integer(2);\n  vm.push_rust_function(square);\n  vm.call(1, FuncReturns::Exactly(1)).unwrap();\n\n  let res = vm.pop_integer().unwrap();\n  println!(\"{}\", res); // prints: 4\n}\n```\n\nUnlike **Lua**, the syntax is inspired by **Rust** and **Go**.\n\nExample:\n\n```\nfunc make_action(kind) {\n  func action(fn) {\n    print(kind \u003c\u003e \": \" \u003c\u003e fn() \u003c\u003e \"\\n\");\n  }\n\n  return action;\n}\n\nfunc greeter(name) {\n  func greet() {\n    return \"hello \" \u003c\u003e name;\n  }\n\n  return greet;\n}\n\nlet say := make_action(\"say\");\nlet greet := greeter(\"world\");\n\nsay(greet); // prints: say: hello world\n```\n\nTo provide your own Rust types to the VM:\n\n```rust\nuse airscript::prelude::*;\nuse airscript::interpreter::{VM, FuncReturns};\n\n#[derive(Debug, Clone)]\nstruct Vector {\n  pub x: f64,\n  pub y: f64,\n}\n\nfn vec_mag(vm: \u0026mut VM\u003cVector\u003e) -\u003e Result\u003cusize\u003e {\n  let v_ref = vm.pop_userdata()?;\n  let v = v.lock().unwrap();\n  let m = (v.x * v.x + v.y * v.y).sqrt();\n  vm.push_float(m);\n  Ok(1)\n}\n\nfn main() {\n  let mut vm: VM\u003cVector\u003e = VM::new();\n\n  vm.push_userdata(Vector { x: 3f64, y: 4f64 });\n  vm.push_rust_function(vec_mag);\n  vm.call(1, FuncReturns::Exactly(1)).unwrap();\n\n  let res = vm.pop_float().unwrap();\n  println!(\"{}\", res); // prints: 5\n}\n```\n\n## Disclaimer\n\nThis is still a **Work In Progress**:\n\n - the VM's API is not complete nor definitive\n - the syntax is not complete nor definitive\n - the semantics are not specified\n\n## License\n\nThis project is released under the terms of the [MIT License](./LICENSE.txt).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdd%2Fairscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkdd%2Fairscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdd%2Fairscript/lists"}