From text you wrote to instructions a CPU runs.

A compiler is a translator with several passes. It reads your source, checks it makes sense, and lowers it step by step into machine code — optimizing along the way.

The classic phases

Lexing. Break the source into tokens: keywords, identifiers, literals.

Parsing. Assemble tokens into an abstract syntax tree following the grammar.