{"id":31536432,"url":"https://github.com/aabanakhtar/mini-c-compiler","last_synced_at":"2026-04-13T01:34:11.075Z","repository":{"id":306511043,"uuid":"1008454876","full_name":"aabanakhtar/mini-c-compiler","owner":"aabanakhtar","description":"LLVM based compiler for a subset of C","archived":false,"fork":false,"pushed_at":"2025-09-21T02:14:09.000Z","size":224,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-04T07:23:17.354Z","etag":null,"topics":["c","compilers","ir","lexer","llvm","parsing"],"latest_commit_sha":null,"homepage":"","language":"C++","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/aabanakhtar.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-25T15:10:25.000Z","updated_at":"2025-09-21T02:14:12.000Z","dependencies_parsed_at":"2025-07-26T05:56:37.469Z","dependency_job_id":"19791867-522a-4bbd-91d3-061f63511b8d","html_url":"https://github.com/aabanakhtar/mini-c-compiler","commit_stats":null,"previous_names":["aabanakhtar-github/baby-c","aabanakhtar-github/mini-c-compiler","aabanakhtar/mini-c-compiler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aabanakhtar/mini-c-compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabanakhtar%2Fmini-c-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabanakhtar%2Fmini-c-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabanakhtar%2Fmini-c-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabanakhtar%2Fmini-c-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aabanakhtar","download_url":"https://codeload.github.com/aabanakhtar/mini-c-compiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabanakhtar%2Fmini-c-compiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31736723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T22:19:12.206Z","status":"ssl_error","status_checked_at":"2026-04-12T22:18:33.088Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["c","compilers","ir","lexer","llvm","parsing"],"created_at":"2025-10-04T07:16:32.029Z","updated_at":"2026-04-13T01:34:11.067Z","avatar_url":"https://github.com/aabanakhtar.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mini-c\n### Watch an explanation by clicking down here\n\n[![Watch the video](https://img.youtube.com/vi/rlQPR69gjhY/0.jpg)](https://www.youtube.com/watch?v=rlQPR69gjhY)\n\n\nMini-C is a compiler for a restricted subset of the C programming language, written in C++ using LLVM's backend. It is primarily built to learn how the LLVM backend cooperates with a frontend. \n\nExample Input: \n```c\nint add(int a, int b)\n{\n        return a + b;\n}\n\n\nint main() {\n        return add(2, 3);\n}\n```\n\nCorresponding Output:\n```llvm\n; ModuleID = 'main'\nsource_filename = \"main\"\n\ndefine i32 @add(i32 %a, i32 %b) {\nentry:\n  %a.addr = alloca i32, align 4\n  store i32 %a, ptr %a.addr, align 4\n  %b.addr = alloca i32, align 4\n  store i32 %b, ptr %b.addr, align 4\n  %loadedVal = load i32, ptr %a.addr, align 4\n  %loadedVal1 = load i32, ptr %b.addr, align 4\n  %0 = add i32 %loadedVal, %loadedVal1\n  ret i32 %0\n}\n\ndefine i32 @main() {\nentry:\n  %callresult = call i32 @add(i32 2, i32 3)\n  ret i32 %callresult\n}\n```\n\n## Features\n- Simple lexer based on a large switch\n- Recursive Descent Parsing using `std::variant`\n- Semantic Analysis using recursive descent\n- Supports core C language features:\n  - `int` type\n  - `while`, `if`, and `else` statements\n  - Function declarations of type `int` and `void`\n\n## Requirements\n- C++20 compiler (tested with GCC and Clang)\n- LLVM (version 15 or newer recommended)\n- CMake\n\n## Building\nFirst, ensure LLVM is installed and available via `find_package`.  \nOn Linux, you may need to install LLVM development packages, for example:\n\n```sh\nsudo apt-get install llvm-dev clang\n```\n\nThen, build the CMake Project\n```sh\nmkdir build\ncd build\ncmake -G .. \ncmake --build . \n```\n\nThen, run the project:\n\n```sh\n./mini-c-compiler main.c \n``` \n\nThe project will spit out an llvm IR file, which you can compile using clang. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabanakhtar%2Fmini-c-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faabanakhtar%2Fmini-c-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabanakhtar%2Fmini-c-compiler/lists"}