{"id":27096110,"url":"https://github.com/moxer-mmh/minisoft-compiler","last_synced_at":"2025-10-26T21:09:11.902Z","repository":{"id":286206065,"uuid":"951535204","full_name":"moxer-mmh/minisoft-compiler","owner":"moxer-mmh","description":"The MiniSoft Compiler is a complete compiler for the MiniSoft programming language. It implements a full compilation pipeline that includes lexical analysis, syntax parsing, semantic analysis, and intermediate code generation.","archived":false,"fork":false,"pushed_at":"2025-04-05T00:24:43.000Z","size":43,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T00:27:08.158Z","etag":null,"topics":["antlr4","compiler","java","junit5","maven"],"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/moxer-mmh.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-03-19T20:45:24.000Z","updated_at":"2025-04-05T00:24:47.000Z","dependencies_parsed_at":"2025-04-05T00:37:10.978Z","dependency_job_id":null,"html_url":"https://github.com/moxer-mmh/minisoft-compiler","commit_stats":null,"previous_names":["moxer-mmh/minisoft-compiler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxer-mmh%2Fminisoft-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxer-mmh%2Fminisoft-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxer-mmh%2Fminisoft-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxer-mmh%2Fminisoft-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moxer-mmh","download_url":"https://codeload.github.com/moxer-mmh/minisoft-compiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247458667,"owners_count":20942069,"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","compiler","java","junit5","maven"],"created_at":"2025-04-06T09:20:57.475Z","updated_at":"2025-10-26T21:09:11.890Z","avatar_url":"https://github.com/moxer-mmh.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MiniSoft Compiler\n\nA full-featured compiler implementation for the MiniSoft programming language, designed for educational purposes.\n\n## Project Overview\n\nThis project implements a compiler for the MiniSoft language, featuring a complete frontend with lexical analysis, syntax analysis, symbol table generation, and semantic analysis. The compiler is built using ANTLR4 for grammar definition and parsing, with Java as the implementation language.\n\n## Current Implementation Status\n\nThe compiler currently supports:\n\n- ✅ **Lexical Analysis**: Tokenization of MiniSoft source code using ANTLR4-generated lexer\n- ✅ **Syntax Analysis**: Parsing of tokens into an Abstract Syntax Tree using ANTLR4-generated parser\n- ✅ **Symbol Table Generation**: Collection and validation of program identifiers, types, and scopes\n- ✅ **Semantic Analysis**: Type checking, expression validation, and static error detection\n\n## Future Work\n\nThe following features are planned for future implementation:\n\n- ⏳ **Intermediate Code Generation**: Production of quadruples or other intermediate representation\n- ⏳ **Code Optimization**: Basic optimization techniques\n- ⏳ **Target Code Generation**: Compilation to executable format\n\n## Project Structure\n\n```\nminisoft-compiler/\n├── src/\n│   ├── main/\n│   │   ├── antlr4/com/minisoft/        # ANTLR grammar definitions\n│   │   │   └── MiniSoft.g4             # MiniSoft language grammar\n│   │   ├── java/com/minisoft/\n│   │   │   ├── Main.java               # Compiler entry point\n│   │   │   ├── SemanticAnalyzer.java   # Semantic analysis implementation\n│   │   │   ├── SymbolTableBuilder.java # Symbol table construction\n│   │   │   └── symbol/\n│   │   │       ├── SymbolEntity.java   # Symbol table entries\n│   │   │       └── SymbolTable.java    # Symbol table management\n│   │   └── resources/\n│   │       └── samples/                # Example MiniSoft programs\n│   │           └── example.ms          # Sample MiniSoft code\n├── target/                             # Generated and compiled files\n├── pom.xml                             # Maven project configuration\n├── compile-and-run.bat                 # Utility script for Windows\n└── run.bat                             # Script to run the compiler\n```\n\n## MiniSoft Language Features\n\nMiniSoft is a structured programming language with the following features:\n\n- **Program Structure**: Programs start with `MainPrgm` identifier and include declaration and executable sections\n- **Variable Declarations**: Using `let` keyword with support for multiple variables of the same type\n- **Constants**: Defined with `@define Const` syntax\n- **Data Types**:\n  - `Int`: Integer values\n  - `Float`: Floating-point numbers\n- **Arrays**: One-dimensional arrays with fixed size (`[type;size]` syntax)\n- **Comments**:\n  - Single-line: `\u003c! - text - !\u003e`\n  - Multi-line: `{-- text --}`\n- **Control Structures**:\n  - If-else statements: `if (condition) then { ... } else { ... }`\n  - Do-while loops: `do { ... } while (condition);`\n  - For loops: `for var from expr to expr step expr { ... }`\n- **Expressions**:\n  - Arithmetic operators: `+`, `-`, `*`, `/`\n  - Comparison operators: `\u003e`, `\u003c`, `\u003e=`, `\u003c=`, `==`, `!=`\n  - Logical operators: `AND`, `OR`, `!` (NOT)\n- **Input/Output**:\n  - Input: `input(variable);`\n  - Output: `output(\"message\", expression);`\n\n## Semantic Features and Error Checking\n\nThe compiler performs extensive semantic analysis including:\n\n- Type checking for expressions and assignments\n- Array bounds validation for constant indices\n- Variable declaration and scope validation\n- Constant modification prevention\n- Logical expression type validation\n- Division by zero detection (for constant expressions)\n- Loop control variable verification\n\n## Usage\n\n### Prerequisites\n\n- Java JDK 11 or higher\n- Maven 3.6 or higher\n\n### Building the Project\n\nTo build the compiler from source:\n\n```bash\nmvn clean package\n```\n\nThis will generate a JAR file with all dependencies in the `target` directory.\n\n### Running the Compiler\n\nYou can use the provided batch files for convenience:\n\n1. To build and test with the example file:\n\n   ```bash\n   .\\compile-and-run.bat\n   ```\n2. To compile a specific MiniSoft source file:\n\n   ```bash\n   .\\run.bat path/to/your/source.ms\n   ```\n\nAlternatively, you can run the JAR directly:\n\n```bash\njava -jar target/minisoft-compiler-1.0-SNAPSHOT-jar-with-dependencies.jar path/to/your/source.ms\n```\n\n### Compilation Output\n\nWhen successful, the compiler will display:\n\n- \"Compilation successful!\" message\n- The symbol table showing all identifiers, types, and properties\n- A parse tree visualization (GUI window)\n\nIf errors are detected, the compiler will report:\n\n- **Lexical Errors**: Issues with tokens and character recognition\n- **Syntax Errors**: Problems with the structure of the program\n- **Semantic Errors**: Including:\n  - Type mismatches\n  - Undeclared variables\n  - Double declarations\n  - Array bounds issues\n  - Constant modification attempts\n  - Invalid expressions\n\n## Example Code\n\n```\nMainPrgm L3_software;\nVar\n    \u003c! - Partie declaration - !\u003e\n    let x,y,z: Int;\n    let A,B:[Int;10];\n    @define Const Software: Int= 91 ;\nBeginPg\n{\n    {--Ceci est un commentaire sur\n    Plusieurs lignes --}\n    x := 5;\n    y := (x + 3) * 2;\n    \n    if (x \u003e 3) then\n    {\n        output(\"x is greater than 3\", x);\n    } else {\n        output(\"x is not greater than 3\", x);\n    }\n    \n    do {\n        x := x - 1;\n    } while (x \u003e 0);\n}\nEndPg;\n```\n\n## License\n\nThis project is intended for educational purposes.\n\n## Acknowledgements\n\nThis project was created as part of a compiler design course. The implementation follows standard compiler construction techniques and utilizes the ANTLR parser generator framework.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxer-mmh%2Fminisoft-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoxer-mmh%2Fminisoft-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxer-mmh%2Fminisoft-compiler/lists"}