计算机科学与探索 ›› 2013, Vol. 7 ›› Issue (6): 562-569.DOI: 10.3778/j.issn.1673-9418.1303014

• 学术研究 • 上一篇    下一篇

量子程序设计语言NDQJava2处理系统——词法分析程序及语法分析程序

程振伟1,2,徐家福1,2+   

  1. 1. 南京大学 计算机软件新技术国家重点实验室,南京 210046
    2. 南京大学 计算机科学与技术系,南京 210046
  • 出版日期:2013-06-01 发布日期:2013-05-30

Quantum Programming Language NDQJava2 Processing System: Lexical Analyzer and Syntactic Analyzer

CHENG Zhenwei1,2, XU Jiafu1,2+   

  1. 1. State Key Laboratory for Novel Software Technology, Nanjing University, Nanjing 210046, China
    2. Department of Computer Science and Technology, Nanjing University, Nanjing 210046, China
  • Online:2013-06-01 Published:2013-05-30

摘要: NDQJava2语言是在NDQJava语言的基础上,增添量子条件语句、量子循环语句、量子子程序、量子模块和量子异常处理机制等多种量子成分而成的一种混成式、结构化、命令式量子程序设计语言。在简述NDQJava2处理系统之后,着重介绍了其词法分析程序及语法分析程序,其中用直接转向法进行词法分析,识别出单词,生成单词序列,用递归子程序法进行语法分析,生成语法树。由示例可知,程序结果无误,较好地完成了词法分析与语法分析任务。

关键词: NDQJava2, 处理系统, 词法分析程序, 语法分析程序

Abstract: NDQJava2 is a hybrid, structured and imperative quantum programming language, which is an extension of NDQJava with some additional quantum components, such as quantum conditional statement, quantum loop statement, quantum subprogram, quantum module and quantum exception handling mechanism. After briefly stating the NDQJava2 processing system, this paper focuses on the lexical analyzer and the syntactic analyzer, which uses direct steering method for lexical analysis, identifies the words then generates a sequence of words, uses recursive subroutine method for syntax analysis, generates syntax tree. The example shows that the result of this process is correct, fulfills lexical analysis and syntax analysis tasks.

Key words: NDQJava2, processing system, lexical analyzer, syntactic analyzer