Which phase of the compiler is responsible for transforming source code into an intermediate representation (IR)?

The front end of the compiler scans the input, verifies syntax and semantics, and transforms the source code into an intermediate representation (IR) for further processing. The front end of a compiler encompasses several phases: lexical analysis, syntax analysis, and semantic analysis. These phases work together to transform the source code into an intermediate representation (IR). The primary tasks are to ensure that the code is syntactically and semantically correct and to produce an IR that abstracts away many of the language-specific details.