|国家预印本平台
首页|NDQFP程序中类型关联函数的语法分析

NDQFP程序中类型关联函数的语法分析

Syntax Parsing of Type-Related Functions in NDQFP Program

中文摘要英文摘要

NDQFP语言为函数式量子程序设计语言,其类型系统主要参考了FL语言,提供类型关联函数机制。当程序员定义了一个类型后,无需定义就可以直接使用与类型关联的构造函数、析构函数和谓词函数,这简化了程序员的编程工作。但是由于类型关联函数的定义不显式地出现在源程序中,因而给语法分析工作带来了困难。本文给出并比较了两种解决此问题的方法:预处理方法和语法树构造方法。预处理方法直接从问题出发,在编译程序执行之前将类型关联函数的定义加入到源程序中,但因需要多次扫描源程序,且部分功能与词法、语法分析重合,因而代价较高;而语法树构造方法利用现有的语法分析程序,从类型关联函数的定义特点出发,能较好的解决类型关联函数的语法分析问题。

NDQFP is functional quantum programming language. Its typing system founds on FL language and provides mechanism of type-related function. After defining a type, programmers can use constructing function, deconstructing function and predicting function related to the type straight without defining. It’s convenient for programmers to programming using type-related functions. The syntax parsing of type-related functions is hard because they are not defined explicitly in program. This paper gives two methods to solve this problem: the preprocessing method and syntax tree constructing method. The preprocessing method bases on the problem itself and adds definitions of type-related functions to program before compiling. Preprocessing pays dear for solving the problem because it needs multi-scans and has overlapped functions with lexical analysis and syntax parsing. Syntax tree constructing method, based on characteristics of type-related functions, can uses existing syntax parsing program to solve the problem well.

朱晓瑞

计算技术、计算机技术

函数式程序设计语言类型系统语法分析

functional programming languagetyping systemsyntax parsing

朱晓瑞.NDQFP程序中类型关联函数的语法分析[EB/OL].(2009-04-09)[2025-07-20].http://www.paper.edu.cn/releasepaper/content/200904-298.点此复制

评论