节点文献

TTCN-3/C编译器研究与设计

Research and Design of TTCN-3/C Compiler

【作者】 王文娟

【导师】 曾华燊;

【作者基本信息】 西南交通大学 , 计算机应用技术, 2004, 硕士

【摘要】 随着IPv6协议族及相关产品的出现,路由协议测试又成为热点。传统的路由器测试法只能对路由器的单端口或一对端口进行测试,不能全面反映真实网络环境下路由器的功能与性能指标。四川省网络通信重点实验室设计了路由器多端口并发测试系统,该测试系统可以模拟出路由器在实际网络环境下的工作情况,从而可以使测试更准确、更完备。本论文反映的工作是该项研究的测试支撑工具的重要组成部分。 本论文研究的主题是如何将用TTCN-3描述的测试控制数据转变为能够被测试系统执行的可执行测试控制数据的技术。出于多方面考虑,笔者没有采用较为普遍的解释方式,而采用了编译的方式。为了便于与测试系统中其他部件融为一体,首先TTCN-3语言转换成C这种高级语言,相关C代码再与其他部分进行联合编译,最终生成机器代码。 笔者开发的编译器的处理过程分为4个阶段:词法分析、语法分析、语义分析及代码生成。由于不生成最终的机器码,因此,TTCN-3/C编译器生成的代码可以视为中间代码(如许多程序设计编译器的生成汇编语言代码),因此也不需要考虑最终代码优化问题。本编译器采用两遍扫描。第一遍扫描读入TTCN-3源程序,并对其进行词法分析、语法分析和语义分析。第二遍通过遍历第一遍输出的语法树来完成代码生成。 由于时间关系,本论文中反映的工作仅涵盖词法分析、语法分析、语义分析、构造语法树、符号表的建立以及相关的错误处理。代码生成部分的具体工作由TTCN-3编译器小组的另一位同学完成。为了减少编译器的开发周期,并考虑到其它的一些因素,词法分析部分是用自动构造词法分析的工具LEX的FLEX版本生成的,语法分析部分是用语法分析器的生成器YACC的BISION版本生成的。语义分析部分作为语法分析的子程序,嵌入了YACC的语法规则部分。 其中,语法分析是笔者研究的核心部分。语法分析的难点是如何解决YACC语法规则部分的冲突问题。笔者针对这一问题总结了三种通过改变TTCN-2语法规则部分的书写格式来减少冲突的办法。 西南交通大学硕士研究生学位论文第日页 在语法分析和语义分析阶段设计了语法树和符号表这两个编译器中重要的数据结构。并且笔者抽象出了fTCN一3中和语义相关的内容。 最后简要介绍了错误处理,以及代码生成的设计思路。

【Abstract】 With the advent of IPv6, testing of IPv6 routers has redrawn attentions of the network community. Traditional test methods are only capable of observing and testing a single port or a pair of ports simultaneously. They are not adequate for testing of modern routers in its real working environment, especially in performance testing. This is the very reason for SC-Netcom Lab (Sichuan Network Communication Key Laboratory) to set up the project of CMPT (Concurrent Multi-Port Testing) for IP routers, which can effectively simulate all possible working conditions for multi-port routers. The work presented in this dissertation is part of test support-tool development.The test control data described in the ISO standardized specification language - TTCN-3 has to be converted into executable code for test systems. The author takes compiling approach instead interpretation as most test systems do in TTCN-3 conversion. The author’s comiler involves converting TTCN-3 specifications into C language in order to enable necessary combined compiling with other parts of the test system. In other word, it is a TTCN-3/C compiler.The compiling process can be divided into four phases: lexical analysis, syntax analysis, semantic analysis, and code generation. The C codes can be thought of as the intermediate codes as in assembly codes in programming language compiling. Therefore, no machine code optimizing process has been involved. The compiling process is composed of two passes in the author compiler. In the first pass, lexical analyzing, syntax analyzing and semantic analyzing are processed, while syntax trees exported from the first pass are used to generating C codes in the compiler.This dissertation has been dedicated to techniques relevant to lexical analysis, syntax analysis, semantic analysis, syntax tree generation, symbol table construction, and error handling. The work of code generation is done by another student in TTCN-3 compiler working group. FLEX (a new version of popular LEX) is used to automate and speed up lexical analysis and BISON (a version of YACC) is used in syntax analysis by the same token. One of difficulties encountered in syntax analysis is how to solve rule conflicts in YACC. The authorhas avoided such conflict by reformatting TTCN-3 rules in YACC and other tactics.Finally, error handling issues are discussed, and basic idea of code generation is briefly introduced although no programming work has been done in this respect.

【关键词】 编译器:TTCN一3语法分析语义分析
【Key words】 compilerTTCN-3syntax analysissemantic analysis
  • 【分类号】TP393.02
  • 【被引频次】8
  • 【下载频次】319
节点文献中: 

本文链接的文献网络图示:

本文的引文网络