Compiler front end (source code)

= Compiler front end

A <compiler front end> reads a source language and checks or translates its meaning into a representation used by later <compilation> stages. <lexical analysis> groups characters into tokens; <parsing> builds structured syntax; name resolution and type checking establish which declarations and operations the program denotes. These responsibilities need not be implemented as completely separate passes.

For example, `x + 2 * y` must be grouped as `x + (2 * y)` under the usual precedence rules. The parser establishes that grouping, while semantic analysis determines whether `x` and `y` exist and support the requested operations. An <abstract syntax tree> can retain source locations for precise diagnostics. The LLVM Kaleidoscope tutorial shows this transition from parsed syntax to LLVM intermediate code.<LLVM 20.1.0 documentation/3. Kaleidoscope: Code generation to LLVM IR>[§§3.1 and3.5]{ref} The front end's language-facing checks complement the machine-facing decisions of a <compiler back end>.