CSC/ECE 517 Fall 2014/ch1a 14 yz

From Expertiza_Wiki
Jump to navigation Jump to search

Refactoring Software Reengineering Toolkit

The Software Reengineering Toolkit is a proprietary set of program transformation tools available for automating custom source program analysis, modification, translation or generation of software systems for arbitrary mixtures of source languages for large scale software systems.

DMS has been used to implement a wide variety of practical tools, include domain-specific languages (such as code generation for factory control), test coverage and profiling tools, clone detection, language migration tools, C++ component reengineering., and for research into difficult topic such as refactoring C++ reliably.


Introduction to the DMS Software Reengineering Toolkit

DMS Capabilities

Available Languages

Compare to other Analysis and Transformation Technology

Industrial Scale


Introduction to the DMS Software Reengineering Toolkit

The DMS Software Reengineering Toolkit is a set of tools for automating customized source program analysis, modification or translation or generation of software systems, containing arbitrary mixtures of languages ("domains"). The term "software" for DMS is very broad and covers any formal notation, including programming languages, markup languages, hardware description languages, design notations, data descriptions, and domain-specific languages. This toolkit is the first step towards the implementation of the Design Maintenance System®, an ambitious vision of a 21st Century software engineering environment that supports the incremental construction and maintenance of large application systems, driven by semantics and captured designs.

A very simple model of DMS is that of an extremely generalized compiler, having a parser, a semantic analyzer, a program transformation engine (to do code generation and optimization), and final output formatting components (producing source code rather than binary code). It is particularly important that the analyzer output can be used to choose the desired transforms. Unlike a conventional compiler, in which each component is specific to its task of translating one source language to one target machine language, each DMS component is highly parameterized, enabling a stunningly wide variety of effects. This means one can change the input language, change the analysis, change the transforms, and change the output in arbitrary ways. Also, unlike a conventional compiler, DMS can process thousands of files from multiple languages at the same moment, allowing analyses and/or consistent code changes across complex systems of files. (An interesting property is that DMS reads formal descriptions of languages, analyses and transforms, and is consequently used to support itself.)

Many program analysis and transformation tools are limited to ASCII or Western European character sets such as ISO-8859; DMS can handle these as well as UTF-8, UTF-16, EBCDIC, Shift-JIS and a variety of Microsoft character encodings.

DMS uses GLR parsing technology, enabling it to handle all practical context-free grammars. Semantic predicates extend this capability to interesting non-context-free grammars (Fortran requires matching of multiple DO loops with shared CONTINUE statements by label; GLR with semantic predicates enables the DMS Fortran parser to produce ASTs for correctly nested loops as it parses).


DMS Capabilities

DMS provides a large set of robust, integrated facilities for building analysis and modification tools:

Full UNICODE-based parser and lexer generation with automatic error recovery. Accepts/generates files encoded in UTF-8 and UTF-16, 7 bit ASCII (ISO-646-US), 8 bit ASCII (ISO-8859-1 thru -16), EBCDIC (CP-37, CP-500), a number of Microsoft code pages (CP-1250 thru -1258), and Japanese Shift-JIS (CP-932 and JIS-0208). Standard support is included for reading multiple source files to enable INCLUDE file management and construct suitable preprocessors. The parser technology is based on GLR, and can handle any context-free language, even with ambiguities (much stronger than YACC/LALR). Proven on dozens of real languages.

Automatic construction of abstract (not concrete) syntax trees (non-value-carrying terminals and unit productions are suppressed; syntax-lists are converted into AST list nodes). Literal values (numbers, escaped strings) are converted to native, normalized binary values for fast internal manipulation. Source comments are captured and attached to AST nodes.

Pretty-printer generation converts ASTs back to nicely formatted legal source file form, according to a specified layout information, including source comments. In fidelity-printing mode, comments, spacing and lexical formatting information of unchanged code is preserved. Customizing allows generation of source code HTML form, or even as obfuscated source text. Trees may be output directly in XML format.

Multi-pass attribute-evaluator generation from grammar, to allow arbitrary analysis (including name/type analysis procedures) to be specified in terms of the concrete grammar provided.

Sophisticated symbol-table construction facilities for global, local, inherited, overloaded and other language-dependent name lookup and namespace management rules.

Control-flow graph construction including traditional entry/exit/action/condition nodes, but also fork/join nodes to model parallelism and/or indeterminate order (e.g., C sequence points). There predefined analyzers for constructing (post) dominators, and inducing structured control-flow regions. Additional machinery can compute compilation-unit local and system/global call graphs.

Data flow analysis framework, to allow data-flow analysis problems to be posed and answered, including predefined analyzers for constructing use-def and def-use chains. (See sample control and data flow graphs)

Points-to analysis for computing local or global points-to data, tested on systems of 13+ million lines of code.

Symbolic Range Analysis computing range constraints on program variables in terms of other variables. This is useful to detecting array-access errors, determining which switch case is selected, ... in conjunction with other analyses.

Multiple domains (notations/languages) can be represented at the same time. This enables processing or generating systems composed of parts from more than one domain (COBOL and JCL, C and Makefiles, etc.), and/or translation from one domain language to another.

Transforms and patterns can be written directly in surface-to-surface domain syntax form. Patterns can be matched against syntax trees and return bindings for parameter subtrees. Alternatively, procedural code can implement transforms, or refer to existing transforms and patterns to enable construction of very sophisticated transforms.

A full Associative/Commutative rewrite engine that operates on trees and DAGs, which can be used to apply sets of transforms.

A metaprogramming language, XCL, provides the ability to control the sequencing of the application of transforms and sets of transforms. (Future Release)

An algebraic specification subsystem can be used to specify arbitrary algebras (this is just a DMS domain!). The axioms can be treated as a set of rewrite rules. (This allows one to code arbitrary simplification procedures. (We have done simplification on boolean equations that are essentially 1 million terms in size; we have also modeled optimization of transistor [not gates!] circuits this way).


Avaiable Languages

The list of language modules includes:

Ada 83/95

C (ANSI, GNU, C99, Microsoft dialects), with intelligently managed include and preprocessor directives, full name and type resolution, control and data flow analysis, system-wide call graph, system-wide points-to analysis

C++ (ANSI, GNU, Microsoft dialects), including C++0x with intelligently managed include and preprocessor directives, and full name and type resolution

C# (Microsoft's .NET language) versions 1.2, 2.0, 3.0 and 4.0

COBOL 85 ("ANSI"), IBM VS COBOL II, IBM Enterprise COBOL with preprocessor, COPYLIB management and Report Writer, having full name and type resolution, and control and data flow analysis

CFEngine v3, a system configuration and policy enforcement aid

Delphi 6 ("Borland ObjectPascal")

ECMAScript (ECMA-262, JavaScript [Microsoft and Netscape dialects], ActionScript, ActionScript2, ActionScript3, ASP, JSP, HTML and XML scripts)

EGL and VAGen (IBM)

FORTRAN 95/90/77

HLASM (IBM)

HTML 4.0, XHTML, plus IE dialect

IDL (Corba 2.3)

IEC 61131-3 Structured Text (Industrial Automation Control)

Java 1.1,1.2,1.3,1.4,1.5,1.6, with full name and type resolution including the JDK and class files, control flow analysis and call graph construction.

JCL (IBM)

JOVIAL (Legacy military embedded systems language) with full name and type analysis

Mathematica

MATLAB M-files and Simulink

Motorola M6800/M6801/M6805/M6808/M6809/M6811/M6812 Assembly language

PARLANSE

Natural (Mainframe application programming language) and Adabas DDMs Pascal (ISO 7185) Perl 5 PHP3, PHP4 and PHP5 Pick Data Basic (Universe dialect) PL/1 (IBM) PL/SQL (Oracle Database programming language) Progress aka OpenEdge (a 4GL) Python 2.6 and 3.1 Rational Rose UML (.MDL files) SQL ANSI 2011 SystemC 2.1 Verilog 1995, 2001 and SystemVerilog 3.1a VHDL 1993 Visual Basic (VB.net, VB6, VBScript+ASP) XML


Industrial Scale