Font Size: a A A

Design And Implementation Of Software Tool Based Tree Structure

Posted on:2007-06-19Degree:MasterType:Thesis
Country:ChinaCandidate:P LiuFull Text:PDF
GTID:2178360182496425Subject:Computer software and theory
Abstract/Summary:PDF Full Text Request
In the current programming field, programmers would rather moremaintainable source code than efficient ones. After all, in modern society,the cost of software has highly exceeded the cost of hardware, the cost ofpeople has highly exceeded the ones of computer itself. So more and moreprogrammers pay high attention to the code quality. Many softwarecompanies have their own code standards. Recently , code refactoringhas become more and more important culture in programming world. Inorder to encourage programmers to refactor their code , software toolswhich can help us refactor our code automatically should be developed .Code detecting and code refactoring are called code improving together.This is the object which we worked on.In this paper , "abstract "syntax tree is the base data structure whichhelp to complete our code improving tools. During implementing the tool,"concrete" syntax tree was used to parse, code detecting and coderefactoring .In the paper , tree structure which in the compilers is spreaded .It is used to implement the software tools which help to improve sourcecode . At first , we describe the tree structure as intermediaterepresentation . We analyze the advantage and the shortcoming of the datastructure. We also show the reasons why tree data structure can be used incode improving tools. In order to demonstrate our viewpoint, we designand implement the JM language which is like the Java language. Thesyntax of JM is simple but is enough to support the view in this paper.While we implement the JM, our work to us in lex and syntax parsing. Inthe parsing stage, we build the tree structure which is used in the followingstages. Because the main object of the paper is not implementing a kind oflanguage, we fail to implement the code generation. This is equal toimplement the front end of the JM language during the implement progress.Visitor is the most important pattern which we describe in detail. We alsoexplain the depth first traversal of tree structure in JM. With these basework, we can use tree structure in static analyze and code refactoring.Static analyze and code refactoring. Static analyze complete the work ofcode detecting.In the part of code detecting there are three kinds of application,including type-checking ,class private variables and private methodsdetecting, customized-standard detecting. Type-checking is implementedby almost all compliers. In out implement, type-checking is simple. Itfocus on the demonstrate the use of Visitor pattern and tree data structure.Class private variable and private methods detecting stands for a large classof code quality detecting. We focus on the class private instance variable todescribe this term. We also combine it to the "concrete" tree structure anddescribe the algorithm of detecting the private variable in detail.Customized-standard fully reflect the intension of the paper, that is , wecan easily add various code-detectings which we need. In the description ofthis part, we not only explain the algorithm in detail but give oursuggestions for adding other customized-detecting function to JM. The treestructure is not only works well in code-detecting, but can make the wordof code refactoring easier. We explain the implementation of the coderefactoring, including the code pretty. Code pretty is not only of thepractice meaning, but one of the base works for code refactoring. When weuse the tree structure to refactor our code in the way of this paper, we firsttranslate the source code into the tree structure. then the refactoringalgorithm modify the intermediate representation and then we translate thetree structure into source code. So code pretty can be considered as thesimplest code refactoring. To implement this function, we combine therecursive decomposition of the tree node and the use of Visitor pattern. Wealso introduce the code refactoring in JM. The variable rename is theexample of code refactoring in JM. We then demonstrate how to do othercode refactoring kinds and give our suggestions.In this paper, we describe the design and implement of codeimproving tools based tree structure. We also design and implement thefront end of the JM language. We use JM as work platform to illustrate therole of the tree structure in code detecting and code refactoring. We hopeout opinions can promote the development of code improving tools.
Keywords/Search Tags:compile principle, abstract syntax tree, intermediate representation
PDF Full Text Request
Related items