{"id":31762258,"url":"https://github.com/rossadrian/minlang","last_synced_at":"2026-05-19T05:43:33.408Z","repository":{"id":308717768,"uuid":"1022692429","full_name":"RossAdrian/minLang","owner":"RossAdrian","description":"A Minimalist Programming Language.","archived":false,"fork":false,"pushed_at":"2025-08-07T12:14:56.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-07T14:19:34.037Z","etag":null,"topics":["compiler","compiler-construction","compiler-design","ocaml","programming-language","rust"],"latest_commit_sha":null,"homepage":"https://ross-agentur.de","language":"OCaml","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/RossAdrian.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,"zenodo":null}},"created_at":"2025-07-19T16:10:26.000Z","updated_at":"2025-08-07T12:14:59.000Z","dependencies_parsed_at":"2025-08-07T14:31:40.145Z","dependency_job_id":null,"html_url":"https://github.com/RossAdrian/minLang","commit_stats":null,"previous_names":["rossadrian/minlang"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/RossAdrian/minLang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RossAdrian%2FminLang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RossAdrian%2FminLang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RossAdrian%2FminLang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RossAdrian%2FminLang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RossAdrian","download_url":"https://codeload.github.com/RossAdrian/minLang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RossAdrian%2FminLang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002124,"owners_count":26083307,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["compiler","compiler-construction","compiler-design","ocaml","programming-language","rust"],"created_at":"2025-10-09T22:17:27.188Z","updated_at":"2025-10-09T22:17:29.282Z","avatar_url":"https://github.com/RossAdrian.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧵 MinLang — A Minimalist Programming Language\n\nMinLang is a compact, clean, and expressive programming language designed for educational, experimental, and low-overhead compiler development. With just a handful of core features, MinLang makes it easy to explore compiler design, code generation, and systems programming in OCaml.\n\nThis repository includes **`mincc.ml`**, a single-file compiler that transforms MinLang source code into assembly.\n\n## 🔧 Language Features\n\nMinLang draws inspiration from C, while stripping the syntax down to the essentials. Here's what the language supports:\n\n- **Primitive types**: `int`, `char`, `ptr\u003cT\u003e` (pointers)\n- **Variable declarations** with type inference (i.e. `let x = 0;`, optionally `let x: int = 0`)\n- **Functions** with typed parameters and return values\n- **Function calls**: Nested function calls result in undefined behavior\n- **Basic expressions** and operators:\n  - Binary: `+`, `-`, `*`, `/`, `%`, `==`, `!=`, `\u003c`, `\u003e`, `\u003c=`, `\u003e=`, `=`\n  - Unary: `!`, `*` (dereference), `\u0026` (address-of)\n- **Return statements**\n- No runtime, no standard library—just minimal code and direct control\n\n## 🔧 Status\n\nMinLang is an experimental programming language not meant to be used in production. Up to now, it includes\nseveral features, but contains some limits:\n\n- No vaiadic functions\n- No position independent binaries\n- Until now, only x64 assembler output is tested\n- No nested function calls (no compiler rejection, but execution is undefined behavior)\n\nAlso, this project is currently *WIP*. The following features are still under construction:\n\n- More x64 tests\n- RISC-V testing infrastructure\n- Add support for variadic C function calls (i.e. `fn printf(fmt: ptr\u003cchar\u003e, ...): int;` declaration support)\n\n## 💻 Example\n\n```minlang\nfn square(x: int): int {\n    return x * x;\n}\n\nfn main(): int {\n    let a: int = 5;\n    let b: int = square(a);\n    return b;\n}\n```\n\n## 🚀 Using the Compiler\n\nThe compiler is implemented in OCaml as a single file: `mincc.ml`. To build and run:\n\n### 1️⃣ Build the Compiler\n\n```bash\nocamlc -o mincc mincc.ml\n```\n\n### 2️⃣ Compile a MinLang Source File\n\nTo compile a *minLang* source file to an executable, run the\nfollowing script (x64 linux):\n\n```bash\n# Compile the source file to assembler code\n./mincc -c input.minLang -o output.asm -a nasm\n\n# Assemble assembly code to object file\nnasm -felf64 output.asm -o output.o\n\n# Link object file with C standard library\ngcc -fno-pie -no-pie output.o -o Output\n```\n\n### Using a standard library\n\nBy default, *minLang* is linked with the *C standard library*\nby linking with *gcc*. You can freely access library functions\nby declaring function prototypes:\n\n```minLang\nfn printf(ptr\u003cchar\u003e): int;\nfn exit(int): int;\n\nfn main(): int {\n  printf(\"Hello World!\\n\");\n  return exit(1);\n}\n```\n\nOr for example using files:\n\n```minLang\nfn fopen(ptr\u003cchar\u003e, ptr\u003cchar\u003e): ptr\u003cvoid\u003e;\nfn fclose(ptr\u003cvoid\u003e);\nfn fputs(ptr\u003cchar\u003e, ptr\u003cvoid\u003e);\n\nfn main(): int {\n    let msg = \"Hello world!\\n\";\n\n    let fd = fopen(\"hello.txt\", \"w\");\n\n    fputs(msg, fd);\n    fclose(fd);\n    return 0;\n}\n```\n\n### Parameters\n\n- `-c \u003cinput\u003e`: MinLang source file to compile\n- `-o \u003coutput\u003e`: Output assembly file\n- `-a \u003casm\u003e`: Assembler dialect\n  - `riscv`: Generate *32bit RISC-V* code\n  - `ir`: Dump *IR (Intermediate Representation)* code\n  - `nasm`: Generate *64bit x64 NASM assembler* code\n\n## 📦 Output\n\nThe compiler emits x86 assembly code with basic structure, suitable for further compilation via `nasm`, `gcc`, or similar tools.\n\n## 🧪 Goals\n\nMinLang is designed for:\n\n- Learning compiler internals\n- Playing with parsing, ASTs, and code generation in OCaml\n- Keeping things as simple as possible—and nothing more\n\n## 📚 License\n\nThis project is open source under the MIT License. See the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossadrian%2Fminlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frossadrian%2Fminlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossadrian%2Fminlang/lists"}