
Chapter 3
Parsing
3.1 Introduction
Once we have identified the tokens in our program, we then want to determine its syntactic
structure. That is, we want to put the tokens together to make the larger syntactic entities:
expressions, statements, methods, and class definitions. This process of determining the
syntactic structure of a program is called parsing.
First, we wish to make sure the program is syntactically valid—that it conforms to the
grammar that describes its syntax. As the parser parses the program it should identify
syntax errors and report them and the line numbers they appear on. Moreover, when the
parser does find a syntax error, it should ...