question: Explain the stages of the compilation process in compiler theory. Choose from the following: ("lexical analysis", "syntax analysis", "semantic analysis", "optimization", "code generation"). Please include the exact phrase "compilation process" in your response. Format: 5 bullet lists.
answer: - **Lexical Analysis**: The first stage in the compilation process where the source code is converted into tokens. These tokens represent the smallest units of meaning, such as keywords, operators, and identifiers.
  
  - **Syntax Analysis**: In this stage of the compilation process, the sequence of tokens is analyzed against the grammatical rules of the programming language to construct a parse tree, ensuring the code's structure is correct.
  
  - **Semantic Analysis**: During this stage of the compilation process, the compiler checks for semantic errors, ensuring that the syntax that passed the previous stage adheres to the language's meaning rules, such as type checking.
  
  - **Optimization**: This stage of the compilation process involves improving the intermediate code to make it more efficient, without altering its semantics, to enhance performance or reduce resource usage.
  
  - **Code Generation**: The final stage in the compilation process where the optimized intermediate code is translated into target machine code, making it executable on the intended hardware architecture.