Method and code generator controller to generate set of source code files

EP4740104A1Pending Publication Date: 2026-05-13YINWANG INTELLIGENT TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
EP · EP
Patent Type
Applications
Current Assignee / Owner
YINWANG INTELLIGENT TECHNOLOGIES CO LTD
Filing Date
2023-08-04
Publication Date
2026-05-13

AI Technical Summary

Technical Problem

Conventional code generators face challenges in efficiently, accurately, and reliably verifying the code they generate, particularly in safety-critical applications where errors can lead to adverse outcomes.

Method used

A code generator controller is developed to receive a plurality of test models, generate a set of source code files based on code templates, and produce annotation files and abstract syntax trees to facilitate efficient verification. This controller generates a superior abstract syntax tree structure representing all possible outputs, allowing for comprehensive verification with reduced human intervention.

Benefits of technology

The solution enables efficient, accurate, and reliable verification of automatically generated code, reducing the time and effort required for code validation while ensuring the correctness and reliability of the generated source code files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure EP2023071707_13022025_PF_FP_ABST
    Figure EP2023071707_13022025_PF_FP_ABST
Patent Text Reader

Abstract

A code generator controller is configured to receive a plurality of test models and generate a set of source code files based on code templates. Moreover, the test models cover all possible code templates. Moreover, the code generator controller is further configured to generate an annotation file comprising annotations for each generated set of source code files. The annotations indicate which templates were used to produce the computer code instructions generate an annotation abstract syntax tree for each annotation file generate a code abstract syntax tree for each generated set of source code files and generate one superior abstract syntax tree structure representing all possible outputs for the code generator based on the code abstract syntax trees and the annotation abstract syntax tree.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] METHOD AND CODE GENERATOR CONTROLLER TO GENERATE SET OF SOURCE CODE FILES

[0002] TECHNICAL FIELD

[0003] The present disclosure relates generally to the field of source code generators and more specifically, to a code generator controller and a method for the code generator controller to receive a plurality of test models and generate a set of source code files based on code templates.

[0004] BACKGROUND

[0005] Generally, a code generator is an application that acts as a key component in a model-based design (MBD) process that takes a model as an input and generates code as an output. The code generator is used to provide a clear separation between the code and a logic of the application that is further used to generate the code in a convenient and reliable manner. Conventionally, code generators are widely used in embedded systems for different domains, such as automotive, avionics, and the like. However, such code generators may contain bugs, errors, and malfunctions at runtime due to which the output of the code generators is affected adversely. Therefore, the output generated by the code generators is required to be verified thoroughly, especially in several applications in which safety plays a major role.

[0006] Conventional code generators are used to generate a behavioural code from a functional model of the application and a structural code from an architectural model. However, such conventional code generators may fail to generate executable codes if an error occurs during their execution, which is not desirable. Conventionally, certain attempts have been made to verify the correctness of the generated code by the conventional code generators, such as by performing a visual inspection through different navigating tools, backtracking the generated codes, and the like. However, such attempts are impractical and time-consuming and require either analysis of large portions of the generated code or in-depth knowledge of the generated code and the generated logic, which is not desirable. As a result, there exists a technical problem of how to provide an efficient, accurate and reliable process for verification of the code generated by the code generators. Therefore, in light of the foregoing discussion, there exists a need to overcome the aforementioned drawbacks associated with the conventional methods of verifying the codes generated by the code generators.

[0007] SUMMARY

[0008] The present disclosure provides a code generator controller and a method for the code generator controller configured to receive a plurality of test models and generate a set of source code files based on code templates. The present disclosure provides a solution to the existing problem of how to provide an efficient, accurate and reliable verification of the code generated by the code generators. An objective of the present disclosure is to provide a solution that overcomes at least partially the problems encountered in the prior art and provides an improved code generator controller and an improved method for the code generator controller for the verification of an automatically generated code.

[0009] One or more objectives of the present disclosure are achieved by the solutions provided in the enclosed independent claims. Advantageous implementations of the present disclosure are further defined in the dependent claims.

[0010] In one aspect, the present disclosure provides a code generator controller configured to receive a plurality of test models and generate a set of source code files based on code templates. Moreover, the plurality of test models covers all code templates, and the code generator controller is further configured to generate one or more annotation files comprising annotations for each generated set of source code files. Moreover, the annotations indicate which templates were used to produce the computer code instructions. Furthermore, the code generator controller is configured to generate an annotation abstract syntax tree for each annotation file, generate a code abstract syntax tree for each generated set of source code files, and generate one superior abstract syntax tree structure representing all possible outputs for the code generator based on the code abstract syntax trees and the annotation abstract syntax tree.

[0011] The code generator controller is configured to verify the automatic code generation efficiently, accurately, and reliably from the plurality of test models (model-to-text transformation) or text (text-to-text transformation). The code generator controller is further configured to generate the set of source code files after receiving the plurality of test models that cover all the possible potential scenarios or variations in the code templates to ensure that the code generator is capable of handling different scenarios and requirements effectively and efficiently with desired functionality specified by the plurality of test models. Furthermore, the code generator controller is configured to generate the annotation file for each of the generated set of source code files. The generated annotation file is used to provide a record of the code template that is used to produce the computer code instructions. Moreover, the corresponding record can be used for tracking and understanding the generated set of source code files efficiently and accurately with reduced time. Furthermore, the code generator controller is configured to generate the annotation abstract syntax tree (AST) for each annotation file that allows the structured representation of the annotations that is further used to verify the correctness of the generated set of source code files even if the test model from the plurality of test models is not functional and the generated set of source code files is not executable.

[0012] Furthermore, the code generator controller is configured to generate the code abstract syntax tree for each generated set of source code files to provide an efficient, reliable, and accurate code analysis, transformation, targeted code generation, and visualization to provide an improved code quality. Furthermore, the code generator controller is configured to generate one superior abstract syntax tree structure representing all possible outputs for the code generator that can be used for the verification of the correctness of the set of generated set of source code files, such as by comparing the generated superior AST structure with the content of a reference superior AST. Therefore, the code generator controller is configured for the verification of the auto-generated codes, such as the generated set of source code files with reduced human interaction and reduced time that is required to verify each of the generated set of source code files.

[0013] In an implementation form, the code generator controller is further configured to generate the superior AST structure by extracting nodes of each code AST using a parser, extracting nodes of the templates from each annotation AST, and merging these trees.

[0014] In such an implementation, the generation of the superior AST structure allows the code generator controller to verify the generated set of source code files efficiently, accurately, and reliably with reduced time consumption.

[0015] In a further implementation form, the code generator controller is further configured to generate the set of source code files as comprising the annotation file, wherein the annotations are interleaved with the computer code instructions. Advantageously, the annotations can be used for the modification, customization or debugging of the generated set of source code files as per the requirement.

[0016] In a further implementation form, the annotations in the annotation file allow for backtracking each character generated in the computer code instructions to the code generator template responsible for generating the character.

[0017] Beneficially, the code generator controller is configured to provide precise character backtracking of each of the characters that are generated in the computer code instructions to the code generator template responsible for generating the character that can be used in debugging, customization, and analysing of the generated set of source code files.

[0018] In another aspect, the present disclosure provides a code generator controller configured to receive a production model and generate a set of source code files based on code templates. Moreover, the code generator controller is further configured to receive a superior AST structure as per any preceding claim and to verify the computer code instructions based on the superior AST structure by generating an annotation file for the generated set of source code files, generating an annotation abstract syntax tree for the annotation file, and generating a code abstract syntax tree for the generated set of source code files. Furthermore, the code generator controller is configured for generating one production superior abstract syntax tree structure representing the generated computer code instructions based on the code abstract syntax trees and the annotation abstract syntax tree, and comparing the production superior AST to the received superior AST structure to determine if each node of the production superior AST has a corresponding node in the received superior AST structure and if so verifying the computer code instructions.

[0019] The code generator controller is configured to verify the generated set of source code files efficiently, accurately, and reliably from the production model (model-to-text transformation) or text (text-to-text transformation), which is suitable for code generators that aim at generating the skeleton of the application that can be used in different domains, such as avionics and other embedded systems. Therefore, the code generator controller is configured for the verification of the auto-generated codes, such as the generated set of source code files with reduced human interaction and reduced time that is required to verify each of the generated set of source code files. In an implementation form, the code generator controller is further configured to compare the production superior AST to the received superior AST structure by recursively navigating both the production superior AST structure and the received superior AST structure and applying a matching rule. Moreover, the matching rule depends on the type of node currently visited.

[0020] In such an implementation, the code generator controller is configured to identify the differences or discrepancies between the production superior AST structure and the received superior AST structure that can be further used to determine the errors and bugs in the generated set of source code files.

[0021] In a further implementation form, the code generator controller is further configured to navigate the production superior AST and the received superior AST structure by starting the matching in a node of the production superior AST and determine that there is a match if the annotation node of the production superior AST has the same name, the same number of children and if an analysis on the children indicates no error as a corresponding node in the received superior AST structure.

[0022] Advantageously, the navigation of the production superior AST and the received AST structure enables the code generator controller to ensure that the matched nodes along with their child nodes are consistent and error-free.

[0023] In yet another aspect, the present disclosure provides a method for a code generator controller configured to receive a plurality of test models and generate a set of source code files based on code templates. Moreover, the test models cover all possible code templates, the method comprising generating an annotation file comprising annotations for each generated set of source code files. Moreover, the annotations indicate which templates were used to produce the computer code instructions. Furthermore, the method includes generating an annotation abstract syntax tree for each annotation file, generating a code abstract syntax tree for each generated set of source code files, and generating one superior abstract syntax tree structure representing all possible outputs for the code generator based on the code abstract syntax trees and the annotation abstract syntax tree.

[0024] The method achieves all the advantages and technical effects of the code generator controller of the present disclosure. In another aspect, the present disclosure provides a method for a code generator controller configured to receive a production model and generate a set of source code files based on code templates, the method comprising receiving a superior AST structure as per any preceding claim, and to verify the computer code instructions based on the superior AST structure by generating an annotation file for the generated set of source code files, generating an annotation abstract syntax tree for the annotation file, generating a code abstract syntax tree for the generated set of source code files, generating one production superior abstract syntax tree structure representing the generated computer code instructions based on the code abstract syntax trees and the annotation abstract syntax tree, and comparing the production superior AST to the received superior AST structure to determine if each node of the production superior AST has a corresponding node in the received superior AST structure, and if so verifying the computer code instructions.

[0025] The method achieves all the advantages and technical effects of the code generator controller of the present disclosure.

[0026] It is to be appreciated that all the aforementioned implementation forms can be combined.

[0027] It has to be noted that all devices, elements, circuitry, units and means described in the present application could be implemented in the software or hardware elements or any kind of combination thereof. All steps which are performed by the various entities described in the present application as well as the functionalities described to be performed by the various entities are intended to mean that the respective entity is adapted to or configured to perform the respective steps and functionalities. Even if, in the following description of specific embodiments, a specific functionality or step to be performed by external entities is not reflected in the description of a specific detailed element of that entity which performs that specific step or functionality, it should be clear for a skilled person that these methods and functionalities can be implemented in respective software or hardware elements or any kind of combination thereof. It will be appreciated that features of the present disclosure are susceptible to being combined in various combinations without departing from the scope of the present disclosure as defined by the appended claims. Additional aspects, advantages, features, and objects of the present disclosure would be made apparent from the drawings and the detailed description of the illustrative implementations construed in conjunction with the appended claims that follow.

[0028] BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The summary above, as well as the following detailed description of illustrative embodiments, is better understood when read in conjunction with the appended drawings. For the purpose of illustrating the present disclosure, exemplary constructions of the disclosure are shown in the drawings. However, the present disclosure is not limited to specific methods and instrumentalities disclosed herein. Moreover, those in the art will understand that the drawings are not to scale. Wherever possible, like elements have been indicated by identical numbers.

[0030] Embodiments of the present disclosure will now be described, by way of example only, with reference to the following diagrams wherein:

[0031] FIG. l is a block diagram of a code generator controller configured to receive a plurality of test models and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure;

[0032] FIG. 2 is a flowchart of a method for a code generator controller configured to receive a plurality of test models and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure;

[0033] FIG. 3 is a block diagram of a code generator controller configured to receive a production model and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure;

[0034] FIG. 4 is a flowchart of a method for a code generator controller configured to receive a production model and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure;

[0035] FIG. 5A and FIG. 5B are diagrams that depict a high-level representation of a process of verification of an auto-generated code, in accordance with different embodiments of the present disclosure;

[0036] FIG. 6 is a diagram that depicts an exemplary scenario of a verification of a generated set of source code files, in accordance with an embodiment of the present disclosure;

[0037] FIG. 7 is a sequence diagram that depicts a structure inference phase, in accordance with an embodiment of the present disclosure; FIG. 8A, FIG. 8B, and FIG. 8C are diagrams that depict an extraction and merging phase of verification of a generated set of source code files, in accordance with different embodiments of the present disclosure;

[0038] FIG. 9A and FIG. 9B are diagrams that depict exemplary operations that can be performed while merging superior-abstract syntax trees, in accordance with an embodiment of the present disclosure;

[0039] FIG. 10 is a sequence diagram that depicts the verification phase, in accordance with an embodiment of the present disclosure; and

[0040] FIG. 11 A, FIG. 1 IB, and FIG. 11C are diagrams that depict the verification of a code structure tree, in accordance with an embodiment of the present disclosure.

[0041] In the accompanying drawings, an underlined number is employed to represent an item over which the underlined number is positioned or an item to which the underlined number is adjacent. A non-underlined number relates to an item identified by a line linking the nonunderlined number to the item. When a number is non-underlined and accompanied by an associated arrow, the non-underlined number is used to identify a general item at which the arrow is pointing.

[0042] DETAILED DESCRIPTION OF EMBODIMENTS

[0043] The following detailed description illustrates embodiments of the present disclosure and ways in which they can be implemented. Although some modes of carrying out the present disclosure have been disclosed, those skilled in the art would recognize that other embodiments for carrying out or practicing the present disclosure are also possible.

[0044] FIG. l is a block diagram of a code generator controller configured to receive a plurality of test models and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure. With reference to FIG. 1, there is shown a block diagram 100 of a code generator controller 102. There is further shown a plurality of test models 104, a set of source code files 106, and an annotation file 108.

[0045] The code generator controller 102 is configured to receive the plurality of test models 104 to generate the set of source code files 106. Examples of the code generator controller 102 may include, but are not limited to, a microcontroller, a microprocessor, a central processing unit (CPU), a complex instruction set computing (CISC) processor, an application-specific integrated circuit (ASIC) processor, a reduced instruction set (RISC) processor, a very long instruction word (VLIW) processor, a data processing unit, and other processors or control circuitry.

[0046] In operation, the code generator controller 102 is configured to receive a plurality of test models 104 and generate the set of source code files 106 based on code templates. The set of source code files 106 may include a first source code file 106A, a second source code file 106B, up to nth source code file 106N. Moreover, the plurality of test models covers all possible code templates. In an implementation, the plurality of test models 104, such as a functional test model, architectural model, and the like, depicts the functionality and the behaviour of the generated set of source code files 106. In an implementation, the code templates correspond to pre-defined templates that are used for generating the set of source code files 106. As a result, the code generator controller 102 is configured to cover all the possible potential scenarios or variations in the code templates to ensure that the generated set of source code files 106 cover all the possible scenarios and requirements of the code effectively, and efficiently with desired functionality specified by the plurality of test models 104.

[0047] Furthermore, the code generator controller 102 is configured to generate the annotation file 108 including annotations 110 for each generated set of source code files. For example, the code generator controller 102 is configured to generate a first annotation file including annotations for a generated first set of source code files. Similarly, the code generator controller 102 is configured to generate a second annotation file including annotations for a second generated set of source code files 106. Moreover, the annotations 110 indicates the code templates that are used to produce the computer code instructions. In an implementation, a program or application, such as through a “Back Annotator” is configured to generate the annotation file 108. Moreover, the annotations 110 are used to link the generated set of source code files, such as the generated set of source code files 106 with the corresponding part of the test models from the plurality of test models 104, which is responsible for the generation of the set of source code files 106. Moreover, the annotations 110 are used to provide valuable information about the code generation process that is used to indicate the corresponding code template, which is used to generate the set of source code files 106. In an implementation, the code generator controller 102 is further configured to generate the set of source code files 106 including the annotation file 108. Moreover, the annotations 110 are interleaved with the computer code instructions that are used to provide additional information that improves the readability, and transparency of the generated set of source code files 106 to provide insights into the logic and behaviour of the code. As a result, the annotations 110 can be further used for the modification, customization and debugging of the generated set of source code files 106 as per the requirement.

[0048] In accordance with an embodiment, the annotations 110 in the annotation file 108 allows for backtracking of each character generated in the computer code instructions to the code generator template responsible for generating the character. The backtracking of each of the characters generated in the computer code instructions to the code generator template is responsible for generating the character that is used to trace the errors or issues within the generated set of source code files 106 that can be further used to customize, modify, or improve the generated set of source code files 106. As a result, the code generator controller 102 is configured to provide precise character backtracking of each of the characters that is generated in the computer code instructions to the code generator template responsible for generating the character that can be used in debugging, customization, and analysing of the generated set of source code files 106.

[0049] Furthermore, the code generator controller 102 is configured to generate an annotation abstract syntax tree (AST) for each annotation file. For example, the code generator controller 102 is configured to generate the annotation AST for a first annotation file. Similarly, the code generator controller 102 is configured to generate the annotation AST for a second annotation file. In an implementation, the annotation AST corresponds to a tree representation of an abstract syntactic structure of a text (or a source code) written in a formal language. For an example, the grouping parentheses are implicit in the annotation AST structure, then, in such case, the grouping parentheses are not required to be represented as a separate node. Similarly, a syntactic construct, such as an ‘if-else’ condition can be denoted by a single node with two branches (or sub-nodes). As a result, the code generator controller 102 is configured to distinguish between the abstract AST and a concrete syntax tree that can be further used for program analysis and transformation systems. Furthermore, the abstract AST is used to verify the correctness of the generated set of source code files 106 even if the plurality of test models are not functional models and the generated set of source code files 106 is not executable. Furthermore, the code generator controller 102 is configured to generate a code abstract syntax tree (AST) for each generated set of source code files. For example, the code generator controller 102 is configured to generate a code abstract syntax tree (AST) for a first generated set of source code files. Similarly, the code generator controller 102 is configured to generate a code abstract syntax tree (AST) for a second generated set of source code files 106. In an implementation, the code AST corresponds to a hierarchical representation of the code that represents a relationship of different elements of the code, such as variables, functions, expressions, control flow statements, and the like. As a result, the code generator controller 102 is configured to provide an efficient, reliable, and accurate code analysis, transformation, targeted code generation, and visualization to provide an improved code quality.

[0050] Furthermore, the code generator controller 102 is configured to generate one superior abstract syntax tree (AST) structure representing all possible outputs for the code generator based on the code abstract syntax trees and the annotation abstract syntax tree. The one superior abstract syntax tree structure corresponds to an extended abstract syntax tree that includes information about the AST of the generated code that is the code AST and the annotation AST. Moreover, the superior AST structure represents all the possible outputs for the plurality of test models 104. As a result, the generated superior AST structure is used for the verification of the correctness of the set of generated set of source code files, such as by comparing the generated superior AST structure with the content of a reference superior AST. In accordance with an embodiment, the code generator controller 102 is further configured to generate the superior AST structure by extracting nodes of each code AST using a parser, extracting nodes of the templates from each annotation AST, and merging these nodes. Firstly, the code generator controller 102 is configured to generate the code AST and the annotation AST for each of the generated set of source code files. Thereafter, the code generator controller 102 is configured to extract the nodes of each of the code AST using the parser. After that, the code generator controller 102 is configured to extract the nodes of each of the annotation AST. Finally, the code generator controller 102 is configured to merge the extracted nodes of each of the code AST and the annotation AST to generate the superior AST structure. Hence, the generation of the superior AST structure allows the code generator controller 102 to verify the generated set of source code files 106 efficiently, accurately, and reliably.

[0051] The code generator controller 102 is configured to generate the set of source code files based on the code templates that cover all the possible potential scenarios or variations in the code templates to ensure that the generated set of source code files 106 is capable to handle different scenarios and requirements effectively, efficiently with desired functionality specified by the plurality of test models 104. Furthermore, the code generator controller 102 is configured to generate the annotation file 108 for each of the generated set of source code files 106. The generated annotation file 108 is used to provide a record of which code template was used to produce the computer code instructions that are used for backtracking and understanding the generated set of source code files 106 efficiently and accurately with reduced time consumption. The code generator controller 102 is configured to provide precise character backtracking of each of the characters that are generated in the computer code instructions that is responsible for generating the character that can be used in debugging, customization, and analysing of the generated set of source code files 106. Furthermore, the code generator controller 102 is configured to generate the annotation AST for each annotation file that allows the structured representation of the annotations 110 that is further used to verify the correctness of the generated set of source code files 106 even if the test model from the plurality of test models 104 is not a functional model and the generated set of source code files 106 is not executable.

[0052] Furthermore, the code generator controller 102 is configured to generate the code AST for each generated set of source code files to provide an efficient, dependable, and accurate code analysis to provide an improved code quality. Furthermore, the code generator controller 102 is configured to generate one superior AST structure representing all possible outputs for the code generator that can be used for the verification of the correctness of the set of generated set of source code files, such as by comparing the generated superior AST structure with the content of a reference superior AST structure.

[0053] FIG. 2 is a flowchart of a method for a code generator controller configured to receive a plurality of test models and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure. FIG. 2 is described in conjunction with elements from FIG. 1. With reference to FIG. 2, there is shown a flowchart of method 200 that includes steps 202 to 208. The code generator controller 102 is configured to execute the method 200.

[0054] The method 200 for the code generator controller 102 (of FIG. 1) can be configured to receive the plurality of test models 104 and generate the set of source code files 106 based on code templates. Moreover, the plurality of test models 104 covers all possible code templates. As a result, the code generator controller 102 is configured to cover all the possible potential scenarios or variations in the code templates to ensure that the generated set of source code files 106 is capable to handle different scenarios and requirements effectively, and efficiently with desired functionality specified by the plurality of test models 104. Furthermore, at step 202, the method 200 includes generating the annotation file 108 including annotations 110 for each generated set of source code files. Moreover, the annotations 110 indicate which templates were used to produce the computer code instructions. In an implementation, a program or application, such as through a “Back Annotator” is configured to generate the annotation file 108 that includes the annotations 110. At step 204, the method 200 includes generating an annotation abstract syntax tree for each annotation file 108. Furthermore, at step 206, the method 200 includes generating a code abstract syntax tree for each generated set of source code files. The code AST corresponds to a hierarchical representation of the code that represents a relationship of different elements of the code, such as variables, functions, expressions, control flow statements, and the like. As a result, an efficient, reliable, and accurate code with an improved code quality is obtained. At step 208, the method 200 includes generating one superior abstract syntax tree structure representing all possible outputs for the code generator based on the code abstract syntax trees (AST) and the annotation abstract syntax tree (AST). The one superior abstract syntax tree structure corresponds to an extended abstract syntax tree that includes information about the AST of the generated code that is the code AST and the annotation AST. Moreover, the superior AST structure represents all the possible outputs for the plurality of test models 104. As a result, the generated one superior AST structure is used for the verification of the correctness of the set of generated set of source code files, such as by comparing the generated superior AST structure with the content of a reference superior AST.

[0055] The method 200 is used to generate the set of source code files based on the code templates that cover all the possible potential scenarios or variations in the code templates to ensure that the generated set of source code files 106 is capable to handle different scenarios and requirements effectively, and efficiently with desired functionality specified by the plurality of test models 104. Furthermore, the method 200 is used to generate the annotation file 108 for each of the generated set of source code files 106. The generated annotation file 108 is used to provide a record of which code template was used to produce the computer code instructions that are used for backtracking and understanding the generated set of source code files efficiently and accurately with reduced time consumption. The method 200 provides precise character backtracking of each of the characters that are generated in the computer code instructions to the code generator template responsible for generating the character that can be used in debugging, customization, and analysing of the generated set of source code files 106. Furthermore, the method 200 is used to generate the annotation abstract syntax tree (AST) for each annotation file that allows the structured representation of the annotations 110 that is further used to verify the correctness of the generated set of source code files 106 even if the test model from the plurality of test models 104 is not a functional model and the generated set of source code files 106 is not executable.

[0056] Furthermore, the method 200 is used to generate the code AST for each generated set of source code files 106 to provide an efficient, dependable, and accurate code analysis, transformation, targeted code generation, and visualization to provide an improved code quality. Furthermore, the method 200 is used to generate one superior AST structure representing all possible outputs for the code generator that can be used for the verification of the correctness of the set of generated set of source code files 106, such as by comparing the generated superior AST structure with the content of a reference superior AST structure.

[0057] The steps 202 to 208 are only illustrative, and other alternatives can also be provided where one or more steps are added, one or more steps are removed, or one or more steps are provided in a different sequence without departing from the scope of the claims herein.

[0058] There is provided a computer program product comprising program instructions for performing the method 200 when executed by one or more processors in a code generator system. The computer program product is implemented as an algorithm, embedded in a software stored in the non-transitory computer-readable storage medium having program instructions stored thereon, the program instructions being executable by the one or more processors in the computer system to execute the method 200. The non-transitory computer-readable storage means may include, but are not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. Examples of implementation of computer- readable storage medium, but are not limited to, Electrically Erasable Programmable Read- Only Memory (EEPROM), Random Access Memory (RAM), Read Only Memory (ROM), Hard Disk Drive (HDD), Flash memory, a Secure Digital (SD) card, Solid-State Drive (SSD), a computer-readable storage medium, and / or CPU cache memory.

[0059] FIG. 3 is a block diagram of a code generator controller configured to receive a production model and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure. With reference to FIG. 3, there is shown a block diagram 300 of a code generator controller 302 that is configured to receive a production model 304 and generate a set of source code files 306.

[0060] The code generator controller 302 may be different from the code generator controller 102 (of FIG. 1). Examples of the code generator controller 302 may include, but are not limited to, a microcontroller, a microprocessor, a central processing unit (CPU), a complex instruction set computing (CISC) processor, an application-specific integrated circuit (ASIC) processor, a reduced instruction set (RISC) processor, a very long instruction word (VLIW) processor, a data processing unit, and other processors or control circuitry.

[0061] There is provided the code generator controller 302 that is configured to receive the production model 304 and generate the set of source code files 306 based on code templates. In an implementation, the production model 304 acts as an input to the code generator controller 302 in order to generate the set of source code files 306 based on the code templates. For example, the code generator controller 302 is configured to generate a first set of source code files based on a first code template. Furthermore, the code generator controller 302 is configured to receive a superior AST structure. In an example, the superior AST is generated by another code generator controller, such as the code generator controller 102 of FIG. 1. Moreover, the received superior AST represents all the possible outputs for the code generator based on the code AST and the annotation AST that are generated by other code generator controllers, such as the code generator controller 102 of FIG. 1. Furthermore, the code generator controller 302 is configured to verify the computer code instructions based on the superior AST by generating an annotation file 308 for the generated set of source code files, generating an annotation abstract syntax tree for the annotation file 308 and generating a code abstract syntax tree for the generated set of source code files. Furthermore, the code generator controller 302 is configured to verify the computer code instructions based on the superior AST structure by generating one production superior abstract syntax tree structure representing the generated computer code instructions based on the code abstract syntax trees and the annotation AST. Firstly, the code generator controller 302 is configured to generate the annotation file 308 for each of the generated set of source code files 306. Thereafter, the code generator controller 302 is configured to verify the computer code instructions based on the production superior AST structure. Moreover, the annotation AST represents the structure and relationships of the annotations, and the code AST represents the hierarchical structure of code elements, such as variables, functions, control flow statements, and the like of the generated set of source code files 306. Furthermore, the code generator controller 302 is configured to verify the computer code instructions based on the superior AST structure by generating one production superior AST structure representing the generated computer code instructions based on the code AST and the annotation AST, such as by extracting and merging the nodes of each of the generated code AST and the nodes of each of the generated annotation AST.

[0062] Furthermore, the code generator controller 302 is configured to verify the computer code instructions based on the superior AST structure by comparing the production superior AST to the received superior AST structure to determine if each node of the production superior AST has a corresponding node in the received superior AST structure, and if so, verifying the computer code instructions. In other words, the code generator controller 302 is configured to compare each of the nodes of the received superior AST with each of the nodes of the generated production superior AST. In an implementation, the code generator controller 302 receives the superior AST from another code generator controller, such as the code generator controller 102 of FIG. 1. By virtue of verifying the computer code instructions by comparing the received superior AST structure with the production superior AST, the code generator controller 302 is configured to detect any discrepancies or inconsistencies. For example, if all the nodes of the received superior AST structure have corresponding nodes in the production superior AST, then, in that case, the code generator controller 302 is configured to indicate that the computer instructions are in line with the expected structure. Hence, the code generator controller 302 is configured to ensure the correctness and reliability of the generated set of source code files 306.

[0063] In an implementation, the code generator controller 302 is further configured to compare the production superior AST to the received superior AST structure by recursively navigating both the production superior AST and the received superior AST and applying a matching rule. The matching rule depends on the type of a node currently visited. In an implementation, each node from the production superior AST and the superior AST structure may have different criteria for matching. For example, if the node represents an assignment statement, then, in that case, the matching rule may compare the variable and the expression that is assigned to the corresponding node. As a result, the code generator controller 302 is configured to identify the differences or discrepancies between the production superior AST and the received superior AST structure that can be further used to determine the errors and bugs in the generated set of source code files 306. However, additional checks can also be performed while comparing the production superior AST to the received superior AST structure. For example, the code generator controller 302 is configured to check that references to the production model are valid (i.e., the production model is not changed since when the set of source code files 306 has been generated) or not.

[0064] In a further implementation, the code generator controller 302 is further configured to navigate the production superior AST and the received superior AST structure by starting the matching in a node of the production superior AST. Furthermore, the code generator controller 302 is configured to determine that there is a match if a set of attributes of the node of the production superior AST are equal to the ones in the received superior AST structure node, and if the analysis on the child nodes returns, they match as well. The set of attributes checked may vary depending on the type of node that is under analysis and may include the node name, the number of children, and other types of attributes. In other words, the code generator controller 302 is configured to select a node from the production superior AST as a starting point that acts as a reference for comparing the node to the corresponding node in the received superior AST structure. Furthermore, the code generator controller 302 is configured to examine the annotation node of the corresponding node in the production superior AST as the annotation node includes information about the node, such as name, number of children and the like. In order to determine that there is a match, the code generator controller 302 is configured to determine if a set of attributes have the same value in the corresponding node in the received superior AST structure as the node in the production superior AST or not. Furthermore, if a corresponding node in the received superior AST structure has the same attributes as the node in the production superior AST, then in that case, the code generator controller 302 is configured to inspect the children of the annotation node in the production superior AST to verify that the corresponding children in the received superior AST structure do not include any error. As stated beforehand, the number and type of attributes checked may vary depending on the node under analysis. For example, a ‘for loop’ includes a variable number of iterations which cannot be predicted a priori. Hence, the corresponding nodes that include the ‘for loop’ match even if the number of children is not the same. In addition, the code generator controller 302 may not check the name of the corresponding node if the name of the corresponding node depends on a string, which is read from the model. As a result, the code generator controller 302 is configured to ensure that the matched nodes, along with their child nodes, are consistent and error-free.

[0065] The code generator controller 302 is configured to verify the generated set of source code files efficiently, accurately, and reliably from the production model 304 (model-to-text transformation) or text (text-to-text transformation), which is suitable for code generators that aims at generating the skeleton of the application that can be used in different domains, such as avionics and other embedded systems. Therefore, the code generator controller 302 is configured for the verification of the auto-generated codes, such as the generated set of source code files with reduced human interaction and reduced time that is required to verify each of the generated source code file 306.

[0066] FIG. 4 is a flowchart of a method for a code generator controller configured to receive a production model and generate a set of source code files based on code templates, in accordance with an embodiment of the present disclosure. FIG. 4 is described in conjunction with elements from FIG. 3. With reference to FIG. 4, there is shown a flowchart of method 400 that includes steps 402 to 406. The code generator controller 302 is configured to execute the method 400.

[0067] There is provided the method 400 for the code generator controller 302 (of FIG. 3) configured to receive the production model and generate a set of source code files based on code templates. In an implementation, the production model 304 acts as an input to the code generator controller 302 in order to generate the set of source code files 306 based on the code templates. At step 402, the method 400 includes receiving a superior AST structure. Moreover, the received superior AST represents all the possible outputs for the code generator based on the code AST and the annotation AST that are generated by other code generator controllers, such as the code generator controller 102 of FIG. 1. At step 404, the method 400 includes verifying the computer code instructions based on the superior AST structure by using sub-step 404A to 404D. At substep 404A and sub-step 404B, the method 400 includes generating an annotation file for the generated set of source code files and generating an annotation abstract syntax tree (AST) for the annotation file 308. Furthermore, at sub-step 404C, the method 400 includes generating a code abstract syntax tree for the generated set of source code files and at sub-step 404D, the method 400 includes generating one production superior abstract syntax tree structure representing the generated computer code instructions based on the code AST and the annotation AST. Firstly, the code generator controller 302 is configured to generate the annotation file 308 for each of the generated set of source code files. Moreover, the generated annotation file 308 indicates the code template from the code templates that are used to produce the computer code instructions. In other words, the annotation file 308 serves as a reference to track the origin and purpose of each section of the generated set of source code files. Thereafter, the code generator controller 302 is configured to verify the computer code instructions based on the production superior AST structure. Moreover, the annotation AST represents the structure and relationships of the annotations, and the code AST represents the hierarchical structure of code elements, such as variables, functions, control flow statements, and the like of the generated set of source code files 306. After that, the code generator controller 302 is configured to verify the computer code instructions based on the superior AST structure by generating one production superior AST structure representing the generated computer code instructions based on the code AST and the annotation AST, such as by extracting and merging the nodes of each of the generated code AST and the nodes of each of the generated annotation AST.

[0068] At sub-step 406, the method 400 includes comparing the production superior AST to the received superior AST structure to determine if each node of the production superior AST has a corresponding node in the received superior AST structure and if so, verifying the computer code instructions. By virtue of verifying the computer code instructions by comparing the received superior AST structure with the production superior AST, the code generator controller 302 is configured to detect any discrepancies or inconsistencies. For example, if all the nodes of the received superior AST structure have corresponding nodes in the production superior AST, then, in that case, the code generator controller 302 is configured to indicate that the computer instructions are in line with the expected structure.

[0069] The method 400 is used to verify the generated set of source code files efficiently, accurately, and reliably from the production model 304 (model-to-text transformation) or text (text-to-text transformation), which is suitable for code generators that aim at generating the skeleton of the application that can be used in different domains, such as avionics and other embedded systems. Therefore, the method 400 is used for the verification of the auto-generated codes, such as the generated set of source code files 306 with reduced human interaction and reduced time that is required to verify each of the generated set of source code files 306. The steps 402 to 406 are only illustrative, and other alternatives can also be provided where one or more steps are added, one or more steps are removed, or one or more steps are provided in a different sequence without departing from the scope of the claims herein.

[0070] There is provided a computer program product comprising program instructions for performing the method 400 when executed by one or more processors in a code generator system. The computer program product is implemented as an algorithm, embedded in a software stored in the non-transitory computer-readable storage medium having program instructions stored thereon, the program instructions being executable by the one or more processors in the computer system to execute the method 400. The non-transitory computer-readable storage means may include, but are not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. Examples of implementation of computer- readable storage medium, but are not limited to, Electrically Erasable Programmable Read- Only Memory (EEPROM), Random Access Memory (RAM), Read Only Memory (ROM), Hard Disk Drive (HDD), Flash memory, a Secure Digital (SD) card, Solid-State Drive (SSD), a computer-readable storage medium, and / or CPU cache memory.

[0071] FIG. 5A and FIG. 5B are diagrams that depict a high-level representation of a process of verification of an auto-generated code, in accordance with different embodiments of the present disclosure. With reference to FIG. 5 A, there is shown a diagram that represents a first step 500A for the verification of the process of the verification of the auto-generated code. In such implementation, at operation 504, a tool developer 502 (or a vendor) uses the code generator controller 102 that is configured to obtain a set of test cases, such as the plurality of test models 104 and link code generator components with the output of the set of test cases, such as at operation 506. In other words, the code generator controller 102 is configured to test the generated code and each fragment of the generator application. After that, at operation 508, information to infer all possible code structures generated by any function in the code generator application is obtained through the code generator controller 102. With reference to FIG. 5B, there is shown a diagram that represents a second step 500B for the verification of the process of the verification of the auto-generated code. In such implementation, the second step 500B is performed by a code generator user 510. In an implementation, the code generator user 510 uses the code generator controller 302 that is configured to generate set of source code files, such as at operation 512. Thereafter, at operation 514, execute an algorithm or application to verify the generated set of source code files, such as by matching the structure of the generated set of source code files, which is obtained in the first step 500A. As a result, an efficient, an accurate, reliable, and verified code is obtained from the code generator controller 102.

[0072] FIG. 6 is a diagram that depicts an exemplary scenario of a verification of a generated set of source code files, in accordance with an embodiment of the present disclosure. With reference to FIG. 6, there is shown a diagram 600 that represents a workflow that includes activities, inputs, outputs, and actors that are used for the verification of the generated set of source code files.

[0073] In such an exemplary scenario, a code generator developer 602 (or a vendor), such as through the code generator controller 102 (of FIG. 1) generates a set of source code files 612 through a plurality of test models 606 based on the code templates. The generated set of source code files 612 includes annotations 614. For example, a hypothetical generated set of source code files is shown below: int sum (int a, int b) { return a+b;

[0074] }

[0075] Furthermore, the annotations that are generated by the code generator controller 102 are shown below:

[0076] <template name=”sum_fun” start=0 end=42>

[0077] <template name=”sum_sign” start=0 end=21>

[0078] <var path- 7path / in / model / a” start=12 end=13>

[0079] <var path- 7path / in / model / b” start=19 end=20>

[0080] < / template>

[0081] <template name=”sum_body” start=26 end=39>

[0082] <var path- 7path / in / model / a” start=33 end=34>

[0083] <var path- 7path / in / model / b” start=37 end=38>

[0084] < / template>

[0085] < / template> In addition, the generation of the annotations 614 depends upon the number of variables, such as the destination format, the code generator implementation, the input model, and the like and can be written inline in the generated set of source code files or as a separate file. However, the syntax and a destination format of the annotations may vary. Finally, the code generator controller is configured to read all the possible sets of generated set of source code files, such as through a test code 612 and annotations 614 to infer all the possible code structures 618. Thereafter, a code generator user 604, such as through the code generator controller 302 is configured to receive a production model 620 and generate a set of source code files 626 that includes annotations 628 based on code templates, wherein the code generator controller 302 is further configured to verify the computer code instructions (or verify a code structure), such as by the code generator controller 630. In an implementation, the production model 620 is further connected to a code generator 622 and a back-annotator 624 respectively. In an example, the set of source code files 626 that includes the annotation code 628 are generated by the code generator controller 302 via the code generator 622 and the back-annotator 624. Finally, the code generator controller 302 is configured to produce a report 632 in human-readable or computer-readable format. Hence, the verification of the generated set of source code files is performed efficiently, reliably, and accurately with reduced time consumption.

[0086] FIG. 7 is a sequence diagram that depicts a structure inference phase, in accordance with an embodiment of the present disclosure. With reference to FIG. 7, there is shown a sequence diagram 700 that includes operations from 702 to 710. At operation 702 and operation 704, a code abstract syntax tree (AST) and an annotation (AST) are extracted. In an implementation, the code generator controller 102 is configured to extract the code abstract syntax tree (AST) and the annotation (AST) from the generated set of source code files 106. Moreover, the extraction of the generator AST from the annotations is shown and described in detail in FIG. 8A. Furthermore, at operation 706, a superior AST is generated, and further superior-AST computations are performed accordingly. In an implementation, the code generator controller 102 is configured to merge the code abstract syntax tree (AST) and the annotation AST to generate a superior-AST structure that is used to perform computations. At operation 708, the multiple super-ASTs are merged and at operation 710, the merged multiple superior-AST are serialized on a disk. In an implementation, the serialization format may vary (XML, JSON, binary format, and the like) as per the requirement. As a result, the superior-AST (or a reference superior AST) is generated, which is further used to perform verification of the generated source code file, such as to verify the set of source code files 306.

[0087] FIG. 8A, FIG. 8B, and FIG. 8C are diagrams that depict an extraction and merging phase of verification of a generated set of source code files, in accordance with different embodiments of the present disclosure. With reference to FIG. 8A, there is shown a diagram 800A that depicts the extraction of an annotation abstraction syntax tree (AST). In such implementation, a code structure includes a template node 802A with value sum fun (0,42). In an example, the number ‘0’ and ‘42’ in the value sum_fun (0,42) represents the character offset of objects in a file (i.e., the character at which that object starts and end in the file). Optionally, the number ‘0’ and ‘42’ are used to merge containment relationships from the character offsets (e.g., an item with offset (10,11) is contained by another with offset (8, 15)). The template node 802A further includes a template node 802B, and a template node 802C as sub-nodes of the template node 802A. Moreover, the template node 802B represents a function with a value sum sign (0,21) and the template node 802C represents a function with sum body (26,39). Furthermore, the template node 802B includes a sub-node var 804A with value a (12,13) and another sub-node var 804B with value b (19,20). Similarly, the template node 802C includes a sub-node var 804C with value a (33,34) and another sub-node var 804D with value b (37,38). As a result, the annotation AST is extracted by a code generator controller, which is further used for the verification of the generated set of source code files, such as the generated set of source code files 306.

[0088] With reference to FIG. 8B, there is shown a diagram 800B that depicts the extraction of a code abstraction syntax tree (AST). In such implementation, a code structure represents a function node, which is represented by a FuncDef node 806 that includes a function sum (0,42). Furthermore, the FuncDef node 806 include sub-nodes, such as an argument functions that are represented by a FuncArg node 808A, and a FuncArg node 808B. In addition, the FuncDef node 806 further includes a body function that is represented by a FuncBody node 810 with value (23,42). In addition, the FuncArg node 808A represents a value a (8,13), the FuncArg node 808B includes a value b (15,20) and the FuncBody node 810 represents a value (23,42). The FuncBody node 810 includes the sub-node ReturnStmt 812 with value (26,38) that further includes the sub-node Binary OP node 814 with addition operation with value added (33,38). Furthermore, the sub-node BinaryOP node 814 includes sub-nodes that are VarRef node 816A with value a (33,34) and a VarRef node 816B with value b (37,38). As a result, the code AST is extracted by the code generator controller.

[0089] Furthermore, with reference to FIG. 8C, there is shown a diagram 800C that represents a superior abstract tree, which is generated by merging an annotation abstract syntax tree (AST) and a code abstract syntax tree (AST). In an implementation, the code generator controller 102 is configured to merge the extracted code AST and the annotation AST to generate a superior AST. In such implementation, a code structure includes the template node 802A that represents a value sum fun (0,42). The template node 802A further includes a sub-node that represents a function, such as a FuncDef node 806. In addition, the FuncDef node 806 further includes subnodes, such as the template node 802B with the sum sign (0,21) and the FuncBody node 810 with the value (23,42). In addition, the template node 802B further includes a FUNCARG node 808A and the FuncArg node 808B that includes sub-nodes, such as the var node 804A and the var node 804B. In a further implementation, the FuncBody node 810 includes the sub-node that is the template node 802C with a value of sum body (26,39). The template node 802C further includes a sub-node, such as a ReturnStmt node 812 with the value (26,38) that further includes the sub-node Binary OP node 814. Finally, the Binary OP node 814 further includes the subnode that are var node 804C with value a (33,34) and a var node 804D with value b (37,38). Moreover, the var node 804C and the var node 804D further include the varRef sub-nodes, such as the VarRef node 816A with value a (33,34) and VarRef node 816B with value b (37,38) respectively. As a result, each of the nodes extracted from the annotation AST and the code AST are merged to generate the superior-AST.

[0090] FIG. 9A and FIG. 9B are diagrams that depict exemplary operations that can be performed while merging superior-abstract syntax trees, in accordance with an embodiment of the present disclosure. With reference to FIG. 9A, there is shown a diagram 900A that depicts the merging of an ‘if operation with ‘then’ and ‘else’ operation. In such an exemplary scenario, an operation 902 (i.e., ‘if operation) with a sub-node that includes a then operation 904 is merged with another operation 906 (i.e., another ‘if operation) with a sub-node that includes an operation 908 (i.e., ‘else’ operation). Thus, the merged superior AST is formed that includes an operation 910 (i.e., ‘if operation) with sub-nodes that includes an operation 912 (i.e., ‘then’ operation) and an operation 914 (i.e., ‘else’ operation).

[0091] With reference to FIG. 9B, there is shown a diagram 900B that depicts the merging of an operation 916 (i.e., ‘for’ operation) with a first iteration operation 918A and a second iteration operation 918B. In such an exemplary scenario, an operation 920 (i.e., ‘for’ operation) with the first iteration operation 918A and the second iteration operation 918B is merged to form a superior-AST. The first iteration operation 918A includes a sub-node, which represents an operation 920 (i.e., ‘if operation) that further includes the sub-node with operation 926 (i.e., ‘then’ operation). Similarly, the second iteration operation 918B includes a sub-node, which represents an operation 924 (i.e., ‘if operation) that further includes a sub-node with an operation 928 (i.e., ‘else’ operation). Finally, the merged superior-AST includes a parent node that represents an operation 920 (i.e., ‘for’ operation) with a sub-node that represents an operation 924 (i.e., ‘iteration’ operation). Furthermore, the operation 924 (i.e., ‘iteration’ operation) includes a sub-node with an operation 928 (i.e., ‘if operation) with sub-nodes that represents an operation 918 (i.e., ‘then operation) and an operation 920 (i.e., ‘else1operation). In an implementation, the code generator controller 102 is configured to compress multiple traces of executions, such as each of the code AST and each of the annotation AST in a single tree that contains all the possibilities, such as all the possible generated set of source code files that is generated based on the code templates. As a result, the merged superior-AST is generated that can be further used for the optimized verification of the generated set of source code files, such as the generated set of source code files 106.

[0092] FIG. 10 is a sequence diagram that depicts the verification phase, in accordance with an embodiment of the present disclosure. With reference to FIG. 10, there is shown a sequence diagram 1000A that includes operations from 1002 to 1012 of the verification phase. At operation 1002 and at operation 1004, a code abstract syntax tree (AST) and an annotation (AST) are extracted. In an implementation, the code generator controller 302 is configured to extract the code abstract syntax tree (AST) and the annotation AST from the generated set of source code files 306.

[0093] Furthermore, at operation 1006, a superior AST is generated to further superior-AST computations are performed accordingly. In an implementation, the code generator controller 302 is configured to merge the code abstract syntax tree (AST) and the annotation AST to generate a superior-AST structure that is used to perform computations. Furthermore, at operation 1008, the superior-AST is compared with the inferred code structure. Moreover, additional checks can be performed during the verification phase, such as the validity of the references to model objects 304 can be checked, such as at operation 1010. Finally, at operation 1012, an output report in human-readable or computer-readable format is produced. Furthermore, the generated superior-AST structure is matched with a reference superior-AST structure, such as by recursively navigating both the inferred code structure tree and the generated code tree and applying some matching rules that depend on the type of node. As a result, the generated set of source code files 306 is verified based on the code templates.

[0094] FIG. 11 A, FIG. 1 IB, and FIG. 11C are diagrams that depict the verification of a code structure tree, in accordance with an embodiment of the present disclosure. With reference to FIG. 11 A, there is shown a diagram 1100A that depicts a code structure, which is inferred from the plurality of test models (i.e., the plurality of test models 104 of FIG. 1). As 1100A represents a superior-AST, it contains both nodes coming from annotations (marked with a T) and nodes read from the generated file AST (marked with a C). In such implementation, a code structure includes a template node 1102A (e.g., ‘TemplateA’) includes a sub-node with an operation 1104A (i.e., ‘for’ operation) that further includes a sub-node with an operation 1106A (i.e. ‘iter’ operation) that further includes a sub-node with an operation 1108A (i.e., ‘if operation) which further includes two sub-nodes with an operation 1110 (i.e. ‘then’ operation) and another operation 1114A (i.e., ‘else’ operation). Moreover, the sub-node with the operation 1110A (i.e., the ‘then’ operation) further includes a sub-node that represents a function FnCall 1112A with ‘foo ()’ value. Thereafter, the sub-node with another operation 1114A (i.e., an ‘else’ operation) includes a sub-node with an operation 1116A (i.e., ‘if operation) which further includes two sub-nodes with an operation 1118A (i.e., ‘then’ operation) and another operation 1122A (i.e., an ‘else’ operation). Moreover, the sub-node with the operation 1118A (i.e., ‘then’ operation) further includes a sub-node that represents a function ‘FNCALL’ 1120A with value ‘bar ()’ and the other operation 1122A (i.e., an ‘else’ operation) includes a sub-node that represents a template call 1124A (e.g., ‘TemplateB’).

[0095] With reference to FIG. 1 IB, there is shown a diagram 1100B that depicts the matching of the code structure. In such implementation, the code structure includes the template node 1102B (e.g., ‘TemplateA’) that includes the sub-node with the operation 1104B (i.e., ‘for’ operation) that includes the sub-nodes with operations 1106B, 1114B and 1126B (i.e., ‘iter’ operations). The sub-node with operation 1106B includes a sub-node with operation 1108B (i.e., ‘if operation), that further includes a sub-node with operation 1110B (i.e., ‘then’ operation), that further includes a sub-node with operation 1112B that represents a function call FnCall with ‘foo ()’ value. Moreover, the sub-node with operation 1114B further includes a sub-node with operation 1116B (i.e. ‘if operation) that further includes a sub-node with operation 1118B (i.e. ‘else’ operation) that further includes a sub-node with operation 1120B (i.e. ‘if operation) that further includes a sub-node with operation 1122B (i.e. ‘else’ operation) that includes a subnode that represents a template call 1124B (e.g. ‘TemplateB’). Moreover, the sub-node with operation 1126B includes a sub-node with operation 1128B (i.e., ‘if operation), that further includes a sub-node with operation 1130B (i.e., ‘then’ operation), that further includes a subnode with operation 1132B that represents a function call FnCall with ‘foo ()’ value. In an implementation, the code generator controller, such as the code generator controller 302 analysis from a template node (i.e., the template node 1102B). Thereafter, the code generator controller is further configured to navigate the code structure and start matching the node of the code structure. For example, in the exemplary scenario, the code generator controller is configured to analyse the operation 1104B (i.e., the ‘for’ operation). Moreover, the number of iterations in executing the operation 1104B (i.e., the ‘for’ operation) may vary from one execution to another execution. However, the corresponding node can be considered equal only if all the children (i.e., the sub-nodes of the node that includes the ‘for’ operation) of the for loop in the current generation match one of the possibilities in the code structure.

[0096] With reference to FIG. 11C, there is shown a diagram 1100C that depicts a non-matching of the code structure. In such implementation, the code structure includes the template node 1102C (e.g., ‘TemplateA’) includes the sub-node with the operation 1104C (i.e., ‘for’ operation) that further includes the sub-nodes with the operations 1106C, 1114C, 1126C (i.e., ‘iter’ operations). Moreover, the sub-node with operation 1106C further includes a sub-node with operation 1108C (i.e., ‘if operation) that further includes a sub-node with operation 1110C (i.e., ‘then’ operation), that further includes a sub-node that represents a function call FnCall 1112C with ‘foo ()’ value. Moreover, the sub-node with operation 1114C further includes a sub-node with operation 1116C (i.e. ‘if operation) that further includes a sub-node with operation 1118C (i.e. ‘else’ operation) that further includes a sub-node with operation 1120C (i.e. ‘if operation) that further includes a sub-node with operation 1122C (i.e. ‘else’ operation) that includes a sub-node that represents a return statement 1124C. Moreover, the sub-node with operation 1126C includes a sub-node with operation 1128C (i.e., ‘if operation), that further includes a sub-node with operation 1130C (i.e., ‘then’ operation), that further includes a subnode with operation 1132C that represents a function call FnCall with ‘bar ()’ value. In an implementation, the code generator controller, such as the code generator controller 302 is configured to analyse the sub-nodes of the code structure. If the code generator controller analyses the first sub-node (or a child node) of the node that represents operation 1104C (i.e., the ‘for’ operation), then, in that case, the code generator controller reports no error. If the code generator controller analyses sub-node with operation 1114C (or one of its child nodes), then, in that case, the code generator controller reports an error as there exists a possibility for a node to include an ‘else’ operation that ends a code with a return statement instead of a template invocation. In addition, the code generator controller would report an error while analysing subnode with operation 1126C (or one of its child nodes) due to the change in the function that is invoked. Thus, the code generator controller is configured to mark ancestor nodes (i.e., a parent node) as faulty due to the errors in the sub-nodes. Hence, the code generator controller is configured to perform efficient, reliable, and accurate verification of the generated set of source code files.

[0097] Modifications to embodiments of the present disclosure described in the foregoing are possible without departing from the scope of the present disclosure as defined by the accompanying claims. Expressions such as "including", "comprising", "incorporating", "have", and "is" used to describe, and claim the present disclosure are intended to be construed in a non-exclusive manner, namely allowing for items, components or elements not explicitly described also to be present. Reference to the singular is also to be construed to relate to the plural. The word "exemplary" is used herein to mean "serving as an example, instance or illustration". Any embodiment described as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments or to exclude the incorporation of features from other embodiments. The word "optionally" is used herein to mean "is provided in some embodiments and not provided in other embodiments". It is appreciated that certain features of the present disclosure, which are, for clarity, described in the context of separate embodiments, may also be provided in combination in a single embodiment. Conversely, various features of the invention, which are, for brevity, described in the context of a single embodiment, may also be provided separately or in any suitable combination or as suitable in any other described embodiment of the disclosure.

Claims

CLAIMS1. A code generator controller (102) configured to receive a plurality of test models (104) and generate a set of source code files (106) based on code templates, wherein the plurality of test models (104) covers all possible code templates, wherein the code generator controller (102) is further configured to: generate an annotation file (108) comprising annotations (110) for each generated set of source code files, wherein the annotations (110) indicate which templates were used to produce the computer code instructions, generate an annotation abstract syntax tree for each annotation file, generate a code abstract syntax tree for each generated set of source code files, and generate one superior abstract syntax tree structure representing all possible outputs for the code generator based on the code abstract syntax trees and the annotation abstract syntax tree.

2. The code generator controller (102) according to claim 1, wherein the code generator controller (102) is further configured to generate the superior AST structure by extracting nodes of each code AST using a parser, extracting nodes of the templates from each annotation AST, and merging these nodes.

3. The code generator controller (102) according to any preceding claim, wherein the code generator controller (102) is further configured to generate the set of source code files (106) as comprising the annotation file, wherein the annotations (110) are interleaved with the computer code instructions.

4. The code generator controller (102) according to any preceding claim, wherein the annotations (110) in the annotation file (108) allow for backtracking each character generated in the computer code instructions to the code generator template responsible for generating the character.

5. A code generator controller (302) configured to receive a production model (304) and generate a set of source code files (306) based on code templates, wherein the code generator controller (302) is further configured toreceive a superior AST structure as per any preceding claim and to verify the computer code instructions based on the superior AST structure by generating an annotation file (308) for the generated set of source code files (306), generating an annotation abstract syntax tree for the annotation file (308), generating a code abstract syntax tree for the generated set of source code files (306), generating one production superior abstract syntax tree structure representing the generated computer code instructions based on the code abstract syntax trees and the annotation abstract syntax tree, and comparing the production superior AST to the received superior AST structure to determine if each node of the production superior AST has a corresponding node in the received superior AST structure, and if so, verifying the computer code instructions.

6. The code generator controller (302) according to claim 5, wherein the code generator controller (302) is further configured to compare the production superior AST to the received superior AST structure by recursively navigating both the production superior AST and the received superior AST structure and applying a matching rule, wherein the matching rule depends on a type of a node currently visited.

7. The code generator controller (302) according to claim 6, wherein the code generator controller (302) is further configured to navigate the production superior AST and the received superior AST structure by starting the matching in a node of the production superior AST and determine that there is a match if annotation node of the production superior AST has the same name, same number of children and if an analysis on the children indicates no error as a corresponding node in the received superior AST structure.

8. A method (200) for a code generator controller (102) configured to receive a plurality of test models (104) and generate a set of source code files (106) based on code templates, wherein the plurality of test models (104) covers all possible code templates, the method (200) comprising:generating an annotation file (108) comprising annotations (110) for each generated set of source code files (106), wherein the annotations (110) indicate which templates were used to produce the computer code instructions, generating an annotation abstract syntax tree for each annotation file, generating a code abstract syntax tree for each generated set of source code files, and generating one superior abstract syntax tree structure representing all possible outputs for the code generator based on the code abstract syntax trees and the annotation abstract syntax tree.

9. A computer program product comprising program instructions for performing the method (200) according to claim 8, when executed by one or more processors in a code generator system.

10. A method (400) for a code generator controller (302) configured to receive a production model (304) and generate a set of source code files (306) based on code templates, the method (400) comprising: receiving a superior AST structure as per any preceding claim and to verifying the computer code instructions based on the superior AST structure by generating an annotation file (308) for the generated set of source code files (306), generating an annotation abstract syntax tree for the annotation file (308), generating a code abstract syntax tree for the generated set of source code files (306), generating one production superior abstract syntax tree structure representing the generated computer code instructions based on the code abstract syntax tree and the annotation abstract syntax tree, and comparing the production superior AST to the received superior AST structure to determine if each node of the production superior AST has a corresponding node in the received superior AST structure, and if so, verifying the computer code instructions.

1. A computer program product comprising program instructions for performing the method (400) according to claim 10, when executed by one or more processors in a code generator system.