Title: Code Generation from UnParameterised Algebraic Specifications
1Code Generation from (Un)Parameterised Algebraic
Specifications
- Master Thesis Defence
- Sudhanshu Singh
- Supervisor Dr S. Sadaoui
2Outline
- Problem Statement
- Solution
- Code Generation Process
- Code Generator Tool
- Conclusion Future Work
31. Problem Statement
- Incorrect code
- Defects during testing phase
- Knowledge domain
- From user to programmer
- Inconsistent code
- Over budget
- Poor quality
- Loss of time, resources human life
42. Solution
- Automatic Code Generation A way to generate
code directly from specifications
Translation
UML Diagram
C Code
52.1 Benefits of Code Generation
- High productivity, quality
- Consistency in coding style architecture
- More design time
- Agile development
- No ambiguities
- Shorter and less error prone software life cycle
- Easier maintenance
62.2 Specifications
- Contract between clients and developers
Specification
Informal English, French, Dutch
Semi-Formal UML, DFD, ERD
Formal Process, Algebraic
7 2.3 Code Generation Types
- Informal specifications to code
- Ambiguities of natural languages
- Different knowledge domains
- Semi-formal specifications to code
- Graphical notations to code
- Correctness completeness difficult
- Inappropriate tools
- Formal specifications to code
- Unambiguous, correct, consistent code
82.4 Formal Specifications
- Prove correctness consistency
- High quality of software
- User requirements well defined
- Simplified maintenance
- Easy to obtain correct code from correct
specifications
92.5 Code Generation Strategies
- Term Rewriting Strategy
- Specification Interpretation Strategy
- Interpret specification to code
- Generate tree structure
- Abstract concepts to concrete concepts
Syntax Analyzer
Formal Specification
Transformation Engine
Program Code
103. Code Generation Process
- 1. Specification Interpretation Strategy
- Advantage Incremental approach, complete code
- 2. Transformation approach
- Syntactic Transformation Transforms syntactic
part to skeletal code - Semantic Transformation Transforms the equations
to generate first version of functions
113. Code Generation Process
- 3. Source Language CafeOBJ
- Parameterized programming, theorem prover
- New formal specification language
- An algebraic specification language
- 4. Target Language Java 1.5
- Parameterization instantiation
- Platform Independence, neutral architecture,
close correspondence
123. Code Generation Process
133.1 Syntactic Transformation
Module Parameterization Instantiation Record
Class
Sort Sub sorts
Data Type
Operation Predicate Behavioral
Method
Exception handling
Error handling
Inheritance
Inheritance
143.2 Semantic Transformation
- Operations are segregated
- Constructors determine generic methods
- Non constructor determine methods
- Number of equations determine the details
Generic Methods Java Method Details
CafeOBJ Equations
154. Code Generator Tool
- C2J Code Generator prototyping tool
- Development Environment
- Windows XP, 2.8 GHZ, 20 GB Hard disk, 1 GB RAM
- NetBeans 4.1
164.1 Compiler Structure
tokens
characters
code
Optimized code
174.2 Code Generation Process in C2J
GUI
Module in CafeOBJ
Scanner Parser
Analyzer
Syntactic Transformation
Code Generator
Java Code
Scanner Parser
Analyzer
Semantic Transformation
Code Generator
Improved Java Code
184.3 Graphical User Interface
Syntactic Transformation
194.3 Graphical User Interface
Semantic Transformation
205. Conclusions
- Specification Interpretation Strategy and
Compiler - Syntactic and Semantic Transformation Algorithms
- Parameterization and Instantiation
- Supporting tool C2J
- Code Generation Process applicable to any
algebraic specification language
216. Future Work
- Include transition declaration
- Include optimization algorithms
- Develop an integrated system including theorem
prover
22Questions ?