- 38
- 0
- 约1.4万字
- 约 42页
- 2017-08-11 发布于重庆
- 举报
编译原理-上下无关文法和文法分析.ppt
Introduction Parsing is the task of determining the syntax, or structure, of a program. It is also called syntax analysis. The syntax of a programming language is usually given by the grammar rules of a context-free grammar. The rules of context-free grammar are recursive. Data structures representing the syntactic structure are also recursive – a parse tree or syntax tree. The Parsing Process Usually, the sequence of tokens is not an explicit input parameter, but the parser calls a scanner procedure such as getToken to fetch the next token from the input as it is needed during the parser process. Context-Free Grammars A context-free grammar is a specification for the syntactic structure of a programming language. Context-free grammar involves recursive rules. Example: integer arithmetic expressions with additions, subtraction, and multiplication operations BNF Names are written in italic. | - metasymbol for choice. Concatenation is used as a standard operation. No repetitions. - is used to express the definitions of names. Regular expressions are used as components. The notation was developed by John Backus and adapted by Peter Naur. The grammar rules in this form are said to be in Backus-Naur Form, or BNF. Formal Definition CFL A context-free grammar consists of the following: 1) A set T of terminals 2) A set N of nonterminals ( disjoint from T) 3) A set fo productions ,or grammer rles , of the form A? a, where A is an element of N and a is an element of (T u N )* 4) A start symbol S from the set N A derivation over the grammer G is of the form S=*w ,where w is belonged to T*. The language generated by G The language ,written L(G) , is defined as the set L(G)= { w is belonged to T*| there exists a derivation S =* w of G } Context-Free Grammar Rules Grammar rules are defined over an alphabet, or set of symbols. The symbols are usually tokens representing strings of characters. Context-free grammar rule consists of a string of symbols Name for a
您可能关注的文档
- 管理层讨论和分析6.pdf
- 管理案例分析模拟试卷一.doc
- 管理案例分析模拟试卷二.doc
- 管理测试与训练.doc
- 管理类联考论证有效性分析真题案例.doc
- 管理系历年教材订购单(自09—10年开始).xls
- 管理统计实验报告.doc
- 管理驾驶舱软件如何设置计算指标样式.pdf
- 篮球进攻战术配合探讨与分析.doc
- 粗晶大理岩裂隙法向闭合曲线的拟合分析.pdf
- 2026年口服美容产品行业消费人群画像与市场格局报告.docx
- 《沉浸式AR+AI教育互动平台互动游戏开发与应用研究》教学研究课题报告.docx
- 派特灵HPV防治专家共识PPT课件.pptx
- 2026浙江杭州市西湖区翠苑第五幼儿园和新城幼儿园诚聘幼儿教师(非事业)备考试题及完整答案详解1套.docx
- 2026浙江杭州市西湖区紫萱幼儿园金地园区诚聘教师和保育员(非事业)3人备考试题附答案详解.docx
- 2026浙江杭州市西湖区紫萱幼儿园金地园区诚聘教师和保育员(非事业)3人备考试题附答案详解.docx
- 2026浙江杭州市西湖区紫萱幼儿园金地园区诚聘教师和保育员(非事业)3人备考试题及答案详解一套.docx
- 露营经济十年兴起:2026年露营装备市场报告.docx
- 2026年河南物流职业学院单招职业技能考试题库带答案详解.docx
- 2026年智能监测设备五年行业报告.docx
原创力文档

文档评论(0)