Syntax Analysis(Section 2.2-2.3).ppt
《Syntax Analysis(Section 2.2-2.3).ppt》由会员分享,可在线阅读,更多相关《Syntax Analysis(Section 2.2-2.3).ppt(26页珍藏版)》请在麦多课文档分享上搜索。
1、Syntax Analysis (Section 2.2-2.3),CSCI 431 Programming Languages Fall 2003,A modification of slides developed by Felix Hernandez-Campos at UNC Chapel Hill,Review: Compilation/Interpretation,Compiler or InterpreterTranslation Execution,Review: Syntax Analysis,Compiler or InterpreterTranslation Execut
2、ion,Source Code,Specifying the formof a programming languageTokens Regular Expressions (also F.A.s & Reg. Grammars)Syntax Context-FreeGrammars (also P.D.A.s),Target Code,Phases of Compilation,Syntax Analysis,Syntax: Websters definition: 1 a : the way in which linguistic elements (as words) are put t
3、ogether to form constituents (as phrases or clauses) The syntax of a programming language Describes its form Organization of tokens Context Free Grammars (CFGs) Must be recognizable by compilers and interpreters Parsing LL and LR parsers,Context Free Grammars,CFGs Add recursion to regular expression
4、s Nested constructions Notation expression identifier | number | - expression| ( expression ) | expression operator expression operator + | - | * | /Terminal symbols Non-terminal symbols Production rule (i.e. substitution rule) terminal symbol terminal and non-terminal symbols,Parsing,Parsing an arb
5、itrary Context Free Grammar O(n3) Too slow for large programs Linear-time parsing LL parsers (a Left-to-right, Left-most derivation) Recognize LL grammar Use a top-down strategy LR parsers (a Left-to-right, Right-most derivation) Recognize LR grammar Use a bottom-up strategy,Parsing example,Example:
6、 comma-separated list of identifierCFGid_list id id_list_tail id_list_tail , id_list_tail id_list_tail ;ParsingA, B, C;,Top-down derivation of A, B, C;,CFG,Top-down derivation of A, B, C;,CFG,Bottom-up parsing of A, B, C;,CFG,Left-to-right, Right-most derivation LR parsing (a shift-reduce parser),Bo
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SYNTAXANALYSISSECTION2223PPT
