Program transformation: Difference between revisions
Khonsuhorus (talk | contribs) mNo edit summary Tag: Reverted |
ENGVAR ok. Undid revision 1108974329 by Khonsuhorus (talk) |
||
Line 7: | Line 7: | ||
A practical requirement for [[source code]] transformation systems is that they be able to effectively process programs written in a [[programming language]]. This usually requires integration of a full front-end for the programming language of interest, including source code [[parsing]], building internal program representations of code structures, the meaning of program symbols, useful [[Static program analysis|static analyses]], and regeneration of valid source code from transformed program representations. The problem of building and integrating adequate front ends for conventional languages ([[Java (programming language)|Java]], [[C++]], [[PHP]] etc.) may be of equal difficulty as building the program transformation system itself because of the complexity of such languages. To be widely useful, a transformation system must be able to handle many target programming languages, and must provide some means of specifying such front ends. |
A practical requirement for [[source code]] transformation systems is that they be able to effectively process programs written in a [[programming language]]. This usually requires integration of a full front-end for the programming language of interest, including source code [[parsing]], building internal program representations of code structures, the meaning of program symbols, useful [[Static program analysis|static analyses]], and regeneration of valid source code from transformed program representations. The problem of building and integrating adequate front ends for conventional languages ([[Java (programming language)|Java]], [[C++]], [[PHP]] etc.) may be of equal difficulty as building the program transformation system itself because of the complexity of such languages. To be widely useful, a transformation system must be able to handle many target programming languages, and must provide some means of specifying such front ends. |
||
A |
A generalisation of semantic equivalence is the notion of [[program refinement]]: one program is a refinement of another if it terminates on all the initial states for which the original program terminates, and for each such state it is guaranteed to terminate in a possible final state for the original program. In other words, a refinement of a program is ''more defined'' and ''more deterministic'' than the original program. If two programs are refinements of each other, then the programs are equivalent.{{clarify|this description of equivalence permits different things to be "the same", begging the question of what equivalent means|date=November 2016}} |
||
==See also== |
==See also== |
Revision as of 04:50, 5 October 2022
This article possibly contains original research. (August 2016) |
A program transformation is any operation that takes a computer program and generates another program. In many cases the transformed program is required to be semantically equivalent to the original, relative to a particular formal semantics and in fewer cases the transformations result in programs that semantically differ from the original in predictable ways.[1]
While the transformations can be performed manually, it is often more practical to use a program transformation system that applies specifications of the required transformations. Program transformations may be specified as automated procedures that modify compiler data structures (e.g. abstract syntax trees) representing the program text, or may be specified more conveniently using patterns or templates representing parameterized source code fragments.[2]
A practical requirement for source code transformation systems is that they be able to effectively process programs written in a programming language. This usually requires integration of a full front-end for the programming language of interest, including source code parsing, building internal program representations of code structures, the meaning of program symbols, useful static analyses, and regeneration of valid source code from transformed program representations. The problem of building and integrating adequate front ends for conventional languages (Java, C++, PHP etc.) may be of equal difficulty as building the program transformation system itself because of the complexity of such languages. To be widely useful, a transformation system must be able to handle many target programming languages, and must provide some means of specifying such front ends.
A generalisation of semantic equivalence is the notion of program refinement: one program is a refinement of another if it terminates on all the initial states for which the original program terminates, and for each such state it is guaranteed to terminate in a possible final state for the original program. In other words, a refinement of a program is more defined and more deterministic than the original program. If two programs are refinements of each other, then the programs are equivalent.[clarification needed]
See also
- List of program transformation systems
- Metaprogramming
- Program synthesis
- Source-to-source compiler
- Source code generation
- Transformation language
- Transformational grammar
- Dynamic recompilation
References
- ^ Ward, Martin (1989). Proving Program Refinements and Transformations (DPhil Thesis). Oxford University.
{{cite book}}
: CS1 maint: location missing publisher (link) - ^ Pawlak, Renaud; Monperrus, Martin; Petitprez, Nicolas; Noguera, Carlos; Seinturier, Lionel (2016). "SPOON: A library for implementing analyses and transformations of Java source code". Software: Practice and Experience. 46 (9): 1155–1179. doi:10.1002/spe.2346.
External links
- The Program transformation Wiki
- Papers on program transformation theory and practice
- Transformation Technology Bibliography
- DMS Software Reengineering Toolkit: A Program Transformation System for DSLs and modern (C++, Java, ...) and legacy (COBOL, RPG) computer languages
- Spoon: A library to analyze, transform, rewrite, and transpile Java source code. It parses source files to build a well-designed AST with powerful analysis and transformation API.
- JavaParser: The JavaParser library provides you with an Abstract Syntax Tree of your Java code. The AST structure then allows you to work with your Java code in an easy programmatic way..