CN116009847A - Code generation method, device, electronic equipment and storage medium - Google Patents

Code generation method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116009847A
CN116009847A CN202310126603.5A CN202310126603A CN116009847A CN 116009847 A CN116009847 A CN 116009847A CN 202310126603 A CN202310126603 A CN 202310126603A CN 116009847 A CN116009847 A CN 116009847A
Authority
CN
China
Prior art keywords
logic
code
flow chart
component
generating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310126603.5A
Other languages
Chinese (zh)
Inventor
张波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Burgeon Co ltd
Original Assignee
Shanghai Burgeon Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Burgeon Co ltd filed Critical Shanghai Burgeon Co ltd
Priority to CN202310126603.5A priority Critical patent/CN116009847A/en
Publication of CN116009847A publication Critical patent/CN116009847A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the invention discloses a code generation method, a code generation device, electronic equipment and a storage medium. The method comprises the following steps: displaying a visual code editing interface, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component; generating description codes according to grammar conversion rules and logic configuration identifiers of the configured logic components; and determining target logic configuration content corresponding to the logic identifier, and generating target codes corresponding to the logic flow chart of the configured codes based on the target logic configuration content and the description codes. The technical scheme of the embodiment of the invention realizes simpler and faster code generation, reduces the development cost of the code and improves the development efficiency of the code.

Description

Code generation method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a code generating method, a code generating device, an electronic device, and a storage medium.
Background
For software development, a technician is often required to write program code manually in the related art. Once project requirements or business processing logic change, it is often necessary to re-write the program code. The method for processing the code has the technical problems of higher code development cost and lower development efficiency.
Disclosure of Invention
In view of the above problems, the present invention provides a code generation method, apparatus, electronic device, and storage medium, so as to generate a code more simply and rapidly, reduce the development cost of the code, and improve the development efficiency of the code.
According to an aspect of the present invention, there is provided a code generation method including:
displaying a visual code editing interface, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component;
generating description codes according to grammar conversion rules and logic configuration identifiers of the configured logic components;
and determining target logic configuration content corresponding to the logic identifier, and generating target codes corresponding to the logic flow chart of the configured codes based on the target logic configuration content and the description codes.
Optionally, the generating, based on the target logic configuration content and the description code, target code corresponding to the configured code logic flow chart includes:
generating an abstract syntax tree based on the target logic configuration content and the description code;
And generating target codes corresponding to the configured code logic flow chart based on the abstract syntax tree.
Optionally, the generating an abstract syntax tree based on the target logic configuration content and the description code includes:
analyzing the description code and determining a logic configuration identifier in the description code;
replacing the logic configuration identifier with target logic configuration content corresponding to the logic configuration identifier to obtain a replaced code;
and carrying out grammar analysis processing on the replaced codes to obtain an abstract grammar tree.
Optionally, the generating, based on the abstract syntax tree, object code corresponding to the configured code logic flow diagram includes:
and generating a structural template and the abstract syntax tree based on preset codes, and generating target codes corresponding to the configured code logic flow chart.
Optionally, the visual code editing interface includes a logic component selection area, where the logic component selection area displays a logic component to be dragged; the method further comprises the steps of:
receiving a drag operation aiming at the logic component to be dragged, and obtaining a logic flow chart of a code to be configured based on the logic component to be dragged;
And obtaining a configured code logic flow chart based on the code logic flow chart to be configured.
Optionally, the visual code editing interface includes a logical configuration area; the obtaining a configured code logic flow chart based on the code logic flow chart to be configured comprises the following steps:
receiving a selection operation acting on a logic component in the logic flow chart of the code to be configured, and displaying a logic configuration item corresponding to the selected logic component in the logic configuration area;
receiving configuration operation acting on the logic configuration item to obtain a configured logic component corresponding to the selected logic component;
based on the configured logic component, a configured code logic flow diagram is generated.
Optionally, the determining the target logic configuration content corresponding to the logic identifier includes:
and determining preset logic configuration content corresponding to the logic configuration identifier as target logic configuration content based on the corresponding relation between the logic configuration identifier and the preset logic configuration content.
According to another aspect of the present invention, there is provided a code generating apparatus. The device comprises:
the logic component display module is used for displaying a visual code editing interface, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component;
The description code generation module is used for generating description codes according to the grammar conversion rules and the logic configuration identifiers of the configured logic components;
and the object code generation module is used for determining object logic configuration content corresponding to the logic identifier and generating object codes corresponding to the configured code logic flow chart based on the object logic configuration content and the description codes.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform any one of the code generation methods of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to execute any one of the code generation methods of the present invention.
According to the technical scheme, the visual code editing interface is displayed, wherein the visual code editing interface is provided with the configured code logic flow chart, and the configured code logic flow chart comprises the configured logic component, so that the business processing logic can be edited and adjusted more flexibly; generating description codes according to grammar conversion rules and logic configuration identifiers of the configured logic components; and determining target logic configuration content corresponding to the logic identifier, and generating target codes corresponding to the logic flow chart of the configured codes based on the target logic configuration content and the description codes. The technical scheme of the embodiment of the invention realizes simpler and faster code generation, reduces the development cost of the code and improves the development efficiency of the code.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a code generation method according to a first embodiment of the present invention;
FIG. 2 is an interface diagram of a code generation method according to a first embodiment of the present invention;
FIG. 3 is an interface diagram of a code generation method according to a first embodiment of the present invention;
fig. 4 is a flow chart of a code generating method according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of a code generating device according to a third embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It is noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present invention and in the foregoing figures, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus.
It will be appreciated that the data (including but not limited to the data itself, the acquisition or use of the data) involved in the present technical solution should comply with the corresponding legal regulations and the requirements of the relevant regulations.
Example 1
Fig. 1 is a schematic flow chart of a code generating method according to a first embodiment of the present invention, where the method may be applied to a case of generating a code, and the method may be performed by a code generating apparatus, where the code generating apparatus may be implemented in hardware and/or software, and the code generating apparatus may be configured in an electronic device such as a computer or a server.
As shown in fig. 1, the method of the present embodiment includes:
s110, displaying a visual code editing interface, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component.
The visual code editing interface can be understood as a preset visual interface for editing and configuring the code logic flow chart. Exposing the visual code editing interface may include: receiving an interface display instruction for displaying a visual code editing interface; and further, based on the interface display instruction, a visual code editing interface can be displayed. How many interface display instructions are generated. For example, a launch operation for an application may be received, and an interface presentation instruction may be generated based on the launch operation; or, after the application program is started, in response to a configuration operation for configuring the code logic flow chart, an interface display instruction is generated, so that the default main interface display of the application program is switched to a visual editing interface based on the interface display instruction.
In an embodiment of the present invention, the visual code editing interface may expose an unconfigured code logic flow diagram. After the unconfigured code logic flow chart displayed in the visual code editing interface is configured, the configured code logic flow chart can be displayed in the visual code editing interface. A configured code logic flow chart may be understood as a flow chart of a code logic configuration completion.
In an embodiment of the invention, the visual code editing interface may include a logical component selection area. The logical component selection area shows logical components to be dragged. The logic component to be dragged is a pre-packaged visual component and can be used for setting execution logic of a program. In the embodiment of the invention, the logic component to be dragged can be dragged to flexibly configure more complex service processing logic.
In practical applications, the number of logical components to be dragged that are shown in the logical component selection area is typically a plurality. In the embodiment of the invention, the logic component to be dragged can comprise, but is not limited to, a custom business process component and a basic logic component. Illustratively, as shown in FIG. 2, the custom business process component may be a 1 business process, a 2 business process, or a 3 business process.
The custom business process component can be understood as a component which is preconfigured according to actual needs and can be used for processing business. The business processes of the custom business process component may include at least one system atomic business process (system atomic operations in FIG. 2) and/or at least one custom atomic business process (model atomic operations in FIG. 2). That is, the business process of a single custom business process component may be a system atomic business process; alternatively, it may be a custom atomic business process; or, the business process can be obtained by combining at least one system atomic business process and at least one custom atomic business process; or, may be a business process performed by at least one system atom; or, the business process may be a business process obtained by combining at least one custom atomic business process.
In the embodiment of the invention, the business process of the custom business process component is constructed based on the custom atomic business process and/or the system atomic business process which are predefined, so that the custom business process component can be constructed more conveniently and flexibly, and the configuration difficulty of the custom business process component is reduced.
Wherein a basic logic component may be understood as a component for configuring a business process flow. The basic logic components may include a first loop component (the "while" component in FIG. 2), a second loop component (the "for" component in FIG. 2), a continue execution component (the "continuous" component in FIG. 2), a jump-out execution component (the "break" component in FIG. 2), a first decision component (the "if" component in FIG. 2), a second decision component (the "else" component in FIG. 2), a third decision component (the "if-else" component in FIG. 2), a select component (the switch in FIG. 2), and a return component (the "return" component in FIG. 2).
In addition, the logic component to be dragged may further include a start component, an end component, and a connection component. Wherein the start component can be utilized to characterize the start of the code logic. An end component can be employed to characterize an end of code logic. The connection component can connect the business processes which need to be connected according to the actual requirements.
In the embodiment of the present invention, the method for obtaining the configured code logic flow chart may specifically include: receiving a drag operation aiming at the logic component to be dragged, and obtaining a logic flow chart of a code to be configured based on the logic component to be dragged; and obtaining a configured code logic flow chart based on the code logic flow chart to be configured. The code logic flow chart to be configured can be understood as a code logic flow chart to be configured.
Specifically, a drag operation for a logical component to be dragged presented in the logical component selection area is received. And a logic flow chart of the code to be configured can be obtained based on the logic component dragged by the dragging operation. In practical applications, the number of logical components dragged based on the drag operation is typically plural. That is, the code logic flow diagram to be configured may be made up of a plurality of dragged logic components. After the code logic flow diagram to be configured is obtained, the code logic flow diagram to be configured can be configured. So that a configured code logic flow diagram may be obtained.
In an embodiment of the present invention, the visual code editing interface may include a logical configuration area. The logic configuration region may be used to logically configure the logic flow diagram to be configured. The obtaining a configured code logic flow chart based on the code logic flow chart to be configured may include: receiving a selection operation acting on a logic component in the logic flow chart of the code to be configured, and displaying a logic configuration item corresponding to the selected logic component in the logic configuration area; receiving configuration operation acting on the logic configuration item to obtain a configured logic component corresponding to the selected logic component; based on the configured logic component, a configured code logic flow diagram is generated.
The selecting operation may be used to select a logic component in the logic flow chart of the code to be configured, so as to configure the selected logic component. The logical configuration area may be used to expose logical configuration items corresponding to the selected logical components. The correspondence between logical components and logical configuration items may be one-to-one or one-to-many. In practical applications, the number of logical configuration items presented in the logical configuration area may be one or more. The logic configuration item may be used to configure selected logic components in the logic flow diagram of the code to be configured. A configuration operation may be understood as an operation for configuring a logical component in a logic flow diagram of code to be configured. A configured logic component may be understood as a component that results from configuring any logic component in a logic flow diagram of code to be configured.
In the embodiment of the invention, the selected logic component is configured, which can be understood as the configuration of the business flow of the selected logic component. The business process corresponding to the selected logic component may be understood as a business processing method corresponding to the selected logic component. Specifically, the configuration of the selected logic component may be: and configuring the entry parameter, the data type of the entry parameter, the return value and the data type of the return value of the service processing method corresponding to the selected logic component.
Specifically, a selection operation (e.g., a single click operation or a double click operation, etc.) is received that acts on a logic component in the logic flow diagram of the code to be configured. So that the selected logic component in the logic flow diagram of the code to be configured can be determined based on the selection operation. Further, a logical configuration item corresponding to the selected logical component may be determined based on a correspondence between the logical component and the logical configuration item. And further, the logic configuration items corresponding to the selected logic components can be displayed in the logic configuration area.
Illustratively, as shown in FIG. 3, the selected logic component in the logic flow diagram of the code to be configured is the for loop component. The logical configuration items corresponding to the for loop component may include loop-way configuration items ("traversal container" and "custom" in FIG. 3) and loop-condition configuration items. The loop condition configuration items may include an initial condition configuration item (var= "initial value" in fig. 3), a termination condition configuration item, and a step size configuration item.
Specifically, after receiving a configuration operation acting on the logic configuration item, a configured logic component corresponding to the selected logic component may be obtained based on the configuration operation. After the logic components in the code logic flow chart to be configured are configured, the code logic flow chart of the configured logic components can be used as the configured code logic flow chart.
The layout structure of the logic component selection area and the logic configuration area in the visual code editing interface may be set according to actual requirements, and the layout structure is not specifically limited herein, for example, an up-down layout structure, a left-right layout structure, and the like.
S120, generating description codes according to grammar conversion rules and logic configuration identifiers of the configured logic components.
Wherein, grammar conversion rules can be used for embodying grammar corresponding to each logic component. In the embodiment of the invention, each logic component is bound with the corresponding grammar conversion rule in advance. The logic configuration identifier may be a preset logic identifier. The logical configuration identification may be used to distinguish between different preset logical configuration contents. The preset logic configuration content may be understood as preset logic configuration content. The correspondence between the logical configuration identifiers and the preset logical configuration content may be one-to-one. The preset logic configuration content may include a name of a service processing method, an entry parameter, a data type of the entry parameter, a return value, and a data type of the return value. Description code may be understood as pseudo code generated based on the grammar conversion rules and logical configuration identification of the configured logical components. Alternatively, the language describing the code may be a domain specific language (Domain Specific Language, DSL).
In the implementation of the present invention, generating the description code according to the grammar conversion rule and the logic configuration identifier of the configured logic component may include: for a configured code logic flow diagram, determining grammar conversion rules and logic configuration identifications of configured logic components in the configured code logic flow diagram. Furthermore, the description code can be generated according to the configuration logic of the configured logic component in the configured code logic flow chart based on the grammar conversion rule and the logic configuration identification of the configured logic component.
S130, determining target logic configuration content corresponding to the logic identifier.
The target logic configuration content may be understood as preset logic configuration content corresponding to a logic configuration identifier of the configured logic component.
In an embodiment of the present invention, the determining the target logic configuration content corresponding to the logic configuration identifier may include: and determining preset logic configuration content corresponding to the logic configuration identifier based on the corresponding relation between the logic configuration identifier and the preset logic configuration content. Therefore, the preset logic configuration content corresponding to the logic configuration identifier can be used as target logic configuration content.
The corresponding relation between the logic configuration identification and the preset logic configuration content can be preconfigured, and the advantage of the method is that the corresponding relation between the logic configuration identification and the preset logic configuration content can be flexibly adjusted.
Illustratively, the preset logical configuration is identified as $type_234, and the preset logical configuration content corresponding to $type_234 is int. Then, when the logical configuration of the data type of the entry parameter is identified as $type_234, the data type of the entry parameter set in advance is int.
And S140, generating the target code corresponding to the configured code logic flow chart based on the target logic configuration content and the description code.
Where object code may be understood as computer programming code corresponding to a logic flow diagram of configured code.
Specifically, after determining the target logic configuration content corresponding to the logic configuration identifier and obtaining the description code corresponding to the configured code logic flow chart, the description code can be analyzed. Thereby identifying the logical configuration identification in the description code. For each logic configuration identifier in the description code, the logic configuration identifier in the description code may be replaced with target logic configuration content corresponding to the logic configuration identifier. And obtaining the replaced code, and taking the replaced code as the target code corresponding to the configured code logic flow chart.
According to the technical scheme, the visual code editing interface is displayed, wherein the visual code editing interface is provided with the configured code logic flow chart, and the configured code logic flow chart comprises the configured logic component, so that the business processing logic can be edited and adjusted more flexibly; generating description codes according to grammar conversion rules and logic configuration identifiers of the configured logic components; and determining target logic configuration content corresponding to the logic identifier, and generating target codes corresponding to the logic flow chart of the configured codes based on the target logic configuration content and the description codes. The technical scheme of the embodiment of the invention realizes simpler and faster code generation, reduces the development cost of the code and improves the development efficiency of the code.
Example two
Fig. 4 is a flow chart of a code generation method according to a second embodiment of the present invention, on the basis of the foregoing embodiment, optionally, the generating, based on the target logic configuration content and the description code, the target code corresponding to the configured code logic flow chart includes: generating an abstract syntax tree based on the target logic configuration content and the description code; and generating target codes corresponding to the configured code logic flow chart based on the abstract syntax tree. Wherein, the technical terms identical to or corresponding to the above embodiments are not repeated herein.
As shown in fig. 4, the method in this embodiment specifically includes:
s210, displaying a visual code editing interface, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component.
S220, generating description codes according to the grammar conversion rules and the logic configuration identifications of the configured logic components.
S230, determining target logic configuration content corresponding to the logic identifier.
S240, generating an abstract syntax tree based on the target logic configuration content and the description code.
In an embodiment of the present invention, the generating an abstract syntax tree based on the target logic configuration content and the description code may include: analyzing the description code and determining a logic configuration identifier in the description code; replacing the logic configuration identifier with target logic configuration content corresponding to the logic configuration identifier to obtain a replaced code; and carrying out grammar analysis processing on the replaced codes to obtain an abstract grammar tree.
Specifically, after the description code is obtained, the description code may be analyzed. So that the logical configuration identification in the description code can be determined. For each logical configuration identifier in the description code, the logical configuration identifier may be replaced with target logical configuration content corresponding to the logical configuration identifier. After the replacement is completed, a replaced code can be obtained. After the replaced code is obtained, the replaced code may be analyzed to determine a syntax of the replaced code. And further generating an abstract syntax tree based on the syntax of the replaced code.
Optionally, the parsing processing of the replaced code may include: and adopting a grammar analysis engine of a preset grammar recognition tool (such as an Antlr4 grammar recognition tool) to carry out grammar analysis processing on the replaced codes.
S250, generating object codes corresponding to the configured code logic flow chart based on the abstract syntax tree.
Specifically, after the abstract syntax tree is obtained, a tree structure of the abstract syntax tree may be determined. Each node in the abstract syntax tree may then be traversed based on the tree structure of the abstract syntax tree. For traversing in the abstract syntax tree to each node, node description information for the node may be determined. And further, a node code corresponding to the node can be generated based on the node description information. Further, object code corresponding to the configured code logic flow diagram may be generated based on the organization of the program code and the node code.
The node description information may be used to characterize attribute information of a program object (e.g., a field, a class, or a method) to which the node corresponds. Illustratively, the program object corresponding to the node may be a field, and the node description information may include: the attribute modifier of the node is "private", the attribute name is "name", and the attribute type is "java. Node code may be understood as program code corresponding to a node. Along the above example, the program code corresponding to the node is private String name.
In an embodiment of the present invention, in order to generate the object code more accurately, the generating, based on the abstract syntax tree, the object code corresponding to the configured code logic flow chart may include: and generating a structural template and the abstract syntax tree based on preset codes, and generating target codes corresponding to the configured code logic flow chart.
The preset code generation structure template may be understood as a preset structure template for describing the object code to generate the object code. In the embodiment of the invention, the structure of the preset code generation structure template corresponds to the structure of the abstract syntax tree. In other words, the structure of the preset code generation structure template description object code and the structure of the abstract syntax tree description object code may be the same.
Specifically, a code generation structure template is preset. And generating a structural template based on a preset code, and analyzing the abstract syntax tree. Thus, object code corresponding to the configured code logic flow diagram may be generated.
According to the technical scheme, an abstract syntax tree is generated based on the target logic configuration content and the description code; and generating target codes corresponding to the configured code logic flow chart based on the abstract syntax tree, so that the generation of the target codes is realized more accurately.
Example III
Fig. 5 is a schematic structural diagram of a code generating device according to a third embodiment of the present invention. As shown in fig. 5, the apparatus includes: a logic component presentation module 310, a description code generation module 320, and an object code generation module 330. Wherein, the liquid crystal display device comprises a liquid crystal display device,
the logic component display module 310 is configured to display a visual code editing interface, where a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart includes a configured logic component;
a description code generating module 320, configured to generate a description code according to the grammar conversion rule and the logic configuration identifier of the configured logic component;
and the object code generating module 330 is configured to determine object logic configuration content corresponding to the logic identifier, and generate object code corresponding to the configured code logic flow chart based on the object logic configuration content and the description code.
According to the technical scheme, a visual code editing interface is displayed through a logic component display module, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component; generating a description code according to the grammar conversion rule and the logic configuration identifier of the configured logic component through a description code generation module; and determining target logic configuration content corresponding to the logic identifier through a target code generation module, and generating target codes corresponding to the configured code logic flow chart based on the target logic configuration content and the description codes. The technical scheme of the embodiment of the invention realizes simpler and faster code generation, reduces the development cost of the code and improves the development efficiency of the code.
Optionally, the object code generating module 330 includes an abstract syntax tree generating unit and an object code generating unit; wherein, the liquid crystal display device comprises a liquid crystal display device,
an abstract syntax tree generating unit for generating an abstract syntax tree based on the target logic configuration content and the description code;
and the object code generating unit is used for generating object codes corresponding to the configured code logic flow chart based on the abstract syntax tree.
Optionally, the abstract syntax tree generating unit is specifically configured to:
analyzing the description code and determining a logic configuration identifier in the description code;
replacing the logic configuration identifier with target logic configuration content corresponding to the logic configuration identifier to obtain a replaced code;
and carrying out grammar analysis processing on the replaced codes to obtain an abstract grammar tree.
Optionally, the object code generating unit is specifically configured to:
and generating a structural template and the abstract syntax tree based on preset codes, and generating target codes corresponding to the configured code logic flow chart.
Optionally, the visual code editing interface includes a logic component selection area, where the logic component selection area displays a logic component to be dragged; the apparatus also includes a configured code logic flow diagram derivation module to:
Receiving a drag operation aiming at the logic component to be dragged, and obtaining a logic flow chart of a code to be configured based on the logic component to be dragged;
and obtaining a configured code logic flow chart based on the code logic flow chart to be configured.
Optionally, the visual code editing interface includes a logical configuration area; the configured code logic flow diagram obtains the module, specifically for:
receiving a selection operation acting on a logic component in the logic flow chart of the code to be configured, and displaying a logic configuration item corresponding to the selected logic component in the logic configuration area;
receiving configuration operation acting on the logic configuration item to obtain a configured logic component corresponding to the selected logic component;
based on the configured logic component, a configured code logic flow diagram is generated.
Optionally, the object code generating module 330 is configured to determine, based on a correspondence between the logic configuration identifier and preset logic configuration content, the preset logic configuration content corresponding to the logic configuration identifier as the object logic configuration content.
The code generation device provided by the embodiment of the invention can execute the code generation method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
It should be noted that each unit and module included in the code generating apparatus are only divided according to the functional logic, but not limited to the above division, so long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the embodiments of the present invention.
Example IV
Fig. 6 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the respective methods and processes described above, for example, a code generation method.
In some embodiments, the code generation method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the code generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the code generation method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may 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 Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. 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.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, 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: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A code generation method, comprising:
displaying a visual code editing interface, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component;
generating description codes according to grammar conversion rules and logic configuration identifiers of the configured logic components;
and determining target logic configuration content corresponding to the logic identifier, and generating target codes corresponding to the logic flow chart of the configured codes based on the target logic configuration content and the description codes.
2. The method of claim 1, wherein the generating object code corresponding to the configured code logic flow diagram based on the object logic configuration content and the description code comprises:
generating an abstract syntax tree based on the target logic configuration content and the description code;
and generating target codes corresponding to the configured code logic flow chart based on the abstract syntax tree.
3. The method of claim 2, wherein the generating an abstract syntax tree based on the target logical configuration content and the description code comprises:
analyzing the description code and determining a logic configuration identifier in the description code;
replacing the logic configuration identifier with target logic configuration content corresponding to the logic configuration identifier to obtain a replaced code;
and carrying out grammar analysis processing on the replaced codes to obtain an abstract grammar tree.
4. The method of claim 2, wherein generating object code corresponding to the configured code logic flow diagram based on the abstract syntax tree comprises:
and generating a structural template and the abstract syntax tree based on preset codes, and generating target codes corresponding to the configured code logic flow chart.
5. The method of claim 1, wherein the visual code editing interface comprises a logical component selection area that exposes logical components to be dragged; the method further comprises the steps of:
receiving a drag operation aiming at the logic component to be dragged, and obtaining a logic flow chart of a code to be configured based on the logic component to be dragged;
and obtaining a configured code logic flow chart based on the code logic flow chart to be configured.
6. The method of claim 5, wherein the visual code editing interface comprises a logical configuration area; the obtaining a configured code logic flow chart based on the code logic flow chart to be configured comprises the following steps:
receiving a selection operation acting on a logic component in the logic flow chart of the code to be configured, and displaying a logic configuration item corresponding to the selected logic component in the logic configuration area;
receiving configuration operation acting on the logic configuration item to obtain a configured logic component corresponding to the selected logic component;
based on the configured logic component, a configured code logic flow diagram is generated.
7. The method of claim 1, wherein the determining the target logical configuration content corresponding to the logical identification comprises:
And determining preset logic configuration content corresponding to the logic configuration identifier as target logic configuration content based on the corresponding relation between the logic configuration identifier and the preset logic configuration content.
8. A code generating apparatus, comprising:
the logic component display module is used for displaying a visual code editing interface, wherein a configured code logic flow chart is displayed in the visual code editing interface, and the configured code logic flow chart comprises a configured logic component;
the description code generation module is used for generating description codes according to the grammar conversion rules and the logic configuration identifiers of the configured logic components;
and the object code generation module is used for determining object logic configuration content corresponding to the logic identifier and generating object codes corresponding to the configured code logic flow chart based on the object logic configuration content and the description codes.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the code generation method of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the code generation method of any one of claims 1-7 when executed.
CN202310126603.5A 2023-02-16 2023-02-16 Code generation method, device, electronic equipment and storage medium Pending CN116009847A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310126603.5A CN116009847A (en) 2023-02-16 2023-02-16 Code generation method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310126603.5A CN116009847A (en) 2023-02-16 2023-02-16 Code generation method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116009847A true CN116009847A (en) 2023-04-25

Family

ID=86019387

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310126603.5A Pending CN116009847A (en) 2023-02-16 2023-02-16 Code generation method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116009847A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7370315B1 (en) * 2000-11-21 2008-05-06 Microsoft Corporation Visual programming environment providing synchronization between source code and graphical component objects
CN107977236A (en) * 2017-12-21 2018-05-01 上海智臻智能网络科技股份有限公司 Generation method, terminal device, storage medium and the question answering system of question answering system
CN112685036A (en) * 2021-01-13 2021-04-20 北京三快在线科技有限公司 Front-end code generation method and device, computer equipment and storage medium
CN113504908A (en) * 2021-07-19 2021-10-15 中国建设银行股份有限公司 Business code generation method and device, electronic equipment and computer readable medium
CN113918151A (en) * 2021-10-12 2022-01-11 平安国际智慧城市科技股份有限公司 Low-code page development method, device, equipment and storage medium
CN114064040A (en) * 2021-11-30 2022-02-18 上海汇付数据服务有限公司 Terminal code automatic generation method and platform based on visual interface
CN115061674A (en) * 2022-06-16 2022-09-16 平安银行股份有限公司 Business process online arranging method, device and system and readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7370315B1 (en) * 2000-11-21 2008-05-06 Microsoft Corporation Visual programming environment providing synchronization between source code and graphical component objects
CN107977236A (en) * 2017-12-21 2018-05-01 上海智臻智能网络科技股份有限公司 Generation method, terminal device, storage medium and the question answering system of question answering system
CN112685036A (en) * 2021-01-13 2021-04-20 北京三快在线科技有限公司 Front-end code generation method and device, computer equipment and storage medium
CN113504908A (en) * 2021-07-19 2021-10-15 中国建设银行股份有限公司 Business code generation method and device, electronic equipment and computer readable medium
CN113918151A (en) * 2021-10-12 2022-01-11 平安国际智慧城市科技股份有限公司 Low-code page development method, device, equipment and storage medium
CN114064040A (en) * 2021-11-30 2022-02-18 上海汇付数据服务有限公司 Terminal code automatic generation method and platform based on visual interface
CN115061674A (en) * 2022-06-16 2022-09-16 平安银行股份有限公司 Business process online arranging method, device and system and readable storage medium

Similar Documents

Publication Publication Date Title
CN111177231A (en) Report generation method and report generation device
CN115509522A (en) Interface arranging method and system for low-code scene and electronic equipment
CN116451619A (en) Component information processing method, device, medium and equipment
CN115469849B (en) Service processing system, method, electronic equipment and storage medium
CN116303461A (en) Component library creation method and device, electronic equipment and storage medium
CN114168119B (en) Code file editing method, device, electronic equipment and storage medium
CN116126719A (en) Interface testing method and device, electronic equipment and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN113138760B (en) Page generation method and device, electronic equipment and medium
CN112860811B (en) Method and device for determining data blood relationship, electronic equipment and storage medium
CN115329150A (en) Method and device for generating search condition tree, electronic equipment and storage medium
CN116009847A (en) Code generation method, device, electronic equipment and storage medium
CN113691403A (en) Topological node configuration method, related device and computer program product
CN114595231B (en) Database table generation method and device, electronic equipment and storage medium
CN116431698B (en) Data extraction method, device, equipment and storage medium
CN114741072B (en) Page generation method, device, equipment and storage medium
CN117573561B (en) Automatic test system, method, electronic equipment and storage medium
CN115981657A (en) Code generation method and device, electronic equipment and readable medium
CN117234509A (en) Routing management method, device and equipment of front-end page and storage medium
CN117371416A (en) Project document generation method, device, equipment and storage medium
CN117742686A (en) Program source code file generation method and device, electronic equipment and storage medium
CN116450400A (en) Application program abnormality analysis method and device, electronic equipment and storage medium
CN115329999A (en) Operation and maintenance task processing method, device, platform and storage medium
CN117331475A (en) Task creation method, device, equipment and storage medium
CN117931155A (en) Code generation method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination