320 likes | 499 Views
Gordana Rakić, Zoran Budimac. - eCST Generator -. Contents. Abstract Motivation Background Description Conclusion and results Future work . Abstract. In SMIILE w e introduce d enriched Concrete Syntax Tree (eCST) as universal intermediate representation of source code
E N D
Gordana Rakić, Zoran Budimac - eCST Generator -
Contents Abstract Motivation Background Description Conclusion and results Future work
Abstract • In SMIILE we introduced enriched Concrete Syntax Tree (eCST) as universal intermediate representation of source code • Part of SMIILE eCST Generator
Contents Abstract Motivation Background Description Conclusion and results Future work References
Systematic review on tools - conclusion - Practice needs new tool which Is platform independent Is programming language independent Calculates broad specter of metrics Supports keeping of source code history Supports keeping of calculated values of software metrics !!!will be supported by other techniques … we need software tool for software quality assessment applicable through evolution phases
Broader applicability of eCST(1) Limitation: eCST represents only separate compilation unit (class, module,...) Solution: detect function, procedure, mothod,... (FUNCTION_DECL, FUNCTION_DEF) and their calls (FUNCTION_CALL) and connect compilation units in enriched Call Graph
Broader applicability of eCST(2) Transform eCST to eCFG (enriched Control Flow Graph)
Broader applicability of eCST (2a) Transform eCST to eCFG (enriched Control Flow Graph) which can be used in software testing dead and duplicated code discovering, code-clone analysis basis for connecting compilation units instead of original eCST. In this case language independent call graph would be created by connecting eCFG components that represent compilation units.
Broader applicability of eCST (3) Automatic source code translation between programming languages (e.g. translation from Java to Modula-2 or from Modula-2 to Java) For automatic translation by using eCST we would have reflection table with rules for translation. E.g. we should have rule about: How to translate the loop How to translate the condition How to translate inside statements Imperfections in source code could be eliminated by several cycles of code transformation
Broader applicability of eCST (4) Indirectly – through SMIILE tool In development input language independent metric based advising system which would communicate with its user by concrete advices for corrections and refactoring of the source code based on calculated software metrics metric values storage well organized XML file system as primarily planed external software metrics repository This gives additional value to possibility for code translation Possibility of keeping history of source code (in XML storage) enables support of code-change analysis important support in software reengineering process
*Software Metrics Independent of Input LanguagE*SMIILE Tool • Developed in Java programing language • Based on eCST: • Plograming language independency • Source code history keeping (in XML) • Metric values history keeping (in XML) • In current prototype • Metrics • Cyclomatic Complexity – CC (by predicate counting) • Lines of Code – LOC (by filled lines counting) • Halstead • Programming languages • Java • C# • Delphi • Modula 2 • COBOL
Contents Abstract Motivation Background Description Conclusion and results Future work References
Parser Generators • Tool used for generation of language translators • Input • language grammar • Output • Language scanner • Language parser • + Intermediate representation of language constructions • !syntax trees! • ANTLR, JavaCC, CocoR,...
Syntax Trees Syntax Trees Intermediate structure produced by parser generator directly translator generated by parser generator Represent language in abstract form concrete source code concrete source code elements attached to corresponding abstract language elements
Syntax Trees (2) Classification of Syntax trees used in this thesis Abstract Syntax Tree (AST) represents concrete source code Concrete Syntax Tree (CST) represents concrete source code elements attached to corresponding abstract language elements Enriched Concrete Syntax Tree (eCST) Represents concrete source code elements attached to corresponding abstract language elements Contains additional information - universal nodes as markers for language elements figuring in metric algorithms
Contents Abstract Motivation Background Description Conclusion and results. Future work References
Background of the universality Enriched Concrete Syntax Tree (eCST) Generated by Parser generator Generation is based on programming language grammar Enrichment is based on modification of programming language grammar by adding universal nodes into tree Stored to XML structure Enrichment does not effect structure of the tree Only content of the tree is affected by these changes
Content of the CST and eCSTUniversal Nodes IF parenthesizedExpression ifStat = statement(ELSE elseStat = statement -> ^(BRANCH_STATEMENT IF ^(BRANCH ^(IF parenthesizedExpression $ifStat)) ^(BRANCH ELSE $elseStat))| -> ^(BRANCH_STATEMENT IF ^(BRANCH ^(IF parenthesizedExpression $ifStat))))
Example: universal nodes for Cyclomatic Complexity metric algorithm • Cyclometic Complexity (CC) is counted by predicate counting method • We are searching eCST for universal nodes representing language characteristic syntax elements and counting universal nodes intead elements of language syntax
JUMP_STATEMENT open questions • Return, break,... • Are these statements always the jumps? • GO_TO (and similar statements) • Could it be improved (maybe by involving the enriched Control Flow Graph - eCFG)? • Could we distinguish: • JUMP_TO_BACK • JUMP_TO_FORWARD
Storing additional data - Programming Languages - Enables dynamic recognition of input programming language based on input file extension
Contents Abstract Motivation Background Description Conclusion and results. Future work References
Results eCST - new source code and model representation eCST generator – component that generate and extract eCST in XML format Idea for introducing eCST is supported by example of successful development of the prototype of language independent software metrics tool Fresh idea for further usage of eCST in software development and maintenance
Contents Abstract Motivation Background Description Conclusion and results. Future work References
Future work Adding parsers for new programming languages Maintenance of existing once according to changes of set of universal nodes
Thank you