Syntax Analysis
摘要
Syntax analysis (parsing) is the next phase after lexical analysis. This chapter explains how to write a parser for MicroJava using recursive descent as the parsing technique. The parser checks the syntactic correctness of the input program according to a given context-free grammar. We look at how to systematically derive parsing actions from the grammar. When the parser detects an error, it has to report it and then to recover in order to continue parsing and to detect further errors. For this purpose, we describe several error handling techniques. We also look at how to possibly transform a given grammar in order to make it suitable for recursive descent parsing.