SmallC Compiler - ECE467
Compiler diagram. Image from T. Abdelrahman, in Compilers and Interpreters, 2023
In my ECE467 (compilers) class, I undertook the development of a compiler for a subset of C, termed SmallC. This comprehensive project not only tested my programming skills but also deepened my understanding of compiler construction and optimization techniques.
Key Contributions:
- Grammar Definition and Parser Implementation:
-
Created a formal grammar for SmallC and implemented a robust parser using ANTLR4.
-
Translated parsed code into an abstract syntax tree (AST), laying the foundation for subsequent processing steps.
-
- Semantic Checker in C++:
-
Developed a semantic checker in C++ to ensure code adherence to SmallC language standards.
-
This step was crucial in identifying and rectifying potential errors before code generation.
-
- Intermediate Code Generation:
-
Generated intermediate code from the validated AST, a pivotal step in making the code platform-independent.
-
Set the stage for further optimization and eventual translation to machine-specific code.
-
- Insights into Optimization Techniques:
- Learned about optimization passes, gaining insights into how compilers enhance code efficiency.
Key Takeaways:
- Holistic Understanding of Compilation Process:
-
Gained a comprehensive understanding of the compilation process from parsing and semantic checking to code generation and optimization.
-
Developed skills to address challenges at each stage of the compiler pipeline.
-
- Impact on Coding Practices:
-
Acquired valuable insights into how code is compiled and optimized, directly influencing my day-to-day coding practices.
-
Strengthened ability to write efficient and optimized code by leveraging compiler principles.
-
Conclusion:
The SmallC Compiler project in ECE467 was a pivotal experience that sharpened my programming and problem-solving skills while providing a holistic understanding of the intricate compilation process. This endeavor not only expanded my knowledge in compiler construction but also equipped me with practical insights applicable to future coding endeavors.