清华大学:《编译原理》课程教学资源_(英文译文)Chapter 4.1 Top-Down Parsing byRecursive-Descent

COMPILER CONSTRUCTION Principles and practice Kenneth C. louden
COMPILER CONSTRUCTION Principles and Practice Kenneth C. Louden

4. Top-Down Parsing PART TWO
4. Top-Down Parsing PART TWO

Contents PART ONE 4. 1 Top-Down Parsing by recursive-Descent 4.2Ll(I) Parsing More PART TWO 4.3 First and Follow Sets More 4.4A Recursive-Descent Parser for the tiny Language More 4. 5 Error recovery in Top-Down Parsers
Contents PART ONE 4.1 Top-Down Parsing by Recursive-Descent 4.2 LL(1) Parsing [More] PART TWO 4.3 First and Follow Sets [More] 4.4 A Recursive-Descent Parser for the TINY Language [More] 4.5 Error Recovery in Top-Down Parsers

4. 1 Top-Down Parsing by Recursive-Descent
4.1 Top-Down Parsing by Recursive-Descent

4.2LL(1) Parsing
4.2 LL(1) Parsing

4.2.1 The Basic Method oflL(1) Parsing
4.2.1 The Basic Method of LL(1) Parsing

Main idea LL(1 Parsing uses an explicit stack rather than recursive calls to perform a parse An example d a simple grammar for the strings of balance parentheses S→(S)S|e The following table shows the actions of a top down parser given this grammar and the string o
Main idea • LL(1) Parsing uses an explicit stack rather than recursive calls to perform a parse • An example: – a simple grammar for the strings of balanced parentheses: S→(S) S∣ε • The following table shows the actions of a topdown parser given this grammar and the string ( )

Table of actions Steps Parsing Stack Input Action SS ()$ (S)S SS)S( ()$ match SS)S )$ →)£ 4 SS) )$ match SS S→ε accept
Table of Actions Steps Parsing Stack Input Action 1 $S ( ) $ S→(S) S 2 $S)S( ( ) $ match 3 $S)S )$ S→ε 4 $S) )$ match 5 $S $ S→ε 6 $ $ accept

General schematic a top-down parser begins by pushing the start symbol onto the stack It accepts an input string if, after a series of actions, the stack and the input become empty A general schematic for a successful top-down parse S Start Symbol Inputstring s //one of the two actions one of the two actions acce
General Schematic • A top-down parser begins by pushing the start symbol onto the stack • It accepts an input string if, after a series of actions, the stack and the input become empty • A general schematic for a successful top-down parse: $ StartSymbol Inputstring$ … … //one of the two actions … … //one of the two actions $ $ accept

TWO Actions The two actions Generate: Replace a non-terminal a at the top of the stack by a string a(in reverse) using a grammar rule a-a, and Match: Match a token on top of the stack with the next input token The list of generating actions in the above table S→>(S)S[S→(S)S] (S[S→→8 ()[S → E Which corresponds precisely to the steps in a leftmost derivation of string This is the characteristic of top-down parsing
Two Actions • The two actions – Generate: Replace a non-terminal A at the top of the stack by a string α(in reverse) using a grammar rule A →α, and – Match: Match a token on top of the stack with the next input token. • The list of generating actions in the above table: S => (S)S [S→(S) S] => ( )S [S→ε] => ( ) [S→ε] • Which corresponds precisely to the steps in a leftmost derivation of string ( ). • This is the characteristic of top-down parsing
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 4.1 Top-Down Parsing by Recursive-Descent.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 5.3 SLR(1)Parsing.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 5.1 Overview of Bottom-UpParsing.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8.6 Code Generation in Commercial Compilers:Two Case Studies.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8.1 Intermediate Code and Data.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8 Code Generation.ppt
- 《NFS报文分析》讲义.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)What makes a good manager.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)Ten attributes of a good employee.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:9 Project Procurement Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:8 Project Risk Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:7 Project Communication Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:6 Project HR Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:5 Project Cost Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:4 Project Time Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:3 Project Scope Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:2 Project The Project Management Context and Processes.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:1 Introduction to Project Management.ppt
- 深圳职业技术学院:《C语言程序设计》第九单元:共用体,枚举(乌云高娃).pdf
- 深圳职业技术学院:《C语言程序设计》第八单元:结构体(乌云高娃).pdf
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 1.1 Why? A Brief History.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.1 Memory Organization During Program Execution.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.4 Dynamic Memory.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.1 Attributes and AttributeGrammars.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.3 The Symbol Table.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 3.1 The Parsing Process.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 2.1 The Scanning Process.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 2.4 From Regular Expression To DFAs.ppt
- 《多媒体技术》课程教学资源(PPT课件讲稿).ppt
- 《JAVA基础实例200题》Java例题(一).pdf
- 《JAVA基础实例200题》Java例题(二).pdf
- 《JAVA基础实例200题》Java例题(三).pdf
- 《JAVA基础实例200题》Java例题(四).pdf
- 《JAVA基础实例200题》Java例题(五).pdf
- 《JAVA基础实例200题》练习题.pdf
- 长江大学:《微型计算机技术及应用课件》第一章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第七章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第三章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第九章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第二章习题答案(李华贵).doc