{"id":23665614,"url":"https://github.com/zuojianfa/ca-lang","last_synced_at":"2025-09-01T18:32:04.077Z","repository":{"id":269898395,"uuid":"858641847","full_name":"zuojianfa/ca-lang","owner":"zuojianfa","description":"CA is a new programming language, has similar grammar to rust, compatible with C ABI, support calling C functions directly, support for JIT execution, support garbage collections","archived":false,"fork":false,"pushed_at":"2024-09-21T04:12:36.000Z","size":1165,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"generic","last_synced_at":"2024-12-27T02:38:52.984Z","etag":null,"topics":["compiler-design","llvm","programming-language","rust"],"latest_commit_sha":null,"homepage":"","language":"LLVM","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mulanpsl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zuojianfa.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-09-17T09:19:47.000Z","updated_at":"2024-12-26T15:59:08.000Z","dependencies_parsed_at":"2024-12-27T04:16:14.728Z","dependency_job_id":null,"html_url":"https://github.com/zuojianfa/ca-lang","commit_stats":null,"previous_names":["zuojianfa/ca-lang"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuojianfa%2Fca-lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuojianfa%2Fca-lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuojianfa%2Fca-lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuojianfa%2Fca-lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuojianfa","download_url":"https://codeload.github.com/zuojianfa/ca-lang/tar.gz/refs/heads/generic","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231705088,"owners_count":18413950,"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-design","llvm","programming-language","rust"],"created_at":"2024-12-29T06:13:54.249Z","updated_at":"2024-12-29T06:14:01.372Z","avatar_url":"https://github.com/zuojianfa.png","language":"LLVM","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The CA Programming Language\n\n## 🌟 About\n\nCA is a programming language which has similar grammars as rust language, similar to C language in many features, compatible with C ABI, support calling C functions directly without any matching and transformation. It uses Mark-and-Sweep style garbage collections for it's memory management.\n\nCA compiler uses LLVM as its backend, and uses JIT or AOT technology in LLVM to run program directly without compile. Currently, CA compiler is under development, it has already realized most of grammars, but still have a lot of works to do. \n\nFor language details see the book: [CA book](book/ca-book.md).\n\n## ⚡ Quick Code\n\n### Getting Started\n\nHere’s a simple example to help you get started quickly:\n\n```rust\n// Example of basic functionality\nfn main() {\n    let greeting = \"Hello, CA!\\n\";\n    print(greeting);\n}\n```\n\n### Key Features\n\n#### Function Definition\n\n```rust\nfn add(a: i32, b: i32) -\u003e i32 {\n    return a + b;\n}\n```\n\n### Advanced Example\n\nHere’s a more advanced code snippet showcasing a feature:\n\n```rust\n// quickcode.ca\n\n// introduce external function\nextern fn printf(fmt: *char, ...) -\u003e i32;\n\nfn fibonacci_at(index: i32) -\u003e u64 {\n    if (index == 0 || index == 1) {\n        return 1;\n    }\n\n    let a = 1u64;\n    let b = 1u64;\n    let c = 0;\n    let t = 0u64;\n    index -= 1;\n    while (c \u003c index) {\n        t = a;\n        a = b;\n        b = t + a;\n        c = c + 1;\n    }\n\n    return b;\n}\n\nstruct Integer {\n    value: i64\n}\n\nimpl Integer {\n    fn new(value: i64) -\u003e Integer {\n        return Integer {value};\n    }\n\n    fn fibonacci(self) -\u003e u64 {\n        return fibonacci_at(self-\u003evalue as i32);\n    }\n}\n\nfn main() -\u003e i32 {\n    // define variable, whose type is inferred from the right-hand side value\n    let f10 = fibonacci_at(10);\n    printf(\"fibonacci number at 10 is: %llu\\n\", f10);\n    \n    // print the type information of variable f10\n    print \"return type is: \";\n    dbgprinttype(typeof(f10));\n\n    // create an Integer instance\n    let v1 = Integer::new(30);\n    printf(\"\\nfibonacci number at 30 is: %llu\\n\", v1.fibonacci()); \n    \n    print \"return type is: \";\n    dbgprinttype(typeof(v1));\n    return 0;\n}\n```\n\nRun result:\n\n```\nfibonacci number at 10 is: 89\nreturn type is: size = 8, type: t:u64\n\nfibonacci number at 30 is: 1346269\nreturn type is: size = 8, type: t:{Integer;value:i64}\n```\n\n## 🌟 Features\n\n- **CA is static type language**\n- **Supports optimization through LLVM IR.**\n- **Supports JIT functionality that run from source file directly**\n- **Supports compile CA source file into native executable file: ELF file on linux**\n- **Supports compile CA source file into readable IR assembly file `.ll`**\n- **Supports compile CA source file into native (as) assembly file: `.s`**\n- **Supports debug with gdb debugger**\n- **The object file compatible with C ABI**\n- **Internal Support standard C library functions**\n- **Supports garbage collection feature using GC**\n- **Supports run as script feature, with `-main` option**\n- **Supports generate `.dot` file to show the graph of grammar tree**\n- **Supports llvm12 or llvm13 library**\n- **Supports compile unit which adhering with C ABI**\n- **Include the whole test cases in the source code**\n\n## 📜 Supported Grammars\n\nThe grammar of CA language is similar to rust language in most cases. For the details see [CA book](book/ca-book.md). Here list some of the special grammars in CA.\n\n- **Support pointer like in C language**\n- **Support array convert to pointer**\n- **Support char array convert into string type**\n- **Support `print` or `dbgprint`statement for debugging purpose, which can print any value**\n- **Support `dbgprinttype` statement which is used to print the type informations**\n- **Support `typeof` statement to get the type of a variable dynamically, also support and then use the type to define another variable**\n- **The CA variable is mutable**\n- **Support binary number literals**\n- **Support zero Initialization keyword `__zero_init__`**\n- **support `box`, `drop` grammar for memory management**\n- **support pointer in `for .. in` statement**\n- **support `goto` statement**\n\n## 🛡️ License\nThis project is licensed under the Mulan PSL v2 License. You may obtain a copy of the license at http://license.coscl.org.cn/MulanPSL2.\n\n## ✍️ Author\n\n​\t**Rusheng Xia**\n\n- **Organization:** Rocket Software\n- **GitHub:** [github.com/zuojianfa](https://github.com/zuojianfa)\n  Explore my projects and contributions!\n- **LinkedIn:** [linkedin.com/in/zuojianfa](https://www.linkedin.com/in/zuojianfa)\n  Connect with me for professional networking!\n\n## 📫 Contact Information\n\nHave questions, suggestions, or want to contribute? Feel free to reach out!\n\n- **Email:** [xrsh_2004@163.com](mailto:xrsh_2004@163.com)\n\nLooking forward to hearing from you!\n\n## 🚀 Roadmap for the Language\n\n### Core Language Features\n\n- **Support for String Type in Language Level**\n- **Generic Programming**\n- **Union Types**\n- **Enumerated Types (Tagged Union Types)**\n- **Function Pointers**\n- **Module System**\n\n### Language Structure and Organization\n\n- **Compile Units Management**.\n- **Interfaces between Compile Units**: Establish mechanisms for communication and data sharing between different compile units, crucial for modularity and reusability.\n- **External Libraries Interactive**: Providing mechanisms for integrating external libraries can expand the language's capabilities and ecosystem.\n- **Package Management Tools**\n- **Runtime Libraries**\n\n### Language Features and Constructs\n\n- **Match Statement**\n- **Trait Objects and Polymorphism**\n- **Multi-line Comments (`/* ... */`)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuojianfa%2Fca-lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuojianfa%2Fca-lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuojianfa%2Fca-lang/lists"}