{"id":25317295,"url":"https://github.com/morteza363831/simple-c-compiler","last_synced_at":"2026-05-09T10:26:32.378Z","repository":{"id":276793373,"uuid":"927025869","full_name":"Morteza363831/simple-c-compiler","owner":"Morteza363831","description":"A simple compiler for C language ","archived":false,"fork":false,"pushed_at":"2025-02-10T12:55:48.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T17:14:02.908Z","etag":null,"topics":["antlr4","c","compiler","java","lexer","maven","parser","semantic-analyzer","simple-compiler","three-address-code"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Morteza363831.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}},"created_at":"2025-02-04T09:26:02.000Z","updated_at":"2025-02-10T13:01:42.000Z","dependencies_parsed_at":"2025-02-10T13:49:43.596Z","dependency_job_id":null,"html_url":"https://github.com/Morteza363831/simple-c-compiler","commit_stats":null,"previous_names":["morteza363831/simple-c-compiler"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morteza363831%2Fsimple-c-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morteza363831%2Fsimple-c-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morteza363831%2Fsimple-c-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morteza363831%2Fsimple-c-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morteza363831","download_url":"https://codeload.github.com/Morteza363831/simple-c-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694876,"owners_count":20980733,"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":["antlr4","c","compiler","java","lexer","maven","parser","semantic-analyzer","simple-compiler","three-address-code"],"created_at":"2025-02-13T19:25:14.138Z","updated_at":"2026-05-09T10:26:32.302Z","avatar_url":"https://github.com/Morteza363831.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple C Language Compiler\n\nThis project is a **C language compiler** that includes a lexer, parser, semantic analyzer, and TAC (Three Address Code) generator. It was developed by [Morteza Mahdi Zadeh](https://github.com/Morteza363831) and [Soheil Nouhi](https://github.com/SoheilNouhi).\n\n---\n\n## 🚀 **Features**\n\n### **1. Grammar**\nThe compiler uses **ANTLR** to define the grammar for the C language. The grammar supports the following features:\n- **Function Declarations**: `int main() { ... }`\n- **Statements**:\n  - Expression statements (`x = 10;`)\n  - Return statements (`return x;`)\n  - Blocks (`{ ... }`)\n  - Printf statements (`printf(\"value is %d\", x);`)\n  - Control structures:\n    - **If-Else Statements** (`if (x \u003c 10) { ... } else { ... }`)\n    - **While Loops** (`while (x \u003e 0) { ... }`)\n    - **For Loops** (`for (int i = 0; i \u003c 10; i++) { ... }`)\n- **Variable Declarations and Assignments**:\n  - Supported types: `int`, `float`, `char`, `void`\n  - Example: `int x = 10;`\n- **Expressions**:\n  - Arithmetic operations (`+`, `-`, `*`, `/`, `^`)\n  - Comparison operators (`\u003c`, `\u003e`, `\u003c=`, `\u003e=`, `==`, `!=`)\n  - String, character, and numeric constants.\n\n---\n\n## 📂 **Project Structure**\nThe project is organized into the following packages:\n- **`org.compiler.antlr`**: Contains the `CLang.g4` grammar file.\n- **`org.compiler.lexer`**: Contains the `CLangLexer` for tokenizing the source code.\n- **`org.compiler.parser`**: Includes:\n  - `CLangParser` for parsing the tokens.\n  - `CLangBaseListener` and `CLangBaseVisitor` interfaces and their implementations.\n- **`org.compiler.semantic`**: Contains the `SemanticAnalyzer` for scope and type checking.\n- **`org.compiler.tac`**: Contains:\n  - `TacGenerator` for generating three-address code.\n  - `TacInstruction` for representing TAC instructions.\n\n---\n\n## 🛠️ **Running the Compiler**\n\n### **Clone the Repository**\n```bash\ngit clone https://github.com/Morteza363831/compiler.git\ncd compiler\n```\n### **Run the Main Program**\n```bash\nmvn exec:java -Dexec.mainClass=\"org.compiler.Main\"\n```\n### **Build the Project**\n```bash\nmvn clean package\n```\n### **Run Using the Jar File**\n\nA precompiled **JAR** file is available in the **Releases** section.\nTo run it :\n```bash\njava -jar compiler-1.0.jar\n```\n## 🤝 **Contributors**\nThanks to the following **developers** for their contributions:\n- [Morteza Mahdi Zadeh](https://github.com/Morteza363831)\n- [Soheil Nouhi](https://github.com/moonwinee)\n\n\n### **Notes:**\n- I added sections for features, contributors, and instructions for running the project.\n- If there's any additional information you'd like, let me know!\n#### **Contact with us**\n- Morteza Mahdi Zadeh's email : [morteza363831official@gmail.com](morteza363831official@gmail.com)\n- Soheil Nouhi's email : [soheilnohi83@gmail.com](soheilnohi83@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorteza363831%2Fsimple-c-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorteza363831%2Fsimple-c-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorteza363831%2Fsimple-c-compiler/lists"}