TINY-C编译器的设计与实现-语法分析器的设计与实现

上传人:206****923 文档编号:37511318 上传时间:2018-04-17 格式:DOC 页数:46 大小:351KB
返回 下载 相关 举报
TINY-C编译器的设计与实现-语法分析器的设计与实现_第1页
第1页 / 共46页
TINY-C编译器的设计与实现-语法分析器的设计与实现_第2页
第2页 / 共46页
TINY-C编译器的设计与实现-语法分析器的设计与实现_第3页
第3页 / 共46页
TINY-C编译器的设计与实现-语法分析器的设计与实现_第4页
第4页 / 共46页
TINY-C编译器的设计与实现-语法分析器的设计与实现_第5页
第5页 / 共46页
点击查看更多>>
资源描述

《TINY-C编译器的设计与实现-语法分析器的设计与实现》由会员分享,可在线阅读,更多相关《TINY-C编译器的设计与实现-语法分析器的设计与实现(46页珍藏版)》请在金锄头文库上搜索。

1、目 录 摘 要.4 1. 前 言.6 2. 语法分析器的设计原理.7 2.1 语法分析器的功能.7 2.2 语法分析的目标和作用.7 2.3 构造语法分析器的步骤.7 2.4 上下文无关文法及分析.8 2.5 常用的语法分析方法和几种算法的比较.10 2.5.1 自上而下分析法.10 2.5.2 自下而上分析法.12 3. 语法分析器的设计和实现.15 3.1 TINY 语言的介绍.15 3.2 TINY 的文法生成.15 3.3 TINY 语法分析器算法的选择.18 3.4 TINY 语言的递归下降分析程序.21 3.5 TINY 语法分析的输出.23 3.5.1 语法分析的输出结果.23

2、3.5.2 抽象语法树的节点声明.24 3.5.3 语法树结构.25 3.6 语法分析的主要函数与核心代码.29 3.6.1 语法分析器的主要文件和函数.29 3.6.2 语法分析模块.30 4. 测试分析.40 4.1 测试方法.40 4.2 测试计划.40 4.3 测试项目说明.40 4.4 测试结论.44 5. 结论与心得.45 参 考 文 献.46 致 谢.47 附 录.472ContentsAbstract.4 1. Preface.6 2. Syntax analyzer principle of design.7 2.1 Function of parsing.7 2.2 Pur

3、pose and function of parsing.7 2.3 The of parsing analyzer structure.7 2.4 Context-free grammar and analysis.8 2.5Commonly syntax analysis method and several algorithms comparison .10 2.5.1 From top to bottom analytic method.10 2.5.2 From bottom to top analytic method.12 3. Syntax analyzer design an

4、d realization.15 3.1 Introduce of TINY language.15 3.2 Production of TINY grammar.15 3.3 Choice of TINY syntax analyzer algorithm.18 3.4 Recursion decline analysis programe of TINY.21 3.5 Output of TINY grammar analysis.23 3.5.1 Result of parsing.23 3.5.2 Statement of abstract syntax tree node.24 3.

5、5.3 The syntax tree struction.25 3.6 Main function and core code of syntax analyzer.29 3.6.1Master document and function of syntax analyze29 3.6.2Parsing module.30 4. Testing parse.40 4.1 Testing method.40 4.2 Testing Propose.40 4.3 Explanation of test item.40 4.4 Conclusion of testing.44 5. Conclus

6、ion and what one has learned.45 Bibliography.46 Thanks.47 Appendix.473TINY-CTINY-C 编译器的设计与实现编译器的设计与实现-语法分析器的设计与实现语法分析器的设计与实现摘摘 要要 编译器是将一种源语言翻译为目标语言的计算机程序。 本项目采用一种类(ANSI)C 的小型语言:TINY 语言作为源语言,构造TINY语言的编译器。项目由三人共同完成,其中本人主要是完成了语法分析器的构造,主要工作如下:研究语法分析器的设计原理,并对几种典型的语法分析算法进行分析。生成TINY文法,并证明该文法为LL(1)文法,在此基础上,

7、选择递归下降算法实现TINY语法分析。最终实现了一个TINY语法分析器,它以词法分析器所产生的记号为输入,采用递归下降分析程序进行语法分析,并输出语法树作为下阶段编译的输入。我们最后构造了一个Dephi接口程序,显式输出抽象语法树。关键词关键词 : : 编译器 TINY 记号 语法分析 语法树Tiny-C Complier design and realization-Syntax analyzer design and realization4Ren Jun AbstractThe compiler is a computer program which translates the sou

8、rce language into the target language. This project uses a language similar to (ANSI) C: Using the TINY language as the source language to construct the compiler of TINY. The whole process of the project is finished by the joint effort of three people, and I myself mainly completed the structure of syntax analyzer. The major work is as follows: Analyzing the designing pr

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号