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.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Syntax Analysis

  • Hanspeter Mössenböck

摘要

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.