Data processing method and device and electronic equipment
By building and initializing the API's abstract syntax tree in software development, the problem of inconsistent API interface specifications is solved, and the unified specification and efficient development of API interfaces are realized.
Patent Information
- Application Number
- CN202510106685.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-06-20
AI Technical Summary
In the field of software development, the lack of unified API interface specifications makes it difficult to follow consistent standards when accessing different APIs, which increases development complexity and uncertainty, and complex interface configurations make developers' adaptation cost expensive, seriously hindering development progress.
By determining the application programming interface (API) in the application page, building a source abstract syntax tree (AST), initializing the API, merging or splitting the API, setting up asynchronous or multi-threaded execution, and generating target AST to unify the API interface specification.
It realizes unified specifications of API paths, parameter formats and data sources, provides a consistent interface style, improves code quality and maintenance effects, and reduces development complexity and cost.
Smart Images

Figure CN120179239A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of software development, and in particular, to a data processing method, apparatus, and electronic device. Background Art
[0002] In the field of software development, there are still some problems in binding application programming interfaces (APIs). Due to the lack of a unified specification, it is difficult to follow a consistent standard when different APIs are accessed, increasing the development complexity and uncertainty; moreover, the complex interface configuration makes the adaptation cost for developers extremely high, seriously hindering the development progress. Summary of the Invention
[0003] The present disclosure provides a data processing method, apparatus, and electronic device to at least solve the above technical problems existing in the prior art.
[0004] According to a first aspect of the present disclosure, there is provided a data processing method, including:
[0005] Determine at least one application programming interface in an application page; the application page includes an application page of a development platform or a browser page;
[0006] Determine a source abstract syntax tree based on the at least one application programming interface;
[0007] Initialize the at least one application programming interface;
[0008] Determine a target abstract syntax tree based on the source abstract syntax tree and the initialized at least one application programming interface;
[0009] Determine code for implementing the at least one application programming interface based on the target abstract syntax tree.
[0010] In the above solution, for determining at least one application programming interface in the application page of the development platform, the method further includes:
[0011] Confirm the attribute information of each component in the application page;
[0012] Based on the attribute information of each component, confirm the application programming interface corresponding to each component;
[0013] Determine the application programming interface corresponding to each component as at least one application programming interface in the application page of the development platform.
[0014] In the above solution, the initializing the at least one application programming interface includes:
[0015] Parse the source abstract syntax tree;
[0016] Confirm at least one application programming interface included in the source abstract syntax tree by matching.
[0017] In the above solution, the initialization of the at least one application programming interface includes at least one of the following:
[0018] Merge at least two application programming interfaces with an associated relationship into one application programming interface;
[0019] Set the application programming interface with an execution duration greater than a preset threshold to asynchronous invocation;
[0020] Set the application programming interfaces of the same type but different dimensions to multi-threaded parallel execution;
[0021] Confirm the uniform resource locator of each application programming interface.
[0022] In the above solution, the determination of the target abstract syntax tree based on the source abstract syntax tree and the initialized at least one application programming interface includes:
[0023] Process the tokens in the source abstract syntax tree according to preset rules to obtain at least one token sequence;
[0024] Confirm the syntax structure in the at least one token sequence and construct the target abstract syntax tree.
[0025] In the above solution, the process of processing the tokens in the source abstract syntax tree according to preset rules to obtain at least one token sequence includes:
[0026] Convert the tokens in the source abstract syntax tree into tokens applicable to the target abstract syntax tree;
[0027] Decompose the code corresponding to the source abstract syntax tree into a token sequence.
[0028] In the above solution, the confirmation of the syntax structure in the at least one token sequence and the construction of the target abstract syntax tree include:
[0029] Identify the at least one token sequence based on the syntax rules and confirm at least one syntax structure;
[0030] Create abstract syntax tree nodes based on the at least one syntax structure and connect them to the nodes in the target abstract syntax tree based on the logical relationship to construct the target abstract syntax tree.
[0031] In the above solution, the development platform includes a low-code platform.
[0032] According to a second aspect of the present disclosure, there is provided a data processing apparatus, including:
[0033] A first determination unit configured to determine at least one application programming interface in an application page; the application page includes an application page of a development platform or a browser page;
[0034] A second determination unit configured to determine a source abstract syntax tree based on the at least one application programming interface;
[0035] An initialization unit configured to initialize the at least one application programming interface;
[0036] A construction unit configured to determine a target abstract syntax tree based on the source abstract syntax tree and the initialized at least one application programming interface;
[0037] A generation unit configured to determine code for implementing the at least one application programming interface based on the target abstract syntax tree.
[0038] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0039] At least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the present disclosure.
[0040] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] By referring to the accompanying drawings and reading the following detailed description, the above and other objects, features, and advantages of the exemplary embodiments of the present disclosure will become easily understood. In the drawings, several embodiments of the present disclosure are shown in an exemplary rather than restrictive manner, wherein:
[0042] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0043] Figure 1 Shows a first alternative flowchart of the data processing method provided by the embodiments of the present disclosure;
[0044] Figure 2 Shows a second alternative flowchart of the data processing method provided by the embodiments of the present disclosure;
[0045] Figure 3Shows a schematic flowchart of the data processing method provided by an embodiment of the present disclosure;
[0046] Figure 4 Shows a third alternative flowchart of the data processing method provided by an embodiment of the present disclosure;
[0047] Figure 5 Shows a schematic diagram of an alternative structure of the data processing device provided by an embodiment of the present disclosure;
[0048] Figure 6 Shows a schematic diagram of the composition structure of an electronic device according to an embodiment of the present disclosure. Detailed implementation manners
[0049] To make the objectives, features, and advantages of the present disclosure more obvious and understandable, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present disclosure.
[0050] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0051] In the following description, the terms "first / second" are only used to distinguish similar objects, and do not represent a specific order for the objects. It can be understood that "first / second" can be interchanged with a specific order or sequence when allowed, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0052] Unless otherwise defined, all technical and scientific terms used in the present disclosure have the same meaning as commonly understood by those skilled in the technical field to which the present disclosure belongs. The terms used in the present disclosure are only for the purpose of describing the embodiments of the present disclosure, and are not intended to limit the present disclosure.
[0053] It should be understood that in various embodiments of the present disclosure, the magnitude of the sequence numbers of each implementation process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present disclosure.
[0054] In the related art, for example, an application code development platform, a web page code development platform, or a low-code development platform can quickly generate a user interface, facilitating page development for developers. However, there are still some problems in binding APIs, such as the lack of a unified specification, complex interface configuration, and the self-development and maintenance costs of APIs. In the existing solutions, API developers develop API customization according to the specifications of the code development platform, with high learning costs and poor reusability and scalability. In addition, the code development platform provides an API management system, and API developers enter the APIs into the system and call them through request encapsulation and forwarding, resulting in poor performance; moreover, the User Interface (UI) and APIs are interdependent, leading to low development efficiency.
[0055] Figure 1 FIG. 1 shows a first alternative flowchart of the data processing method provided by an embodiment of the present disclosure, which will be described according to each step.
[0056] Step S101, determine at least one application programming interface in the application page.
[0057] In some embodiments, the application page includes an application page of a development platform or a browser page; the development platform includes a low-code development platform, a no-code development platform, a full-code development platform, and rapid application development.
[0058] In some embodiments, the at least one application programming interface is used to obtain data in the backend database to implement the code of the application page.
[0059] Step S102, determine a source abstract syntax tree based on the at least one application programming interface.
[0060] In some embodiments, the source abstract syntax tree includes tree-structured data of the code structure corresponding to the application page, determined based on the at least one application programming interface. The source abstract syntax tree is used to represent the requirements for implementing the code of the application page.
[0061] In some embodiments, the carrier (hereinafter referred to as the carrier) for implementing the data processing method converts the application programming interfaces of different components in the application page into a source abstract syntax tree; the source abstract syntax tree also includes the component names and component types of the application page. Converting the application programming interfaces of different components into a source abstract syntax tree can further make the paths, parameter formats, data sources, etc. of each application programming interface follow a unified specification, that is, a consistent interface style.
[0062] The carrier can be a computer program, electronic circuit, database, mobile application, electronic device, cloud computing platform, distributed system, artificial intelligence framework, mathematical model, automation tool, microcontroller, etc., which are software or hardware capable of implementing algorithms and method flows.
[0063] Step S103: Initialize the at least one application programming interface.
[0064] In some embodiments, the initialization of the at least one application programming interface includes at least one of defining the at least one application programming interface, performing thread optimization on the at least one application programming interface, building a framework for the code of the application page, and generating a Uniform Resource Locator (URL) corresponding to each application programming interface.
[0065] Specifically, defining the at least one application programming interface includes determining whether there is an association relationship between the at least one application programming interface, and merging or splitting the at least one application programming interface based on the result of whether there is an association relationship; the thread optimization of the at least one application programming interface includes whether to perform parallel processing on the service corresponding to any application programming interface.
[0066] Step S104: Determine a target abstract syntax tree based on the source abstract syntax tree and the initialized at least one application programming interface.
[0067] In some embodiments, the carrier converts the parameter tags in the source abstract syntax tree into parameter tags applicable to the target abstract syntax tree, and constructs the target abstract syntax tree by combining the parameter tags of the target abstract syntax tree based on the syntax rules or grammar rules corresponding to the source abstract syntax tree.
[0068] Step S105: Determine the code for implementing the at least one application programming interface based on the target abstract syntax tree.
[0069] In some embodiments, the carrier obtains the dependency packages required to generate the corresponding code based on the target abstract syntax tree, determines the input and output formats corresponding to the application programming interface to unify the interaction interfaces between different components; integrates the nodes of the target abstract syntax tree of the business logic and data corresponding to the application page into the corresponding code files and modules according to the programming language and framework requirements corresponding to the application page, and obtains the code corresponding to the at least one application programming interface. The code is used to implement the application page.
[0070] Wherein, the dependency package includes a pre-written code combination, which contains functional modules.
[0071] In this way, through the data processing method provided in the embodiments of the present disclosure, developers do not need to write code from scratch, improving development efficiency; the generated API paths, parameter formats, data sources, etc. follow unified specifications, providing a consistent interface style, which helps to improve code quality and maintenance effects.
[0072] Figure 2 Fig. 6 shows a second optional flowchart of the data processing method provided in the embodiments of the present disclosure. Figure 3 Fig. 8 shows a flowchart of the data processing method provided in the embodiments of the present disclosure; it will be described according to each step.
[0073] Step S201: Parse the application page to determine at least one application programming interface in the application page.
[0074] In some embodiments, the carrier analyzes the application page to confirm the attribute information of each component in the application page; based on the attribute information of each component, confirm the application programming interface corresponding to each component; determine that the application programming interface corresponding to each component is at least one application programming interface in the application page of the development platform, or determine that the application programming interface corresponding to each component is at least one application programming interface in the browser page. Wherein, the attribute information includes component name, component type, and keyword.
[0075] In some embodiments, the application page is generated based on user requirements. The application page includes the attribute information of each component, but does not include the specific data corresponding to each component, nor the code of the application page, and needs to obtain it from the backend database through the corresponding application programming interface.
[0076] Step S202: Generate a source abstract syntax tree based on the at least one application programming interface.
[0077] In some embodiments, as Figure 3 shown, the carrier parses the application page and generates a source abstract syntax tree based on a predefined application programming interface type dictionary and the at least one application programming interface; the predefined application programming interface type dictionary includes supported data types and node types, and is used to convert at least one application programming interface into corresponding identifiers in the source abstract syntax tree based on its component type.
[0078] For example, if the component type is an image type, it is labeled as 1; if the component type is an audio type, it is labeled as 2; if the component type is a text type, it is labeled as 3. If Application Programming Interface 1 corresponds to an image type component, during the process of generating the source abstract syntax tree, the component type corresponding to Application Programming Interface 1 is labeled as 1. If Application Programming Interface 2 corresponds to a text type component, during the process of generating the source abstract syntax tree, the component type corresponding to Application Programming Interface 2 is labeled as 2.
[0079] In some embodiments, the carrier also constructs a source abstract syntax tree based on the component names, component types, and keywords of each component in the application page, as well as the interface definitions, data processing events, and error handling events of the corresponding application programming interfaces.
[0080] For example, if the application page includes a form type component, and the form type component includes an input box and a submit button, then the generated source abstract syntax tree includes nodes for processing form data submission and form data validation.
[0081] In this way, first generate a source abstract syntax tree based on at least one application programming interface, and then convert it to a target abstract syntax tree and generate code in the subsequent process, rather than directly generating code based on at least one application programming interface. This can enable the application page to interact with the backend database based on the paths and parameter formats of the standardized application programming interfaces, which is beneficial to improving the code quality and maintenance effect in the future.
[0082] Step S203, convert the source abstract syntax tree into a target abstract syntax tree.
[0083] In some embodiments, the carrier parses the source abstract syntax tree to obtain at least one application programming interface.
[0084] Specifically, the carrier matches the source abstract syntax tree based on regular expression keywords to determine at least one application programming interface in the source abstract syntax tree. The carrier's matching of the source abstract syntax tree based on regular expression keywords includes determining the annotations in the source abstract syntax tree based on the regular expression keywords, and determining at least one application programming interface in the source abstract syntax tree based on the correspondence between the annotations and the component types.
[0085] In some embodiments, the carrier performs initialization processing on the at least one application programming interface.
[0086] Specifically, the initialization processing includes determining whether the at least one application programming interface is split, merged, asynchronous, or multi-threaded, and the uniform resource locator corresponding to each application programming interface.
[0087] In some embodiments, if it is parsed that there is an association relationship between at least two application programming interfaces on the application page, that is, it is necessary to sequentially call the at least two application programming interfaces in the same request to complete a certain function, then the at least two application programming interfaces are merged into one application programming interface.
[0088] In some embodiments, if it is parsed that the execution duration of any application programming interface on the application page is greater than a preset threshold, then the any application programming interface is set to be asynchronously called to avoid blocking the loading of the application page.
[0089] In some embodiments, if it is parsed that there are different-dimensional services of the same type in the application programming interface, then the application programming interface is processed in a multi-threaded parallel manner to improve the performance of the application programming interface. For example, if the service corresponding to any application programming interface is to obtain table data, if it is processed in a single thread, each row of table data needs to be obtained separately; if it is changed to parallel processing, multiple rows of table data can be obtained simultaneously, shortening the duration of obtaining data.
[0090] In some embodiments, a unique uniform resource locator is generated according to the type of each application programming interface, and the standard HyperText Transfer Protocol (HTTP), such as GET, POST, PUT, or DELETE, is used to operate on the resource. At the same time, when confirming the application programming interface, the naming specification of the resource, the passing method of parameters, and the format of the returned data are determined to ensure compliance with the RESTful specification, improving the maintainability and scalability of the system.
[0091] Step S204, based on the source abstract syntax tree and the at least one initialized application programming interface, determine the target abstract syntax tree.
[0092] In some embodiments, the carrier processes the tokens in the source abstract syntax tree according to a preset rule to obtain at least one token sequence; confirms the syntax structure in the at least one token sequence, and constructs the target abstract syntax tree.
[0093] Specifically, the carrier converts the tokens in the source abstract syntax tree into tokens applicable to the target abstract syntax tree; decomposes the code corresponding to the source abstract syntax tree into a token sequence; identifies the at least one token sequence based on the syntax rule to confirm at least one syntax structure; creates abstract syntax tree nodes based on the at least one syntax structure, and connects them with the nodes in the target abstract syntax tree based on the logical relationship to construct the target abstract syntax tree. For example, if the token applicable to the source abstract syntax tree is "a", correspondingly, the token applicable to the target abstract syntax tree is "a_", then the token "a" in the source abstract syntax tree is converted to "a_".
[0094] Among them, the tokens include a basic unit in the source abstract syntax tree, such as keywords, identifiers, operators, etc.; during conversion, tokens such as whitespace and comments that do not affect the code expression or function can be ignored. The carrier can generate a token sequence according to the lexical analyzer and construct the target abstract syntax tree according to the syntax rules. The structures in the source abstract syntax tree, such as expressions, statements, function definitions, etc., are recognized through context-free grammar and represented as nodes in a tree structure.
[0095] In some embodiments, such as Figure 3 As shown, the carrier converts the source AST to the target AST. For each syntax structure recognized in the source abstract syntax tree by the carrier, an abstract syntax tree node corresponding thereto is created in the target abstract syntax tree and connected to the existing abstract syntax tree nodes in the target abstract syntax tree, gradually constructing a complete target abstract syntax tree. Among them, each abstract syntax tree node (or node) of the abstract syntax tree generally represents a syntax structure in the code, such as an expression, a statement, a function, etc., and the hierarchical structure of the code is represented by the parent-child relationship between the nodes.
[0096] In some embodiments, after determining the target abstract syntax tree, the carrier traverses the target abstract syntax tree to obtain and process the information in the target abstract syntax tree. The target abstract syntax tree is traversed in a depth-first manner, and corresponding operations are performed according to the need to access different nodes in the target abstract syntax tree, such as generating code and performing static analysis.
[0097] Step S205, based on the target abstract syntax tree, determine the code for implementing the at least one application programming interface.
[0098] In some embodiments, the carrier, based on the target abstract syntax tree, obtains the dependency packages required to generate the corresponding code, determines the input and output formats corresponding to the application programming interface, and unifies the interaction interfaces between different components; integrates the nodes of the target abstract syntax tree of the business logic and data corresponding to the application page into the corresponding code files and modules according to the programming language and framework requirements corresponding to the application page, to obtain the code corresponding to the at least one application programming interface. The code is used to implement the application page.
[0099] Among them, the dependency packages include pre-written code combinations that contain functional modules.
[0100] In this way, through the data processing method provided in the embodiments of the present disclosure, developers do not need to write code from scratch, improving development efficiency; the generated API paths, parameter formats, data sources, etc. follow unified specifications, providing a consistent interface style, which helps to improve code quality and maintenance effects. The API placeholders in the application page can also be used to automatically complete the definition of the API (including whether to split, merge, asynchronous, multi-threaded, etc.); continuously optimize the API performance.
[0101] Next, a specific example will be used for illustration. If the application page is the product page of a shopping type application, the components included in the application page are product images, product names, product details, buttons, etc. The carrier analyzes the application page, determines at least one application programming interface based on the product images, product names, product details, and buttons in the application page, and a predefined application programming interface dictionary; generates a source abstract syntax tree based on the at least one application programming interface; parses the meta-abstract syntax tree to determine at least one application programming interface required by the application page, and initializes the at least one application programming interface (including splitting, merging, synchronization, asynchrony, single-threading, multi-threading, and URL definition), generates a target abstract syntax tree based on the at least one application programming interface after initialization, obtains specific data such as product images, product names, and product details from the database based on the target abstract syntax tree, and generates the code corresponding to the at least one application programming interface.
[0102] Figure 4 FIG. 3 shows a third alternative flowchart of the data processing method provided in the embodiments of the present disclosure, and will be described according to each step.
[0103] Step S401, determine the application page based on the user operation.
[0104] In some embodiments, step S401 is a front-end operation for the user, that is, according to the user's mouse click, mouse drag, keyboard input, etc., the design of the application page by the user is obtained; the application page can be a UI, and the design of the application page includes the positions of various components in the application page and the associations between the components, the types of each component, the names of each component, keywords, and the functions of each component.
[0105] Step S402, initialize the application programming interface.
[0106] In some embodiments, step S402 is a back-end operation.
[0107] In some embodiments, the carrier analyzes, initializes, and generates at least one application programming interface included in the application page.
[0108] In some embodiments, the carrier analyzes at least one application programming interface included in the application page, including the process of generating a source abstract syntax tree: obtaining keyword information such as the name and component type of components from the application interface configuration, and then generating a source abstract syntax tree containing actual parameters according to a predefined application programming interface type dictionary. Each node of the source abstract syntax tree includes interface definitions, data processing, and error handling events, etc. For example, when a user adds a form element (or form component) on the application page, including an input box and a submit button, the system will automatically generate a source abstract syntax tree for processing form data submission and verification APIs. The source abstract syntax tree represents a tree-shaped data structure of the code structure. It should be noted that the actual parameters include the types and data sources of the data required when building the application page, rather than specific data. That is to say, the source abstract syntax tree only includes the types and names of the data that need to be obtained from the database, not specific data.
[0109] In some embodiments, the carrier initializes at least one application programming interface included in the application page, which may include a keyword matching and parsing algorithm based on a custom regular expression, and combines it with the API best practice library built into the tool to initialize the API. The custom regular expression is used to parse the APIs included in the source abstract syntax tree. For example, according to a predefined application programming interface type dictionary, the application programming interfaces corresponding to different components are labeled as corresponding component types (such as image type components, audio type components, etc.). The carrier matches the labels in the source abstract syntax tree based on the custom regular expression to determine the component type corresponding to each application programming interface.
[0110] For example, based on a predefined application programming interface type dictionary, the image type components in the source abstract syntax tree are labeled as 1, and the audio type components in the source abstract syntax tree are labeled as 2; correspondingly, based on the custom regular expression, it is determined that the API labeled as 1 in the source abstract syntax tree corresponds to an image type component, and the API labeled as 2 in the source abstract syntax tree corresponds to an audio type component.
[0111] Specifically, the carrier defines whether to split or merge the APIs; if there is a strong dependency between different APIs on the application page and these APIs need to be called sequentially in the same request to complete a certain function, then these APIs are merged into a unified API to simplify the call process and reduce the number of network requests.
[0112] Specifically, the carrier determines whether to make the APIs asynchronous; if some APIs on the application page take a long time to execute, it may cause the page loading speed to slow down. In this case, the time-consuming APIs are designed to be asynchronously called to avoid blocking the page loading and improve the user experience.
[0113] Specifically, the carrier determines whether the API performs multi-threading processing or the like; if there are different-dimensional services of the same type in a single API on the page, such service data will be processed in parallel by multiple threads to improve the API performance.
[0114] Specifically, the carrier determines the URL corresponding to each API: generates a unique URL for each API according to the API type, and uses standard HTTP methods (such as GET, POST, PUT, DELETE) to operate on resources. The design of the API also considers the naming specifications of resources (or returned components, data), the parameter passing methods, the formats of return results, etc., to ensure compliance with the RESTful specification and improve the maintainability and scalability of the system.
[0115] Step S403, generate the target abstract syntax tree.
[0116] In some embodiments, the carrier performs lexical analysis and syntax analysis on the source abstract syntax tree to generate the target abstract syntax tree.
[0117] Specifically, lexical analysis includes converting the source AST (source abstract syntax tree) into a series of tokens, and each token represents a basic unit in the code, such as keywords, identifiers, operators, etc. The carrier will ignore irrelevant content such as spaces and comments and decompose the code into a token sequence.
[0118] Specifically, syntax analysis includes gradually constructing the target AST (target abstract syntax tree) according to the token sequence generated by the lexical analyzer. The syntax analyzer will identify various structures in the code, such as expressions, statements, function definitions, etc., according to the syntax rules (usually using context-free grammars), and represent these structures as nodes of a tree structure.
[0119] Specifically, during the syntax analysis process, whenever a syntax structure is recognized, a corresponding target AST node will be created and connected to the existing nodes to gradually construct a complete target AST. Each node of the target AST usually represents a syntax structure in the code, such as an expression, a statement, a function, etc., and the hierarchical structure of the code is represented by the parent-child relationship between the nodes.
[0120] In some embodiments, after the construction of the target AST is completed, the information in the target AST is obtained and processed by traversing the target AST. The target AST is traversed in a depth-first manner, and different nodes in the target AST are accessed according to needs for corresponding operations, such as generating code and performing static analysis.
[0121] Step S404, generate API code.
[0122] In some embodiments, based on the target abstract syntax tree, the carrier obtains dependency packages required for generating corresponding code, determines the input / output formats corresponding to application programming interfaces, and unifies the interaction interfaces between different components; nodes of the target abstract syntax tree of the business logic and data corresponding to the application page are integrated into corresponding code files and modules according to the programming language and framework requirements corresponding to the application page, to obtain the code corresponding to the at least one application programming interface. The code is used to implement the application page.
[0123] Wherein, the dependency package includes a pre-written code combination, which contains functional modules.
[0124] In this way, through the data processing method provided by the embodiments of the present disclosure, developers do not need to write code from scratch, improving development efficiency; the generated API paths, parameter formats, data sources, etc. follow unified specifications, providing a consistent interface style, which helps to improve code quality and maintenance effects. The API placeholders in the application page can also be used to automatically complete the definition of APIs (including whether to split, merge, asynchronous, multi-threaded, etc.); continuously optimize the performance of APIs.
[0125] Figure 5 FIG. shows an optional structural schematic diagram of a data processing device provided by an embodiment of the present disclosure, which will be described according to each part.
[0126] In some embodiments, the data processing device 500 includes a first determination unit 501, a second determination unit 502, an initialization unit 503, a construction unit 504, and a generation unit 505.
[0127] The first determination unit 501 is configured to determine at least one application programming interface in the application page; the application page includes an application page of a development platform or a browser page;
[0128] The second determination unit 502 is configured to determine a source abstract syntax tree based on the at least one application programming interface;
[0129] The initialization unit 503 is configured to initialize the at least one application programming interface;
[0130] The construction unit 504 is configured to determine a target abstract syntax tree based on the source abstract syntax tree and the initialized at least one application programming interface;
[0131] The generation unit 505 is configured to determine code for implementing the at least one application programming interface based on the target abstract syntax tree.
[0132] The first determination unit 501 is specifically configured to confirm the attribute information of each component in the application page;
[0133] Based on the attribute information of each component, confirm the application programming interface corresponding to each component;
[0134] Determine that the application programming interface corresponding to each component is at least one application programming interface in the application page of the development platform.
[0135] The initialization unit 503 is specifically configured to parse the source abstract syntax tree;
[0136] Confirm at least one application programming interface included in the source abstract syntax tree by means of matching.
[0137] The initialization unit 503 is specifically configured to perform at least one of the following:
[0138] Merge at least two application programming interfaces with an association relationship into one application programming interface;
[0139] Set the application programming interface with an execution duration greater than a preset threshold to asynchronous invocation;
[0140] Set application programming interfaces of the same type but different dimensions to execute in parallel with multiple threads;
[0141] Confirm the uniform resource locator of each application programming interface.
[0142] The construction unit 504 is specifically configured to process the tokens in the source abstract syntax tree according to preset rules to obtain at least one token sequence;
[0143] Confirm the syntax structure in the at least one token sequence, and construct a target abstract syntax tree.
[0144] The construction unit 504 is specifically configured to convert the tokens in the source abstract syntax tree into tokens applicable to the target abstract syntax tree;
[0145] Decompose the code corresponding to the source abstract syntax tree into a token sequence.
[0146] The construction unit 504 is specifically configured to identify the at least one token sequence based on syntax rules, and confirm at least one syntax structure;
[0147] Create abstract syntax tree nodes based on the at least one syntax structure, and connect them to the nodes in the target abstract syntax tree based on logical relationships to construct the target abstract syntax tree.
[0148] In some embodiments, the development platform includes a low-code platform.
[0149] According to embodiments of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0150] Figure 6 FIG. shows a schematic block diagram of an exemplary electronic device 800 that can be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, for example, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, for example, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0151] As Figure 6 shown, the electronic device 800 includes a computing unit 801 that can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0152] A plurality of components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0153] The computing unit 801 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 executes the various methods and processes described above, such as the data processing method. For example, in some embodiments, the data processing method can be implemented as a computer software program that is tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the data processing method described above can be executed. Alternatively, in other embodiments, the computing unit 801 can be configured to execute the data processing method in any other suitable manner (e.g., by means of firmware).
[0154] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor, and can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0155] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to the processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program codes can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0156] In the context of this disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0157] To provide for interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can also be used to provide for interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic, speech, or tactile input).
[0158] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0159] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is generated by computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
[0160] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution disclosed in the present disclosure can be achieved, and no limitations are imposed herein.
[0161] In addition, the terms "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, "a plurality of" means two or more, unless otherwise specifically defined.
[0162] As described above, the above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present disclosure can easily think of changes or substitutions, which should all be covered by the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.
Claims
1. A data processing method, the method comprising: determining at least one application programming interface in the application page; The application page includes an application page or a browser page of a development platform; determining a source abstract syntax tree based on the at least one application programming interface; Initializing the at least one application programming interface; Determine a target abstract syntax tree based on the source abstract syntax tree and the at least one initialized application programming interface; Based on the target abstract syntax tree, code for implementing the at least one application programming interface is determined.
2. The method according to claim 1, wherein the determining at least one application programming interface in the application page of the development platform further comprises: Confirming the attribute information of each component in the application page; Based on the attribute information of each component, confirm the application programming interface corresponding to each component; Determine that the application programming interface corresponding to each component is at least one application programming interface in the application page of the development platform.
3. The method according to claim 1, wherein initializing the at least one application programming interface comprises: Parsing the source abstract syntax tree; At least one application programming interface included in the source abstract syntax tree is confirmed by matching.
4. The method according to claim 1 or 3, wherein initializing the at least one application programming interface comprises at least one of the following: Merging at least two associated application programming interfaces into one application programming interface; Set the API whose execution time exceeds the preset threshold to asynchronous call; Setting application programming interfaces of the same type but different dimensions to execute in parallel through multiple threads; Identify the Uniform Resource Locator for each API.
5. The method according to claim 1, wherein determining a target abstract syntax tree based on the source abstract syntax tree and the at least one initialized application programming interface comprises: Processing the tokens in the source abstract syntax tree according to preset rules to obtain at least one token sequence; A grammatical structure in the at least one token sequence is confirmed, and a target abstract syntax tree is constructed.
6. The method according to claim 5, wherein the processing of the tags in the source abstract syntax tree according to the preset rules to obtain at least one tag sequence comprises: Convert tokens in the source abstract syntax tree into tokens suitable for the target abstract syntax tree; Decompose the code corresponding to the source abstract syntax tree into a sequence of tokens.
7. The method according to claim 5, wherein the confirming the grammatical structure in the at least one token sequence and constructing the target abstract syntax tree comprises: Recognize the tag sequence based on grammatical rules to confirm at least one grammatical structure; An abstract syntax tree node is created based on the at least one grammatical structure, and is connected with the node in the target abstract syntax tree based on a logical relationship to construct a target abstract syntax tree.
8. According to the method according to claim 1, the development platform includes a low-code platform.
9. A data processing device, comprising: A first determining unit, configured to determine at least one application programming interface in the application page; The application page includes an application page or a browser page of a development platform; a second determining unit, configured to determine a source abstract syntax tree based on the at least one application programming interface; an initialization unit, configured to initialize the at least one application programming interface; A construction unit, configured to determine a target abstract syntax tree based on the source abstract syntax tree and the at least one initialized application programming interface; A generating unit is used to determine a code for implementing the at least one application programming interface based on the target abstract syntax tree.
10. An electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 8.