Lexical Analysis
Lexical analysis is the first phase of compiler design, where the source code is converted into a sequence of tokens. Tokens are the basic building blocks of a programming language, representing keywords, operators, identifiers, and symbols. This process helps in simplifying the code for further analysis and processing.
During lexical analysis, a tool called a lexer or scanner reads the input code and identifies these tokens while ignoring whitespace and comments. The output is a structured representation that can be easily understood by the next phase of the compiler, known as parsing, which organizes the tokens into a syntax tree.