The lexical analyzer, also known as a lexer or scanner, reads the source code and breaks it down into a sequence of tokens, which are meaningful units such as keywords, identifiers, operators, and literals.
The syntactic analyzer, also known as a parser, analyzes the sequence of tokens produced by the lexer and checks whether it conforms to the syntax rules of the programming language. It builds a parse tree or an abstract syntax tree, which represents the structure of the program in terms of the language's grammar.
The semantic analyzer checks the meaning of the program in terms of its context and purpose. It performs type checking, resolves references to variables and functions, and enforces other semantic rules of the language. It also generates intermediate code or machine code that can be executed by a computer.
All three analyzers work together to ensure that the source code is valid, meaningful, and executable in the desired programming language.
Java 8.2, JCup, JFlex, Java Swing 🍃