{"id":16799747,"url":"https://github.com/bugenzhao/lime","last_synced_at":"2025-04-11T00:31:45.485Z","repository":{"id":54227894,"uuid":"337271015","full_name":"BugenZhao/Lime","owner":"BugenZhao","description":"🍋 A Rust/Swift-like modern interpreted programming language. First-class functions, first-class expressions, and functional techniques included!","archived":false,"fork":false,"pushed_at":"2021-03-02T10:12:24.000Z","size":962,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T21:47:29.189Z","etag":null,"topics":["functional","interpreter","language","peg","programming-language","rust","swift"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BugenZhao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-09T02:35:51.000Z","updated_at":"2024-02-20T04:44:29.000Z","dependencies_parsed_at":"2022-08-13T09:40:32.668Z","dependency_job_id":null,"html_url":"https://github.com/BugenZhao/Lime","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/BugenZhao%2FLime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BugenZhao%2FLime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BugenZhao%2FLime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BugenZhao%2FLime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BugenZhao","download_url":"https://codeload.github.com/BugenZhao/Lime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322123,"owners_count":21084333,"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":["functional","interpreter","language","peg","programming-language","rust","swift"],"created_at":"2024-10-13T09:29:43.800Z","updated_at":"2025-04-11T00:31:45.466Z","avatar_url":"https://github.com/BugenZhao.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lime\n\nA Rust/Swift-like modern interpreted programming language, hosted by Rust.\n\n- Serious PEG(Parsing Expression Grammar)-based parser\n- Most of the statements are expressions that have values\n- Dynamic but strict typing system\n- First-class functions with Rust's closure style\n- Functional techniques, like currying, composing, and higher-order function [WIP]\n- \"nil with cause\" error handling design and nil safety\n- REPL with friendly error reporting, auto-completer, syntax checker included\n- ...\n\n```swift\nclass Name { chn, eng }\nclass Student { name, age, gpa, langs }\n\nimpl Student {\n    assoc org = \"SJTU\";\n    assoc is_good = |self| { \n        self.gpa \u003e= 4.29\n    };\n    assoc print_name = |self| {\n        println(\"Chinese name:\", self.name.chn, \n                \"\\nEnglish name:\", self.name.eng);\n    };\n    assoc try_make_money = |self| {\n        if self.is_good() { 1000000000.0 }\n        else { nil.expect(\"there's no money for you\") }\n    };\n    assoc get_older = |self| {\n        self.age = self.age + 1;\n        nil\n    };\n}\n\nvar i = Student {\n    name: Name { chn: \"zq\", eng: \"bugen\" },\n    age: 20.3 as Int,\n    gpa: 1.7,\n    langs: [\"Lime\", \"Rust\"],\n};\n\ni.print_name();\nprintln(\"Is\", i.name.eng, \"a good student? =\u003e\", i.is_good());\n\ni.langs.map(|lang| { \"Hello, \" + lang + \"!\" }).map(println);\n\nvar money? = i.try_make_money();\nif var money = money? {\n    money = money * 0.7;  // tax :P\n    println(\"Wow! I've made $\", money);\n} else {\n    println(\"Oh-no! I failed since\", money?.cause());\n}\n\nvar rep = |n, fn| { || {\n    for _ in 0..n { fn(); }\n}; };\n\nvar i_get_older = i.get_older;\nvar i_get_much_older = rep(10, i_get_older);\n\ni_get_much_older();\nassert_eq(i.age, 30);\n\nnil;\n```\n\n## Demos\n\n### REPL\n[![asciicast](https://asciinema.org/a/xp5O4UQEfQCDT1ZePhdR219gi.svg)](https://asciinema.org/a/xp5O4UQEfQCDT1ZePhdR219gi)\n\n### Error Reporting\n![error-reporting](docs/error-reporting.png)\n\n## Roadmap\n\n### Lime\n\n- [x] peg-based grammar\n- [x] a basic calculator\n- [x] variable set and get\n- [x] primitive types and cast expression\n    - [x] literal overflow handling\n- [x] more binary and unary ops\n- [x] `print` \u0026 `assert` statements\n- [x] block expression and scope\n- [x] control flow\n    - [x] `if`\n    - [x] `while`\n        - [x] default branch\n        - [x] continue \u0026 break with values\n    - [x] `for in`\n    - [x] make them expressions\n- [x] `nil` and `nil` safety\n    - [x] `nil`...\n    - [x] ...with cause\n    - [x] allow `name?` to hold `nil`\n    - [x] `nil` check on fields and assocs\n- [x] function types and function call\n- [ ] function\n    - [x] arity check\n    - [x] rust native funcs as built-in functions\n        - [x] replace `print` stmt with `print` func\n        - [x] I/O: `readln`, `time`\n        - [x] `panic` and LimeError\n        - [ ] ...\n    - [ ] functional\n        - [ ] composed\n        - [x] partial-applied\n        - [ ] higher-order functions\n            - [x] map\n            - [x] fold\n            - [ ] ...\n        - [ ] ...\n    - [x] lime function (closure)\n    - [x] `return` statement\n- [x] resolver\n    - [x] preprocess assert stmt\n    - [x] semantic analysis for variable binding\n    - [ ] `break` `continue` `return` static analysis\n- [x] a small lime-hosted prelude standard library\n- [x] add force-cmp and ref-cmp ops\n- [ ] object\n    - [x] refactor a lot for pass-by-ref types\n    - [x] class decl and object construction\n    - [x] built-in (deep)copy func\n    - [x] get field\n    - [x] set field\n    - [x] `impl` block\n        - [x] class-associated funcs\n        - [x] class-associated fields\n    - [x] `assoc` func call\n    - [ ] magic assocs\n        - [x] `iter` and `next`\n        - [x] `equals`\n        - [x] `finalize`\n        - [x] `to_string`\n        - [ ] ...\n    - [ ] anonymous fields\n    - [ ] casting\n    - [ ] indexing `[]`\n    - [x] primitive values as objects\n    - [ ] ...\n- [x] error handling\n    - [x] panic\n    - [x] backtrace for lime error\n    - [x] backtrace for all error\n    - [x] recoverable Lime errors\n        - [x] nil with cause design\n            - [x] is_some, is_nil, cause, expect\n        - [x] sugars\n            - [x] if var\n            - [x] while var\n    - [ ] ...\n- [x] friendly error reporting\n    - [ ] ... with backtrace\n- [ ] pass-by-value `struct` object\n    - [ ] refactor object clone logic\n    - [ ] syntax\n    - [ ] ...\n- [ ] `enum` type\n    - [ ] pattern match\n- [ ] string interpolation / runtime format\n- [ ] immutable value\n- [ ] trait / duck type\n- [ ] fix potential cyclic references\n\n\n\n### Lime REPL\n\n- [x] Read! Eval! Print! Loop!\n- [ ] auto-completer\n    - [x] global-scoped hints\n    - [x] token-based hints\n    - [ ] analysis while typing\n- [x] syntax checker\n    - [x] bracket pair checker\n    - [x] lime syntax checker\n    - [x] lime semantics analysis\n- [ ] highligher\n    - [x] bracket pair\n    - [ ] lime literal\n    - [ ] lime keyword\n    - [ ] lime syntax\n- [ ] special commands\n    - [x] basic `:ls`\n    - [x] basic `:help`\n    - [ ] ...\n- [ ] web-assembly build\n\n\n### Lime Standard Library\n\n- [ ] built-in classes\n    - [x] `Vec`\n    - [x] `Range`\n    - [ ] `HashMap`\n    - [ ] `HashSet`\n    - [ ] string utilities\n    - [x] literals\n    - [x] iterators\n    - [ ] ...\n- [ ] higher-order funcs\n    - [x] `map`\n    - [x] `fold`\n    - [ ] generic\n    - [ ] ...\n- [ ] I/O\n    - [x] `print` \u0026 `println`\n    - [x] `readln`\n    - [ ] file r/w\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugenzhao%2Flime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugenzhao%2Flime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugenzhao%2Flime/lists"}