This project is the construction of a compiler for a simple programming language. We're building a compiler from scratch to deepen our understanding of how programming languages are processed and executed.
- Understand the fundamental stages of compilation
- Implement each component of a basic compiler
- Create a simple programming language to compile
- Generate executable code or interpretable bytecode
Our compiler will include the following stages:
- Lexical Analysis: Tokenizing the input source code
- Syntax Analysis: Parsing tokens into an Abstract Syntax Tree (AST)
- Semantic Analysis: Checking for semantic errors and type checking
- Intermediate Code Generation: Creating an intermediate representation
- Code Optimization: Improving the intermediate code (optional)
- Code Generation: Producing the target code (e.g., assembly or bytecode)
Our simple programming language will support the following features:
- Variables: Declaring and initializing variables
- Arithmetic Operations: Addition, subtraction, multiplication, division
- Control Structures:
ifstatements,forloops - Functions: Defining and calling functions