CN116974545A - Programming building block generation method and device, electronic equipment and readable storage medium - Google Patents

Programming building block generation method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN116974545A
CN116974545A CN202310274570.9A CN202310274570A CN116974545A CN 116974545 A CN116974545 A CN 116974545A CN 202310274570 A CN202310274570 A CN 202310274570A CN 116974545 A CN116974545 A CN 116974545A
Authority
CN
China
Prior art keywords
interface
target
programming
type
building block
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
CN202310274570.9A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202310274570.9A priority Critical patent/CN116974545A/en
Publication of CN116974545A publication Critical patent/CN116974545A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/253Grammatical analysis; Style critique
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a method and a device for generating programming building blocks, electronic equipment and a computer readable storage medium, and relates to the field of graphical programming. The method comprises the following steps: and constructing a target abstract syntax tree corresponding to the target code information, converting each node into corresponding field information based on building block conversion rules, filling each field information into a template configuration file corresponding to the field information in a plurality of template configuration files, and inputting all template configuration files corresponding to the field information filled with each node into a preset graphical programming tool to obtain the target programming building blocks corresponding to the interfaces to be processed. The embodiment of the application displays the object code information in a tree structure, can accurately mine the code structure and logic in the object code information, does not need a technician to analyze the processing logic of each interface to be processed one by one, and reduces the time consumed by the technician in interface analysis and conversion.

Description

Programming building block generation method and device, electronic equipment and readable storage medium
Technical Field
The application relates to the technical field of graphical programming, in particular to a method and a device for generating programming building blocks, electronic equipment and a computer readable storage medium.
Background
In recent years, with rapid development of computer technology, attention is paid to programming education, and graphical programming tools for programming beginners are increasingly used by users. The graphical programming tool packages the Javascript interface in the graphical programming building blocks, and a user can complete programming by building the programming building blocks; such graphical programming tools generally have the advantages of simple operating environment, high standardization level, easy sharing and propagation, and the like.
The target programming blocks in the existing graphical programming tools are generated through manual conversion modes, and the manual conversion modes are two. Firstly, technicians manually analyze each Javascript interface (analyzing the function, the type and the like of the interface), manually edit each configuration item and code of the programming building block corresponding to each Javascript interface based on analysis results, and obtain each target programming building block; and the other is to drag the basic programming building blocks provided by the google based on the analysis result, and combine and define the basic building blocks to obtain the target programming building blocks corresponding to each Javascript interface.
The Javascript interface is provided by a basic programming library, and as the basic programming library accessed by the graphical programming tool is more and more, the more interfaces need to be converted, a great deal of human resources can be consumed by a manual conversion mode. In addition, in some cases, in order to improve the development efficiency, in the process of generating the target programming building blocks, developers often use copying, pasting, and other means, and these means easily cause some parameters to be unmodified, so that many unexpected errors are caused, and it is difficult to locate the unexpected errors. Therefore, the target programming building blocks corresponding to the Javascript interface are generated in a manual conversion mode, so that time and resource are consumed, and mistakes are easy to occur.
Disclosure of Invention
The embodiment of the application provides a method, a device, electronic equipment, a computer readable storage medium and a computer program product for generating programming building blocks, which can solve the problems in the background technology. The technical scheme is as follows:
according to a first aspect of an embodiment of the present application, there is provided a method of generating a programming building block for indicating an interface function required for graphical programming, the method comprising: acquiring target code information containing code information of an interface to be processed;
performing word segmentation on the object code information, and determining the interface function type of the interface to be processed and a target abstract syntax tree according to a word segmentation result; the non-root node of the target abstract syntax tree represents one word in the word segmentation result and the attribute of the word in the target code information;
determining building block conversion rules of an interface to be processed and a plurality of template configuration files according to the interface function type; the building block conversion rule is used for indicating field information corresponding to each node in the target abstract tree;
traversing the target abstract syntax tree, converting the nodes into corresponding field information based on building block conversion rules for each node in the abstract syntax tree, and filling the field information into a template configuration file corresponding to the field information in a plurality of template configuration files;
And inputting all template configuration files which are filled with field information corresponding to each node into a preset graphical programming tool to obtain target programming building blocks corresponding to the interfaces to be processed, wherein the target programming building blocks are related to interface functions of the interfaces to be processed.
According to a second aspect of an embodiment of the present application, there is provided a device for generating a programming building block for indicating an interface function required for graphical programming, the device comprising:
the target code information acquisition module is used for acquiring target code information containing code information of an interface to be processed;
the processing module is used for word segmentation of the target code information and determining the interface function type of the interface to be processed and a target abstract syntax tree according to the word segmentation result; the non-root node of the target abstract syntax tree represents one word in the word segmentation result and the attribute of the word in the target code information;
the determining module is used for determining building block conversion rules of the interface to be processed and a plurality of template configuration files according to the interface function type; the building block conversion rule is used for indicating field information corresponding to each node in the target abstract tree;
the conversion module is used for traversing the abstract syntax tree, converting the nodes into corresponding field information based on building block conversion rules for each node in the abstract syntax tree, and filling the field information into a template configuration file corresponding to the node in the plurality of template configuration files;
The target programming building block generating module is used for inputting all template configuration files corresponding to the field information corresponding to each node into a preset graphical programming tool to obtain target programming building blocks corresponding to the interfaces to be processed, wherein the target programming building blocks are related to interface functions of the interfaces to be processed.
In one possible implementation, the word segmentation result includes at least one word segment and a data type for each word segment; the processing module comprises:
the grammar analysis sub-module is used for carrying out grammar analysis processing on all the segmented words according to the data type of each segmented word to obtain a grammar analysis result; the grammar analysis result comprises the interface function type and the attribute of each word in the object code information;
the node determining submodule is used for regarding each word, taking the word and the attribute of the word in the object code information as a non-root node of the candidate abstract syntax tree, and the root node of the candidate abstract syntax tree represents the interface function type;
the target abstract syntax obtaining sub-module is used for deleting redundant information from the candidate abstract syntax tree to obtain a target abstract syntax tree.
In one possible implementation, the attribute includes a sentence type of a sentence in which the segmentation is located;
The redundant information includes at least one of:
representing nodes of punctuation marks;
the word segmentation in the leaf node is in the sentence type of the sentence.
In one possible implementation manner, the code information of the interface to be processed includes annotation information, and the annotation information includes interface types;
the object code information acquisition module includes:
the building block type determining submodule is used for determining the building block type of the target programming building block corresponding to the interface to be processed according to the interface type, and the building block type is the same as the interface type of the interface to be processed;
the target color determining sub-module is used for obtaining target colors corresponding to target programming building blocks according to the pre-established association relation between the types and colors of the building blocks, and combining the target colors serving as annotation information to code information of an interface to be processed to obtain target code information.
In one possible implementation, the apparatus further includes:
the building block display module is used for displaying the target programming building blocks and the building block types of the target programming building blocks in a menu bar of the graphical programming tool, wherein the interface functions of the interfaces to be processed are displayed in the target programming building blocks, and the colors of the target programming building blocks are target colors.
In one possible implementation, the annotation information further includes an interface function description;
the apparatus further comprises:
and the building block prompt information display module is used for responding to the target programming building blocks of which the cursors move to the menu bar, displaying building block prompt information of the target programming building blocks above the target programming building blocks, wherein the building block prompt information is an interface function description in the annotation information.
In one possible implementation manner, the interface function type is any one of a function call type, a variable acquisition type, an expression judgment type and a function statement type; the programming building blocks corresponding to the function statement types and the programming building blocks corresponding to the function call types are in nested relation; the shapes of the programming building blocks corresponding to any two function call types are in a nested relation; the shapes of the programming building blocks corresponding to any two function statement types are in nested relation; the shape of the programming building block corresponding to the function call type and the shape of the programming building block corresponding to the variable acquisition type have an upper-lower layer relationship on the image layer; the shapes of the programming building blocks corresponding to the expression judgment type and the programming building blocks corresponding to the function statement type have an upper-lower layer relationship on the image layer.
According to a third aspect of embodiments of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory, the processor implementing the steps of the method as provided in the first aspect when the program is executed.
According to a fourth aspect of embodiments of the present application, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method as provided by the first aspect.
According to a fifth aspect of embodiments of the present application, there is provided a computer program product comprising computer instructions stored in a computer readable storage medium, which when read from the computer readable storage medium by a processor of a computer device, the computer instructions are executed by the processor causing the computer device to perform the steps of the method as provided by the first aspect.
The technical scheme provided by the embodiment of the application has the beneficial effects that: according to the method, the device and the system, the interface information of the interface to be processed is included in the target code information, the target abstract syntax tree corresponding to the target code information is constructed, the target abstract syntax tree is traversed, the target code information is displayed in a tree structure, the code structure and logic in the target code information can be accurately and comprehensively mined, in the traversing process of the target abstract syntax tree, each node can be converted into corresponding field information based on building block conversion rules, each field information is filled into a template configuration file corresponding to the field information in a plurality of template configuration files, all template configuration files corresponding to the field information corresponding to each node are input into a preset graphical programming tool, the target programming building blocks corresponding to the interface to be processed can be obtained, the whole process can be automatically processed through a program, on one hand, copying and pasting operations are reduced, unintended omission and error problems of research personnel are avoided, on the other hand, a technician is not required to analyze the processing logic of each interface to be processed one by one, the time consumed by the interface analysis and conversion of the technician is reduced, and the program development efficiency can be accelerated.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings that are required to be used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic diagram of a system architecture for implementing a method for generating programming building blocks according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for generating a programming building block according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a structure for graphically exposing a target abstract syntax tree according to an embodiment of the present application;
fig. 4 is a schematic diagram of a target programming building block corresponding to an interface C provided in an embodiment of the present application;
FIG. 5 is a schematic diagram of a target programming building block with interface C shown in a menu bar of a graphical editing tool according to an embodiment of the present application;
fig. 6 is a schematic diagram of building block prompt information displayed when a cursor moves to a target programming building block corresponding to an interface C according to an embodiment of the present application;
FIG. 7 is a schematic diagram of the shapes of the programming blocks corresponding to the function call type, the variable acquisition type, the expression judgment type and the function declaration type according to the embodiment of the present application;
FIG. 8a is a schematic diagram of a shape obtained by nesting the shapes of a programming building block corresponding to a function declaration type and a programming building block corresponding to a function call type according to an embodiment of the present application;
FIG. 8b is a schematic diagram of a shape of a program building block according to an embodiment of the present application after nesting the shapes of two function call types;
FIG. 8c is a schematic diagram of a shape of a program building block of two function declaration types nested according to an embodiment of the present application;
FIG. 8d is a schematic diagram of a shape obtained by superposing the shapes of the programming blocks corresponding to the function call type and the variable acquisition type on a layer according to the embodiment of the present application;
FIG. 8e is a schematic diagram of a shape obtained by superposing the shape of a programming building block corresponding to a function declaration type and the shape of a programming building block corresponding to an expression judgment type on a layer according to an embodiment of the present application;
FIG. 9 is an interface diagram of a game developed from a programming block generated in a graphical programming tool based on the present solution according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of a device for generating programming building blocks according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below with reference to the drawings in the present application. It should be understood that the embodiments described below with reference to the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and the technical solutions of the embodiments of the present application are not limited.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and "comprising," when used in this specification, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, all of which may be included in the present specification. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates that at least one of the items defined by the term, e.g., "a and/or B" may be implemented as "a", or as "B", or as "a and B".
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
First, several terms related to the present application are described and explained:
graphical programming, namely visual programming or visual programming, refers to the design of an interface by an intuitive operation mode, a programmer can utilize various controls provided by software per se to construct various interfaces of an application program like building blocks, the programmer can complete the design of the application program without writing codes or only by writing a small amount of program codes, and the development efficiency of the designer can be greatly improved. The visual programming is based on the idea of object-oriented, introduces the concept of class and event drive, and in the visual programming process, firstly draws the interface, and then writes the program code based on the event to respond to various actions of the mouse and the keyboard, thereby realizing the interface design.
An abstract Syntax tree (AbstractSyntaxTree, AST), or simply Syntax tree (syncax tree), is an abstract representation of the source code Syntax structure. It represents the syntax structure of a programming language in the form of a tree, each node on the tree representing a structure in the source code.
In recent years, with rapid development of computer technology, attention is paid to programming education, and graphical programming tools for programming beginners are increasingly used by users. The graphical programming tool packages the Javascript interface in the graphical programming building blocks, and a user can complete programming by building the programming building blocks; such graphical programming tools generally have the advantages of simple operating environment, high standardization level, easy sharing and propagation, and the like.
The programming blocks in the existing graphical programming tools are generated through manual conversion modes, and the manual conversion modes are two. The first is that a technician manually analyzes each Javascript interface (analyzes the function, the type and the like of the interface), manually edits each configuration item and code of the programming building block corresponding to each Javascript interface based on the analysis result, and obtains the programming building block corresponding to each Javascript interface; and the other is to drag basic programming building blocks provided by google based on analysis results, and combine and define the basic building blocks to obtain programming building blocks corresponding to each Javascript interface.
The Javascript interface is provided by a basic programming library, and as the basic programming library accessed by the graphical programming tool is more and more, the more interfaces need to be converted, a great deal of human resources can be consumed by a manual conversion mode. In addition, in some cases, in order to improve the development efficiency, in the process of generating the target programming building blocks, developers often use copying, pasting, and other means, and these means easily cause some parameters to be unmodified, so that many unexpected errors are caused, and it is difficult to locate the unexpected errors. Therefore, the target programming building blocks corresponding to the Javascript interface are generated in a manual conversion mode, so that time and resource are consumed, and mistakes are easy to occur.
The application provides a method, a device, electronic equipment, a computer readable storage medium and a computer program product for generating programming building blocks, and aims to solve the technical problems in the prior art.
The technical solutions of the embodiments of the present application and technical effects produced by the technical solutions of the present application are described below by describing several exemplary embodiments. It should be noted that the following embodiments may be referred to, or combined with each other, and the description will not be repeated for the same terms, similar features, similar implementation steps, and the like in different embodiments.
Fig. 1 is a schematic diagram of a system architecture for implementing a method for generating programming building blocks according to an embodiment of the present application, where the system architecture includes a first terminal 110, a server 120, and a second terminal 130. The first terminal may access the programming library, obtain code information of each interface to be processed in the programming library, generate, for each interface to be processed, a plurality of configuration files of corresponding programming building blocks based on the code information of the interface to be processed, and send the plurality of configuration files to the server 120. The server 120 may receive a plurality of configuration files generated based on the code information of each interface to be processed and sent by the first terminal 110, and input the plurality of configuration files of each interface to be processed into a preset graphical programming tool to obtain an updated graphical programming tool, where the updated graphical programming tool includes programming blocks corresponding to the interfaces to be processed, the server 120 issues the updated graphical programming tool to the second terminal 130, the second terminal 130 installs the updated graphical programming tool for a user to use, and the user may drag the programming blocks corresponding to the interfaces to be processed in the updated graphical programming tool to perform graphical programming.
The first terminal 110 and the second terminal 120 may be personal computers, tablets, mobile phones, etc., and the number of the first terminal 110 and the second terminal 120 may be greater or less. For example, the first terminal 110 may be only one, and the second terminal 120 may be several tens or hundreds, or more. The number and the equipment types of the first terminal and the second terminal are not limited in the embodiment of the application. The embodiment of the application mainly uses the application scene of a single terminal for explanation.
The first terminal 110 is connected to the server 120 through a wireless network or a wired network, and the second terminal 130 may be connected to the server 120 through a wireless network or a wired network as well.
The server 120 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server or a server cluster for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs (Content Delivery Network, content delivery networks), basic cloud computing services such as big data and artificial intelligence platforms, and the like.
The embodiment of the present application provides a method for generating a programming building block, which may be executed by the first terminal 110, where the programming building block is used to indicate an interface function required for graphical programming, as shown in fig. 2, and the method includes:
Step S201, acquiring target code information including code information of an interface to be processed.
The embodiment of the application aims to generate a programming building block which corresponds to a to-be-processed interface and is applied to graphical programming, wherein the programming building block is a movable operation control in nature, the appearance of the programming building block is displayed as the graphical building block, in the graphical programming, a user can realize programming by dragging the programming building block, modifying parameter values of functions in the programming building block and the like, the whole programming process is object-oriented, namely the to-be-processed interface belongs to an object-oriented interface, for example, the to-be-processed interface can be a Javascript interface (a subsequent to-be-processed interface is explained by taking the Javascript interface as an example), and an object-oriented programming library can provide the to-be-processed interface, for example, the object-oriented programming library can be a p5.Js programming library.
According to the embodiment of the application, the Javascript interfaces and the programming building blocks are in one-to-one correspondence, one Javascript interface can generate one programming building block, and the generated programming building block is provided with the interface function of the Javascript interface and the default parameters of the interface function.
The object code information comprises code information of an interface to be processed and colors of object programming building blocks corresponding to the interface to be processed; the color of the target programming building block is recorded in the form of code annotation in the target code information.
The code information of the interface to be processed in the embodiment of the application comprises source codes and annotation information corresponding to the interface to be processed, wherein the annotation information comprises interface types and interface function descriptions.
The source code may be a code compiled based on javascript, and includes processing logic of a corresponding interface to be processed, where the source code includes a function corresponding to the interface to be processed, for example, a function corresponding to the canvas interface is created as a createCanvas function.
The interface types are divided based on interface functions, and are used for representing the types to which the interface belongs, such as creating a canvas interface and creating a table interface, which belong to drawing types, and can be divided into drawing types, shape types, operation types, environment types, text types, function types, 3D types and the like. In the graphical programming tool, the building block type and the interface type are the same, the interface type is drawing, and then the building block type is drawing. In the graphical programming tool, a plurality of building block categories are contained in the building block menu bar, and each building block category contains at least one programming building block, namely the programming building blocks belong to the building block category.
The interface function description is a statement characterized in natural language that indicates the function of the interface, for example, the interface function description of interface a is "rotate about the x-axis" that indicates the role of the interface is rotate about the x-axis, and the interface function description of interface C is "create canvas element in document and set its size" that indicates the role of the interface is to create canvas element in document and set its corresponding size. After the programming blocks are generated based on the interfaces, the interface function description is converted into prompt information of the programming blocks, and a user can determine the function of the programming blocks based on the prompt information.
The object code information in the embodiment of the application can be recorded according to the format of the code line, wherein the source code of the interface to be processed accords with the compiling rule, the type of the interface, the description of the function of the interface and the color of the programming building block are used as annotation information, for example, the object code information comprising the code information of the interface C is: "
/(and drawing)
//rgb(91,139,248);
Creation of canvas elements in a document and sizing thereof
creatCanvas(W=300,H=300,renderer=P2D)”
Wherein, "drawing" is an interface type, "creating canvas elements and setting the size thereof as interface function descriptions" in a document, "rgb (91,139,248)" is the color of the programming building block, the interface type, the color of the programming building block and the interface function descriptions are recorded by annotation information, "creatCanvas (w=300, h=300, renderer=p2d)" is the source code of the interface.
Step S202, word segmentation is carried out on object code information, and the interface function type of an interface to be processed and a target abstract syntax tree are determined according to word segmentation results; the non-root node of the target abstract syntax tree characterizes a word segment in the word segment result and the attribute of the word segment in the target code information.
The embodiment of the application generates programming building blocks based on target code information, carries out lexical analysis on the target code information after the target code information is obtained, so as to segment the target code information to obtain a word segmentation result, wherein the word segmentation result comprises at least one word segmentation, and specifically, the code information can be segmented based on a preset rule, and the preset rule comprises: for a code line containing "//", taking the "//", and contents after "//", in the code line, as a word segmentation (the contents after "/" areannotation parts and can be used as a word segmentation), and segmenting the contents before "/", in the code line, based on characters, numbers, character strings, identifiers, punctuation marks and operation symbols; for code lines that do not contain "//", word segmentation is directly based on text, numbers, punctuation, and arithmetic symbols.
It will be appreciated that for line annotation or block annotation in javascript code, the computer may determine that "///" is followed by annotation and does not focus on annotation content, so that content following "//" may be treated as a word segment; for string of the character string in the javascript code, in terms of a computer, the content of the character string is either participated in calculation or used for display, the content of the character string is not required to be divided, and is an undetachable minimum unit, and the character string can be used as a word; for the digital Numeric in the javascript code, there are 16, 10, 8 system and scientific expression and other digital expression grammars, and the digital is also the minimum unit which is not detachable and can be used as a word segmentation; for the Identifier in the javascript code, consecutive characters which are not expanded by quotation marks can comprise letters, _, $, and numbers (numbers cannot be used as the beginning), the Identifier can represent a variable, or built-in constants such as true and false, and can be keywords such as if, return, function, and the Identifier is a single word; for operators in javascript code, such as + (plus), - (minus), (multiplied),/(divided), > (greater than), = (equal to) and < (less than), etc., the Operator can be used as a separate word; for brackets "()", "(… …)" in the javascript code may indicate operation priority, and may also indicate function call, the word segmentation stage does not focus on that, and "or") "is directly regarded as a basic syntax element, i.e., as a separate word segmentation; other contents in the javascript code, such as a middle bracket ("[ ]), a large bracket (" { }), a semicolon (";") a colon (":"), a dot (") and the like, are taken as a single word.
After the object code information containing the code information of the interface C is segmented, the obtained segmentation is as follows: the "// draw", "// rgb (91,139,248)", "// create canvas elements in the document and set their dimensions", "creatCanvas", "(", "w", "=", "" h "," = "," "render", "=", "" P2D "" "" "" "" ".
In fact, the interface type, the color of the programming building block and the interface function description can be divided into a word, the object code information is divided into words, and the source code in the object code information is divided into words essentially based on the function name, the parameter, the punctuation mark, the operation symbol and the number.
The word segmentation result of the embodiment of the application further comprises a data type (type) of each word segment, wherein the data type comprises a String, a numerical value numerical, an Operator, an Identifier, a punctuation Fu Haoxing Puncturator and the like, and other parts of speech can be further contained, and the embodiment of the application is not exemplified here one by one.
Continuing the foregoing embodiment, the word types corresponding to the respective word segments obtained from the object code information including the code information of the interface C are:
The data type of "// drawing" is String, the data type of rgb (91,139,248), "canvas is created in a document and set to its size" is String, the data type of "creatCanvas" is Identifier, "(" data type is pullover, "w" data type is Identifier, "=" data type is pullover, "300" data type is Numeric, "," data type is pullover, "h" data type is Identifier, "=" data type is pullover, "400" data type is Numeric, "," data type is pullover, "render" data type is Identifier, "=" data type is Identifier, "=" P2D "data type is Identifier,") "data type is Identifier.
After the word segmentation result is obtained, the code information is subjected to grammar analysis based on the data type of each word in the word segmentation result to obtain a grammar analysis result, and the grammar analysis is essentially to carry out three-dimensional combination on the word segmentation, so as to determine the expressed meaning among the words with multiple meanings, the relation among the words with multiple meanings and the like.
The interface types, the colors of the programming building blocks and the interface function description belong to code annotation, grammar analysis is not needed, the grammar analysis result of annotation information is directly determined to be 'readingComments-commentLine', namely, the grammar analysis of target code information is essentially to carry out grammar analysis on source codes in the target code information, the grammar analysis of the code annotation is not needed, and the grammar analysis result can be obtained by carrying out grammar analysis on the source codes based on a preset grammar analysis algorithm and grammar of compiling language corresponding to the source codes.
The grammar analysis result of the embodiment of the application comprises the interface function type corresponding to the interface to be processed and the attribute of each word in the object code information, wherein the attribute of each word in the object code information comprises the sentence type of the sentence where each word is located and the data type of each word.
The interface function type is the type of the interface function corresponding to the interface to be processed, and the interface function type is any one of a function call type callExpression, a variable acquisition type Identifier, an expression judgment type BinaryExpression and a function declaration type function description.
Specifically, an interface function "fill (r, g, b, a)" of the interface M is a function call type; the interface function of the interface N is HALF_PI which is a variable acquisition type; an interface function 'key ISown' of the interface P is an expression judgment type; the interface function of the interface Q is "function draw () { }" which is a function declaration type.
The statement types include method call statements, expression statements (including assignment expressions, arithmetic expressions, relational expressions, logic expressions, bit operation expressions, conditional expressions, etc.), null statements, compound statements, control statements, loop flow control statements, interrupt flow control statements, etc., and may also include other statement types, and the embodiments of the present application are not illustrated here one by one.
Specifically, the source code of the interface C is "creatCanvas (w=300, h=400, render=p2d)", where "w=300", "h=300", and "render=p2d" all belong to the assigned expression in the expression statement.
The grammar analysis result of the embodiment of the application further comprises a data type of each word, and the data type of each word can be any one of a function name, an operator, a parameter name and a parameter value, for example, in the previous embodiment, "creatCanvas" represents the function name, "w" is the parameter name, and "300" is the parameter value.
The parsing result of the embodiment of the application includes the interface function type corresponding to the interface, the sentence type corresponding to each sentence contained in the function, and the data type of each word in the object code information, and of course, other information, such as whether the words belong to the same sentence or expression, which is not limited in the embodiment of the application.
After the grammar analysis result is obtained, a target abstract grammar tree corresponding to the grammar analysis result is constructed, specifically, the target abstract grammar tree is generated on the basis of a candidate abstract grammar tree, for each word, each word and the attribute of the word in target code information can be used as one node of the candidate abstract grammar tree, each node is sequentially connected to the root node of the candidate abstract grammar tree, the root node in the candidate abstract grammar tree represents the interface function type, the candidate abstract grammar tree contains redundant information, and the redundant information needs to be deleted from the candidate abstract grammar tree to obtain the target abstract grammar tree.
The target abstract syntax tree has two expression forms, one is that the abstract syntax tree is represented by intermediate codes, and the intermediate codes corresponding to the target code information containing the code information of the interface C are:
/>
Wherein, the 2 nd-3 rd line represents the interface function type of the interface C as the function call CallExpression in the expressstate, the 4 th-5 th line represents the function name of the called function as "createCanvas", the 7 th line to the 14 th line represent the sentence "w=300", wherein, the 8 th line represents the sentence as the assignment expression assignetExpression, the 9 th line represents the operator in the sentence as "=", the 10 th-11 th line represents the parameter in the sentence as "w", the attribute of "w" is identifier, the 12 th-14 th line represents the parameter value of the sentence as 300, and the attribute of the parameter value as numericLiterl; lines 16 to 25 represent the sentence "h=300", wherein line 16 represents the sentence as the assignment expression, line 17 represents the operator in the sentence as "=", lines 18 to 19 represent the parameter in the sentence as "H", the attribute of "H" is identifier, lines 21 to 23 represent the parameter value of the sentence as 300, and the attribute of the parameter value is numericl; lines 26 to 37 represent the statement "render=p2d", wherein line 26 represents the statement is the assignment expression, line 27 represents the operator in the statement is "=", lines 28 to 29 represent the parameter in the statement is "render", the attribute of "render" is identifier, and lines 31 to 32 represent the parameter value of the statement is "P2D", the attribute of the parameter value is identifier; lines 38-40 represent annotation sentences corresponding to interface types, wherein the attribute of the annotation sentences is CommentLine; lines 42-43 represent the annotation sentence "rgb (91,139,248)", corresponding to the color of the building blocks, and the attribute of "rgb (91,139,248)" is CommentLine; lines 45-46 characterize the attributes of the annotation statement corresponding to the interface function description "create canvas element in document and set its size" and "create canvas element in document and set its size" as CommentLine.
The embodiment of the application can characterize the abstract syntax tree structure as a graphical target abstract syntax tree, and continues the previous embodiment, as shown in fig. 3, which exemplarily shows a schematic structural diagram for graphically displaying the target abstract syntax tree, wherein the root node of the target abstract tree characterizes an interface function type expressstate; the second layer node is ExpressionStatement CallExpression createCanvas, wherein ' createCanvas ' is a word, expressionStatement CallExpression ' is the attribute of the word, the characterization word ' createCanvas ' is a function name and a function type is a function call type CallExpression; the first node in the third layer node is 'AssignmentExpression operator: =', wherein '=' is a word, 'AssignmentExpression operator' is the attribute of the word '=', the characterization word '=' is an operator, and the expression where the operator is located is an assigned expression type; the fourth layer node is a leaf node, a first node and a second node in the fourth layer node are all child nodes of the first node of the third layer node, and the first node of the fourth layer is an Identifier name: w ", wherein" w "is a word, and" Identifier "is an attribute, and the characterization word" w "belongs to a parameter; the second node of the fourth layer is 'Literal value: 300', wherein '300' is a word, 'Literal' is an attribute, the characterization word '300' is a parameter value, and the first node of the third layer, the first node of the fourth layer and the second node of the fourth layer belong to the same sentence, namely in the target abstract syntax tree, the leaf node and the father node of the leaf node belong to the same sentence; the second node in the third layer node is 'AssignmentExpression operator: =', wherein '=' is a word, 'AssignmentExpression operator' is the attribute of the word '=', the characterization word '=' is an operator, and the expression where the operator is located is an assigned expression type; the third node and the fourth node in the fourth layer node are all child nodes of the second node of the third layer node, and the third node in the fourth layer is an Identifier name: h ", wherein" h "is a word, and" Identifier "is an attribute, and the characterization word" h "belongs to a parameter; the fourth node in the fourth layer is "Literal value:300", wherein "300" is a word, and "Literal" is an attribute, and the representation word "300" is a parameter value, and the second node in the third layer, the second node in the fourth layer and the second node in the fourth layer belong to the same sentence, and other nodes in the target abstract tree also represent a word and the attribute of the word, and/or the type of the expression where the word is located, which are not described one by one.
The target abstract syntax tree structure corresponding to other interfaces to be processed can be subjected to lexical analysis and syntax analysis based on the same steps to obtain a code of the target abstract syntax tree structure, wherein the function name, each parameter, the expression where each parameter is located and the parameter value are recorded in the code of the target abstract syntax tree structure.
Step S203, determining building block conversion rules of the interface to be processed and a plurality of template configuration files according to the interface function type; the building block conversion rule is used for indicating field information corresponding to each node in the target abstract tree.
The foregoing embodiments have already described that the embodiment of the present application includes multiple interface function types, including a function call type CallExpression, a variable acquisition type Identifier, an expression determination type BinaryExpression, a function declaration type functiondescription, and the like, and each function type of the embodiment of the present application is provided with a corresponding building block conversion rule and multiple template configuration files.
The building block conversion rules define field information and configuration files where the field information is located, which are required to be converted, of nodes of each type in the target abstract syntax tree, each function type has corresponding building block conversion rules, the building block conversion rules corresponding to function call types are function call building block conversion rules, the building block conversion rules corresponding to variable acquisition types are variable acquisition building block conversion rules, the building block conversion rules corresponding to expression judgment types are expression judgment building block conversion rules, and the building block conversion rules corresponding to function statement types are function statement conversion rules.
A programmed building block has 3 configuration files, namely a building block style configuration file, a building block conversion code configuration file and a building block display configuration file. The building block pattern configuration file defines the type of building blocks, the colors of the building blocks, the prompt information of the building blocks and the like, is a json format file, and defines the shape of the programmed building blocks; the building block conversion code configuration file defines logic for converting the building blocks into codes and logic corresponding to the corresponding interfaces, and the codes in the building block conversion code configuration file are javascript codes; the building block display configuration file defines the display position and display style of the building blocks in the menu bar and the displayed functions and default parameters of the functions, and the building block display configuration file is an xml format file.
Similarly, in the embodiment of the application, each interface function type has 3 corresponding template configuration files, in fact, the interface function types define the shape of the generated programming building blocks, and the graphics of the programming building blocks corresponding to different interface function types are different, so that the template configuration files corresponding to the interface function types are different.
Step S204, traversing the abstract syntax tree, converting the nodes into corresponding field information based on building block conversion rules for each node in the abstract syntax tree, and filling the field information into a template configuration file corresponding to the node in the plurality of template configuration files.
In the target abstract syntax tree, nodes in the target abstract syntax tree can be divided into two types, namely statement nodes corresponding to source code parts and comment nodes corresponding to comment information, wherein the statement nodes can also be divided into function name nodes corresponding to function names, parameter nodes corresponding to parameters, operator nodes corresponding to operators and parameter value nodes corresponding to parameter values.
The building block conversion rule comprises: in the building block style configuration file, for the function name node, converting the function name into a type field in the building block style configuration file; for the annotation node, directly converting the annotation node into a message0 field in the building block style configuration file; for statement nodes, converting parameters, parameter types and parameter values into args0 fields configured in building block patterns; for the nodes of the annotation node representing the color, the color field in the building block style configuration is directly converted. In the building block display configuration file, obtaining tab options from the word segmentation represented by each node and the data type of the word segmentation, and adding the generated building block display configuration to the corresponding category (building block type). And traversing all parameter nodes of the target abstract syntax tree based on the input Javascript interface in the building block conversion code configuration file to generate conversion codes.
Each function type in the embodiment of the application has 3 corresponding template configuration files, namely, the template configuration file corresponding to the building block style configuration file, the template configuration file corresponding to the building block conversion code configuration file and the template configuration file corresponding to the building block display configuration file. The template configuration file comprises placeholders of each field information, and after each node is converted into the corresponding field information, each field information can be respectively filled into the corresponding placeholders.
After the building block conversion rule is determined, each node is converted into corresponding field information based on the building block conversion rule, the field information is filled into the template configuration files corresponding to the field information in the plurality of template configuration files, and each field information can be respectively filled into the corresponding placeholders to obtain each configuration file.
Continuing with the previous embodiment, the codes in the building block style configuration file generated based on the object code information including the code information of the interface C are:
/>
the codes in the building block display configuration file generated based on the target code information containing the code information of the interface C are as follows:
the building block conversion code configuration file generated based on the object code information including the code information of the interface C is:
/>
Step S205, inputting all template configuration files corresponding to the field information corresponding to each node into a preset graphical programming tool to obtain target programming building blocks corresponding to the interfaces to be processed, wherein the target programming building blocks are related to interface functions of the interfaces to be processed.
The graphical programming tool refers to software that supports the operation of graphical controls (i.e., programming bricks) to implement graphical programming, and may be blockly.
After field information of all nodes is respectively filled into all template configuration files, inputting all template configuration files corresponding to the field information filled into all nodes into a preset graphical programming tool, and obtaining target programming building blocks corresponding to the interfaces to be processed, wherein the target programming building blocks are related to interface functions of the interfaces to be processed, and the interface functions of the corresponding interfaces to be processed are displayed in the target programming building blocks.
As shown in fig. 4, a schematic diagram of a target programming building block corresponding to the interface C is exemplarily shown, where the content displayed in the target programming building block is "creatCanvas (W: 300, h:300, render: p2 d)".
According to the embodiment of the application, the interface information of the interface to be processed is included in the target code information, the target abstract syntax tree corresponding to the target code information is constructed, the target abstract syntax tree is traversed, the target code information is displayed in a tree structure, compared with the process of manually analyzing the code structure and logic in the target code information, the code structure and logic in the target code information can be accurately and comprehensively mined, in the traversing process of the target abstract syntax tree, each node can be converted into corresponding field information based on building block conversion rules, each field information is filled into the template configuration files corresponding to the field information in a plurality of template configuration files, all the template configuration files corresponding to the field information corresponding to each node are input into a preset graphical programming tool, the target programming building blocks corresponding to the interface to be processed can be obtained, and the whole process can be automatically processed through a program.
The embodiment of the application provides a possible implementation mode, and the word segmentation result comprises at least one word segmentation and the data type of each word segmentation;
determining the interface function type of the interface to be processed and the target abstract syntax tree according to the word segmentation result, wherein the method comprises the following steps:
according to the data type of each word, carrying out grammar analysis processing on all the words to obtain grammar analysis results; the grammar analysis result comprises the interface function type and the attribute of each word in the object code information; wherein the attribute comprises the sentence type of the sentence where the segmentation is located;
for each word, taking the word and the attribute of the word in the object code information as a non-root node of a candidate abstract syntax tree, wherein the root node of the candidate abstract syntax tree represents the interface function type;
and deleting redundant information from the candidate abstract syntax tree to obtain a target abstract syntax tree.
The redundant information includes at least one of: representing nodes of punctuation marks; the word segmentation in the leaf node is in the sentence type of the sentence.
The word segmentation result comprises at least one word segment and a data type corresponding to each word segment in the at least one word segment, and the word segment and the data type of the word segment can be expressed in a key-value pair mode, wherein the key is the data type, and the value is the word segment. The word segmentation result corresponding to the object code information including the code information of the postsegment C may be characterized as:
{ "type": "String", "value": "draw" },
{"type":"String","value":"rgb(91,139,248)"},
{ "type": "String", "value": "// create canvas elements in the document and set its size" },
{"type":"Identifier","value":"createCanvas"},
{"type":"Punctuator","value":"("},
{"type":"Identifier","value":"w"},
{"type":"Punctuator","value":"="},
{"type":"Numeric","value":"300"},
{"type":"Punctuator","value":","},
{"type":"Identifier","value":"h"},
{"type":"Punctuator","value":"="}
{"type":"Numeric","value":"400"},
{"type":"Punctuator","value":","},
{"type":"Identifier","value":"renderer"},
{"type":"Punctuator","value":"="},
{"type":"Identifier","value":"P2D"},
{"type":"Punctuator","value":")"},
after the word segmentation type of each word segment is obtained, the embodiment of the application can carry out grammar analysis processing on all the word segments according to the data type of each word segment, and the grammar analysis is essentially that three-dimensional combination is carried out on the word segments, so as to determine the expressed meaning among the word segments with multiple meanings, the relation among a plurality of word segments and the like.
The grammar analysis result of the embodiment of the application comprises an interface function type and an attribute of each word in the object code information, wherein the interface function type is an interface function type, and comprises a function call type, a variable acquisition type, an expression judgment type, a function statement type and the like, and the foregoing embodiment is described and will not be repeated here.
The attribute of each word in the object code information in the embodiment of the present application includes the sentence type of the sentence in which each word is located and the data type of each word, and for the word in the sentence, the sentence type of the sentence and the data type of the word are already described in the foregoing embodiments, and will not be described herein.
The target abstract syntax tree is generated on the basis of the candidate abstract syntax tree, and the segmentation words and the attribute of the segmentation words in the target code information can be used as a node of the candidate abstract syntax tree, so that a complete candidate abstract syntax tree can be obtained.
The candidate abstract syntax tree also comprises nodes for representing punctuation marks and attributes of the punctuation marks in the target code information, and when the field information is obtained by the subsequent conversion node, the nodes for representing the punctuation marks and the attributes of the punctuation marks in the target code information have no practical meaning and belong to redundant information, so that the nodes for representing the punctuation marks can be deleted in the candidate abstract syntax tree.
In addition, in order to accurately determine the sentence where each word is located, the attribute of each word in the object code information includes the type of the sentence where the word is located, in fact, the leaf node and the parent node of the leaf node represent that the word represented by the node belongs to an expression, the expression type is only reserved in the parent node, and the type of the expression where the word is located in the leaf node can be deleted as redundant information.
The embodiment of the application provides a possible implementation mode, wherein the code information of the interface to be processed comprises annotation information, and the annotation information comprises interface types;
Acquiring target code information containing code information of an interface to be processed, including:
determining the type of the building blocks of the target programming building blocks corresponding to the interfaces to be processed according to the type of the interfaces, wherein the type of the building blocks is the same as the type of the interfaces to be processed;
according to the pre-established association relation between the types and colors of the building blocks, obtaining target colors corresponding to target programming building blocks, and combining the target colors as annotation information to code information of an interface to be processed to obtain target code information.
The embodiment of the application aims at target programming building blocks corresponding to a plurality of interfaces to be processed, the information which can be provided by the interfaces to be processed is code information of the interfaces to be processed, the code information comprises source codes and annotation information, the color of the target programming building blocks is not included, and the color of the target programming building blocks is determined based on the interfaces of the interfaces to be processed.
The annotation information includes interface types, which are divided based on interface functions, and the interface types are used for representing the types to which the interface belongs, for example, in a certain embodiment, the interface types can be divided into drawing types, shape types, operation types, environment types, characters types, functions types, 3D types, and the like, the types of the target programming blocks and the types of the blocks of the interface to be processed are the same, in the graphical programming tool, in order to increase the degree of interface friendliness, the colors of the programming blocks under each block type are the same, for example, each programming block under the drawing types is blue, each programming block under the conversion types is purple, each programming block under the operation is green, and the like.
According to the embodiment of the application, the types of the building blocks are the same as those of the interfaces, the target color corresponding to the target programming building blocks is obtained according to the pre-established association relationship between the types and the colors of the building blocks, the target color is used as annotation information and is combined with code information of the interface to be processed, so that the target code information is obtained, and a developer does not need to manually set the color for each programming building block one by one.
The embodiment of the application provides a possible implementation manner, and the method for obtaining the target building block speed corresponding to the interface to be processed further comprises the following steps:
and displaying the target programming building blocks and the building block types of the target programming building blocks in a menu bar of the graphical programming tool, wherein the interface functions of the interfaces to be processed are displayed in the target programming building blocks, and the colors of the target programming building blocks are target colors.
After all template configuration files corresponding to field information corresponding to each node are input into a preset graphical programming tool, the graphical programming tool displays the target programming building blocks, specifically, the target programming building blocks are displayed in menu bars of the graphical programming tool, interface functions of interfaces to be processed are displayed in the target programming building blocks, and the colors of the building blocks are target colors in annotation information.
In addition, the shape (namely, the building block style) of the displayed target programming building block is related to the interface function type, wherein the shape of the programming building block corresponding to the function call type is a first graph, the shape of the programming building block corresponding to the variable acquisition type is a second graph, the shape of the programming building block corresponding to the expression judgment type is a third graph, the shape of the programming building block corresponding to the function statement is a fourth graph, and the first graph, the second graph, the third graph and the fourth graph are different from each other.
As shown in fig. 5, a schematic diagram of a target programming building block of an interface C is shown in a menu bar of the graphical editing tool, where the menu bar includes a plurality of building block types, including "drawing, shape, transformation, constant, control" and the like, the target programming building block is displayed under "drawing", the building block type representing the target programming building block is "drawing", the building block types "drawing" also include other programming building blocks corresponding to the interface, such as a programming building block corresponding to "Color ()" and a programming building block corresponding to "noFill ()", the building block style of the target programming building block corresponding to the interface C is a first graphic corresponding to a function call, and the content displayed in the target programming building block is "creatCanvas (W: 300, h:300, render: p2 d)", and the Color of the target programming building block is blue (not shown in the figure) corresponding to "rgb (91,139,248)".
The embodiment of the application provides a possible implementation mode, and the annotation information also comprises interface function description;
after the menu bar of the graphical programming tool displays the target programming building blocks and the building block types of the target programming building blocks, the method further comprises:
and responding to the cursor moving to the target programming building blocks in the menu bar, and displaying building block prompt information of the target programming building blocks above the target programming building blocks, wherein the building block prompt information is an interface function description in the annotation information.
The annotation information of the embodiment of the application also comprises an interface function description, wherein the interface function description is a statement which is characterized by natural language and indicates the function of the interface, for example, the interface function description of the interface A is rotated around the x axis and indicates that the function of the interface is rotated around the x axis, and the interface function description of the interface C is rotated around the x axis and indicates that the function of the interface is rotated around the x axis. After the programming building blocks are generated based on the interfaces, the interface function description is converted into prompt information of the programming building blocks, in the graphical programming tool, when a cursor moves to a programming building block in a menu bar, building block prompt information of the programming building blocks is popped up, the display content of the building block prompt information is the interface function description, and a user can determine the function of the programming building blocks based on the prompt information.
As shown in fig. 6, which illustrates the building block hint information displayed as "create canvas element in document and size it" when the cursor is moved to the target programming building block corresponding to interface C.
The embodiment of the application provides a possible implementation mode, wherein the interface function type is any one of a function call type, a variable acquisition type, an expression judgment type and a function statement type; the programming building blocks corresponding to the function statement types and the programming building blocks corresponding to the function call types are in nested relation; the shapes of the programming building blocks corresponding to any two function call types are in a nested relation; the shapes of the programming building blocks corresponding to any two function statement types are in nested relation; the shape of the programming building block corresponding to the function call type and the shape of the programming building block corresponding to the variable acquisition type have an upper-lower layer relationship on the image layer; the shapes of the programming building blocks corresponding to the expression judgment type and the programming building blocks corresponding to the function statement type have an upper-lower layer relationship on the image layer.
As shown in fig. 7, which exemplarily shows schematic diagrams of the shapes of the programming blocks of which interface function types are function call types, variable acquisition types, expression judgment types, and function declaration types, respectively, the shapes of the various types of programming blocks are different.
Because the function call type is to call the declared function, in order to characterize the call relationship in the graphical programming, a nesting relationship is set between the shapes of the programming building blocks corresponding to the function declaration type and the programming building blocks corresponding to the function call type, as shown in fig. 8a, which schematically illustrates a schematic diagram of the shape obtained by nesting the shapes of the programming building blocks corresponding to the function declaration type and the programming building blocks corresponding to the function call type, which is provided by the embodiment of the application, the building block type of the programming building block 1 is the function declaration type, and the building block type of the programming building block 2 is the function call type.
Because the function of the function call type and the function of the function call type are also in parallel relationship, in order to characterize the parallel relationship, in the graphical programming tool, a nested relationship is also arranged between the shapes of the programming blocks corresponding to the two function call types, as shown in fig. 8b, which exemplarily shows a schematic diagram of the shapes obtained by nesting the shapes of the programming blocks of the two function call types, and the block types of the programming blocks 1 and 2 are both of the function call types.
In addition, since the function of the function declaration type and the function of the function declaration type are in parallel relationship, in the graphical programming tool, in order to characterize the parallel relationship, a nested relationship is also provided between the shapes of the programming blocks corresponding to the two function declaration types, as shown in fig. 8c, which schematically shows a schematic diagram of the shape obtained by nesting the shapes of the programming blocks of the two function declaration types, and the block types of the programming blocks 1 and 2 are the types for function declaration.
The return value when the function call is performed can be used as a new variable, which is a transfer relation in the graphical programming tool, in order to characterize the transfer relation, the shapes of the programming building blocks corresponding to the function call type and the programming building blocks corresponding to the variable acquisition type are set to have an upper-lower layer relation on the layer, namely, the two can be overlapped on the layer, as shown in fig. 8d, a schematic diagram of the shape obtained by overlapping the shapes of the programming building blocks corresponding to the function call type and the programming building blocks corresponding to the variable acquisition type on the layer is exemplarily shown, the building blocks type of the programming building blocks 1 is the function call type, and the building blocks type of the programming building blocks 2 is the variable acquisition type.
In addition, when the function declaration is performed, the function may also include an expression judgment, in order to characterize the inclusion relationship, a relationship between upper and lower layers exists on the layer between the shape of the programming building block corresponding to the function declaration type and the shape of the programming building block corresponding to the expression judgment type, that is, the two may be superimposed on the layer, as shown in fig. 8e, which schematically illustrates a schematic diagram of a shape obtained by superimposing the shape of the programming building block corresponding to the function declaration type and the shape of the programming building block corresponding to the expression judgment type on the layer, where the building block type of the programming building block 1 is the function declaration type, and the building block type of the programming building block 2 is the expression judgment type.
Of course, other relationships may be included between the interface function types, and relationships between the interface function types may be characterized based on relationships between shapes of the programming blocks, which are not examples herein.
The programming building blocks generated based on the scheme can be applied to games, as shown in fig. 9, which illustrates a game interface diagram of a graphical programming game developed on the basis of the programming building blocks generated based on the scheme, wherein the left side area of the game interface is a building block menu bar, various building block categories are displayed in the building block menu bar, the building block categories comprise drawing, shape, transformation, constant, control, operation and the like, each building block category comprises at least one programming building block, and each programming building block is provided with an interface function of a corresponding interface to be processed; the middle area of the interface is a working area, and a user can click and drag the programming building blocks in the menu bar to the working area; the right side area of the interface is an effect display area, wherein the effect display area comprises a game scene of a game to be developed and virtual objects in the game scene, and the virtual objects in the game scene are football and virtual characters are small; the player can drag the programming building blocks of various building block types in the menu bar to the working area, and each time one programming building block is positioned at the correct position in the working area, the virtual character 'min' plays a foot 'football', so that after the preset programming task is finished, the virtual character 'min' brings 'football' into the goal.
The embodiment of the application provides a device for generating programming building blocks, wherein the programming building blocks are used for indicating interface functions required by graphical programming, and as shown in fig. 10, the device 100 for generating the programming building blocks comprises:
an object code information obtaining module 1001, configured to obtain object code information including code information of an interface to be processed;
the processing module 1002 is configured to segment the object code information, and determine an interface function type of the interface to be processed and a target abstract syntax tree according to a segmentation result; the node of the target abstract syntax tree represents one word in the word segmentation result and the attribute of the word in the target code information;
a determining module 1003, configured to determine a building block conversion rule and a plurality of template configuration files of the interface to be processed according to the interface function type; the building block conversion rule is used for indicating field information corresponding to each node in the target abstract tree;
the conversion module 1004 is configured to traverse the abstract syntax tree, convert, for each node in the abstract syntax tree, the node into corresponding field information based on the building block conversion rule, and fill the field information into a template configuration file corresponding to the node in the plurality of template configuration files;
the target programming building block generating module 1005 is configured to input all template configuration files corresponding to the field information corresponding to each node after filling into a preset graphical programming tool to obtain a target programming building block corresponding to the interface to be processed, where the target building block is related to an interface function of the interface to be processed.
According to the method, the device and the system, interface information of the interface to be processed is included in target code information, a target abstract syntax tree corresponding to the target code information is constructed, the target abstract syntax tree is traversed, the target code information is displayed in a tree structure, the code structure and logic in the target code information can be accurately mined, in the process of traversing the target abstract syntax tree, each node can be converted into corresponding field information based on building block conversion rules, each field information is filled into a template configuration file corresponding to the field information in a plurality of template configuration files, all template configuration files corresponding to the field information corresponding to each node are input into a preset graphical programming tool, the target programming building blocks corresponding to the interface to be processed can be obtained, the whole process can be automatically processed through a program, on one hand, copy and paste operations are reduced, unintended omission and error problems of research staff are avoided, on the other hand, technicians are not required to analyze the processing logic of each interface to be processed one by one, the time consumed by one interface analysis and conversion of the technicians is reduced, and program development efficiency can be accelerated.
The embodiment of the application provides a possible implementation mode, and the word segmentation result comprises at least one word segmentation and the data type of each word segmentation; the processing module comprises:
The grammar analysis sub-module is used for carrying out grammar analysis processing on all the segmented words according to the data type of each segmented word to obtain a grammar analysis result; the grammar analysis result comprises the interface function type and the attribute of each word in the object code information;
the node determining submodule is used for regarding each word, and taking the word and the attribute of the word in the target code information as a node of the candidate abstract syntax tree;
the target abstract syntax obtaining sub-module is used for deleting redundant information from the candidate abstract syntax tree to obtain a target abstract syntax tree.
The embodiment of the application provides a possible implementation mode, and the attribute comprises the sentence type of the sentence where the word is located;
the redundant information includes at least one of:
representing nodes of punctuation marks;
the word segmentation in the leaf node is in the sentence type of the sentence.
The embodiment of the application provides a possible implementation mode, wherein the code information of the interface to be processed comprises annotation information, and the annotation information comprises interface types;
the object code information acquisition module includes:
the building block type determining submodule is used for determining the building block type of the target programming building block corresponding to the interface to be processed according to the interface type, and the building block type is the same as the interface type of the interface to be processed;
The target color determining sub-module is used for obtaining target colors corresponding to target programming building blocks according to the pre-established association relation between the types and colors of the building blocks, and combining the target colors serving as annotation information to code information of an interface to be processed to obtain target code information.
The embodiment of the application provides a possible implementation manner, and the device further comprises:
the building block display module is used for displaying the target programming building blocks and the building block types of the target programming building blocks in a menu bar of the graphical programming tool, wherein the interface functions of the interfaces to be processed are displayed in the target programming building blocks, and the colors of the target programming building blocks are target colors.
The embodiment of the application provides a possible implementation mode, and the annotation information also comprises interface function description;
the apparatus further comprises:
and the building block prompt information display module is used for responding to the target programming building blocks of which the cursors move to the menu bar, displaying building block prompt information of the target programming building blocks above the target programming building blocks, wherein the building block prompt information is an interface function description in the annotation information.
The embodiment of the application provides a possible implementation mode, wherein the interface function type is any one of a function call type, a variable acquisition type, an expression judgment type and a function statement type; the programming building blocks corresponding to the function statement types and the programming building blocks corresponding to the function call types are in nested relation; the shapes of the programming building blocks corresponding to any two function call types are in a nested relation; the shapes of the programming building blocks corresponding to any two function statement types are in nested relation; the shape of the programming building block corresponding to the function call type and the shape of the programming building block corresponding to the variable acquisition type have an upper-lower layer relationship on the image layer; the shapes of the programming building blocks corresponding to the expression judgment type and the programming building blocks corresponding to the function statement type have an upper-lower layer relationship on the image layer.
The device of the embodiment of the present application may perform the method provided by the embodiment of the present application, and its implementation principle is similar, and actions performed by each module in the device of the embodiment of the present application correspond to steps in the method of the embodiment of the present application, and detailed functional descriptions of each module of the device may be referred to the descriptions in the corresponding methods shown in the foregoing, which are not repeated herein.
The embodiment of the application provides electronic equipment, which comprises a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to realize the steps of a method for generating programming building blocks, and compared with the related technology, the method can realize the following steps: according to the method, the device and the system, interface information of the interface to be processed is included in target code information, a target abstract syntax tree corresponding to the target code information is constructed, the target abstract syntax tree is traversed, the target code information is displayed in a tree structure, the code structure and logic in the target code information can be accurately mined, in the process of traversing the target abstract syntax tree, each node can be converted into corresponding field information based on building block conversion rules, each field information is filled into a template configuration file corresponding to the field information in a plurality of template configuration files, all template configuration files corresponding to the field information corresponding to each node are input into a preset graphical programming tool, the target programming building blocks corresponding to the interface to be processed can be obtained, the whole process can be automatically processed through a program, on one hand, copy and paste operations are reduced, unintended omission and error problems of research staff are avoided, on the other hand, technicians are not required to analyze the processing logic of each interface to be processed one by one, the time consumed by one interface analysis and conversion of the technicians is reduced, and program development efficiency can be accelerated.
In an alternative embodiment, there is provided an electronic device, as shown in fig. 11, the electronic device 4000 shown in fig. 11 includes: a processor 4001 and a memory 4003. Wherein the processor 4001 is coupled to the memory 4003, such as via a bus 4002. Optionally, the electronic device 4000 may further comprise a transceiver 4004, the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of data, etc. It should be noted that, in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The processor 4001 may be a CPU (Central Processing Unit ), general purpose processor, DSP (Digital Signal Processor, data signal processor), ASIC (Application Specific Integrated Circuit ), FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic device, transistor logic device, hardware components, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. The processor 4001 may also be a combination that implements computing functionality, e.g., comprising one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
Bus 4002 may include a path to transfer information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Industry Standard Architecture ) bus, or the like. The bus 4002 can be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 11, but not only one bus or one type of bus.
Memory 4003 may be, but is not limited to, ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, RAM (Random Access Memory ) or other type of dynamic storage device that can store information and instructions, EEPROM (Electrically Erasable Programmable Read Only Memory ), CD-ROM (Compact Disc Read Only Memory, compact disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store a computer program and that can be Read by a computer.
The memory 4003 is used for storing a computer program for executing an embodiment of the present application, and is controlled to be executed by the processor 4001. The processor 4001 is configured to execute a computer program stored in the memory 4003 to realize the steps shown in the foregoing method embodiment.
Among them, the electronic device package may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 11 is merely an example, and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
Embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of the foregoing method embodiments and corresponding content. Compared with the prior art, can realize: according to the method, the device and the system, interface information of the interface to be processed is included in target code information, a target abstract syntax tree corresponding to the target code information is constructed, the target abstract syntax tree is traversed, the target code information is displayed in a tree structure, the code structure and logic in the target code information can be accurately mined, in the process of traversing the target abstract syntax tree, each node can be converted into corresponding field information based on building block conversion rules, each field information is filled into a template configuration file corresponding to the field information in a plurality of template configuration files, all template configuration files corresponding to the field information corresponding to each node are input into a preset graphical programming tool, the target programming building blocks corresponding to the interface to be processed can be obtained, the whole process can be automatically processed through a program, on one hand, copy and paste operations are reduced, unintended omission and error problems of research staff are avoided, on the other hand, technicians are not required to analyze the processing logic of each interface to be processed one by one, the time consumed by one interface analysis and conversion of the technicians is reduced, and program development efficiency can be accelerated.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having 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. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The embodiment of the application also provides a computer program product, which comprises a computer program, wherein the computer program can realize the steps and corresponding contents of the embodiment of the method when being executed by a processor. Compared with the prior art, can realize:
according to the method, the device and the system, interface information of the interface to be processed is included in target code information, a target abstract syntax tree corresponding to the target code information is constructed, the target abstract syntax tree is traversed, the target code information is displayed in a tree structure, the code structure and logic in the target code information can be accurately mined, in the process of traversing the target abstract syntax tree, each node can be converted into corresponding field information based on building block conversion rules, each field information is filled into a template configuration file corresponding to the field information in a plurality of template configuration files, all template configuration files corresponding to the field information corresponding to each node are input into a preset graphical programming tool, the target programming building blocks corresponding to the interface to be processed can be obtained, the whole process can be automatically processed through a program, on one hand, copy and paste operations are reduced, unintended omission and error problems of research staff are avoided, on the other hand, technicians are not required to analyze the processing logic of each interface to be processed one by one, the time consumed by one interface analysis and conversion of the technicians is reduced, and program development efficiency can be accelerated.
The terms "first," "second," "third," "fourth," "1," "2," and the like in the description and in the claims and in the above figures, if any, 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 application described herein may be implemented in other sequences than those illustrated or otherwise described.
It should be understood that, although various operation steps are indicated by arrows in the flowcharts of the embodiments of the present application, the order in which these steps are implemented is not limited to the order indicated by the arrows. In some implementations of embodiments of the application, the implementation steps in the flowcharts may be performed in other orders as desired, unless explicitly stated herein. Furthermore, some or all of the steps in the flowcharts may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or phases may be performed at the same time, or each of these sub-steps or phases may be performed at different times, respectively. In the case of different execution time, the execution sequence of the sub-steps or stages can be flexibly configured according to the requirement, which is not limited by the embodiment of the present application.
The foregoing is only an optional implementation manner of some implementation scenarios of the present application, and it should be noted that, for those skilled in the art, other similar implementation manners based on the technical ideas of the present application are adopted without departing from the technical ideas of the scheme of the present application, which also belongs to the protection scope of the embodiments of the present application.

Claims (11)

1. A method of generating a programming building block for indicating an interface function required for graphical programming, the method comprising:
acquiring target code information containing code information of an interface to be processed;
performing word segmentation on the object code information, and determining the interface function type of the interface to be processed and a target abstract syntax tree according to a word segmentation result; the non-root node of the target abstract syntax tree represents one word in the word segmentation result and the attribute of the word in the target code information;
determining building block conversion rules of the interface to be processed and a plurality of template configuration files according to the interface function type; the building block conversion rule is used for indicating field information corresponding to each node in the target abstract tree;
traversing the target abstract syntax tree, for each node in the abstract syntax tree, converting the node into corresponding field information based on the building block conversion rule, and filling the field information into a template configuration file corresponding to the field information in the plurality of template configuration files;
And inputting all template configuration files which are correspondingly filled with field information corresponding to each node into a preset graphical programming tool to obtain the target programming building blocks corresponding to the interfaces to be processed.
2. The method of claim 1, wherein the word segmentation result comprises at least one word segment and a data type for each word segment;
the determining the interface function type of the interface to be processed and the target abstract syntax tree according to the word segmentation result comprises the following steps:
according to the data type of each word, carrying out grammar analysis processing on all the words to obtain grammar analysis results; the grammar analysis result comprises the interface function type and the attribute of each word in the object code information;
for each word, taking the word and the attribute of the word in the target code information as a non-root node of a candidate abstract syntax tree, wherein the root node of the candidate abstract syntax tree represents the interface function type;
and deleting redundant information from the candidate abstract syntax tree to obtain a target abstract syntax tree.
3. The method of claim 2, wherein the attribute comprises a sentence type of a sentence in which the segmentation is located;
The redundant information includes at least one of:
representing nodes of punctuation marks;
the word segmentation in the leaf node is in the sentence type of the sentence.
4. The method according to claim 1, wherein the code information of the interface to be processed includes comment information, and the comment information includes an interface type;
the obtaining the target code information containing the code information of the interface to be processed comprises the following steps:
determining the type of the building blocks of the target programming building blocks corresponding to the interface to be processed according to the type of the interface, wherein the type of the building blocks is the same as the type of the interface to be processed;
and obtaining a target color corresponding to the target programming building block according to the pre-established association relation between the type and the color of the building block, and combining the target color as annotation information to the code information of the interface to be processed to obtain the target code information.
5. The method of claim 4, wherein the obtaining the target building block corresponding to the interface to be processed further comprises:
and displaying the target programming building blocks and the building block types of the target programming building blocks in a menu bar of the graphical programming tool, wherein the interface functions of the interface to be processed are displayed in the target programming building blocks, and the color of the target programming building blocks is the target color.
6. The method of claim 5, wherein the annotation information further comprises an interface function description;
after the menu bar of the graphical programming tool displays the target programming building blocks and the building block types of the target programming building blocks, the method further comprises the following steps:
and responding to the cursor moving to the target programming building block in the menu bar, and displaying building block prompt information of the target programming building block above the target programming building block, wherein the building block prompt information is an interface function description in the annotation information.
7. The method of claim 1, wherein the interface function type is any one of a function call type, a variable acquisition type, an expression judgment type, and a function declaration type;
the programming building blocks corresponding to the function statement types and the programming building blocks corresponding to the function call types are in nested relation;
the shapes of the programming building blocks corresponding to any two function call types are in a nested relation;
the shapes of the programming building blocks corresponding to any two function statement types are in nested relation;
the shapes of the programming building blocks corresponding to the function call type and the programming building blocks corresponding to the variable acquisition type have an upper-lower layer relationship on the image layer;
The programming building blocks corresponding to the expression judgment types and the programming building blocks corresponding to the function statement types have upper and lower layer relations on the layers.
8. A device for generating a programming block for indicating an interface function required for graphical programming, the device comprising:
the target code information acquisition module is used for acquiring target code information containing code information of an interface to be processed;
the processing module is used for word segmentation of the target code information and determining the interface function type of the interface to be processed and a target abstract syntax tree according to word segmentation results; the non-root node of the target abstract syntax tree represents one word in the word segmentation result and the attribute of the word in the target code information;
the determining module is used for determining building block conversion rules of the interface to be processed and a plurality of template configuration files according to the interface function type; the building block conversion rule is used for indicating field information corresponding to each node in the target abstract tree;
the conversion module is used for traversing the abstract syntax tree, converting each node in the abstract syntax tree into corresponding field information based on the building block conversion rule, and filling the field information into a template configuration file corresponding to the node in the plurality of template configuration files;
And the target programming building block generating module is used for inputting all template configuration files corresponding to the field information corresponding to each node into a preset graphical programming tool to obtain the target programming building blocks corresponding to the interface to be processed.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to carry out the steps of the method according to any one of claims 1-7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any of claims 1-7.
11. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any of claims 1-7.
CN202310274570.9A 2023-03-17 2023-03-17 Programming building block generation method and device, electronic equipment and readable storage medium Pending CN116974545A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310274570.9A CN116974545A (en) 2023-03-17 2023-03-17 Programming building block generation method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310274570.9A CN116974545A (en) 2023-03-17 2023-03-17 Programming building block generation method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN116974545A true CN116974545A (en) 2023-10-31

Family

ID=88482069

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310274570.9A Pending CN116974545A (en) 2023-03-17 2023-03-17 Programming building block generation method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN116974545A (en)

Similar Documents

Publication Publication Date Title
US9395889B1 (en) Identification of semantically relevant concepts in a graphical model
US20200356350A1 (en) Methods and Systems for Visual Programming using Polymorphic, Dynamic Multi-Dimensional Structures
US20150067640A1 (en) Input suggestions for free-form text entry
US20180189033A1 (en) Graphical software meta-development tool
Nandavar et al. Interactive Virtual Reality Tool for BIM Based on IFC
CN113535165A (en) Interface generation method and device, electronic equipment and computer readable storage medium
US20110126171A1 (en) Dynamic native editor code view facade
CN111273900A (en) On-line drag code generation method based on gitlab real-time code sharing
US20220308841A1 (en) Enabling custom software development by domain experts
Roldán React Design Patterns and Best Practices: Design, build and deploy production-ready web applications using standard industry practices
WO2005098662A1 (en) Document processing device and document processing method
CN115564903B (en) Three-dimensional scene asset data processing method and device, electronic equipment and storage medium
KR20180135654A (en) Intuitive method of making a program
CN116755669A (en) Low code development method and tool based on DSL language operation model
US10896161B2 (en) Integrated computing environment for managing and presenting design iterations
CN116974545A (en) Programming building block generation method and device, electronic equipment and readable storage medium
US8548798B2 (en) Representations for graphical user interfaces of operators, data types, and data values in a plurality of natural languages
US20090237405A1 (en) Data processing apparatus and data processing method
CN113296759B (en) User interface processing method, user interface processing system, device and storage medium
CN114896918A (en) Real-time visualization method and system for functional function module
US11119975B2 (en) Digital design application plugin for content updates and delivery
CN114692055A (en) Form processing method and device, storage medium and electronic equipment
CN114217794A (en) Page design method, client device, readable medium, and program product
CN107729499A (en) Information processing method, medium, system and electronic equipment
EP3834080B1 (en) Static reconcilliation of application view hierarchies

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication