CN117742686A - Program source code file generation method and device, electronic equipment and storage medium - Google Patents

Program source code file generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117742686A
CN117742686A CN202311609829.7A CN202311609829A CN117742686A CN 117742686 A CN117742686 A CN 117742686A CN 202311609829 A CN202311609829 A CN 202311609829A CN 117742686 A CN117742686 A CN 117742686A
Authority
CN
China
Prior art keywords
component
code
target
annotation
code segment
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
CN202311609829.7A
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.)
Northking Information Technology Co ltd
Original Assignee
Northking Information Technology 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 Northking Information Technology Co ltd filed Critical Northking Information Technology Co ltd
Priority to CN202311609829.7A priority Critical patent/CN117742686A/en
Publication of CN117742686A publication Critical patent/CN117742686A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses a program source code file generation method, a program source code file generation device, electronic equipment and a storage medium. Comprising the following steps: responding to a code generation instruction, acquiring a visual graph, creating an initial code file corresponding to the visual graph, and arranging and combining at least one target component according to a preset sequence to form the visual graph; for each target component, determining a component code segment corresponding to the target component, determining a first annotation and a second annotation corresponding to the component code segment, and generating a target code segment corresponding to the target component based on the component code segment, the first annotation and the second annotation, wherein the component code segment is located between the first annotation and the second annotation; and storing the target code segments corresponding to each target component in the visual graph to the initial code file in a preset sequence to obtain the target code file corresponding to the visual graph, so that the program code with stronger readability can be generated more quickly and effectively, and the code development cost is reduced.

Description

Program source code file generation method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a method and a device for generating a program source code file, electronic equipment and a storage medium.
Background
The existing software project development codes often need a development team to manually write the program codes according to the software development requirements, and the development cost is high. However, different technicians in a development team typically have their own unique coding styles, which make the software project program code less readable, resulting in higher maintenance costs for the code.
Disclosure of Invention
The invention provides a program source code file generation method, a device, electronic equipment and a storage medium, which are used for realizing faster and more effective generation of a program code with stronger readability, facilitating subsequent code maintenance and reducing the development cost of the code.
According to an aspect of the present invention, there is provided a program source code file generation method, the method comprising:
responding to a code generation instruction, acquiring a visual graph corresponding to the code generation instruction, and creating an initial code file corresponding to the visual graph, wherein the visual graph is formed by arranging and combining at least one target component according to a preset sequence;
for each target component in the visualization graph, determining a component code segment corresponding to the target component, determining a first annotation and a second annotation corresponding to the component code segment, and generating a target code segment corresponding to the target component based on the component code segment, the first annotation and the second annotation, wherein the component code segment in the target code segment is located between the first annotation and the second annotation;
and storing the target code segments corresponding to each target component in the visual graph to the initial code file according to the preset sequence to obtain the target code file corresponding to the visual graph.
According to another aspect of the present invention, there is provided a program source code file generating apparatus. The device comprises:
the image acquisition module is used for responding to a code generation instruction, acquiring a visual image corresponding to the code generation instruction, and creating an initial code file corresponding to the visual image, wherein the visual image is formed by arranging and combining at least one target component according to a preset sequence;
a component code segment generation module configured to determine, for each target component in the visualization graph, a component code segment corresponding to the target component, and determine a first annotation and a second annotation corresponding to the component code segment, and generate, based on the component code segment, the first annotation, and the second annotation, a target code segment corresponding to the target component, wherein the component code segment in the target code segment is located between the first annotation and the second annotation;
and the object code file obtaining module is used for storing the object code segments corresponding to each object component in the visual graph to the initial code file according to the preset sequence to obtain the object code file corresponding to the visual graph.
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 memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the program source code file generation method according to any one of the embodiments 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 implement the program source code file generation method according to any of the embodiments of the present invention when executed.
According to the technical scheme, a visualized graph corresponding to a code generation instruction is obtained through responding to the code generation instruction, and an initial code file corresponding to the visualized graph is created, wherein the visualized graph is formed by arranging and combining at least one target component according to a preset sequence; for each target component in the visualization graph, determining a component code segment corresponding to the target component, determining a first annotation and a second annotation corresponding to the component code segment, and generating a target code segment corresponding to the target component based on the component code segment, the first annotation and the second annotation, wherein the component code segment in the target code segment is located between the first annotation and the second annotation; and storing the target code segments corresponding to each target component in the visual graph to the initial code file according to the preset sequence to obtain the target code file corresponding to the visual graph. According to the technical scheme provided by the embodiment of the invention, the existing program code has the technical problems of higher development cost, poorer program readability and higher code maintenance difficulty, so that the program code with higher readability can be generated more quickly and effectively, subsequent code maintenance is facilitated, and the development cost of the code is reduced.
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 flowchart of a method for generating a program source code file according to an embodiment of the present invention;
FIG. 2 is an exemplary diagram of a visualization suitable for use in a method for generating a program source code file according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating an alternative embodiment of a method for generating a program source code file according to a first embodiment of the present invention;
fig. 4 is a schematic structural diagram of a program source code file generating device according to a second embodiment of the present invention;
fig. 5 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 should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, 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 but may include other steps or elements not 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 flowchart of a program source code file generating method according to a first embodiment of the present invention, where the method may be performed by a program source code file generating device, which may be implemented in hardware and/or software, and the program source code file generating device may be configured in an electronic device such as a computer or a server, and the like.
As shown in fig. 1, the method of the present embodiment includes:
s110, responding to a code generation instruction, acquiring a visual graph corresponding to the code generation instruction, and creating an initial code file corresponding to the visual graph, wherein the visual graph is formed by arranging and combining at least one target component according to a preset sequence.
Wherein code generation instructions may be understood as instructions for generating code based on a visual graphic. In the embodiment of the present invention, the visual pattern may be a visual pattern formed by arranging and combining at least one target component according to a preset sequence (see fig. 2). The target component is understood to be the component that constitutes the visual graphic. In an embodiment of the present invention, the target component may include at least one of a base component and a custom component. The base component may be understood as a component for performing general business processes. The base components may include a judgment component, a loop component, a valuation component, and the like. Custom components can be understood as components that are packaged according to specific business needs. Optionally, the target component may include a base python component and/or a custom python component. The number of target components in the visualization may be one, two, or more than two. In practical applications, the number of target components in the visual image is typically plural. The preset sequence can be set according to actual requirements. An initial code file may be understood as a file for storing program code corresponding to the visual graphic. Alternatively, the file format of the initial code file may be Py format.
In an embodiment of the invention, in response to a code generation instruction, obtaining a visual graphic corresponding to the code generation instruction may include: after receiving the code generation instruction, the visual graphic corresponding to the code generation instruction can be acquired from a graphic library for storing visual graphics. A graphic library is understood to be a database or data warehouse created beforehand for storing at least one visualization.
Alternatively, the code generation instructions may include graphical identifications of visual graphics that need to be transcoded. The graphic identification may be used to distinguish between different visualizations. Correspondingly, the visual graphics corresponding to the code generation instruction is obtained from a graphic library for storing the visual graphics, which may specifically be: for each visual graph in the graph library, comparing the graph identifier in the code generation instruction with the graph identifier of the visual graph; if the comparison is consistent, the visual graph can be used as the visual graph corresponding to the code generation instruction; if the comparison is inconsistent, prompt information can be generated to feed back that no visual graph corresponding to the code generation instruction exists.
In the embodiment of the present invention, an initial code file corresponding to the visual graphic is created, which may be specifically
The method can also comprise the step of obtaining the visual graph. Specifically, an editing interface is displayed, wherein the editing interface displays at least one preset component, and the preset component comprises a custom component and/or a basic component; a visual graphic is generated in response to an editing operation for at least one preset component.
The editing interface may be understood as an interface for editing the visual graphic based on a preset component. The editing interface may be presented with at least one preset component. A preset component may be understood as a pre-packaged component for building a visual graphic. The preset components may include custom components and base components. Optionally, the preset components may include a base python component and/or a custom python component. An editing operation may be understood as an operation for selecting at least one preset component, and arranging and combining the selected preset components in a preset order.
S120, determining a component code segment corresponding to each target component in the visual graph, determining a first annotation and a second annotation corresponding to the component code segment, and generating a target code segment corresponding to the target component based on the component code segment, the first annotation and the second annotation, wherein the component code segment in the target code segment is located between the first annotation and the second annotation.
Wherein a component code segment may be understood as a code segment corresponding to a target component. Alternatively, the component code segment may be a python code segment. The number of lines of code in a component code segment may be one, two, or more than two. The first and second annotations may be understood as annotations for explaining the component code segments. Alternatively, the first annotation may be a starting annotation of the component code segment, which may be located above the component code segment; the second annotation may be an ending annotation of the component code segment and may be located below the component code segment. The target code segment corresponding to the target component may be generated based on the component code segment, the first annotation, and the second annotation. In an embodiment of the invention, a component code segment of the object code segments is located between the starting annotation and the ending annotation. In other words, the beginning notes, the component code segments, and the ending notes in the object code segments may be arranged sequentially from top to bottom.
Specifically, for each target component in the visualization graph, a component code segment corresponding to the target component may be determined. After determining the component code segments, a first annotation and a second annotation corresponding to the component code segments may be determined. After determining the first annotation and the second annotation, the first annotation, the component code segment and the second annotation may be sequentially arranged from top to bottom, so as to obtain a target code segment corresponding to the target component.
In order to improve the readability of the code and resolve the code more quickly, in the embodiment of the invention, the first annotation sequentially comprises but is not limited to a first annotation identifier, a component identifier of the target component and component attribute information, and the second annotation sequentially comprises but is not limited to a second annotation identifier and a component identifier of the target component.
The first annotation identifier may be an annotation identifier set according to actual requirements for starting annotation explanation for the target code segment. Component identification may be understood as the name that the target component renders to display on the interface, and may be used to distinguish between different components. It should be noted that the specific expression form of the component identifier may be at least one of a number, a letter, a word, and a symbol. The component attribute information may be understood as attribute information of the component, and may include at least one of a component name, a component display name, and component image data. The storage format of the component attribute information may be JSON (JavaScript Object Notation, JS object profile) format. In the embodiment of the invention, the attribute information of the components is stored in the JSON format, which is convenient for reading, writing and code maintenance. The second annotation identifier may be understood as an annotation identifier for ending annotation description of the target code segment, which is set according to actual requirements.
Illustratively, the first annotation may be Activity_search { { NameID: loop component { Desc }: traversing the file { Img }: find button image }. The second annotation may be an endof_search. Wherein Activity _ may be identified for characterizing the first annotation. The Search may be identified for the characterization component. The NameID may be a component name in the characterization component attribute information. Descke may display names for components in the characterizing component attribute information. Img may be component image data in the characterizing component attribute information. The component image data may be an image screenshot of the component rendered on the interface. endof_can be characterized as a second annotation identifier.
In an embodiment of the present invention, the determining a component code segment corresponding to the target component may include: and matching the preset component matched with the target component from a preset component library, and further determining the component code section of the target component based on the corresponding relation between the preset component and the component code section. The preset component library is understood to be a component library which is preset and is used for storing python components. The preset component may be a python component in a preset component library. The correspondence between the preset components and the component code segments may be one-to-one.
Specifically, for each preset component in the preset component library, a component identifier of the preset component may be determined. Comparing the component identification of the preset component with the component identification of the target component; and if the comparison is consistent, determining the preset component as the preset component matched with the target component. And then, based on the corresponding relation between the preset component and the component code segment, the component code segment corresponding to the preset component matched with the target component can be used as the component code segment of the target component.
In an embodiment of the present invention, the determining the first annotation and the second annotation corresponding to the component code segment may include: acquiring a component identifier and component attribute information of the target component; generating a first annotation corresponding to the component code segment according to a first preset annotation format based on the component identification and the component attribute information; and generating a second annotation corresponding to the component code segment according to a second preset annotation format based on the component identification and the component attribute information. The first preset annotation format may be understood as a predefined format for generating the first annotation. The second preset annotation format may understand a predefined format for generating the second annotation.
On the basis of the above embodiment, the method may further include: generating a calling statement for calling the component code segment of the target component based on the component identifier of the target component, the component attribute information and a predefined template statement for calling the component code segment; and adding the calling statement in the component code segment.
A template statement may be understood, among other things, as a predefined statement for invoking a component code segment. The call statement may be a statement generated based on the component attribute information of the target component and the template statement. A call statement may be used to call a component code segment of the target component. In an embodiment of the present invention, the call statement may include an import statement keyword and a call function. The term "keyword of an import sentence" is understood to mean a keyword used for an import sentence. Illustratively, the import statement keyword may be importer. A calling function may be understood as a predefined function for calling a component code segment of a target component. The purpose of adding the call statement in the component code segment is to: the calling statement is included in the component code segment to facilitate the calling of the component code segment and the multiplexing of the subsequent component code segment.
Illustratively, the template statements may specifically be the following code segments:
from component library import component name
Activity_uuid=component name (attribute name=attribute value)
Activity_uuid.run()
Wherein uuid may be characterized as a component identification of the target component.
In the embodiment of the invention, a call statement for calling the component code section of the target component is generated based on the component identifier of the target component, the component attribute information and the predefined template statement for calling the component code section, specifically, the component identifier of the target component and the component attribute information of the target component are assigned to corresponding fields in the predefined template statement for calling the component code section. After the assignment is completed, a call statement may be obtained for invoking the component code segment of the target component.
And S130, storing the target code segments corresponding to each target component in the visual graph to the initial code file according to the preset sequence to obtain the target code file corresponding to the visual graph.
The object code file may be understood as a program source code file generated after converting the visual graphic into a code.
Specifically, after the target code segments corresponding to each target component in the visual graph are obtained, the target code segments corresponding to each target component in the visual graph can be sequentially added to the initial code file according to the preset sequence of each target component combination in the visual graph. Thereby, the object code file corresponding to the visual graph can be obtained.
In an embodiment of the present invention, the initial code file may define a main function. The main function is defined in the initial code file in order to facilitate flexible invocation and definition of the component code segments in said initial code file. Based on this, the storing, in the predetermined order, the object code segment corresponding to each object component in the visual graph to the initial code file may include: and adding the target code segments corresponding to each target component in the visual graph into the function body of the main function according to the preset sequence. That is, the functional body of the main function defines an object code segment corresponding to each object component in the visual graphic.
On the basis of the above embodiment, the method may further include: and determining the end of the target code file, and adding a predefined main function call statement to the end of the file, so that the readability of codes in the target code file is improved. By way of example, the predefined main function call statement may be specifically the following code:
If__name__==’main’:
main()
wherein main () is the main function.
On the basis of the above embodiment, the method may further include: and analyzing the target code file through a preset component renderer to determine a target component defined in the target code file. And may in turn generate a visual interface based on the target component. The preset component renderer can be understood as a predefined renderer for rendering the component, and can be used for positioning the component code segments corresponding to the first annotation and the second annotation according to the first annotation and the second annotation in the object code file, so as to render the object component corresponding to the component code segments.
Referring to FIG. 3, after editing the visualization component logical canvas, a canvas, i.e., a visual graphic, may be obtained. After the canvas is obtained, the canvas may be input into the transcoder to cause the transcoder to generate a python file, i.e., an object code file, based on the canvas. Based on this, after the python file is generated, the python file may be parsed using the component renderer. And by identifying each set of annotations in the python file, locating the component code segments corresponding to each set of annotations. Further, components corresponding to each component code segment may be determined and a canvas generated to cause visualization components combined in a preset order to be displayed in the canvas.
According to the technical scheme, a visualized graph corresponding to a code generation instruction is obtained through responding to the code generation instruction, and an initial code file corresponding to the visualized graph is created, wherein the visualized graph is formed by arranging and combining at least one target component according to a preset sequence; for each target component in the visualization graph, determining a component code segment corresponding to the target component, determining a first annotation and a second annotation corresponding to the component code segment, and generating a target code segment corresponding to the target component based on the component code segment, the first annotation and the second annotation, wherein the component code segment in the target code segment is located between the first annotation and the second annotation; and storing the target code segments corresponding to each target component in the visual graph to the initial code file according to the preset sequence to obtain the target code file corresponding to the visual graph. According to the technical scheme provided by the embodiment of the invention, the existing program code has the technical problems of higher development cost, poorer program readability and higher code maintenance difficulty, so that the program code with higher readability can be generated more quickly and effectively, subsequent code maintenance is facilitated, and the development cost of the code is reduced.
Example two
Fig. 4 is a schematic structural diagram of a program source code file generating device according to a second embodiment of the present invention. As shown in fig. 4, the apparatus includes: a graphics acquisition module 210, a component code segment generation module 220, and an object code file retrieval module 230.
The graphic acquisition module 210 is configured to respond to a code generation instruction, acquire a visual graphic corresponding to the code generation instruction, and create an initial code file corresponding to the visual graphic, where the visual graphic is formed by arranging and combining at least one target component according to a preset sequence; a component code segment generation module 220 configured to determine, for each target component in the visual graph, a component code segment corresponding to the target component, and determine a first annotation and a second annotation corresponding to the component code segment, and generate, based on the component code segment, the first annotation, and the second annotation, a target code segment corresponding to the target component, wherein the component code segment in the target code segment is located between the first annotation and the second annotation; and an object code file obtaining module 230, configured to store, in the predetermined order, the object code segments corresponding to each object component in the visual graph to the initial code file, thereby obtaining an object code file corresponding to the visual graph.
According to the technical scheme, a graphic acquisition module is used for responding to a code generation instruction, acquiring a visual graphic corresponding to the code generation instruction and creating an initial code file corresponding to the visual graphic, wherein the visual graphic is formed by arranging and combining at least one target component according to a preset sequence; a component code segment generation module, configured to determine, for each target component in the visual graph, a component code segment corresponding to the target component, and determine a first annotation and a second annotation corresponding to the component code segment, and generate, based on the component code segment, the first annotation, and the second annotation, a target code segment corresponding to the target component, where the component code segment in the target code segment is located between the first annotation and the second annotation; and storing the target code segments corresponding to each target component in the visual graph to the initial code file according to the preset sequence by a target code file obtaining module to obtain a target code file corresponding to the visual graph. According to the technical scheme provided by the embodiment of the invention, the existing program code has the technical problems of higher development cost, poorer program readability and higher code maintenance difficulty, so that the program code with higher readability can be generated more quickly and effectively, subsequent code maintenance is facilitated, and the development cost of the code is reduced.
Optionally, the first annotation sequentially includes, but is not limited to, a first annotation identification, a component identification of the target component, and component attribute information, and the second annotation sequentially includes, but is not limited to, a second annotation identification and a component identification of the target component.
Optionally, the component code segment generating module 220 is configured to match a preset component matched with the target component from a preset component library, and determine a component code segment of the target component based on a correspondence between the preset component and the component code segment.
Optionally, the device further includes a first call statement adding module, where the first call statement adding module is configured to generate a call statement for calling a component code section of the target component based on the component identifier of the target component, component attribute information, and a predefined template statement for calling the component code section; adding the call statement in the component code segment; the calling statement comprises an imported statement keyword and a calling function.
Optionally, the initial code file defines a main function; and the object code file obtaining module 230 is configured to add the object code segments corresponding to each object component in the visual graph to the function body of the main function according to the preset sequence.
Optionally, the device further comprises a second call statement adding module, wherein the second call statement adding module is used for determining the end of the file of the target code file and adding a predefined main function call statement to the end of the file.
Optionally, the device further comprises a graphic generation module for displaying an editing interface, wherein the editing interface displays at least one preset component, and the preset component comprises a custom component and/or a basic component; a visual graphic is generated in response to an editing operation for at least one preset component.
The program source code file generating device provided by the embodiment of the invention can execute the program source code file generating method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
It should be noted that, each unit and module included in the program source code file 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 III
Fig. 5 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. 5, 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 various methods and processes described above, such as the program source code file generation method.
In some embodiments, the program source code file 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 a computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the program source code file generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the program source code file 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 program source code file generation method, comprising:
responding to a code generation instruction, acquiring a visual graph corresponding to the code generation instruction, and creating an initial code file corresponding to the visual graph, wherein the visual graph is formed by arranging and combining at least one target component according to a preset sequence;
for each target component in the visualization graph, determining a component code segment corresponding to the target component, determining a first annotation and a second annotation corresponding to the component code segment, and generating a target code segment corresponding to the target component based on the component code segment, the first annotation and the second annotation, wherein the component code segment in the target code segment is located between the first annotation and the second annotation;
and storing the target code segments corresponding to each target component in the visual graph to the initial code file according to the preset sequence to obtain the target code file corresponding to the visual graph.
2. The method of claim 1, wherein the first annotation comprises, but is not limited to, a first annotation identification, a component identification of the target component, and component attribute information, and the second annotation comprises, but is not limited to, a second annotation identification and a component identification of the target component.
3. The method of claim 1, wherein the determining a component code segment corresponding to the target component comprises:
and matching the preset component matched with the target component from a preset component library, and determining the component code section of the target component based on the corresponding relation between the preset component and the component code section.
4. The method according to claim 1, wherein the method further comprises:
generating a calling statement for calling the component code segment of the target component based on the component identifier of the target component, the component attribute information and a predefined template statement for calling the component code segment;
adding the call statement in the component code segment; the calling statement comprises an imported statement keyword and a calling function.
5. The method of claim 1, wherein the initial code file defines a master function; storing the target code segments corresponding to each target component in the visual graph to the initial code file according to the preset sequence, wherein the target code segments comprise:
and adding the target code segments corresponding to each target component in the visual graph into the function body of the main function according to the preset sequence.
6. The method of claim 5, wherein the method further comprises:
determining the end of the target code file, and adding a predefined main function call statement to the end of the file.
7. The method according to claim 1, wherein the method further comprises:
displaying an editing interface, wherein the editing interface displays at least one preset component, and the preset component comprises a custom component and/or a basic component;
a visual graphic is generated in response to an editing operation for at least one preset component.
8. A program source code file generation apparatus, comprising:
the image acquisition module is used for responding to a code generation instruction, acquiring a visual image corresponding to the code generation instruction, and creating an initial code file corresponding to the visual image, wherein the visual image is formed by arranging and combining at least one target component according to a preset sequence;
a component code segment generation module configured to determine, for each target component in the visualization graph, a component code segment corresponding to the target component, and determine a first annotation and a second annotation corresponding to the component code segment, and generate, based on the component code segment, the first annotation, and the second annotation, a target code segment corresponding to the target component, wherein the component code segment in the target code segment is located between the first annotation and the second annotation;
and the object code file obtaining module is used for storing the object code segments corresponding to each object component in the visual graph to the initial code file according to the preset sequence to obtain the object code file corresponding to the visual graph.
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 memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the program source code file 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 program source code file generation method of any one of claims 1-7 when executed.
CN202311609829.7A 2023-11-29 2023-11-29 Program source code file generation method and device, electronic equipment and storage medium Pending CN117742686A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311609829.7A CN117742686A (en) 2023-11-29 2023-11-29 Program source code file generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311609829.7A CN117742686A (en) 2023-11-29 2023-11-29 Program source code file generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117742686A true CN117742686A (en) 2024-03-22

Family

ID=90278324

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311609829.7A Pending CN117742686A (en) 2023-11-29 2023-11-29 Program source code file generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117742686A (en)

Similar Documents

Publication Publication Date Title
CN113342345A (en) Operator fusion method and device of deep learning framework
CN114445047A (en) Workflow generation method and device, electronic equipment and storage medium
CN112784588B (en) Method, device, equipment and storage medium for labeling text
CN116302218B (en) Function information adding method, device, equipment and storage medium
CN115905322A (en) Service processing method and device, electronic equipment and storage medium
CN115454971A (en) Data migration method and device, electronic equipment and storage medium
CN117742686A (en) Program source code file generation method and device, electronic equipment and storage medium
CN113961672A (en) Information labeling method and device, electronic equipment and storage medium
CN113138760A (en) Page generation method and device, electronic equipment and medium
CN113342413B (en) Method, apparatus, device, medium, and article for processing components
CN117271840B (en) Data query method and device of graph database and electronic equipment
CN117270838B (en) Method, device, equipment and medium for generating universal formula script
CN115965018B (en) Training method of information generation model, information generation method and device
CN113254826B (en) Dump file processing method and device
US20230316604A1 (en) Reuse of infographics
CN118133794A (en) Table configuration method, apparatus, device and storage medium
CN115525295A (en) Automatic code editing method and device, electronic equipment and storage medium
CN114818617A (en) Document generation method, device, equipment, medium and product
CN116225943A (en) Interactive interface testing method and device, electronic equipment and storage medium
CN117216066A (en) Material code generation method, device, equipment and storage medium
CN115981657A (en) Code generation method and device, electronic equipment and readable medium
CN117668833A (en) Abnormal operation identification method, device, electronic equipment and storage medium
CN114861111A (en) Webpage configuration method and device
CN115858891A (en) Visual display method and device of data, electronic equipment and storage medium
CN117931195A (en) Data dictionary processing method and device, electronic equipment and storage 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