清华大学:《编译原理》课程教学资源_语法分析

③苇大 语店分教术小结 ◇自上而下分祈 ◇自下而上分析 ◇比 ◆二义性处理
语法分析技术小结 自上而下分析 自下而上分析 二义性处理 比较

③苇大 自上而下分析 ◇自上而下分祈一般过程 ◇LL(1)文法 ◇预测分析程序 递下障分析故术 表驱动分析技术
自上而下分析 自上而下分析一般过程 LL(1)文法 预测分析程序 − 递归下降分析技术 − 表驱动分析技术

③苇大 自上而下分析一般过程 In the top-down parsing, we begin with the start symbol and at each step, expand one of the remaining nonterminals by replacing it with the right side of one its productions We repeat until only terminals remain. The top down parse prints a leftmost derivation of the sentence
自上而下分析一般过程 In the top-down parsing,we begin with the start symbol and at each step, expand one of the remaining nonterminals by replacing it with the right side of one its productions. We repeat until only terminals remain. The topdown parse prints a leftmost derivation of the sentence

③苇大 LL(1)文法 The first"L, means we scan the input from left to right; the second L means we create a leftmost derivation and the 1 means one input symbol of lookahead A grammar G is ll(1) iff whenever A->u v are two distinct productions of G, the following conditions hold for no terminal a do both u and v derive strings beginning with a (i. e. first sets are disjoint) at most one of u and v can derive the empty string if v=>*8 then u does not derive any string beginning with a terminal in Follow (A)
LL(1)文法 The first “L” means we scan the input from left to right; the second “L” means we create a leftmost derivation; and the 1 means one input symbol of lookahead. A grammar G is LL(1) iff whenever A –> u | v are two distinct productions of G, the following conditions hold: - for no terminal a do both u and v derive strings beginning with a (i.e. first sets are disjoint) - at most one of u and v can derive the empty string - if v =>* then u does not derive any string beginning with a terminal in Follow(A)

③苇大 First集 The first set of a sequence of symbols u, written as First(u) is the set of terminals which start all the sequences of symbols derivable from u. a bit more formally, consider all strings derivable from u by a leftmost derivation If u=*v, where v begins with some terminal, that terminal is in First(u). Ifu=>*8 then s is in First(u)
The first set of a sequence of symbols u, written as First(u ) is the set of terminals which start all the sequences of symbols derivable from u. A bit more formally, consider all strings derivable from u by a leftmost derivation. If u =>* v , where v begins with some terminal, that terminal is in First(u). If u =>* , then is in First(u ). First 集

③苇大 Fo|low集 The follow set of a nonterminal A is the set of terminal symbols that can appear immediately to the right of a in a valid sentential form a bit more formally for every valid sentential form S ->UAv, where v begins with some terminal that terminal is in FollOw(A)
Follow 集 The follow set of a nonterminal A is the set of terminal symbols that can appear immediately to the right of A in a valid sentential form. A bit more formally, for every valid sentential form S =>*uAv , where v begins with some terminal, that terminal is in Follow(A)

③苇大 计算 First集 To calculate First(u) where u has the form X1X2.Xn, do the following 1. If X1 is a terminal, then add X1 to First(u) otherwise add First(X1)-s to First(u) 2. If X1 is a nullable nonterminal. i e. x1=>c. add First(X2)-8 to First(u). Furthermore if X2 can also go to s, then add First(X3 )-8 and so on, through all xn until the first nonnullable one 3. If X1X2.Xn =>8. add s to the first set
计算First 集 To calculate First(u) where u has the form X1X2...Xn, do the following: 1. If X1 is a terminal, then add X1 to First(u), otherwise add First(X1) - to First(u ) . 2. If X1 is a nullable nonterminal, i.e., X1 =>* , add First(X2) - to First(u). Furthermore, if X2 can also go to , then add First(X3) - and so on, through all Xn until the first nonnullable one. 3. If X1X2...Xn =>* , add to the first set

③苇大 计算Foow集 For each nonterminal in the grammar, do the following 1. Place# in Follow(s) where S is the start symbol and is the input's right endmarker. The endmarker might be end of file, it might be newline, it might be a special symbol whatever is the expected end of input indication for this grammar. We will typically use as the endmarker 2. For every production A-> uBv where u and v are any string of grammar symbols and B is a nonterminal everything in First(v) except s is placed in Follow(B) 3. For every production A-> uB, or a production A-> u Bv where First(v)contains s(i.e. v is nullable), then everything in Follow (A) is added to Follow (B)
计算Follow 集 For each nonterminal in the grammar, do the following: 1. Place# in Follow(S) where S is the start symbol and # is the input's right endmarker.The endmarker might be end of file, it might be newline, it might be a special symbol, whatever is the expected end of input indication for this grammar. We will typically use # as the endmarker. 2. For every production A –> uBv where u and v are any string of grammar symbols and B is a nonterminal, everything in First(v) except is placed in Follow(B). 3. For every production A –> uB, or a production A –> u Bv where First(v ) contains (i.e. v is nullable), then everything in Follow(A) is added to Follow(B)

③苇大 预测分析程序 Predictive parser is a non-backtracking top- down parser. a predictive parser is characterized by its ability to choose the production to apply solely on the basis of the next input symbol and the current nonterminal being processed To enable this the grammar must take a particular form, that is, a grammar LlO
预测分析程序 Predictive parser is a non-backtracking topdown parser. A predictive parser is characterized by its ability to choose the production to apply solely on the basis of the next input symbol and the current nonterminal being processed. To enable this, the grammar must take a particular form,that is, a grammar LL(1)

③苇大 递归下降分析技术 The first technique for implementing a predictive parser is called recursive-descent A recursive descent parser consists of several small functions(procedures), one for each nonterminal in the grammar. as we parse a sentence we call the functions(procedures) that correspond to the left Side nonterminal of the productions we are applying If these productions are recursive, we end up calling the functions recursively
递归下降分析技术 The first technique for implementing a predictive parser is called recursive-descent. A recursive descent parser consists of several small functions(procedures), one for each nonterminal in the grammar. As we parse a sentence, we call the functions (procedures) that correspond to the left side nonterminal of the productions we are applying. If these productions are recursive, we end up calling the functions recursively
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 清华大学:《编译原理》课程教学资源_总结.ppt
- 清华大学:《编译原理》课程教学资源_第六章 补充算符优先分析.ppt
- 清华大学:《编译原理》课程教学资源_第六章 LR分析 6.3 SLR(1)分析技术.ppt
- 清华大学:《编译原理》课程教学资源_第六章 LR分析 6.1 概述 自下而上的语法分析 LR分析器 6.2 LR(0)分析.ppt
- 清华大学:《编译原理》课程教学资源_第六章 LR分析 6.4 LR(1)和LALR(1)分析规范LR分析.ppt
- 清华大学:《编译原理》课程教学资源_第九章 代码优化.ppt
- 清华大学:《编译原理》课程教学资源_第五章 LL(1)文法及其分析程序.ppt
- 清华大学:《编译原理》课程教学资源_第二章 PL/0编译程序.ppt
- 清华大学:《编译原理》课程教学资源_第十章 代码生成.ppt
- 清华大学:《编译原理》课程教学资源_第一章 概述.ppt
- 清华大学:《编译原理》课程教学资源_第八章 目标程序运行时的组织.ppt
- 清华大学:《编译原理》课程教学资源_第七章 语法制导翻译和中间代码生成(7-4)符号表.ppt
- 清华大学:《编译原理》课程教学资源_第七章 语法制导翻译和中间代码生成(7-3)中间代码生成.ppt
- 清华大学:《编译原理》课程教学资源_第七章 语法制导翻译和中间代码生成(7-2)续 要点.doc
- 清华大学:《编译原理》课程教学资源_第七章 语法制导翻译和中间代码生成(7-2)理论要点.doc
- 清华大学:《编译原理》课程教学资源_第七章 语法制导翻译和中间代码生成(7-1)语法制导翻译和中间代码生成.ppt
- 清华大学:《编译原理》课程教学资源_第四章 文法和语言.ppt
- 清华大学:《编译原理》课程教学资源_第三章 词法分析及其自动构造.ppt
- 清华大学:《编译原理》课程教学资源_第三章 练习题.doc
- 西安电子科技大学:《新编计算机应用基础》教材电子教案(PPT教学课件)第七章 Internet操作基础.ppt
- 《计算机组成原理》课程教学资源:期未复习指导.ppt
- 《计算机组成原理》课程教学资源:直播课堂内容.ppt
- 《计算机组成原理》课程教学资源:控制器教学实验.ppt
- 《计算机组成原理》课程教学资源:附录——试题类型及解答.ppt
- 《数据结构》课程教学资源:第一章 绪论.ppt
- 《数据结构》课程教学资源:第七章 树和二叉树.ppt
- 《数据结构》课程教学资源:第三章 栈和队列.ppt
- 《数据结构》课程教学资源:第九章 图.ppt
- 《数据结构》课程教学资源:第二章 线性表.ppt
- 《数据结构》课程教学资源:第五章 数组和稀疏矩阵.ppt
- 《数据结构》课程教学资源:第六章 递归.ppt
- 《数据结构》课程教学资源:第十一章 内排序.ppt
- 《数据结构》课程教学资源:第十章 查找.ppt
- 《数据结构》课程教学资源:第四章 串.ppt
- 郑州大学远程教育学院:《汇编语言》课程电子教案(PPT课件)第一章 概述.ppt
- 郑州大学远程教育学院:《汇编语言》课程电子教案(PPT课件)第二章 8086的指念系统.ppt
- 郑州大学远程教育学院:《汇编语言》课程电子教案(PPT课件)第三章 汇编语言程序格式.ppt
- 郑州大学远程教育学院:《汇编语言》课程电子教案(PPT课件)第四章 基本汇编语言程序设.ppt
- 郑州大学远程教育学院:《汇编语言》课程电子教案(PPT课件)第五章 高级汇编语言程序设计.ppt
- 郑州大学远程教育学院:《汇编语言》课程电子教案(PPT课件)第六章 32位指令及其编程.ppt