Method for handling preprocessing in source code transformation
AssigneeAlcatel-Lucent USA Inc.
InventorsDaniel G. Waddington, Bin Yao
Life of this patent
Estimating the term…
Abstract
A method for handling preprocessing in source code transformation creates a semantically correct view of a program being transformed. This semantically correct view is called a transformed form and it is capable of being parsed with a regular grammar. The original use of preprocessing macros is determined, including their relationship to the transformed form and the preprocessing is reconstructed in the modified source code.
Claims21
A method for handling preprocessing in source code transformation, comprising:
- deconditioning an original source code to produce a parsable source code, the original source code including original preprocessing directives;
- parsing the parsable source code to produce an abstract syntax tree (AST) form, the AST form comprising annotations adapted to facilitate preservation of a style of the original source code;
- performing an AST-based transformation on the AST form to produce a modified AST form;
- and
- reconditioning the modified AST form to produce a modified source code conforming to the original source code style, the reconditioning comprising reconstructing a portion of the original preprocessing directives that was unaffected by the AST-based transformation.
A system for handling preprocessing in source code transformation, the system comprising:
- a memory for storing:
- a deconditioning component for deconditioning an original source code to produce a parsable source code, the original source code including original preprocessing directives;
- a parser component for parsing the parsable source code to produce an abstract syntax tree (AST) form, the AST form comprising annotations adapted to facilitate preservation of a style of the original source code;
- a transformation engine component for performing an AST-based transformation on the AST form to produce a modified AST form;
- and
- a reconditioning component for reconditioning the modified AST form to produce a modified source code conforming to the original source code style, the reconditioning comprising reconstructing a portion of the original preprocessing directives that was unaffected by the AST-based transformation;
- and
- a processor adapted to execute the components stored in the memory to produce the modified source code based on the original source code.
A computer-readable storage medium having instructions stored thereon which, when executed by a processor, perform a method for handling preprocessing in source code transformation, the method comprising:
- deconditioning an original source code to produce a parsable source code, the original source code including original preprocessing directives;
- parsing the parsable source code to produce an abstract syntax tree (AST) form, the AST form comprising annotations adapted to facilitate preservation of a style of the original source code;
- performing an AST-based transformation on the AST form to produce a modified AST form;
- and
- reconditioning the modified AST form to produce a modified source code conforming to the original source code style, reconditioning comprising reconstructing a portion of the original preprocessing directives that was unaffected by the AST-based transformation.
Dependencies are inferred from the claim text.