Top Banner
- eCST Generator - Gordana Rakić, Zoran Budimac
32

- eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Jan 17, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

- eCST Generator -

Gordana Rakić, Zoran Budimac

Page 2: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

ContentsAbstract

Motivation

Background

Description

Conclusion and results

Future work

Page 3: - eCST Generator - Gordana Rakić, Zoran Budimac. 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

Page 4: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Contents

Abstract

Motivation

Background

Description

Conclusion and results

Future work

References

Page 5: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 6: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Broader applicability of eCST

!

Page 7: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 8: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Broader applicability of eCST(2)Transform eCST to eCFG (enriched Control Flow Graph)

Page 9: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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.

Page 10: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 11: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Broader applicability of eCST (4)Indirectly – through SMIILE toolIn 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

Page 12: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

*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

Page 13: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Contents

Abstract

Motivation

Background

Description

Conclusion and results

Future work

References

Page 14: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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,...

Page 15: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 16: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 17: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Contents

Abstract

Motivation

Background

Description

Conclusion and results.

Future work

References

Page 18: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 19: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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))))

Page 20: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Structure of the eCST

Page 21: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 22: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Universal nodes that do not directly affect CC metric

Node \ Language JAVA MODULA-2 COBOL

COMPILATION_UNIT Class MODULE PROGRAM

CONCRETE_UNIT_DECL Concrete Class

(IMPLEMENTATION) MODULE

PROCEDURE DIVISION

FUNCTION_DECL Method Declaraton PROCEDURE Procedure

Declaration

MAIN_BLOCK - BEGIN (Of Main Block ) MAINLINE

CONDITION Start of Condition In Branch Statement Or Loop

BRANCH_STATEMENT

Start of Branch Statement (each part will be additionally marked with BRANCH node)

e.g. switch e.g. case e.g. EVALUATE

Page 23: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Universal nodes that directly affect CC metric Node \ Language JAVA MODULA-2 COBOL

BRANCH

ifelse

?:

case defaultcatch

IFELSIF ELSECASE

WHENEND-OF-PAGE

(ON) EXCEPTIONINVALID KEY

(ON) OVERFLOW(ON) SIZE ERROR

IF

JUMP_STATEMENT

breakreturn

continuethrow(s)

EXITRETURN

STOPEXIT

GO-TOGO-BACK

LOOP_STATEMENT

forwhile

repeatdo-while

FORWHILEREPEATLOOP

VARYINGTIMES

PERFORM-UNTIL

LOGICAL_OPERATOR&& ||

ANDOR

ANDOR

ALSO

Page 24: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 25: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Documenting: all universal nodes

Page 26: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

eCST Generator

Page 27: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Storing additional data - Programming Languages -

Enables dynamic recognition of input programming language based on input file extension

Page 28: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Contents

Abstract

Motivation

Background

Description

Conclusion and results.

Future work

References

Page 29: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

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

Page 30: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Contents

Abstract

Motivation

Background

Description

Conclusion and results.

Future work

References

Page 31: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Future work

• Adding parsers for new programming languages

• Maintenance of existing once according to changes of set of universal nodes

Page 32: - eCST Generator - Gordana Rakić, Zoran Budimac. Contents Abstract Motivation Background Description Conclusion and results Future work.

Thank you