清华大学:《编译原理》课程教学资源_(英文译文)Chapter 3.1 The Parsing Process

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

3. Context-Free Grammars and Parsing PART ONE
3. Context-Free Grammars and Parsing PART ONE

Contents PART ONE 3. 1 The Parsing Process More 3.2 Context-Free Grammars More 3.3 Parse Trees and abstract More 3.4 Ambiguity More PART TWO 3.5 Extended Notations EBNF and Syntax diagrams 3.6 Formal Properties of Context-Free Languages 3. 7 Syntax of the tINY Language
Contents PART ONE 3.1 The Parsing Process [More] 3.2 Context-Free Grammars [More] 3.3 Parse Trees and Abstract [More] 3.4 Ambiguity [More] PART TWO 3.5 Extended Notations: EBNF and Syntax Diagrams 3.6 Formal Properties of Context-Free Languages 3.7 Syntax of the TINY Language

Introduction Parsing is the task of Syntax Analysis Determining the syntax, or structure, of a program The syntax is defined by the grammar rules of a context-Free grammar The rules of a context-free grammar are recursive The basic data structure of Syntax Analysis Is parse tree or syntax tree The syntactic structure of a language must also be recursive
Introduction • Parsing is the task of Syntax Analysis • Determining the syntax, or structure, of a program. • The syntax is defined by the grammar rules of a Context-Free Grammar • The rules of a context-free grammar are recursive • The basic data structure of Syntax Analysis is parse tree or syntax tree • The syntactic structure of a language must also be recursive

3.1 The Parsing Process
3.1 The Parsing Process

Function of a parser Takes the sequence of tokens produced by the scanner as its input and produces the syntax tree as its output arser Sequence of tokens Syntax-Tree
Function of a Parser • Takes the sequence of tokens produced by the scanner as its input and produces the syntax tree as its output. Parser • Sequence of tokens Syntax-Tree

Issues of the Parsing The sequence of tokens is not an explicit input parameter The parser calls a scanner procedure getToken to fetch the next token from the input as it is needed during the parsing process The parsing step of the compiler reduces to a call to the parser as follows: SyntaxTree= parse()
Issues of the Parsing • The sequence of tokens is not an explicit input parameter – The parser calls a scanner procedure getToken to fetch the next token from the input as it is needed during the parsing process. – The parsing step of the compiler reduces to a call to the parser as follows: SyntaxTree = parse( )

Issues of the Parsing The parser incorporate all the other phases of a compiler in a single-pass compiler No explicit syntax tree needs to be constructed The parser steps themselves will represent the syntax tree implicitly by a call Parse(
Issues of the Parsing • The parser incorporate all the other phases of a compiler in a single-pass compiler • No explicit syntax tree needs to be constructed • The parser steps themselves will represent the syntax tree implicitly by a call Parse ( )

Issues of the Parsing In Multi-Pass, the further passes will use the syntax tree as their input The structure of the syntax tree is heavily dependent on the particular syntactic structure of the language This tree is usually defined as a dynamic data structure Each node consists of a record whose fields include the attributes needed for the remainder of the compilation process (i.e, not just those computed by the parser)
Issues of the Parsing • In Multi-Pass, the further passes will use the syntax tree as their input – The structure of the syntax tree is heavily dependent on the particular syntactic structure of the language – This tree is usually defined as a dynamic data structure – Each node consists of a record whose fields include the attributes needed for the remainder of the compilation process (i.e., not just those computed by the parser)

Issues of the Parsing What is more difficult for the parser than the scanner is the treatment of errors Error in the scanner Generate an error token and consume the offending character
Issues of the Parsing • What is more difficult for the parser than the scanner is the treatment of errors. • Error in the scanner – Generate an error token and consume the offending character
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.3 The Symbol Table.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.1 Attributes and AttributeGrammars.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.4 Dynamic Memory.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.1 Memory Organization During Program Execution.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 1.1 Why? A Brief History.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 4.1 Top-Down Parsing byRecursive-Descent.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)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
- 清华大学:《编译原理》课程教学资源_(英文译文)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
- 长江大学:《微型计算机技术及应用课件》第五章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第八章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第六章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第十章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第四章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第10章 模数转换(李华贵).ppt