Program code generation method and device based on pseudo code, electronic equipment and storage medium
By analyzing the required pseudo-code and automatically generating code, the high cost and high threshold problems of embedded system software development are solved, and the automated development of embedded systems is realized.
Patent Information
- Application Number
- CN202510313999.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-08-01
AI Technical Summary
During the software development process of embedded systems, software developers need to master multiple programming languages at the same time and understand the meaning of pseudo-code requirements, resulting in high time and labor costs and high technical thresholds.
Through preset syntax specifications, the requirements pseudo-code is parsed, the syntax structure and transformation relationship are identified, the matching program code segments are filtered, the target code is generated in combination, and automated development is realized.
It reduces the development time and number of personnel, and reduces the cost and difficulty of developing embedded system software.
Smart Images

Figure CN120406951A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device, and storage medium for generating program code based on pseudocode. Background Art
[0002] Pseudocode is an informal programming language used to summarize the core logic of an algorithm. Its primary purpose is to describe the algorithm's logical steps in a clear and concise manner. In embedded system software development, requirements personnel typically generate requirements pseudocode based on the embedded system's corresponding pseudocode. Software developers then write program code based on the requirements pseudocode to implement embedded software development.
[0003] However, during the software development process for these embedded systems, software developers not only need to master the corresponding software development language but also understand the meaning of the requirements pseudocode. Understanding the requirements pseudocode requires mastering the relevant technologies in the specific embedded system's application domain. Therefore, embedded system software development is not only time-consuming and labor-intensive, but also requires a high technical threshold. Summary of the Invention
[0004] The present disclosure provides a method, device, electronic device and storage medium for generating program code based on pseudocode.
[0005] The first embodiment of the present disclosure provides a method for generating program code based on pseudocode, the method comprising:
[0006] Parsing the pre-acquired requirement pseudocode according to a preset grammatical specification to obtain a grammatical structure corresponding to the requirement pseudocode, wherein the grammatical structure includes at least two nodes in the requirement pseudocode and a conversion relationship between the at least two nodes; the preset grammatical specification includes algorithmic rules of the application field corresponding to the requirement pseudocode;
[0007] In a preset program code set, program code segments that match the conversion relationship between each node in the grammatical structure are screened to obtain a plurality of target program code segments corresponding to the grammatical structure;
[0008] Based on the nodes of the grammatical structure and the plurality of target program code segments, target codes are obtained by combining them.
[0009] In the embodiment of the present disclosure, the pre-acquired requirement pseudocode is parsed according to a preset grammar specification to obtain a grammatical structure corresponding to the requirement pseudocode, including:
[0010] Adjusting the pseudo code segments in the initial requirement pseudo code according to a preset program execution logic to obtain the requirement pseudo code that conforms to the preset program execution logic; the preset program execution logic corresponds to a preset grammatical specification;
[0011] Call the preset syntax specification to match the requirement pseudocode, and obtain the syntax structure corresponding to the requirement pseudocode, where the syntax structure includes at least two nodes and the conversion relationship between the at least two nodes.
[0012] In the embodiment of the present disclosure, adjusting the pseudocode segment in the initial requirement pseudocode according to the preset program execution logic to obtain the requirement pseudocode that conforms to the preset program execution logic includes:
[0013] Call a preset large model to adjust the execution logic of the initial requirement pseudocode to the requirement pseudocode corresponding to the preset syntax specification.
[0014] In the embodiment of the present disclosure, calling the preset syntax specification to match the requirement pseudocode and obtaining the syntax structure corresponding to the requirement pseudocode includes:
[0015] Call the preset syntax specification to match the nodes in the requirement pseudocode to obtain at least two nodes; and call the preset syntax specification to match the execution logic in the requirement pseudocode to obtain the target execution logic;
[0016] Based on the target execution logic and the at least two nodes, obtain the syntax structure.
[0017] In the embodiment of the present disclosure, calling the preset syntax specification to match the nodes in the requirement pseudocode to obtain at least two nodes; and calling the preset syntax specification to match the execution logic in the requirement pseudocode to obtain the target execution logic includes:
[0018] Match the requirement pseudocode with each string matching rule in the preset syntax rule to obtain a target string, where the target string is the at least two nodes;
[0019] Match the requirement pseudocode with the regular expression in the preset syntax rule to obtain the target execution logic, where the regular expression represents the execution logic corresponding to the preset syntax rule.
[0020] In the embodiment of the present disclosure, based on the target execution logic and the at least two nodes, obtaining the syntax structure includes:
[0021] Based on the target execution logic, determine the conversion relationship of at least two nodes corresponding to the target execution logic;
[0022] Based on the at least two nodes and the conversion relationship of the at least two nodes, obtain the syntax structure.
[0023] In the embodiments of the present disclosure, the combination of each node based on the syntax structure and a plurality of the target program code segments to obtain the target code includes:
[0024] For any node in the syntax structure, writing the node into the node field in the corresponding target program code segment to obtain the initial target code;
[0025] Based on the conversion relationship between the nodes, combining the initial target code to obtain the target code.
[0026] An embodiment of the second aspect of the present disclosure provides a program code generation device based on pseudocode, characterized in that the device includes:
[0027] A parsing module, configured to parse the pre-acquired requirement pseudocode according to a preset syntax specification to obtain the syntax structure corresponding to the requirement pseudocode, where the syntax structure includes at least two nodes in the requirement pseudocode and the conversion relationship between the at least two nodes; the preset syntax specification includes algorithm rules in the application field corresponding to the requirement pseudocode;
[0028] A matching module, configured to screen, in a preset program code set, program code segments that match the conversion relationship between each node in the syntax structure to obtain a plurality of target program code segments corresponding to the syntax structure;
[0029] A determination module, configured to combine each node based on the syntax structure and a plurality of the target program code segments to obtain the target code.
[0030] According to a third aspect of the embodiments of the present application, there is provided an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the computer program is run by the processor to enable the electronic device to execute the method as described in the first aspect or any optional implementation manner of the first aspect.
[0031] According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable storage medium, on which a computer program is stored, and the program is executed by a processor to implement the method as described in the first aspect or any optional implementation manner of the first aspect.
[0032] The technical solutions provided in the embodiments of the present disclosure have at least the following technical effects or advantages:
[0033] Parse the pre-acquired requirement pseudocode by invoking a preset syntax specification to obtain the syntax structure corresponding to the requirement pseudocode, where the syntax structure includes at least two nodes in the requirement pseudocode and the conversion relationships between at least two nodes. Since the preset syntax specification includes algorithm rules for the application field corresponding to the requirement pseudocode, the at least two nodes included in the pseudocode and the conversion relationships between at least two nodes can be accurately parsed. Further, since the preset program code set includes various program codes, in the preset program code set, filter the program code segments that match the conversion relationships between the nodes in the syntax structure to obtain multiple target program code segments corresponding to the syntax structure. Based on the nodes of the syntax structure and the multiple target program code segments, combine them to obtain the target code, which realizes the automatic implementation of the embedded system in software development and reduces the development time and the number of developers.
[0034] Additional aspects and advantages of the present disclosure will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present disclosure. Also, throughout the drawings, the same reference numerals are used to represent the same components.
[0036] In the drawings:
[0037] Figure 1 The flowchart of a method for generating program code based on pseudocode provided by an embodiment of the present disclosure is shown;
[0038] Figure 2 The structural schematic diagram of a device for generating program code based on pseudocode provided by another embodiment of the present disclosure is shown;
[0039] Figure 3 The structural schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown;
[0040] Figure 4 The schematic diagram of a storage medium provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0041] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.
[0042] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the present disclosure should have the ordinary meanings understood by those skilled in the art to which the present disclosure pertains.
[0043] Pseudocode is an informal programming language used to summarize the core logic of an algorithm. It lies between natural language and programming languages, using the syntax structure of a programming language but omitting the details of a specific language. Its main purpose is to describe the logical steps of an algorithm in a clear and concise manner. Pseudocode uses an expression close to natural language and is easy to understand, even for non-programmers. It does not depend on any specific programming language and can thus be used to describe any algorithm without being restricted by a programming language. The format and expression of pseudocode are relatively flexible and can be adjusted according to needs, with the emphasis on expressing the logic of the algorithm. Pseudocode cannot be directly executed by a computer and is only a tool for designing and describing algorithms.
[0044] An embedded system is a dedicated computer system that is usually designed to perform specific functions and is embedded into other devices or systems as their core component. It is usually optimized for specific tasks or applications. The software and hardware of an embedded system are tightly integrated to meet specific performance and power consumption requirements. It is usually part of other devices, such as: consumer electronics: smartphones, tablets, TVs, washing machines, etc.; automobiles: engine control systems, body control systems, safety systems, etc.; medical devices: such as electrocardiographs, blood glucose meters, monitors, etc.; industrial control: automated production lines, robots, environmental monitoring systems, etc.; aerospace equipment: flight control systems, navigation systems, communication systems, etc. It is usually not used as an independent computer but is embedded into a larger system to provide specific functions.
[0045] In the design phase or software development phase of an embedded system, pseudocode is usually used to plan algorithms and control flows. Pseudocode can help developers clearly express their ideas and perform logical verification before implementation. The embedded system may contain complex algorithms, which are usually described and verified with pseudocode before implementation. Pseudocode can help developers understand the logical structure of the algorithms and guide them to implement in a specific hardware and software environment. Using pseudocode for planning can reduce the error rate in the development process and improve development efficiency. Through pseudocode, developers can more easily identify and solve potential problems, thus avoiding a large number of modifications and debugging in the coding phase.
[0046] However, in the software development process of the above-mentioned embedded system, software developers not only need to master the language corresponding to software development, but also need to understand the meaning of the requirement pseudocode. To understand the meaning of the requirement pseudocode, they need to master the relevant technologies in the applicable field of the corresponding embedded system. It can be seen that the software development of the embedded system not only has high time costs and labor costs, but also has a high technical threshold.
[0047] In view of this, the embodiments of the present disclosure propose a method for generating program code based on pseudocode to solve the above problems. As Figure 1 shown, the method for generating program code based on pseudocode in the embodiments of the present disclosure may include the following steps:
[0048] In step S11, the pre-obtained requirement pseudocode is parsed according to a preset syntax specification to obtain the syntax structure corresponding to the requirement pseudocode.
[0049] Among them, the syntax structure includes at least two nodes in the requirement pseudocode and the conversion relationship between at least two nodes; the preset syntax specification includes the algorithm rules in the application field corresponding to the requirement pseudocode.
[0050] Exemplarily, the preset syntax specification may be the pseudocode specification designed in the pseudocode corresponding to the application scenario of the embodiments of the present disclosure, and may include various grammars involved in the pseudocode, including symbol specifications, operation specifications, and structure specifications, etc. Specifically, it usually includes keywords, operators, data types, control structures (such as loops, conditional statements), function definitions, etc. For example, if the embodiments of the present disclosure are applied in the aerospace field, it may involve standardizing various algorithms included in the aerospace technology field.
[0051] Using this preset syntax specification, the syntax structure of the information included in the requirement pseudocode can be identified. The syntax structure may be a syntax structure in the form of a syntax structure tree, a syntax topology graph, etc. corresponding to the requirement pseudocode. The embodiments of the present disclosure do not limit the specific form of the syntax structure, and those skilled in the art can determine it according to the actual situation.
[0052] After obtaining the requirement pseudocode, the above-mentioned preset syntax specifications can be used to parse the requirement pseudocode. Specifically, a parser can be generated in advance according to the requirement pseudocode, and this parser is used to parse the requirement pseudocode. The parsing methods can include a top-down parser and a bottom-up parser. Among them, the top-down parser starts from the topmost rule of the syntax specification and tries to match the input string. If the match is successful, the sub-rules are recursively applied until the entire input string is consumed. The bottom-up parser starts from the beginning of the input string and gradually constructs the syntax structure.
[0053] In some embodiments, the formats and related logical orders of the requirement pseudocodes generated by different staff or using different tools are different. Therefore, before parsing the requirement pseudocode, the requirement pseudocode can be normalized first, so that the normalized requirement pseudocode is more in line with the expression form and execution logic of the preset syntax specification, thereby further improving the accuracy of parsing the requirement pseudocode.
[0054] For example, in some embodiments, the above step S11 can also be implemented in the following manner: adjusting the pseudocode segments in the initial requirement pseudocode according to the preset program execution logic to obtain a requirement pseudocode that conforms to the preset program execution logic; the preset program execution logic corresponds to the preset syntax specification; calling the preset syntax specification to match the requirement pseudocode to obtain the syntax structure corresponding to the requirement pseudocode, and the syntax structure includes at least two nodes and the conversion relationship between at least two nodes.
[0055] Exemplarily, the purpose of normalizing the initial requirement pseudocode is to make the execution logic of the initial requirement pseudocode meet the preset syntax specification. Therefore, when normalizing the initial requirement pseudocode, it can be normalized with the preset syntax specification as the standard. Specifically, according to the preset program execution logic, the initial requirement pseudocode is adjusted, which specifically involves adding or deleting statements to ensure that the pseudocode conforms to the preset program flow, modifying the statement order to reflect the correct execution order, introducing or deleting variables to meet the requirements of data operations, and adjusting control structures such as replacing a simple conditional statement with a loop statement, or vice versa.
[0056] After adjusting the execution logic of the initial requirement pseudocode to obtain the requirement pseudocode, since the requirement pseudocode is adjusted according to the preset syntax specification, the obtained requirement pseudocode conforms to the preset syntax specification. In this way, by using the preset syntax specification to match the requirement pseudocode, the corresponding syntax structure can be accurately obtained.
[0057] Among them, when adjusting the execution logic of the initial requirement pseudocode, a preset large model can also be called to adjust the execution logic of the initial requirement pseudocode to the requirement pseudocode corresponding to the preset syntax specification. Specifically, the preset large model can be an LLM (Large Language Model) model. When using the preset large model to adjust the execution logic, the preset syntax specification needs to be used as the output standard to adjust the initial requirement pseudocode, and then the requirement pseudocode that meets the output standard (preset syntax specification) is obtained.
[0058] Among them, calling the preset syntax specification to match the requirement pseudocode to obtain the syntax structure corresponding to the requirement pseudocode is achieved by determining the nodes and execution logic respectively. For example, calling the preset syntax specification to match the nodes in the requirement pseudocode to obtain at least two nodes; and calling the preset syntax specification to match the execution logic in the requirement pseudocode to obtain the target execution logic; based on the target execution logic and at least two nodes, the syntax structure is obtained.
[0059] Specifically, each rule set is defined in the preset syntax specification, and the syntax elements in the pseudocode are defined in the rule set, such as keywords, operators, variable names, constants, etc. And the combination methods (control structures (such as loops, conditional statements), function definitions) between each syntax element. When matching, the requirement pseudocode is matched with each string matching rule in the preset syntax rules to obtain the target string, and the target string is at least two nodes; the requirement pseudocode is matched with the regular expression in the preset syntax rules to obtain the target execution logic, and the regular expression represents the execution logic corresponding to the preset syntax rules.
[0060] Specifically, when generating the syntax structure, based on the target execution logic, determine the conversion relationship of at least two nodes corresponding to the target execution logic; based on at least two nodes and the conversion relationship of at least two nodes, obtain the syntax structure.
[0061] The target execution logic describes the execution flow of a program, including control structures (such as conditional judgments, loops), data operations (such as variable assignments, function calls), and the sequence and dependencies among the target execution logics. During the process of parsing the target execution logic, key nodes are identified and determined. These nodes are usually statements, expressions, or operations in the program. For example, in a conditional judgment, the conditional expression and the branch statement are key nodes; in a loop, the loop condition and the loop body are key nodes. The transformation relationships describe how the nodes are connected and sequenced in the execution flow. This involves the transfer of control flow (such as transferring from one branch of a conditional judgment to another, or from the start of a loop to the inside of the loop body), and the passing of data flow (such as the passing and updating of variable values). Based on the determined key nodes and the transformation relationships between the keys, a syntax structure is constructed. The syntax structure is usually represented as a tree structure (such as an Abstract Syntax Tree AST), where each node represents a key element (such as a statement, an expression, or an operation), and the edges between the nodes represent the transformation relationships (such as the transfer of control flow and the passing of data flow).
[0062] When constructing the syntax structure, it is necessary to ensure that it accurately reflects the key nodes and transformation relationships in the target execution logic. This may require adjusting the positions and relationships of the nodes to reflect the correct execution sequence and control flow.
[0063] In step S12, in a preset program code set, program code segments that match the transformation relationships between the various nodes in the syntax structure are filtered to obtain multiple target program code segments corresponding to the syntax structure.
[0064] Exemplarily, when filtering the target program code segments in a preset program code set, first, a program code set needs to be preset, where the preset program code set contains multiple program code segments. These program code segments can be functions, methods, procedures, or other executable code units.
[0065] Parse the syntax structure in the previous step S11 or directly read the transformation relationships between the nodes in the syntax structure. The syntax structure tree can be traversed, and the connection methods and sequences between each node and its adjacent nodes are recorded. Based on the transformation relationships in the syntax structure, a series of matching rules are defined. These rules are used to describe which program code segments match the specific transformation relationships in the syntax structure. The matching rules may involve aspects such as the structure, logic, variable usage, and function calls of the code.
[0066] Using the defined matching rules, search for program code segments in the preset program code set that match the transformation relationships in the syntax structure. This can be achieved through methods such as text search, pattern matching, and logical inference. For each found matching item, the corresponding program code segment is extracted as the target program code segment.
[0067] In step S13, based on each node of the syntax structure and multiple target program code segments, they are combined to obtain the target code.
[0068] Exemplarily, when combining multiple target program code segments, the corresponding target program code segments can be sequentially concatenated in the order of each node in the syntax structure. For example, for any node in the syntax structure, write the node into the node field in the corresponding target program code segment to obtain the initial target code; based on the conversion relationship between each node, combine the initial target codes to obtain the target code.
[0069] The program code generation method based on pseudocode provided by the embodiments of the present disclosure calls a preset syntax specification to parse the pre-obtained requirement pseudocode, and obtains the syntax structure corresponding to the requirement pseudocode, where the syntax structure includes at least two nodes in the requirement pseudocode and the conversion relationship between at least two nodes. Since the preset syntax specification includes the algorithm rules of the application field corresponding to the requirement pseudocode, the at least two nodes included in the pseudocode and the conversion relationship between at least two nodes can be accurately parsed; further, various program codes are included in the preset program code set. Therefore, in the preset program code set, filter the program code segments that match the conversion relationship between each node in the syntax structure to obtain multiple target program code segments corresponding to the syntax structure; based on each node of the syntax structure and multiple target program code segments, combine them to obtain the target code, realizing the automatic implementation of the embedded system in software development, reducing the development time and the number of developers.
[0070] Corresponding to the implementation manner of the above program code generation method based on pseudocode, the embodiments of the present disclosure also provide a program code generation method device based on pseudocode. The program code generation device based on pseudocode is used to execute the above Figure 1 program code generation method according to any one of the illustrated embodiments. As Figure 2 shown, the program code generation device based on pseudocode includes:
[0071] A parsing module 201, configured to parse the pre-obtained requirement pseudocode according to a preset syntax specification, and obtain the syntax structure corresponding to the requirement pseudocode, where the syntax structure includes at least two nodes in the requirement pseudocode and the conversion relationship between the at least two nodes; the preset syntax specification includes the algorithm rules of the application field corresponding to the requirement pseudocode;
[0072] A matching module 202, configured to filter, in a preset program code set, program code segments that match the conversion relationship between each node in the syntax structure, and obtain multiple target program code segments corresponding to the syntax structure;
[0073] A determination module 203, configured to combine each node of the syntax structure and a plurality of the target program code segments to obtain target code.
[0074] Optionally, the parsing module is further configured to: adjust the pseudo code segments in the initial requirement pseudo code according to a preset program execution logic to obtain the requirement pseudo code that conforms to the preset program execution logic; the preset program execution logic corresponds to a preset syntax specification;
[0075] Call the preset syntax specification to match the requirement pseudo code to obtain the syntax structure corresponding to the requirement pseudo code, where the syntax structure includes at least two nodes and the conversion relationship between the at least two nodes.
[0076] ] Optionally, the parsing module is further configured to:
[0077] Call a preset large model to adjust the execution logic of the initial requirement pseudo code to the requirement pseudo code corresponding to the preset syntax specification.
[0078] Optionally, the parsing module is further configured to: call the preset syntax specification to match the nodes in the requirement pseudo code to obtain at least two nodes; and call the preset syntax specification to match the execution logic in the requirement pseudo code to obtain a target execution logic;
[0079] Obtain the syntax structure based on the target execution logic and the at least two nodes.
[0080] Optionally, the parsing module is further configured to:
[0081] Match the requirement pseudo code with each string matching rule in the preset syntax rules to obtain a target string, where the target string is the at least two nodes;
[0082] Match the requirement pseudo code with a regular expression in the preset syntax rules to obtain the target execution logic, where the regular expression represents the execution logic corresponding to the preset syntax rules.
[0083] Optionally, the determination module is further configured to: determine the conversion relationship of at least two nodes corresponding to the target execution logic based on the target execution logic;
[0084] Obtain the syntax structure based on the at least two nodes and the conversion relationship of the at least two nodes.
[0085] Optionally, the determination module is further configured to: for any node in the syntax structure, write the node into the node field in the corresponding target program code segment to obtain initial target code;
[0086] Based on the conversion relationships between the nodes, the initial target code is combined to obtain the target code.
[0087] The panoramic video transmission device provided by the above embodiments of the present disclosure and the panoramic video transmission method provided by the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run, or implemented by the application programs stored therein.
[0088] The embodiments of the present disclosure also provide an electronic device for executing the above data transmission method. Please refer to Figure 3 , which shows a schematic diagram of an electronic device provided by some embodiments of the present disclosure. As Figure 3 shown, the electronic device includes: a processor 300, a memory 301, a bus 302, and a communication interface 303. The processor 300, the communication interface 303, and the memory 301 are connected through the bus 302; a computer program that can run on the processor 300 is stored in the memory 301, and when the processor 300 runs the computer program, it executes the method provided by any of the foregoing Figure 1 illustrated embodiments of the present disclosure.
[0089] Among them, the memory 301 may include a high-speed random access memory (Random Access Memory, RAM), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 303 (which can be wired or wireless), a communication connection between the system network element and at least one other network element is realized, and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used.
[0090] The bus 302 may be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. Among them, the memory 301 is used to store programs. After receiving an execution instruction, the processor 300 executes the program, and the method disclosed in any of the foregoing Figure 1 illustrated embodiments can be applied to the processor 300 or implemented by the processor 300.
[0091] The processor 300 may be an integrated circuit chip with the ability to process signals. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 300 or instructions in the form of software. The above-mentioned processor 300 may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present disclosure. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present disclosure can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 301, and the processor 300 reads the information in the memory 301 and combines its hardware to complete the steps of the above method.
[0092] The electronic device provided by the embodiments of the present disclosure and the data transmission method provided by the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the method adopted, run, or implemented by it.
[0093] The embodiments of the present disclosure also provide a computer-readable storage medium corresponding to the data transmission method provided by the foregoing embodiments. Please refer to Figure 4 , which shows that the computer-readable storage medium is an optical disc 30, on which a computer program (i.e., a program product) is stored. When the computer program runs on the microprocessor, it will execute the data transmission method provided by any of the foregoing embodiments.
[0094] It should be noted that examples of computer-readable storage media may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, or other optical and magnetic storage media, which will not be elaborated here one by one.
[0095] The computer-readable storage medium provided by the above embodiments of the present disclosure and the data transmission method provided by the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the method adopted, run, or implemented by the application program stored in it.
[0096] It should be noted that:
[0097] In the specification provided herein, a large number of specific details are set forth. However, it will be understood that embodiments of the present disclosure may be practiced without these specific details. In some instances, well-known structures and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0098] Similarly, it should be understood that in order to streamline the present disclosure and assist in understanding one or more of the various inventive aspects, in the foregoing description of the exemplary embodiments of the present disclosure, the various features of the present disclosure are sometimes grouped together in a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting an intention that the claimed subject matter of the present disclosure requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, the inventive aspects lie in less than all of the features of the single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the present disclosure.
[0099] Furthermore, those skilled in the art will appreciate that although some embodiments herein include certain features included in other embodiments but not others, the combination of features of different embodiments is meant to be within the scope of the present disclosure and forms different embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
[0100] The above is only a preferred specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed by the present disclosure should be covered by the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.
Claims
1. A method for generating program code based on pseudocode, characterized in that The method includes: Parsing the pre-obtained requirement pseudocode according to a preset syntax specification to obtain a syntax structure corresponding to the requirement pseudocode, where the syntax structure includes at least two nodes in the requirement pseudocode and the conversion relationship between the at least two nodes; the preset syntax specification includes algorithm rules of the application field corresponding to the requirement pseudocode; In a preset program code set, screening program code segments that match the conversion relationship between each node in the syntax structure to obtain multiple target program code segments corresponding to the syntax structure; Combining based on each node of the syntax structure and the multiple target program code segments to obtain target code.
2. The method according to claim 1, characterized in that The parsing the pre-obtained requirement pseudocode according to a preset syntax specification to obtain a syntax structure corresponding to the requirement pseudocode includes: Adjusting the pseudocode segments in the initial requirement pseudocode according to a preset program execution logic to obtain the requirement pseudocode that conforms to the preset program execution logic; the preset program execution logic corresponds to the preset syntax specification; Invoking the preset syntax specification to match the requirement pseudocode to obtain a syntax structure corresponding to the requirement pseudocode, where the syntax structure includes at least two nodes and the conversion relationship between the at least two nodes.
3. The method according to claim 2, wherein The adjusting the pseudocode segments in the initial requirement pseudocode according to a preset program execution logic to obtain the requirement pseudocode that conforms to the preset program execution logic includes: Invoking a preset large model to adjust the execution logic of the initial requirement pseudocode to the requirement pseudocode corresponding to the preset syntax specification.
4. The method according to claim 2, wherein The invoking the preset syntax specification to match the requirement pseudocode to obtain a syntax structure corresponding to the requirement pseudocode includes: Invoking the preset syntax specification to match the nodes in the requirement pseudocode to obtain at least two nodes; and invoking the preset syntax specification to match the execution logic in the requirement pseudocode to obtain a target execution logic; Based on the target execution logic and the at least two nodes, obtaining the syntax structure.
5. The method according to claim 4, wherein The invoking the preset syntax specification to match the nodes in the requirement pseudocode to obtain at least two nodes; and invoking the preset syntax specification to match the execution logic in the requirement pseudocode to obtain a target execution logic includes: Matching the requirement pseudocode with each string matching rule in the preset syntax rules to obtain a target string, where the target string is the at least two nodes; Matching the requirement pseudocode with a regular expression in the preset syntax rules to obtain the target execution logic, where the regular expression represents the execution logic corresponding to the preset syntax rules.
6. The method according to claim 4, characterized in that The obtaining the syntax structure based on the target execution logic and the at least two nodes includes: Based on the target execution logic, determining the conversion relationship of at least two nodes corresponding to the target execution logic; Based on the at least two nodes and the conversion relationship of the at least two nodes, obtaining the syntax structure.
7. The method according to any one of claims 1-6, characterized in that The combining based on each node of the syntax structure and the multiple target program code segments to obtain target code includes: For any node in the syntax structure, write the node into the node field of the corresponding target program code segment to obtain the initial target code; Based on the conversion relationships between the nodes, combine the initial target code to obtain the target code.
8. A program code generation device based on pseudocode, characterized in that, The device includes: A parsing module, configured to parse a pre-obtained requirement pseudo-code according to a preset syntax specification to obtain a syntax structure corresponding to the requirement pseudo-code, where the syntax structure includes at least two nodes in the requirement pseudo-code and conversion relationships between the at least two nodes; the preset syntax specification includes algorithm rules of an application field corresponding to the requirement pseudo-code; A matching module, configured to screen, in a preset program code set, program code segments that match the conversion relationships between the nodes in the syntax structure to obtain a plurality of target program code segments corresponding to the syntax structure; A determination module, configured to combine the target code based on the nodes of the syntax structure and the plurality of target program code segments.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The computer program is run by the processor to enable the electronic device to execute the method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the method according to any one of claims 1-7.