{"id":24227565,"url":"https://github.com/inner-byte/custom-compiler-design","last_synced_at":"2025-03-04T06:14:37.629Z","repository":{"id":271146161,"uuid":"912520991","full_name":"inner-byte/custom-compiler-design","owner":"inner-byte","description":"This project implements a full-featured compiler for a custom programming language, demonstrating modern compiler design principles and optimization techniques. The compiler follows the traditional multi-pass compilation process while incorporating advanced features like optimization frameworks and sophisticated register allocation. ","archived":false,"fork":false,"pushed_at":"2025-01-05T20:10:07.000Z","size":434,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T10:27:54.104Z","etag":null,"topics":["c","compiler","compiler-backend","compiler-design","compiler-frontend","compiler-optimization","computer-architecture","cpp","programming-challenge","programming-logic","programming-project"],"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/inner-byte.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-01-05T19:56:40.000Z","updated_at":"2025-01-05T20:15:12.000Z","dependencies_parsed_at":"2025-01-05T21:19:35.140Z","dependency_job_id":"ee1f36fd-ae76-4aab-9ebe-a8d32df26531","html_url":"https://github.com/inner-byte/custom-compiler-design","commit_stats":null,"previous_names":["inner-byte/custom-compiler-design"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inner-byte%2Fcustom-compiler-design","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inner-byte%2Fcustom-compiler-design/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inner-byte%2Fcustom-compiler-design/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inner-byte%2Fcustom-compiler-design/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inner-byte","download_url":"https://codeload.github.com/inner-byte/custom-compiler-design/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241794137,"owners_count":20021192,"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":["c","compiler","compiler-backend","compiler-design","compiler-frontend","compiler-optimization","computer-architecture","cpp","programming-challenge","programming-logic","programming-project"],"created_at":"2025-01-14T10:18:15.987Z","updated_at":"2025-03-04T06:14:37.603Z","avatar_url":"https://github.com/inner-byte.png","language":"C++","readme":"# Advanced Compiler Design Project\n\n## Overview\n\nThis project implements a full-featured compiler for a custom programming language, demonstrating modern compiler design principles and optimization techniques. The compiler follows the traditional multi-pass compilation process while incorporating advanced features like optimization frameworks and sophisticated register allocation.\n\n## Architecture\n\nThe compiler is structured into several major components:\n\n### Frontend\n- **Lexical Analysis**: \n  - Implemented using Flex for efficient token generation\n  - Handles source code tokenization with support for complex language constructs\n  - Located in [lexer.l](lexer.l) and [src/lexer.cpp](src/lexer.cpp)\n\n- **Parsing**:\n  - Built with Bison for robust grammar processing\n  - Generates Abstract Syntax Tree (AST) representation\n  - Implements error recovery mechanisms\n  - Core files: [parser.y](parser.y) and [src/parser.cpp](src/parser.cpp)\n\n### Middle-end\n- **Semantic Analysis**:\n  - Comprehensive type checking system ([src/type_system.cpp](src/type_system.cpp))\n  - Symbol table management for variable scoping ([src/symbol_table.cpp](src/symbol_table.cpp))\n  - Semantic error detection and reporting\n\n- **Optimization Framework**:\n  - Multiple optimization passes:\n    - Common subexpression elimination\n    - Dead code elimination\n    - Constant propagation\n    - Loop optimization\n  - Configurable optimization levels\n  - Implementation in [src/optimization.cpp](src/optimization.cpp)\n\n### Backend\n- **Code Generation**:\n  - Target-specific code emission\n  - Efficient instruction selection\n  - Located in [src/codegen.cpp](src/codegen.cpp)\n\n- **Register Allocation**:\n  - Graph coloring-based register allocation\n  - Register spilling handling\n  - Implemented in [src/register_allocator.cpp](src/register_allocator.cpp)\n\n## Building the Project\n\n### Prerequisites\n- CMake (3.10 or higher)\n- C++ compiler supporting C++17\n- Flex and Bison\n- Make\n\n### Build Options\n\n#### Using CMake (Recommended)\n```bash\nmkdir build \u0026\u0026 cd build\ncmake ..\nmake\n```\n\n#### Using Make\n```bash\nmake\n```\n\n## Project Structure\n\n```\n.\n├── include/           # Header files\n├── src/              # Source implementations\n├── test/             # Test suite\n├── lexer.l           # Flex lexer definition\n├── parser.y          # Bison parser grammar\n├── CMakeLists.txt    # CMake configuration\n└── Makefile         # Traditional build support\n```\n\n## Current Status\n\n### Implemented Features\n- Complete frontend pipeline (lexing, parsing)\n- Type system with static type checking\n- Basic optimization framework\n- Register allocation using graph coloring\n- Runtime support system\n\n### Roadmap\n1. **Short-term Goals**\n   - Enhance optimization passes\n   - Improve error reporting\n   - Extend type system\n\n2. **Medium-term Goals**\n   - Implement advanced optimizations\n   - Add cross-platform support\n   - Enhance debugging information\n\n3. **Long-term Vision**\n   - JIT compilation support\n   - Parallel compilation\n   - Language server protocol integration\n\n## Contributing\n\nWe welcome contributions! Please follow these steps:\n\n1. Fork the repository\n2. Create a feature branch\n3. Implement your changes\n4. Add tests for new functionality\n5. Submit a pull request\n\n### Development Guidelines\n- Follow the existing code style\n- Add documentation for new features\n- Ensure all tests pass\n- Update relevant documentation\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgments\n\n- The LLVM Project for inspiration\n- The GCC community for optimization insights\n- Contributors and maintainers\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finner-byte%2Fcustom-compiler-design","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finner-byte%2Fcustom-compiler-design","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finner-byte%2Fcustom-compiler-design/lists"}