为实现基于TTCN-3的协议一致性测试系统,提出一种通过编译方式将TTCN-3语言转换为C++语言的编译器方案。通过对TTCN-3核心语言的研究分析,运用正则语言解析方法实现词法分析模块;在词法分析输出基础上编写上下文无关文法规则,使用多种方法较为彻底地解决语法冲突问题,实现语法分析模块;实现将TTCN-3语言转换为C++语言的编译器前端模块。该方案可快速实现对TTCN-3源代码的词法分析和语法分析,输出单词符号序列并检查其是否符合预定义的语法规则,对错误进行定位、报错并输出编译结果。
To realize a TTCN-3 based conformance test system,a compiling solution to transform TTCN-3 to C++was presented.Firstly,TTCN-3 core language was analyzed,and the lexical analyzing module was implemented using regular language analytical method.Then,based on the lexical output,the syntax analyzing module was implemented by writing context-free grammar,solving syntactical conflicts.Finally the frontend modules of TTCN-3/C++ compiler were completed.With the modules constructed,TTCN-3 source code can be successfully accepted,tokenized into symbol sequence,and parsed according to predefined syntax rules.And faults and compilation results can be output successfully.