Code generation method and related equipment

By syntax analysis of the initial code text and generating a syntax tree, automatically obtaining function execution methods and dynamically loading class instances, the problems of low code generation efficiency and inability to respond to business needs in real time in the existing technology are solved, and efficient code generation and real-time response capabilities are achieved.

CN119645412APending Publication Date: 2025-03-18KINGDEE SOFTWARE(CHINA) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411664403.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

Existing code generation methods are inefficient, unable to respond to changes in business needs in real time, and require manual writing of function logic and restarting the application process.

Method used

By performing syntax analysis of the initial code text, a syntax tree is generated, and the function execution methods of built-in and custom functions are automatically obtained based on the syntax tree, and class instances are dynamically loaded to the runtime application to generate and execute the object code text of the target formula expression.

Benefits of technology

Improves the efficiency of code generation, reduces the steps of manually writing function logic, simplifies the code generation process, and can respond to changes in business needs in real time without restarting the application process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645412A_ABST
    Figure CN119645412A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a code generation method and related equipment, which are used for generating codes under the condition of improving the code generation efficiency. The method comprises the steps that a target request is obtained, the target request comprises an initial code text, syntactic analysis is conducted on the initial code text, a syntax tree is obtained, each code block of the syntax tree is used for representing a built-in function and / or a self-defined function corresponding to a target formula expression, and the built-in function and / or the self-defined function correspond to the target formula expression; the tree structure of the syntax tree is used for representing an execution sequence between the built-in functions and / or the self-defined functions, obtaining a function execution method of each built-in function and / or the self-defined function corresponding to each code block, and executing the built-in functions and / or the self-defined functions on the basis of the execution sequence and the function execution method of each built-in function and / or the self-defined function corresponding to each code block. And generating a class instance corresponding to the target formula expression, and loading the class instance to the runtime application to generate and execute a target code text corresponding to the target formula expression.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of code generation, and more specifically, to a code generation method, a code generation apparatus, a code generation device, a computer-readable storage medium, and a computer program product including instructions or a computer program. Background Art

[0002] With the development of enterprises and the advancement of technology, business needs have become increasingly complex and diverse. The methods of executing functions and formula expressions have become particularly important in this context. For example, in salary calculation, attendance calculation, data analysis, report generation, etc., users may need to customize complex formula expressions according to specific business logic. Therefore, it is necessary to generate corresponding code for the calculation requirements of various formula expressions.

[0003] The existing code generation method is that if the target formula expression needs to be calculated, but the code text corresponding to the target formula expression is not written in the original initial static code text, at this time, the developer needs to rewrite (develop) the code text corresponding to the target formula expression based on the original initial static code text, obtain the target code text corresponding to the rewritten target formula expression, and then restart the application process, so that the target code text corresponding to the target formula expression can be executed to obtain the execution result.

[0004] That is to say, in the existing code generation method, the code text of the formula expression is static, the function data type is fixed, and the function logic is fixed. As the business operations change, when new business scenarios appear, the existing functions and formulas often cannot be supported, or the expressions are infinitely realized. At this time, it is necessary to rely on manual development and manually write the corresponding function logic. Therefore, the efficiency of code generation is low. Furthermore, after obtaining the target code text corresponding to the rewritten target formula expression, it is necessary to restart the application process before the target code text corresponding to the target formula expression can be executed to obtain the execution result. Therefore, it is impossible to respond to changes in business needs in real time. Summary of the invention

[0005] The embodiments of the present application provide a code generation method, a code generation apparatus, a code generation device, a computer-readable storage medium, and a computer program product including instructions or a computer program, which can perform code generation while improving code generation efficiency.

[0006] In a first aspect, an embodiment of the present application provides a code generation method, comprising:

[0007] Obtaining a target request, wherein the target request includes an initial code text in a preset language;

[0008] Performing grammatical analysis on the initial code text to obtain a grammar tree corresponding to the initial code text, wherein each code block of the grammar tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression, and the tree structure of the grammar tree is used to represent the execution order between each built-in function and / or user-defined function;

[0009] Obtaining function execution methods of each built-in function and / or user-defined function corresponding to each code block, and generating a class instance corresponding to the target formula expression based on the execution order and the function execution methods of each built-in function and / or user-defined function corresponding to each code block;

[0010] The class instance is loaded into a runtime application to generate and execute a target code text corresponding to the target formula expression to obtain an execution result.

[0011] In a second aspect, an embodiment of the present application provides a code generation device, including:

[0012] An acquisition unit, configured to acquire a target request, wherein the target request includes an initial code text in a preset language;

[0013] An analysis unit, configured to perform syntax analysis on the initial code text to obtain a syntax tree corresponding to the initial code text, wherein each code block of the syntax tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression, and the tree structure of the syntax tree is used to represent the execution order between each built-in function and / or user-defined function;

[0014] A generating unit, configured to obtain a function execution method of each built-in function and / or user-defined function corresponding to each code block, and generate a class instance corresponding to the target formula expression based on the execution order and the function execution method of each built-in function and / or user-defined function corresponding to each code block;

[0015] The generating unit is further used to load the class instance into a runtime application to generate and execute a target code text corresponding to the target formula expression to obtain an execution result.

[0016] In a third aspect, an embodiment of the present application provides a code generation device, including:

[0017] CPU, memory, input and output interfaces, wired or wireless network interfaces, and power supply;

[0018] The memory is a short-term storage memory or a persistent storage memory;

[0019] The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the aforementioned code generation method.

[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes instructions. When the instructions are executed on a computer, the computer executes the aforementioned code generation method.

[0021] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when the computer program product is run on a computer, enables the computer to execute the aforementioned code generation method.

[0022] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: since the initial code text can be parsed to obtain the syntax tree corresponding to the initial code text, the function execution method of the built-in function and / or the custom function can be automatically obtained based on the syntax tree, and the class instance can be dynamically loaded into the runtime application to generate and execute the target code text corresponding to the target formula expression, thereby reducing the steps of manually writing the corresponding function logic and simplifying the steps of generating the target code text corresponding to the target formula expression. Therefore, the code generation efficiency is high. Furthermore, since the code generation efficiency is high and there is no need to reopen the application process, it can respond to changes in business needs in real time. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A schematic diagram of the architecture of a code generation system disclosed in an embodiment of the present application;

[0024] Figure 2 A flowchart of a code generation method disclosed in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of an initial code text in a preset language disclosed in an embodiment of the present application;

[0026] Figure 4 A schematic diagram of a syntax tree corresponding to an initial code text disclosed in an embodiment of the present application;

[0027] Figure 5 A schematic diagram of a process for parsing a target formula expression disclosed in an embodiment of the present application;

[0028] Figure 6 A flowchart of another code generation method disclosed in an embodiment of the present application;

[0029] Figure 7 A schematic diagram of an initial code text of a custom function with multiple output results disclosed in an embodiment of the present application;

[0030] Figure 8 A schematic diagram of a syntax tree of a multi-result output function disclosed in an embodiment of the present application;

[0031] Fig. 9 A flowchart of a method for generating code by an execution engine disclosed in an embodiment of the present application;

[0032] Fig.10 A schematic diagram of a custom function configuration interface disclosed in an embodiment of the present application;

[0033] Fig.11 A schematic diagram of a custom function viewing interface disclosed in an embodiment of the present application;

[0034] Fig.12 A flowchart of another code generation method disclosed in an embodiment of the present application;

[0035] Fig.13 A flowchart of another code generation method disclosed in an embodiment of the present application;

[0036] Fig.14 A schematic diagram of a computing service architecture for code generation disclosed in an embodiment of the present application;

[0037] Fig.15 A schematic diagram of the structure of a code generation device disclosed in an embodiment of the present application;

[0038] Fig.16 A schematic diagram of the structure of a code generation device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0039] The embodiments of the present application provide a code generation method, a code generation apparatus, a code generation device, a computer-readable storage medium, and a computer program product including instructions or a computer program, for performing code generation while improving code generation efficiency.

[0040] See also Figure 1 In the embodiment of the present application, an architecture of the code generation system 100 includes:

[0041] Code generation device 101 and client 102. When performing code generation, code generation device 101 can be connected to client 102. Code generation device 101 can obtain a target request sent by client 102, the target request includes an initial code text in a preset language, can perform syntax analysis on the initial code text, obtain a syntax tree corresponding to the initial code text, and then obtain the function execution method of each built-in function and / or user-defined function corresponding to each code block, and based on the execution order and the function execution method of each built-in function and / or user-defined function corresponding to each code block, generate a class instance corresponding to the target formula expression, then load the class instance to the runtime application to generate and execute the target code text corresponding to the target formula expression, obtain the execution result, and finally return the execution result to client 102.

[0042] Some key terms in the examples of this application are explained as follows:

[0043] Syntax tree: Abstract Syntax Tree (AST), which is a tree data structure used to represent the structure of programming language code.

[0044] Software Development Kit: A software development kit (SDK) is usually a collection of one or more software development tools that help developers create, test, and deploy software applications.

[0045] Javass ist: the abbreviation of Java Programming Assistant, is a lightweight Java bytecode manipulation library that can dynamically expand the structure and methods of a class (and also add new classes) at runtime without modifying the source code.

[0046] based on Figure 1 The code generation system shown in Figure 2 , Figure 2 A schematic diagram of a code generation method disclosed in an embodiment of the present application, the method comprising:

[0047] 201. Obtain a target request, where the target request includes an initial code text in a preset language.

[0048] In this embodiment, when code generation is performed, a target request may be obtained, the target request including an initial code text in a preset language, the initial code text being used to represent a target code text corresponding to the target formula expression to be generated and executed.

[0049] It is understandable that the target request can be a request sent by the client or a request triggered by itself, which is not limited here. The preset language refers to a pre-designed or selected programming language that is relatively easy for users to understand and use. It usually has basic programming concepts such as variables, constants, operators and function calls, etc. Users can express various complex mathematical functions, logical operations and conditional statements through its simple syntax.

[0050] Please refer to Figure 3 , Figure 3 is a schematic diagram of an initial code text of a preset language disclosed in an embodiment of the present application, Figure 3 The target formula expression in the code shown describes a tax calculation logic for "taxpayer type" as "resident". The entire logic is about how to calculate their tax payable according to the tax law regulations of residents, involving the part of donation deduction, and finally get the result of the tax payable. Specifically, first check whether the taxpayer type is a resident. If so, calculate the cumulative taxable income, that is, the balance after deducting tax-free income, deducting expenses, etc. from the total income. Then, if the cumulative taxable income is greater than zero, continue to determine whether there is a donation expenditure. If the donation amount is greater than 30% of the taxable income, then the donation part is deducted from the taxable income at a rate of 70%, and the remaining part is taken as the result. Otherwise, the taxable income minus the donation amount is directly used as the result. If the cumulative taxable income is less than or equal to zero, or it is not a resident, the result is set to 0.

[0051] 202. Perform syntax analysis on the initial code text to obtain a syntax tree corresponding to the initial code text, wherein each code block of the syntax tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression, and the tree structure of the syntax tree is used to represent the execution order between each built-in function and / or user-defined function.

[0052] After obtaining the target request, the initial code text can be parsed to obtain a syntax tree corresponding to the initial code text. Each code block of the syntax tree is used to represent each built-in function and / or custom function corresponding to the target formula expression. The tree structure of the syntax tree is used to represent the execution order between each built-in function and / or custom function.

[0053] Specifically, you can perform syntax analysis on the target formula expression to obtain an AST abstract syntax tree, and then convert the functions corresponding to each code block of the syntax tree into an internal representation. Figure 4 , Figure 4 A syntax tree diagram corresponding to an initial code text disclosed in an embodiment of the present application, consisting of Figure 4It can be seen that each circle in the figure represents a code block (node), and the function (built-in function or custom function) corresponding to each code block and the execution order specify how to connect different function calls in series to complete the calculation of the entire target formula expression. For example, if there is an "IF" structure in the syntax tree, the condition (the expression corresponding to the condition) will be checked first, and then the function in the code block corresponding to the "THEN" or "ELSE" clause will be executed according to the result of the condition. More specifically, the internal representation of the function conversion corresponding to each code block can include but is not limited to ConditionExpress ion (conditional expression), CalExpress ion (calculation expression), ItemExpress ion (calculation element expression), OpExpress ion (operator expression), StrExpress ion (string expression) and AssExpress ion (assignment expression).

[0054] More specifically, let's take the example of the target formula expression for the tax calculation logic with "taxpayer type" as "resident" as described above. The corresponding syntax tree can be found in Figure 4 In the figure, "ConditionExpress ion: IF" can be used to represent "determine whether the taxpayer type is a resident", "Condi t ionExpress ion: THEN" can be used to represent "if the taxpayer type is a resident", "CalExpress ion" can be used to represent "calculate the cumulative taxable income, that is, the total income minus the balance after deductions such as tax-free income and expenses", and "ConditionExpress ion" can be used to represent "determine whether the cumulative taxable income is greater than zero". The execution order is "first determine the taxpayer type, then calculate the cumulative taxable income according to the type, and then determine whether this amount is greater than zero". The other nodes and execution orders are deduced by analogy until the final tax result is calculated. The details will not be repeated here.

[0055] It should be understood that since the initial code text corresponds to each function that needs to be called, the execution of the latter function needs to depend on the output of the previous function, so it is important to determine the execution order.

[0056] 203. Obtain the function execution methods of each built-in function and / or user-defined function corresponding to each code block, and generate a class instance corresponding to the target formula expression based on the execution order and the function execution methods of each built-in function and / or user-defined function corresponding to each code block.

[0057] After performing syntax analysis on the initial code text and obtaining the syntax tree corresponding to the initial code text, the function execution methods of each built-in function and / or custom function corresponding to each code block can be obtained, and based on the execution order and the function execution methods of each built-in function and / or custom function corresponding to each code block, the class instance corresponding to the target formula expression is generated.

[0058] Specifically, the process of generating a class instance corresponding to the target formula expression can also be understood as the process of parsing the target formula expression. For details, please refer to Figure 5 , Figure 5 A schematic diagram of a process for parsing a target formula expression disclosed in an embodiment of the present application, comprising Figure 5 It can be seen that the target formula expression described by the initial code text can be segmented according to symbols, and then the formula block structure can be constructed according to keywords (that is, the initial code text is parsed to obtain the syntax tree corresponding to the initial code text, and each code block of the syntax tree is used to represent the built-in functions and / or custom functions corresponding to the target formula expression), and then the formula block logic is parsed, and then converted into Java code text (that is, the function execution method of each built-in function and / or custom function corresponding to each code block is obtained), and finally the Java code text is compiled and processed through Java's reflection API or compiler, so as to dynamically create a class instance at runtime.

[0059] To be more specific, let's continue with the example of the target formula expression of the tax calculation logic for "resident" for "taxpayer type" described above. After obtaining the corresponding syntax tree, we can obtain the corresponding function execution methods such as "ConditionExpress ion: IF", "ConditionExpress ion: THEN", "CalExpress ion", "ConditionExpress ion", etc., and based on the execution order of "first determine the taxpayer type, then calculate the cumulative taxable income according to the type, and then determine whether this amount is greater than zero, etc.", as well as the obtained function execution methods, generate the class instance corresponding to the target formula expression.

[0060] It should be understood that the code generation module can perform syntax analysis on the initial code text to obtain the syntax tree corresponding to the initial code text, and obtain the function execution method of each built-in function and / or custom function corresponding to each code block to generate a class instance corresponding to the target formula expression. The principle of writing code in the code generation module is to convert the intention of executing the target formula expression into an actual executable code fragment, which is responsible for the specific operation implementation and execution process. The code generation module includes but is not limited to Java's JavaAss ist and other modules that can dynamically generate code.

[0061] It is worth mentioning that the code generation module can perform syntax analysis on the initial code text, automatically obtain the function execution method of each function corresponding to each code block, and based on the execution order and the function execution method of each function corresponding to each code block, automatically generate a class instance, and load the class instance into the runtime application to automatically and dynamically generate and execute the target code text (executable code text) corresponding to the target formula expression. It can automatically and dynamically generate executable code text without the need to manually write the corresponding code, which improves the code generation efficiency to a certain extent. Furthermore, since the initial code text corresponds to each function that needs to be called, the execution of the latter function needs to depend on the output of the previous function, and the tree structure of the syntax tree can represent the accurate execution order, therefore, the embodiment of the present application can ensure the accurate calling and execution of these functions, thereby obtaining accurate execution results.

[0062] 204. Load the class instance into the application program at runtime to generate and execute the target code text corresponding to the target formula expression to obtain the execution result.

[0063] After the class instance corresponding to the target formula expression is generated, the class instance can be loaded into a runtime application to generate and execute the target code text corresponding to the target formula expression to obtain an execution result.

[0064] Specifically, the class instance can be loaded into the runtime application through the code generation module to generate and execute the target code text corresponding to the target formula expression to obtain the execution result.

[0065] It is understandable that a runtime application may refer to an environment or platform that can dynamically load and execute code during program execution, including but not limited to Java's JVM (Java Virtual Machine), NET's CLR (Common Language Runtime), and JavaScript's Web browser engine.

[0066] In the embodiment of the present application, since the initial code text can be parsed to obtain the syntax tree corresponding to the initial code text, the function execution method of the built-in function and / or the custom function can be automatically obtained based on the syntax tree, and the class instance can be dynamically loaded into the application at runtime to generate and execute the target code text corresponding to the target formula expression, thereby reducing the steps of manually writing the corresponding function logic and simplifying the steps of generating the target code text corresponding to the target formula expression. Therefore, the efficiency of code generation is relatively high. Furthermore, since the efficiency of code generation is relatively high and there is no need to restart the application process, it is possible to respond to changes in business needs in real time.

[0067] based on Figure 2 In the described embodiment, during the code generation process, although the function execution method of the built-in function and / or the custom function can be automatically obtained, and the class instance can be dynamically loaded into the runtime application to automatically generate and execute the target code text corresponding to the target formula expression, there is no need to manually write the corresponding function logic, which improves the efficiency of code generation. However, due to the inconvenience of maintaining and debugging the built-in function and / or the custom function, the accuracy and flexibility of the function execution are still often low. In order to solve the above problems, the following provides a detailed embodiment that can be optionally executed during the implementation of this solution, please refer to Figure 6 , Figure 6 This is a flow chart of another code generation method disclosed in an embodiment of the present application. The method of another embodiment of the code generation method of the present application includes:

[0068] 601. Obtain a target request, where the target request includes an initial code text in a preset language.

[0069] 602. Perform syntax analysis on the initial code text to obtain a syntax tree corresponding to the initial code text, wherein each code block of the syntax tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression, and the tree structure of the syntax tree is used to represent the execution order between each built-in function and / or user-defined function.

[0070] Steps 601 to 602 in this embodiment are similar to those in the previous embodiment. Figure 2 Steps 201 to 202 in the illustrated embodiment are similar and will not be described in detail herein.

[0071] Among them, custom functions include multiple result output functions. For a specific example, see Figure 7 , Figure 7 A schematic diagram of the initial code text of a custom function with multiple output results disclosed in an embodiment of the present application, comprising Figure 7 It can be seen that the output results of "absenteeism duration" can be added based on the output results of "lateness duration". Specifically, Figure 7The code shown is used to characterize the calculation logic for calculating the abnormal situation of employees' working days, and is used to generate the employee's lateness or absenteeism records for attendance management and statistics. The specific logic is to first determine whether the current time belongs to the accounting range of the day. If it is within the accounting range, and if the current time is before the clock-in, the result is set to 0 (usually representing that work has not started). If it is between the clock-in and the middle line of the shift, it means lateness, and the preset lateness duration is returned. If it is between the middle line of the shift and the clock-in after get off work, it also means lateness, and the lateness duration is also returned. If it exceeds the clock-in time after get off work, the result may still be lateness, and the lateness duration is also returned. If it is not within the accounting range of the day, or it is overtime or other special circumstances, the code will skip and default to return the lateness duration or absenteeism duration. For another example, continuing with the above example of donation deduction for personal income tax, the output result of "accumulated income" can also be added.

[0072] And wherein, the method of performing grammatical analysis on the initial code text to obtain the grammatical tree corresponding to the initial code text may be to perform grammatical analysis on the initial code text to obtain the grammatical tree corresponding to the initial code text, wherein each code block of the grammatical tree includes a target code block, and the target code block is used to represent a multi-result output function.

[0073] Specifically, each code block includes a target code block and other code blocks. For the example of "calculation logic for calculating abnormal situations of employees' workdays", the target code block is used to represent the multi-result output function of "lateness duration" and "absence duration", and is used to generate the result values ​​corresponding to "lateness duration" and "absence duration". Other code blocks may include, for example, a part for checking time conditions, which is used to determine when lateness or absenteeism occurs. For the example of "tax calculation logic for taxpayers with resident type", the target code block is used to represent the multi-result output function of "cumulative income" and "donation deduction", and is used to generate the result values ​​corresponding to "cumulative income" and "donation deduction". Other code blocks may include, for example, a part for determining the type of taxpayer, which is used to calculate the cumulative taxable income according to the type, and determine whether this amount is greater than zero, etc. For details, please refer to Figure 8 , Figure 8 A schematic diagram of a syntax tree of a multi-result output function disclosed in an embodiment of the present application, comprising Figure 8 It can be seen that Figure 4 On this basis, add the calculation element expression ItemExpress ion NodeText:AC[Cumulative Income] of the output expression ExportExpress ion, that is, add the output result (node) of "Cumulative Income".

[0074] It is worth mentioning that the relationship between the target code block and other code blocks is that they work together in the order of execution, and they jointly realize the calculation of complex multi-output expressions.

[0075] 603. Determine the function execution method of each built-in function corresponding to each code block from the built-in function list, and / or determine the configuration information of each custom function corresponding to each code block from the custom function list, and generate the function execution method of each custom function based on the configuration information of each custom function, and then generate a class instance corresponding to the target formula expression based on the execution order and the function execution method of each built-in function and / or custom function corresponding to each code block.

[0076] Specifically, an execution engine SDK can be created, which traverses each code block of the syntax tree, automatically obtains the function execution method of the built-in function, and / or automatically generates the function execution method of the custom function to generate a class instance corresponding to the target formula expression. The execution engine SDK is used to process loops, conditional execution and other control flow structures.

[0077] Please refer to Fig. 9 , Fig. 9 A flowchart of a method for generating code by an execution engine disclosed in an embodiment of the present application is shown in FIG. Fig. 9 It can be seen that the execute function can be called first to generate and execute the target code text of the target formula expression, and then the ExprParser.parse function is called to parse the target formula expression of the initial code text and convert it into a syntax tree. For the code block of the syntax tree, if it is a custom function, the predefined custom function list will be checked to obtain the relevant configuration of the custom function, such as parameter type, etc., and then a new function class will be dynamically created using bytecode manipulation tools such as the Javaass ist library, inheriting the basic function base class, setting a name for the new function, loading the method body (including execution logic), and adjusting the method to adapt to the required parameter type. Once the function class is created, the function class is instantiated; if it is a built-in function, its corresponding method can be directly obtained from the built-in function list. After the entire process is completed, both custom and built-in functions will be added to the runtime environment to obtain the expression execution context.

[0078] It is worth mentioning that the function library can be pre-set, and the function library includes a custom function list and a built-in function list. The custom function list includes the configuration information of the custom function (function definition, input and output types, etc.). Users (such as developers) can create specific function libraries as needed and provide specific execution logic. For example, new custom functions can be configured according to needs. Therefore, the code is highly scalable. Secondly, users (such as developers) can flexibly organize and call these custom functions according to needs without having to write them from scratch every time, which improves the reusability of the code, reduces duplication of work, and thus improves the efficiency of code generation.

[0079] It is also worth mentioning that a custom function list (including configuration information of each custom function) and a built-in function list (including function execution methods of each built-in function) can be pre-set, and the corresponding function execution method acquisition path is selected according to the different function types corresponding to the code blocks of the syntax tree. The acquisition path is: obtain the configuration information of the custom function from the custom function list, and automatically generate the function execution method of the custom function based on the configuration information of the custom function, and / or directly obtain the function execution method of the built-in function from the built-in function list. Since built-in functions and / or custom functions can be maintained through the custom function list and / or the built-in function list, the convenience of function maintenance and debugging is improved, and the corresponding function execution method acquisition path can be selected according to the different function types, thereby improving the accuracy and flexibility of generating target code text.

[0080] Among them, before determining the configuration information of each custom function corresponding to each code block from the custom function list, the custom function configuration interface can be displayed, the custom function configuration interface includes a field selection area and a function selection area, or a field selection area, a function selection area and a symbol selection area, the field selection area includes at least one field, the function selection area includes at least one function, and the symbol selection area includes at least one symbol, and then the configuration information of each custom function is obtained according to the selected target fields and target functions, or the target fields, target functions and target symbols.

[0081] Please refer to Fig.10 , Fig.10 A schematic diagram of a custom function configuration interface disclosed in an embodiment of the present application, comprising Fig.10It can be seen that the custom function definition interface may include five areas, the original field selection area, the calculation formula selection area, the symbol (calculator, other function symbol) selection area, the custom function editing and display area, and the function description area. For example, if a user (such as a developer on the code generation device side and / or a tenant on the client side) selects "aggregate count" from the multiple calculation formulas (including aggregate averaging, aggregate counting, deduplication counting, aggregate sum, remainder, etc.) in the calculation formula selection area, the function description area will display the function description of "aggregate count", and you can select "employee number", "personnel" and other fields from the multiple original fields in the original field selection area, and select "+" from the multiple calculators in the symbol (calculator, other function symbol) selection area, etc., so as to configure the final custom function "LEN([employee number])+countAGG([employee number])" and display it in the custom function editing and display area.

[0082] Specifically, after configuring a custom function, you can view the detailed information of the custom function in the custom function viewing interface. For details, please refer to Fig.11 , Fig.11 A schematic diagram of a custom function viewing interface disclosed in an embodiment of the present application, comprising Fig.11 It can be seen that Fig.11 Displays the detailed information of the user-defined function "Remainder".

[0083] It is worth mentioning that through the custom function configuration interface, users can select specific fields, functions, symbols, etc. according to actual needs, which can adapt to diverse demand scenarios and improve the simplicity, flexibility and experience of customizing custom function functions.

[0084] Among them, the method of determining the configuration information of each custom function corresponding to each code block from the custom function list, and generating the function execution method of each custom function based on the configuration information of each custom function can be, for a multiple-result output function, determining the configuration information of the multiple-result output function from the custom function list, and generating the function execution method of the multiple-result output function based on the configuration information of the multiple-result output function.

[0085] It is worth mentioning that performing grammatical analysis on the initial code text and obtaining the syntax tree corresponding to the initial code text can well support the new language features of parsing the target formula expression, including but not limited to new formula features with multiple result outputs.

[0086] 604. Load the class instance into the application program at runtime to generate and execute the target code text corresponding to the target formula expression to obtain the execution result.

[0087] Step 604 in this embodiment is similar to the above Figure 2Step 204 in the illustrated embodiment is similar and will not be described in detail here.

[0088] Specifically, the execution engine SDK can dynamically load the class instance into the runtime application to generate and execute the target code text corresponding to the target formula expression to obtain the execution result, which can realize function plug-and-play and support formula expression operations.

[0089] Among them, the method of executing the target code text corresponding to the target formula expression to obtain the execution result can be to execute the target code text, obtain multiple sub-results, and then save the multiple sub-results to a data set to obtain a result data set, and the result data set is the execution result.

[0090] Specifically, continuing with the above example, for the example of "calculation logic for calculating employee workday abnormalities", multiple sub-results are the result values ​​of lateness and absence, and the result values ​​of lateness and absence can be saved in a data set, which is the final execution result. For the example of "tax calculation logic for taxpayer type being residents", multiple sub-results are the result values ​​of donation deduction amount and accumulated income, and the result values ​​of donation deduction amount and accumulated income can be saved in a data set, which is the final execution result.

[0091] In the embodiment of the present application, since the initial code text can be parsed to obtain the syntax tree corresponding to the initial code text, the function execution method of the built-in function and / or the custom function can be automatically obtained based on the syntax tree, and the class instance can be dynamically loaded into the application program at runtime to generate and execute the target code text corresponding to the target formula expression, reducing the steps of manually writing the corresponding function logic, simplifying the steps of generating the target code text corresponding to the target formula expression, and therefore, the efficiency of code generation is high. Further, since the efficiency of code generation is high and there is no need to reopen the application process, it can respond to changes in business needs in real time. Secondly, users (developers) can configure new custom functions according to needs, and the scalability of the code is strong. Secondly, these custom functions can be flexibly organized and called according to the needs, without having to write from scratch every time, which improves the reusability of the code and reduces duplication of work, thereby improving the efficiency of code generation. Furthermore, the built-in function and / or custom function can be maintained through the custom function list and / or the built-in function list, which improves the convenience of function maintenance and debugging, and the acquisition path of the corresponding function execution method can be selected according to the different types of functions, which improves the accuracy and flexibility of generating the target code text. Finally, the initial code text can be parsed to obtain the syntax tree corresponding to the initial code text, which can well support the new language features of parsing the target formula expression.

[0092] based on Figure 2 In the described embodiment, during the code generation process, although the function execution method of the built-in function and / or the custom function can be automatically obtained, and the class instance can be dynamically loaded into the runtime application to automatically generate and execute the target code text corresponding to the target formula expression, there is no need to manually write the corresponding function logic, thereby improving the efficiency of code generation. However, the class instance can only process the task of the next target request after it has processed the task of the current target request, that is, when it is idle. When the number of target requests is large, it takes a long time to process all the target request tasks, and the overall response of the target request is slow. Therefore, the overall execution efficiency of the target request is slow. In order to solve the above problems, a detailed embodiment of this scheme that can be optionally executed during implementation is provided below. Please refer to Fig.12 , Fig.12 This is a flow chart of another code generation method disclosed in an embodiment of the present application. The method of another embodiment of the code generation method of the present application includes:

[0093] 1201. Obtain a target request, where the target request includes an initial code text in a preset language.

[0094] 1202. Perform syntax analysis on the initial code text to obtain a syntax tree corresponding to the initial code text. Each code block of the syntax tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression. The tree structure of the syntax tree is used to represent the execution order between each built-in function and / or user-defined function.

[0095] 1203. Obtain the function execution methods of each built-in function and / or user-defined function corresponding to each code block, and generate a class instance corresponding to the target formula expression based on the execution order and the function execution methods of each built-in function and / or user-defined function corresponding to each code block.

[0096] Steps 1201 to 1203 in this embodiment are similar to those in the previous embodiment. Figure 2 Steps 201 to 203 in the illustrated embodiment are similar and will not be described in detail herein.

[0097] 1204. Use the generated class instance as a class instance template, copy the class instance template, and create an instance pool corresponding to the class instance based on the class instance template and the copied first class instance.

[0098] Specifically, when the number of target requests reaches a preset threshold, an optimization strategy can be adopted to use the generated class instance as a template and copy it to form an instance pool, which stores multiple similar but independent code instances (class instances) so that multiple target requests can be processed simultaneously to improve concurrency capabilities.

[0099] 1205. Based on the response order of multiple target requests, idle class instances are obtained from the instance pool in turn, and the idle class instances are loaded into the runtime application to generate and execute the target code text corresponding to the target formula expression to obtain the execution result.

[0100] It should be understood that idle class instances refer to those class instances that have been prepared in the class instance pool and have not yet been assigned to the task of processing the current target request and can be used immediately. For example, the class instances obtained by copying are idle class instances.

[0101] Specifically, if multiple target requests are used to generate and execute the target code text corresponding to the same target formula expression, and the code block of the syntax tree corresponds to a custom function, then multiple target requests can be responded to in sequence based on the response order of the multiple target requests. For each target request, all calculation formula sets and all function sets used in the formulas can be parsed in the specified order, and the generated code blocks and functions can be dynamically created using javaass ist, and formula methods and function methods can be added for business calculations.

[0102] Please refer to Fig.13 , Fig.13 A flowchart of another code generation method disclosed in an embodiment of the present application is shown in FIG. Fig.13 It can be seen that the process of generating the calculation class FormulaAnalys is (class instance) can be, first, according to the incoming calculation formula (target formula expression) and function set, use Javaass ist and other tool libraries to dynamically create a new class that inherits from the calculation base class (such as ParentFormulaParse). This base class contains the necessary class attributes, methods and abstract calculation entry methods, and implements the Cloneable interface for easy cloning. Then traverse the function collection and insert the specific implementation method (function execution method) of each function into the newly created calculation class to ensure that the function can be executed correctly. Then for each calculation formula, dynamically create the corresponding calculation method (function execution method) and add it to the calculation class so that it can process the specific formula logic.

[0103] It is worth mentioning that in the process of using it on the business side, in order to reduce the consumption of class instance resources, the concept of pooling can be introduced, that is, the computing class is instantiated only once in a container as a template, and the template is copied to obtain an instance pool. By pre-instantiating and reusing the computing class, it is avoided that each request needs to be compiled from scratch, reducing the time spent on creating and deleting class instances, greatly improving the speed of processing a large number of computing requests, and therefore, the efficiency of code generation is high. Secondly, in the order of target request responses, those idle class instances that have been prepared can be prioritized and loaded into the running application to execute the corresponding code, which can improve efficiency and concurrent processing capabilities, and help manage resources and avoid the performance overhead caused by frequent creation and destruction of new class instances.

[0104] Among them, the method of obtaining idle class instances from the instance pool in sequence based on the response order of multiple target requests may be, based on the response order of multiple target requests, determining in sequence whether there are idle class instances in the instance pool; if it is determined that there are idle class instances in the instance pool, obtaining the idle class instances from the instance pool; if it is determined that there are no idle class instances in the instance pool, copying the class instance template, adding the copied second class instance to the instance pool, and using the copied second class instance as the idle class instance.

[0105] Specifically, when multiple threads are executing, you can obtain (get an idle class instance) from the instance pool by thread number. If there is an idle class instance in the instance pool, the acquisition is successful. If there is no idle class instance in the instance pool, the acquisition fails. At this time, you can use the template clone and store the cloned class instance in the instance pool.

[0106] It is worth mentioning that after creating the instance pool, the class instance template can be copied (cloned) again according to the needs of the actual scenario, and the degree of reuse of the class instance can be adjusted according to the needs of the real-time scenario, thereby improving the efficiency of code generation.

[0107] In the embodiment of the present application, since the initial code text can be parsed to obtain the syntax tree corresponding to the initial code text, the function execution method of the built-in function and / or the custom function can be automatically obtained based on the syntax tree, and the class instance can be dynamically loaded into the application at runtime to generate and execute the target code text corresponding to the target formula expression, reducing the steps of manually writing the corresponding function logic, simplifying the steps of generating the target code text corresponding to the target formula expression, and therefore, the efficiency of code generation is high. Further, since the efficiency of code generation is high and there is no need to reopen the application process, it can respond to changes in business needs in real time. Secondly, the concept of pooling can be introduced, and by pre-instantiating and reusing the calculation class, it is avoided that each request needs to be compiled from scratch, and the time spent on creating and deleting class instances is reduced, and the speed of processing a large number of calculation requests is greatly improved, so the efficiency of code generation is high. Secondly, according to the order of the target request response, those idle class instances that have been prepared can be preferentially selected, and they can be loaded into the running application to execute the corresponding code, which can improve efficiency and concurrent processing capabilities, and help manage resources and avoid the performance overhead caused by frequently creating and destroying new class instances. Finally, after the instance pool is created, the class instance template can be copied (cloned) again according to the needs of the actual scenario, and the degree of reuse of the class instance can be adjusted according to the needs of the real-time scenario, thereby improving the efficiency of code generation.

[0108] based on Figure 2 , Figure 6 and Fig.12 On this basis, in order to improve the efficiency of request response execution, you can also execute the request response by deploying the execution engine SDK. For the specific implementation method, please refer to the following description:

[0109] Among them, the method for obtaining the target request can be to obtain the target request sent by the client, and wherein, the class instance is loaded into the runtime application to generate and execute the target code text corresponding to the target formula expression, and after obtaining the execution result, the execution result can be returned to the client.

[0110] Specifically, you can create an execution engine SDK, which is responsible for parsing the syntax structure of formula expressions, finding the execution methods of built-in functions and custom functions, and converting them into corresponding class instances. The instances will be dynamically loaded into the runtime application to form execution codes and finally obtain calculation results. Business services can be implemented through the execution engine SDK, and the class instances of the instance pool can be flexibly deployed to any node (single or multiple nodes). For details, please refer to Fig.14 , Fig.14 A schematic diagram of a code-generated computing service architecture disclosed in an embodiment of the present application, comprising Fig.14It can be seen that the client can connect to a pre-configured instance pool through an API, which contains class instances of code generation equipment. These class instances can execute specified formulas at runtime to provide computing services.

[0111] It is worth mentioning that since class instances can be deployed on a single or multiple servers, they can be flexibly expanded according to demand. For example, when the workload increases or the geographical distribution changes, more service instances can be added to handle more requests, thereby improving the processing power and response speed of the entire system. In addition, this execution engine SDK, as part of the pre-built components and libraries, simplifies the developer's workflow and accelerates the application development, integration and deployment process. It also brings reliability, stability and higher processing power.

[0112] The above describes the code generation method in the embodiment of the present application. The following describes the code generation device in the embodiment of the present application. Fig.15 , one embodiment of the code generation device in the embodiment of the present application includes:

[0113] An acquisition unit 1501 is used to acquire a target request, where the target request includes an initial code text in a preset language;

[0114] An analysis unit 1502 is used to perform syntax analysis on the initial code text to obtain a syntax tree corresponding to the initial code text, wherein each code block of the syntax tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression, and the tree structure of the syntax tree is used to represent the execution order between each built-in function and / or user-defined function;

[0115] A generating unit 1503 is used to obtain a function execution method of each built-in function and / or user-defined function corresponding to each code block, and generate a class instance corresponding to the target formula expression based on the execution order and the function execution method of each built-in function and / or user-defined function corresponding to each code block;

[0116] The generating unit 1503 is further used to load the class instance into the application program at runtime to generate and execute the target code text corresponding to the target formula expression to obtain the execution result.

[0117] The acquisition unit 1501 is specifically used to determine the function execution method of each built-in function corresponding to each code block from the built-in function list; and / or determine the configuration information of each custom function corresponding to each code block from the custom function list, and generate the function execution method of each custom function based on the configuration information of each custom function.

[0118] The code generating device also includes:

[0119] A display unit 1504 is used to display a custom function configuration interface, wherein the custom function configuration interface includes a field selection area and a function selection area, or a field selection area, a function selection area and a symbol selection area, wherein the field selection area includes at least one field, the function selection area includes at least one function, and the symbol selection area includes at least one symbol;

[0120] The generating unit 1503 is further configured to obtain configuration information of each user-defined function according to each selected target field and target function, or each target field, target function and target symbol.

[0121] The analysis unit 1502 is specifically used to perform syntax analysis on the initial code text to obtain a syntax tree corresponding to the initial code text, each code block of the syntax tree includes a target code block, and the target code block is used to represent the multi-result output function;

[0122] The acquisition unit 1501 is specifically used to determine, for a multiple-result output function, configuration information of the multiple-result output function from a custom function list, and generate a function execution method of the multiple-result output function based on the configuration information of the multiple-result output function, wherein the custom function includes a multiple-result output function, and the initial code text is further used to characterize that the form of the execution result obtained after executing the target code text is a multiple-result form.

[0123] The generating unit 1503 is specifically configured to execute the target code text, obtain the multiple sub-results, save the multiple sub-results into a data set, and obtain a result data set, where the result data set is the execution result.

[0124] The generation unit 1503 is specifically used to use the generated class instance as a class instance template, copy the class instance template, and create an instance pool corresponding to the class instance based on the class instance template and the copied first class instance, obtain idle class instances from the instance pool in turn based on the response order of multiple target requests, and load the idle class instances to the runtime application to generate and execute the target code text corresponding to the target formula expression to obtain an execution result, and the number of target requests reaches a preset quantity threshold.

[0125] The generation unit 1503 is specifically used to determine whether there are idle class instances in the instance pool based on the response order of multiple target requests. If it is determined that there are idle class instances in the instance pool, the idle class instances are obtained from the instance pool. If it is determined that there are no idle class instances in the instance pool, the class instance template is copied, the copied second class instance is added to the instance pool, and the copied second class instance is used as the idle class instance.

[0126] The acquisition unit 1501 is specifically used to acquire the target request sent by the client;

[0127] The code generating device also includes:

[0128] The returning unit 1505 is used to return the execution result to the client.

[0129] In the embodiment of the present application, since the initial code text can be parsed to obtain the syntax tree corresponding to the initial code text, the function execution method of the built-in function and / or the custom function can be automatically obtained based on the syntax tree, and the class instance can be dynamically loaded into the application at runtime to generate and execute the target code text corresponding to the target formula expression, thereby reducing the steps of manually writing the corresponding function logic and simplifying the steps of generating the target code text corresponding to the target formula expression. Therefore, the efficiency of code generation is relatively high. Furthermore, since the efficiency of code generation is relatively high and there is no need to restart the application process, it is possible to respond to changes in business needs in real time.

[0130] See below Fig.16 In the embodiment of the present application, an embodiment of the code generation device 1600 includes:

[0131] CPU 1601, memory 1605, input / output interface 1604, wired or wireless network interface 1603 and power supply 1602;

[0132] The memory 1605 is a temporary storage memory or a permanent storage memory;

[0133] The CPU 1601 is configured to communicate with the memory 1605 and execute the instructions in the memory 1605 to perform the aforementioned Figure 2 The method in the illustrated embodiment.

[0134] The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium includes instructions, when the instructions are executed on a computer, the computer executes the aforementioned Figure 2 The method in the illustrated embodiment.

[0135] The present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the aforementioned Figure 2 The method in the illustrated embodiment.

[0136] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0137] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0138] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0140] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0141] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.

Claims

1. A code generation method, characterized in that: include: Obtaining a target request, wherein the target request includes an initial code text in a preset language; Performing grammatical analysis on the initial code text to obtain a grammar tree corresponding to the initial code text, wherein each code block of the grammar tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression, and the tree structure of the grammar tree is used to represent the execution order between each built-in function and / or user-defined function; Obtaining function execution methods of each built-in function and / or user-defined function corresponding to each code block, and generating a class instance corresponding to the target formula expression based on the execution order and the function execution methods of each built-in function and / or user-defined function corresponding to each code block; The class instance is loaded into a runtime application to generate and execute a target code text corresponding to the target formula expression to obtain an execution result.

2. The method according to claim 1, characterized in that The method for obtaining the function execution of each built-in function and / or user-defined function corresponding to each code block includes: Determine the function execution method of each built-in function corresponding to each code block from the built-in function list; and / or The configuration information of each custom function corresponding to each code block is determined from the custom function list, and the function execution method of each custom function is generated based on the configuration information of each custom function.

3. The method according to claim 2, characterized in that Before determining the configuration information of each custom function corresponding to each code block from the custom function list, the method further includes: Displaying a custom function configuration interface, wherein the custom function configuration interface includes a field selection area and a function selection area, or a field selection area, a function selection area, and a symbol selection area, wherein the field selection area includes at least one field, the function selection area includes at least one function, and the symbol selection area includes at least one symbol; According to the selected target fields and target functions, or target fields, target functions and target symbols, configuration information of the user-defined functions is obtained.

4. The method according to claim 2, characterized in that: The custom function includes a multi-result output function, and the grammatical analysis of the initial code text to obtain a grammar tree corresponding to the initial code text includes: Performing grammatical analysis on the initial code text to obtain a grammatical tree corresponding to the initial code text, wherein each code block of the grammatical tree includes a target code block, and the target code block is used to represent the multi-result output function; The step of determining configuration information of each custom function corresponding to each code block from the custom function list, and generating a function execution method of each custom function based on the configuration information of each custom function, includes: For a multiple-result output function, determining configuration information of the multiple-result output function from a user-defined function list, and generating a function execution method of the multiple-result output function based on the configuration information of the multiple-result output function; The executing the target code text corresponding to the target formula expression to obtain the execution result includes: Execute the target code text to obtain multiple sub-results; The multiple sub-results are saved in a data set to obtain a result data set, where the result data set is the execution result.

5. The method according to any one of claims 1 to 4, characterized in that: When the number of the target requests reaches a preset number threshold, the class instance is loaded into the application at runtime to generate and execute the target code text corresponding to the target formula expression to obtain the execution result, including: Using the generated class instance as a class instance template, copying the class instance template, and creating an instance pool corresponding to the class instance based on the class instance template and the copied first class instance; Based on the response order of multiple target requests, idle class instances are obtained from the instance pool in turn, and the idle class instances are loaded into the runtime application to generate and execute the target code text corresponding to the target formula expression to obtain the execution result.

6. The method according to claim 5, characterized in that The step of sequentially acquiring idle class instances from the instance pool based on the response order of the plurality of target requests includes: Based on the response order of the plurality of target requests, determining in sequence whether there are idle class instances in the instance pool; If it is determined that there is an idle class instance in the instance pool, obtaining the idle class instance from the instance pool; If it is determined that there is no idle class instance in the instance pool, the class instance template is copied, the copied second class instance is added to the instance pool, and the copied second class instance is used as an idle class instance.

7. The method according to any one of claims 1 to 4, characterized in that The target acquisition request includes: Obtaining the target request sent by the client; The method further comprises: loading the class instance into the application program at runtime to generate and execute the target code text corresponding to the target formula expression, and obtaining the execution result. The execution result is returned to the client.

8. A code generating device, characterized in that: include: An acquisition unit, configured to acquire a target request, wherein the target request includes an initial code text in a preset language; An analysis unit, configured to perform syntax analysis on the initial code text to obtain a syntax tree corresponding to the initial code text, wherein each code block of the syntax tree is used to represent each built-in function and / or user-defined function corresponding to the target formula expression, and the tree structure of the syntax tree is used to represent the execution order between each built-in function and / or user-defined function; A generating unit, configured to obtain a function execution method of each built-in function and / or user-defined function corresponding to each code block, and generate a class instance corresponding to the target formula expression based on the execution order and the function execution method of each built-in function and / or user-defined function corresponding to each code block; The generating unit is further used to load the class instance into a runtime application to generate and execute a target code text corresponding to the target formula expression to obtain an execution result.

9. A code generating device, characterized in that: include: CPU and memory; The memory is a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises instructions, and when the instructions are executed on a computer, the computer is caused to perform the method according to any one of claims 1 to 7.

11. A computer program product comprising instructions or a computer program, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for accomplishing VBScript language trans-platform uses

    CN101261579A

  • Method and device for managing video streaming resolution

    CN106330878A

  • Object processing method and device

    CN114089960A

  • Parsing tool for optimizing code for deployment on a serverless platform

    US20230083849A1