摘要
抽象语法树(AbstractSyntaxTree,AST)作为程序的一种中间表示形式,在程序分析等诸多领域有广泛的应用.利用抽象语法树可以方便地实现多种源程序处理工具,比如源程序浏览器、智能编辑器、语言翻译器等.本文作者介绍了抽象语法树涉及的原理及解释器的设计方案,针对Java语言,利用设计模式理论提出了创建和遍历抽象语法树的思路,并给出较为详细的代码说明.
Abstract Syntax Tree, referred as intermediate representation of program, has many applications in Program Analysis. Using Abstract Syntax Tree, we can develop tools such as Source Code Explorer, Intellectual Editor, etc. This paper introduces the principles of Abstract Syntax Tree, and presents an appropriate solution to design Interpreter based on Java Program. With the help of Design Patterns, we can build and traverse an Abstract Syntax Tree. Moreover, the paper gives illustrations of concerned source codes.
出处
《长沙大学学报》
2004年第4期50-53,57,共5页
Journal of Changsha University
基金
国家自然科学基金(批准号:60176028)资助项目.
关键词
抽象语法树
解释器
模式
创建
遍历
Abstract Syntax Tree
Interpreter
Pattern
Build
Traverse