Code generation method and device, equipment and storage medium
By obtaining original data and code templates, and using parsing tools of the target programming language to generate AUTOSAR software component codes, the problem of high cost and low efficiency in using AUTOSAR development tools is solved, self-generated code is achieved and efficiency is improved.
Patent Information
- Application Number
- CN202310298279.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2024-09-24
AI Technical Summary
When developing programs based on AUTOSAR, using development tools such as Vector and EB tresos to generate software component codes has the problems of high cost and low efficiency.
By obtaining original data and code templates, and using parsing tools based on the target programming language to generate software component codes, self-code generation without the need for development tools provided by service providers is achieved.
The cost of generating software component code is reduced, the generation efficiency is improved, and users can solve errors in the code by themselves, avoiding the process of feedback to the service provider.
Smart Images

Figure CN118689459A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a code generation method, device, equipment and storage medium. Background Art
[0002] Normally, when developing programs based on the Automotive Open System Architecture (AUTOSAR), it is necessary to use development tools such as Vector and Elektrobit (EB tresos) provided by the service provider to generate software component (SWC) code in order to implement a specific function of the program through the SWC code.
[0003] However, when using development tools such as Vector and EB tresos, you often need to pay a certain fee to the service providers of these development tools. In addition, when these development tools have program errors (bugs), you also need to feedback to the service providers of these development tools to solve the bugs, which often takes a long time.
[0004] It can be seen that generating SWC code through development tools such as Vector and EB tresos has the problems of high cost and low efficiency. Summary of the invention
[0005] The embodiments of the present application provide a code generation method, apparatus, device, and computer-readable storage medium, which can reduce the cost of generating SWC code and improve the efficiency of generating SWC code.
[0006] On the one hand, an embodiment of the present application provides a code generation method, the method comprising:
[0007] Get the original data and code templates;
[0008] Parsing the original data by using a parsing tool to determine a parsing result, wherein the parsing tool is obtained based on a target library of a target programming language, and the parsing result includes a key element and an element type corresponding to the key element;
[0009] Generate SWC code according to the code template and the parsing result.
[0010] Optionally, before obtaining the original data and the code template, the method further includes:
[0011] Get SWC code writing rules;
[0012] In response to the user's operation, a code template that complies with the SWC code writing rule is determined.
[0013] Optionally, before parsing the original data using a parsing tool and determining the parsing result, the method further includes:
[0014] Get the target library for the target programming language;
[0015] According to a preset development script, the target library is developed to obtain a parsing tool.
[0016] Optionally, generating SWC code according to the code template and the parsing result includes:
[0017] Determining a placeholder parameter in the code template that matches the element type;
[0018] The placeholder parameter is replaced with the key element corresponding to the element type.
[0019] Optionally, before parsing the original data by a parsing tool to obtain a parsing result, the method further includes:
[0020] Obtain demand information;
[0021] In response to the user's operation, updating the template content of the code template according to the demand information, wherein the template content at least includes a matching relationship between placeholder parameters and element types, and a computer function;
[0022] In response to the user's operation, the parsing tool is updated according to the requirement information and the target library of the target programming language.
[0023] Optionally, generating SWC code according to the code template and the parsing result includes:
[0024] According to a preset transfer script, receiving the analysis result sent by the analysis tool;
[0025] inputting the code template into the delivery script;
[0026] Generate SWC code based on the parsing result and the code template through the transfer script
[0027] On the other hand, an embodiment of the present application provides a code generation device, the device comprising:
[0028] An acquisition unit, used to acquire original data and code templates;
[0029] A parsing unit, configured to parse the original data by using a parsing tool to determine a parsing result, wherein the parsing tool is obtained based on a target library of a target programming language, and the parsing result includes a key element and an element type corresponding to the key element;
[0030] The production unit is used to generate SWC code according to the code template and the parsing result.
[0031] On the other hand, an embodiment of the present application provides a code generation device, the device comprising:
[0032] a processor and a memory storing computer program instructions;
[0033] When the processor executes the computer program instructions, the code generation method as described in the above aspect is implemented.
[0034] On the other hand, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the code generation method as described in any one of the above aspects is implemented.
[0035] On the other hand, an embodiment of the present application provides a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device implements the code generation method as described in any one of the above aspects.
[0036] The code generation method, device, equipment and medium provided in the embodiments of the present application can generate SWC code based on code templates and parsing tools. The parsing tool is obtained based on the target library of the target programming language, and the code template is self-written, which realizes the generation of SWC code without the development tools such as Vector and EB tresos provided by the service provider. It can be seen that there is no need to pay the usage fee of the development tool, which reduces the cost of generating SWC code. In addition, since the code template and parsing tool used to generate SWC code are self-developed or written, when a BUG occurs, there is no need to feedback to the service provider, and it can be solved by the user himself, which improves the generation efficiency of SWC code. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0038] Figure 1 It is a flowchart of a code generation method provided by an embodiment of the present application;
[0039] Figure 2 This is a schematic diagram of a code generation structure provided by an embodiment of the present application;
[0040] Figure 3is a flowchart of a code generation method provided by another embodiment of the present application;
[0041] Figure 4 A schematic diagram of the structure of a code generation device provided by an embodiment of the present application;
[0042] Figure 5 It is a structural diagram of a code generation device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0044] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.
[0045] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0046] Figure 1 FIG. 1 is a flow chart of a code generation method provided by an embodiment of the present application. Figure 1 As shown, the code generation method provided in the embodiment of the present application includes the following steps: S101 to S103.
[0047] S101: Obtain original data and code template.
[0048] In one or more embodiments of the present application, the code generation method may be implemented by an electronic device. Of course, the electronic device may be a vehicle control center, a mobile phone, a tablet computer, a server, etc. The present application does not limit the specific device and may set the device as needed.
[0049] As described in the background technology, in order to improve the generation efficiency of SWC code and reduce the generation cost of SWC code, the electronic device can generate SWC code through code templates and parsing tools. Therefore, in one or more embodiments of the present application, the electronic device can obtain original data and code templates.
[0050] Among them, the original data is the source code used to generate the SWC code. The source code is usually a SWC configuration file (ARXML). Of course, the source code can also be of other types, and this application is no longer limited here. The code template is a pre-generated code template that conforms to the SWC code writing rules. The code template can be written by the user or generated by an electronic device. The specific determination of the code template is not limited in this application and can be set as needed. The template content of the code template includes computer functions, placeholder parameters, matching relationships between placeholder parameters and element types, etc. The placeholder parameter is a preset value. When generating the SWC code, the placeholder parameter can be replaced with the actual parameter, and the element type is the type of the parameter. For example, if the type of parameter A is B and the type of placeholder parameter C is D, then parameter A cannot replace placeholder parameter C.
[0051] In one or more embodiments of the present application, the code template is determined by the user. Before the electronic device implements step S101, the electronic device can obtain SWC code writing rules. The SWC code writing rules can be obtained based on the AUTOSOR architecture or based on the target library of the target language. The target language is a programming language, such as the Python programming language, the C language, the C++ language, etc. The target library is a library of the programming language, such as the Autosar library in the Python language, the string library in the C language, etc. In response to the user's operation after browsing the SWC code writing rules, the electronic device determines a code template that conforms to the SWC code writing rules.
[0052] In the above manner, the electronic device can obtain the original data for generating SWC code and the code template that complies with the SWC code writing rules, so as to generate SWC code based on the code template, thereby realizing the generation of SWC code without the need for development tools such as Vector and EB tresos provided by the service provider.
[0053] S102: Parsing the original data by using a parsing tool to determine a parsing result, wherein the parsing tool is obtained based on a target library of a target programming language, and the parsing result includes a key element and an element type corresponding to the key element.
[0054] Since only the placeholder parameters and other contents in the code template need to be replaced, it is necessary to determine the replacement values used to replace the placeholder parameters and other contents. Therefore, in one or more embodiments of the present application, the electronic device may parse the original data through a parsing tool to obtain a parsing result including key elements and the element type corresponding to the key elements.
[0055] Among them, the element type is the port name, port type and other contents, and the key element is the actual value corresponding to each element type. For example, after parsing the field "NONQUEUED-SENDER-COM-SPEC+DATA-SEND-POINTS" through the parsing tool, it can be obtained that the port type is S / R Explicit, that is, the value of the key element is determined to be S / R Explicit, and the element type corresponding to the key element is the port type. When replacing the placeholder parameter in the code template based on the key element, it is necessary to ensure that the element type corresponding to the replaced placeholder parameter is also the port type.
[0056] In order to obtain the parsing tool, the electronic device may develop the target library of the target language based on a preset development script to obtain the parsing tool before implementing step S102. Of course, the electronic device may also develop the target library of the target language in response to the user's operation to obtain the parsing tool. The specific determination of the parsing tool is not limited in this application and can be set as needed.
[0057] After determining the parsing tool, the electronic device can parse the raw data through the parsing tool to obtain a parsing result, which includes key elements and element types corresponding to the key elements. For example, the electronic device parses the “Rte_Write_ _ <d> " field, it can be determined that Rte_Write indicates that the port type corresponding to the data interface is S / R Explicit Sender, and< / d> Indicates the name of the part. <d>The name of the data element on the Port.
[0058] In the above manner, after the electronic device obtains the analysis result, it can generate SWC code based on the analysis result and the code template, thereby achieving generation of SWC code without development tools such as Vector and EB tresos provided by the service provider.
[0059] S103: Generate SWC code according to the code template and the parsing result.
[0060] In one or more embodiments of the present application, the electronic device may transmit the parsing result to the code template, thereby generating the SWC code according to the code template and the parsing result.
[0061] Specifically, first, the electronic device can obtain the parsing result from the parsing tool through a preset transfer script (Code Generator), or receive the parsing result sent by the parsing tool through the transfer script, and then transfer the parsing result to the code template through the Code Generator.
[0062] Secondly, the electronic device can determine the placeholder parameters in the code template that match a certain element type, and then determine the key elements corresponding to the element type in the parsing results based on the parsing results passed to the code template, and finally, replace the placeholder parameters matching the element type with the key elements corresponding to the element type.
[0063] In one or more embodiments of the present application, after receiving the parsing result sent by the parsing tool through the transfer script, the electronic device may also input the code template into the transfer script, and then generate SWC code based on the parsing result and the code template through the transfer script.
[0064] Figure 2 Another schematic diagram of code generation structure provided for an embodiment of the present application is as follows: Figure 2 shown.
[0065] The parsing result obtained by the parsing tool 202 after parsing the original data 201 is transferred to the code template 204 through the transfer script 204, thereby generating SWC code.
[0066] By adopting the above method, the electronic device can generate SWC code without the need of development tools such as Vector and EB tresos, thereby reducing the generation cost and improving the generation efficiency.
[0067] In the above embodiment, the electronic device can generate SWC code based on the code template and the parsing tool. The parsing tool is obtained based on the target library of the target programming language, and the code template is self-written, which realizes the generation of SWC code without the development tools such as Vector and EB tresos provided by the service provider. It can be seen that there is no need to pay the usage fee of the development tool, which reduces the cost of generating SWC code. In addition, since the code template and parsing tool used to generate SWC code are self-developed or written, when a BUG occurs, there is no need to feedback to the service provider, and it can be solved by the user, which improves the generation efficiency of SWC code.
[0068] In special circumstances, the user may need the generated SWC code to meet some customized needs, or the generated SWC code may contain program errors (bugs). Therefore, as another implementation method of the present application, the present application also provides another implementation method of the code generation method, see the following embodiments for details.
[0069] See also Figure 3 Another implementation of the code generation method provided in the present application includes the following steps: step S301 to step S306.
[0070] S301: Acquire original data and code template.
[0071] S302: Parsing the original data by using a parsing tool to determine a parsing result, wherein the parsing tool is obtained based on a target library of a target programming language, and the parsing result includes a key element and an element type corresponding to the key element.
[0072] S303: Obtain demand information.
[0073] In one or more embodiments of the present application, the electronic device can obtain demand information in response to the user's operation. The demand information can be determined by the user after determining that the SWC code generated based on the parsing tool and the code template cannot meet certain requirements, or it can be determined by the user after determining that the SWC code generated based on the parsing tool and the code template has a bug. The demand information is a certain requirement. For example, usually, function N is used in the SWC code to implement a certain function, but the user hopes to use function M to implement the function. Therefore, the demand information can be to use function M instead of function N and ensure that the function is implemented normally.
[0074] S304: In response to the user's operation, the template content of the code template is updated according to the demand information, and the template content at least includes a matching relationship between a computer function, a placeholder parameter, and an element type.
[0075] When the user determines that the code template needs to be updated according to the demand information, the electronic device can respond to the user's operation and update the template content of the code template according to the demand information, and the template content includes computer functions, matching relationships between placeholder parameters and element types, etc. A computer function is a function in a computer program.
[0076] S305: In response to the user's operation, the parsing tool is updated according to the demand information and the target library of the target programming language.
[0077] When the user determines that the parsing tool needs to be updated based on the requirement information, the electronic device can update the parsing tool based on the requirement information and the target library of the target programming language in response to the user's operation, so that the SWC code generated based on the updated code template and the parsing tool can meet the requirement information.
[0078] S306: Generate SWC code according to the code template and the parsing result.
[0079] Among them, step S301, step S302, and step S306 are the same as step S101 to step S103, and for the sake of brevity, this application will not repeat them here.
[0080] In addition, the acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0081] Based on the code generation method provided in the above embodiment, the present application also provides a specific implementation of a code generation device. Please refer to the following embodiment.
[0082] See first Figure 4 , the code generation device provided in the embodiment of the present application includes the following units:
[0083] An acquisition unit 801 is used to acquire original data and a code template;
[0084] A parsing unit 802 is used to parse the original data by using a parsing tool to determine a parsing result, wherein the parsing tool is obtained based on a target library of a target programming language, and the parsing result includes a key element and an element type corresponding to the key element;
[0085] The generating unit 803 is used to generate SWC code according to the code template and the parsing result.
[0086] According to the above embodiment, the generation unit 803 can generate SWC code based on the code template and the parsing tool. The parsing tool is obtained based on the target library of the target programming language, and the code template is self-written, which realizes the generation of SWC code without the development tools such as Vector and EB tresos provided by the service provider. It can be seen that there is no need to pay the usage fee of the development tool, which reduces the cost of generating SWC code. In addition, since the code template and parsing tool used to generate SWC code are self-developed or written, when a BUG occurs, there is no need to feedback to the service provider, and it can be solved by the user, which improves the generation efficiency of SWC code.
[0087] As another implementation of the present application, in order to reduce the cost of generating SWC codes, the above-mentioned device may further include: an acquisition subunit 8011.
[0088] The acquisition subunit 8011 is used to acquire the SWC code writing rule and determine the code template that complies with the SWC code writing rule in response to the user's operation.
[0089] As another implementation of the present application, in order to reduce the cost of generating SWC codes, the above apparatus may further include: a parsing subunit 8021 .
[0090] The parsing subunit 8021 is used to obtain a target library of a target programming language, develop the target library according to a preset development script, and obtain a parsing tool.
[0091] As another implementation of the present application, in order to reduce the cost of generating SWC codes, the above-mentioned device may further include: a generating subunit 8031.
[0092] The generating subunit 8031 is used to determine the placeholder parameters in the code template that match the element type, and replace the placeholder parameters with key elements corresponding to the element type.
[0093] As another implementation of the present application, in order to reduce the cost of generating SWC codes, the above apparatus may further include: a generating subunit 8032.
[0094] The generation subunit 8032 is used to obtain requirement information, and in response to user operations, update the template content of the code template according to the requirement information, wherein the template content includes at least a matching relationship between placeholder parameters and element types, and a computer function. In response to the user operations, the parsing tool is updated according to the requirement information and a target library of a target programming language.
[0095] As another implementation of the present application, in order to reduce the cost of generating SWC codes, the above apparatus may further include: a generating subunit 8033.
[0096] The generating subunit 8033 is used to receive the parsing result sent by the parsing tool according to a preset transfer script, input the code template into the transfer script, and generate SWC code based on the parsing result and the code template through the transfer script.
[0097] Figure 5 A schematic diagram of the hardware structure of a code generation device provided in an embodiment of the present application is shown.
[0098] The code generating device may include a processor 901 and a memory 902 storing computer program instructions.
[0099] Specifically, the processor 901 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0100] The memory 902 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 902 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 902 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 902 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 902 is a non-volatile solid-state memory.
[0101] In certain embodiments, the memory 902 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present application.
[0102] The processor 901 implements any one of the code generation methods in the above embodiments by reading and executing computer program instructions stored in the memory 902 .
[0103] In one example, the code generation device may further include a communication interface 903 and a bus 910. Figure 5 As shown, the processor 901, the memory 902, and the communication interface 903 are connected via a bus 910 and communicate with each other.
[0104] The communication interface 903 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0105] Bus 910 includes hardware, software or both, and the parts of code generation equipment are coupled to each other.For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In suitable cases, bus 910 may include one or more buses. Although the present application embodiment describes and shows specific bus, the application considers any suitable bus or interconnection.
[0106] The code generation device can execute the code generation method in the embodiment of the present application based on the currently intercepted spam text messages and the text messages reported by the user, thereby realizing the combination of Figure 1 and Figure 4 The code generation method and device described.
[0107] In addition, in combination with the code generation method in the above embodiment, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the code generation method provided in the above embodiment is implemented.
[0108] In addition, in combination with the code generation method in the above embodiment, an embodiment of the present application also provides a computer program product, which implements the code generation method provided in the above implementation mode when executed by a processor.
[0109] It should be understood that the above specific embodiments of the present invention are only used to illustrate or explain the principles of the present invention, and do not constitute a limitation of the present invention. Therefore, any modifications, equivalent substitutions, improvements, etc. made without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention. In addition, the appended claims of the present invention are intended to cover all changes and modifications that fall within the scope and boundaries of the appended claims, or the equivalent forms of such scope and boundaries.
[0110] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0111] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0112] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.
[0113] The above reference is according to the flowchart and / or block diagram of the method, device and computer program product of the embodiment of the present application to describe various aspects of the present application.It should be understood that each square block in the flowchart and / or block diagram and the combination of each square block in the flowchart and / or block diagram can be realized by computer program instructions.These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the realization of the function / action specified in one or more square blocks of the flowchart and / or block diagram.Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit.It can also be understood that each square block in the block diagram and / or flowchart and the combination of square blocks in the block diagram and / or flowchart can also be realized by the dedicated hardware that performs the specified function or action, or can be realized by the combination of dedicated hardware and computer instructions.
[0114] The above is only a specific implementation of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be covered within the protection scope of the present invention.< / d>
Claims
1. A code generation method, It is characterized in that include: Get the original data and code templates; Parsing the original data by using a parsing tool to determine a parsing result, wherein the parsing tool is obtained based on a target library of a target programming language, and the parsing result includes a key element and an element type corresponding to the key element; Generate SWC code according to the code template and the parsing result.
2. The method according to claim 1, It is characterized in that Before obtaining the original data and the code template, the method further includes: Get SWC code writing rules; In response to the user's operation, a code template that complies with the SWC code writing rule is determined.
3. The method according to claim 1, It is characterized in that Before parsing the original data by using a parsing tool and determining the parsing result, the method further includes: Get the target library for the target programming language; According to a preset development script, the target library is developed to obtain a parsing tool.
4. The method according to claim 1, It is characterized in that The generating SWC code according to the code template and the parsing result includes: Determining a placeholder parameter in the code template that matches the element type; The placeholder parameter is replaced with the key element corresponding to the element type.
5. The method according to claim 1, It is characterized in that Before parsing the original data by using a parsing tool to obtain a parsing result, the method further includes: Obtain demand information; In response to the user's operation, updating the template content of the code template according to the demand information, wherein the template content at least includes a matching relationship between placeholder parameters and element types, and a computer function; In response to the user's operation, the parsing tool is updated according to the requirement information and the target library of the target programming language.
6. The method according to claim 1, It is characterized in that The generating SWC code according to the code template and the parsing result includes: According to a preset transfer script, receiving the analysis result sent by the analysis tool; inputting the code template into the delivery script; The SWC code is generated through the transfer script based on the parsing result and the code template.
7. A code generating device, It is characterized in that The device comprises: An acquisition unit, used to acquire original data and code templates; A parsing unit, configured to parse the original data by using a parsing tool to determine a parsing result, wherein the parsing tool is obtained based on a target library of a target programming language, and the parsing result includes a key element and an element type corresponding to the key element; A generating unit is used to generate SWC code according to the code template and the parsing result.
8. A code generating device, It is characterized in that The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the code generation method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the code generation method according to any one of claims 1 to 6 is implemented.
10. A computer program product, It is characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the code generation method as described in any one of claims 1 to 6.
Citation Information
Cited By
Automatic generation method, system and device for RTE code of Autosar CP
CN119148996A
