清华大学:编译原理课件(英文译文)Chapter 3.5 Extended Notations:EBNFand Syntax Diagrams

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

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

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

3. 5 Extended notationS: EbnF and Syntax Diagrams
3.5 Extended Notations: EBNF and Syntax Diagrams

3.5.1 EBNF Notation
3.5.1 EBNF Notation

Special notations for Repetitive Constructs Repetition A→Ac|B〔 left recursive),and A>aaB right recursive) where a and Bare arbitrary strings of terminals and non-terminals and In the first rule b does not begin with A and In the second B does not end with a
Special Notations for Repetitive Constructs • Repetition – A → A | (left recursive), and – A → A | (right recursive) • where and are arbitrary strings of terminals and non-terminals, and – In the first rule does not begin with A and – In the second does not end with A

Special notations for Repetitive Constructs Notation for repetition as regular expressions use, the asterisk A→Ba,and A→0*B eBNF opts to use curly brackets i. to express repetition A→B{c},and A→{aB The problem with any repetition notation is that it obscures how the parse tree is to be constructed, but, as we have seen, we often do not care
Special Notations for Repetitive Constructs • Notation for repetition as regular expressions use, the asterisk * . A → * , and A → * • EBNF opts to use curly brackets {. . .} to express repetition A → { } , and A → {} • The problem with any repetition notation is that it obscures how the parse tree is to be constructed, but, as we have seen, we often do not care

Examples Example: The case of statement sequences The grammar as follows, in right recursive orm stmt-Sequence- stmt: stmt-Sequence stmt stnt→S In ebnF this would appear as stmt-sequence->stmt;) stmt(right recursive form) stmt-sequence>stmt i; stmt (left recursive form)
Examples • Example: The case of statement sequences • The grammar as follows, in right recursive form: stmt-Sequence → stmt ; stmt-Sequence | stmt stmt → s • In EBNF this would appear as stmt-sequence → { stmt ; } stmt (right recursive form) stmt-sequence → stmt { ; stmt} (left recursive form)

Examples A more significant problem occurs when the associativity matters exp >exp addo term term exp→)term{ adop term} (imply left associativity) exp,term addopfterm (imply right associativity)
Examples • A more significant problem occurs when the associativity matters exp → exp addop term | term exp → term { addop term } (imply left associativity) exp → {term addop } term (imply right associativity)

Special Notations for Optional Constructs Optional construct are indicated by surrounding them with square brackets【…l The grammar rules for if-statements with optional else parts would be written as follows in EBNF: statement>if-stmt other if-stmt>if (exp )statement else statement I exp→0|1 stmt-sequence stmt; stmt-sequence stmt is written as stmt-sequence> stmt stmt-sequence
Special Notations for Optional Constructs • Optional construct are indicated by surrounding them with square brackets [...]. • The grammar rules for if-statements with optional elseparts would be written as follows in EBNF: statement → if-stmt | other if-stmt → if ( exp ) statement [ else statement ] exp → 0 | 1 • stmt-sequence → stmt; stmt-sequence | stmt is written as • stmt-sequence → stmt [ ; stmt-sequence ]
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《典型机械设计范例》讲义(续).ppt
- 《典型机械设计范例》讲义.ppt
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第九章 磨削.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第八章 其他加工刀具.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第六章 回转面加工刀具.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第七章 平面及成形面 加工刀具.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第三章 金属切削基本理论.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第五章 切削加工性表面粗糙度和切削.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第二章 刀具基本定义.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》绪论.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第四章 几何参数选择.doc
- 内蒙古机电职业技术学院:《金属切削原理与刀具》第一章 刀具材料.doc
- 西安工业大学工业中心:《热加工相关工艺》铸造工艺.ppt
- 西安工业大学工业中心:《热加工相关工艺》压力加工.ppt
- 西安工业大学工业中心:《热加工相关工艺》特种铸造.ppt
- 西安工业大学工业中心:《热加工相关工艺》塑料成型工艺简介.ppt
- 西安工业大学工业中心:《热加工相关工艺》焊接工艺.ppt
- 《Ansys结构分析指南》参考书籍PDF电子版(下册)结构动力学.pdf
- 《Ansys结构分析指南》参考书籍PDF电子版(中册)结构非线性.pdf
- 《Ansys结构分析指南》参考书籍PDF电子版(上册)线性静力、疲劳、断裂、复合材料、P-方法、梁分析.pdf
- 《机械基础》第10章 液压传动(顾淑群).ppt
- 《机械基础》第11章 气压传动(顾淑群).ppt
- 《机械基础》第1章 静力学(顾淑群).ppt
- 《机械基础》第2章 材料力学基础(2.1-2.3)材料力学的基本概念(顾淑群).ppt
- 《机械基础》第2章 材料力学基础(2.4-2.5)圆轴扭转(顾淑群).ppt
- 《机械基础》第3章 机械工程材料(顾淑群).ppt
- 《机械基础》第4章 带传动和链传动(顾淑群).ppt
- 《机械基础》第5章 普通螺旋传动(顾淑群).ppt
- 《机械基础》第6章 齿轮传动和蜗杆传动(顾淑群).ppt
- 《机械基础》第7章 轮系和减速器(顾淑群).ppt
- 《机械基础》第8章 常用机构(顾淑群).ppt
- 《机械基础》第9章 轴系零件(顾淑群).ppt
- 《表面粗糙度及其检测》讲义.ppt
- 《机械设计基础》课程教学资源:第二章 机械设计基础.pdf
- 《发动机》课程教学资源(习题答案)汽车发动机构造与维修习题答案.doc
- 《发动机》课程教学资源(习题库,试卷,无答案).doc
- 《发动机》课程教学资源(习题库)高级汽车修理工理论考试.doc
- 《发动机》课程教学资源(习题库)汽车发动机构造与维修理论知识复习题.doc
- 《发动机》课程教学资源(习题库)汽车发动机试题库.doc
- 《汽车电子控制技术》课程教学资源(教材讲义)第10章 CAN-BUS汽车多路信息传输系统.pdf