CN112269566B - Script generation processing method, device, equipment and system - Google Patents

Script generation processing method, device, equipment and system Download PDF

Info

Publication number
CN112269566B
CN112269566B CN202011208798.0A CN202011208798A CN112269566B CN 112269566 B CN112269566 B CN 112269566B CN 202011208798 A CN202011208798 A CN 202011208798A CN 112269566 B CN112269566 B CN 112269566B
Authority
CN
China
Prior art keywords
script
grammar
code
file
action
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.)
Active
Application number
CN202011208798.0A
Other languages
Chinese (zh)
Other versions
CN112269566A (en
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.)
Alipay Hangzhou Information Technology Co Ltd
Original Assignee
Alipay Hangzhou Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN202011208798.0A priority Critical patent/CN112269566B/en
Publication of CN112269566A publication Critical patent/CN112269566A/en
Application granted granted Critical
Publication of CN112269566B publication Critical patent/CN112269566B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing

Abstract

The present specification provides a script generation processing method, device, equipment, and system, which parse an original script file, generate a code file of a specified programming language based on a syntax structure obtained by parsing, and directly generate a target script file that can be used by the specified programming language by combining with a pre-configured script template, without separately compiling the script file, thereby improving the development efficiency and the reuse rate of the script file. Meanwhile, when the original script file is analyzed, each flow link is properly decomposed, if the grammar of the original script file is changed, only the corresponding analysis link needs to be adjusted, the script generation link is flexible, and the applicability is wide.

Description

Script generation processing method, device, equipment and system
Technical Field
The present specification belongs to the field of computer technologies, and in particular, to a script generation processing method, apparatus, device, and system.
Background
Developers, operation and maintenance personnel and other technicians often relate to the development of scripts during ordinary work, and the scripts can be understood as executable files written according to a certain format or executable files after dynamic compilation by using a specific descriptive language. In some project development scenarios, the number of scripts is huge and the development cost is high due to the complexity of the project or the scale of the project.
Disclosure of Invention
An object of the embodiments of the present specification is to provide a script generation processing method, device, apparatus, and system, which improve efficiency of script generation and a reuse rate of scripts.
In one aspect, an embodiment of the present specification provides a script generation processing method, where the method includes:
parsing an original script file to obtain a syntax tree list of the original script file;
analyzing the syntax trees in the syntax tree list to obtain actions corresponding to each syntax tree;
converting the action corresponding to each syntax tree into a code file of a specified programming language by using a code generator;
and generating a target script file according to the script template corresponding to the specified programming language and the code file.
In another aspect, the present specification provides a script generation processing apparatus including:
the grammar parsing module is used for parsing the grammar of the original script file to obtain a grammar tree list of the original script file;
the action analysis module is used for analyzing the syntax trees in the syntax tree list to obtain actions corresponding to each syntax tree;
the code conversion module is used for converting the action corresponding to each syntax tree into a code file of a specified programming language by using the code generator;
and the script generation module is used for generating a target script file according to the script template corresponding to the specified programming language and the code file.
In another aspect, an embodiment of the present specification provides a script generation processing apparatus, which includes at least one processor and a memory for storing processor-executable instructions, where the processor executes the instructions to implement the script generation processing method.
In yet another aspect, an embodiment of the present specification provides a script generation processing system, including: the method comprises the following steps: grammar parser, grammar viewer, code generator, grammar translator, script generator, among them:
the grammar parser is used for parsing the original script file to generate a grammar tree list;
the grammar viewer is used for carrying out grammar analysis on each grammar tree in the grammar tree list and converting each grammar tree into a corresponding action;
the code generator is used for converting the actions converted by the grammar viewer into code files corresponding to a specified programming language, wherein each action corresponds to one code generator;
the code generators transmit the code files generated by the code generators to the script generators according to the sequence of actions in the original script file;
and the script generator is used for generating a target script file according to the code file sent by the grammar translator and the script template corresponding to the specified programming language.
According to the script generation processing method, device, equipment and system provided by the specification, the original script file is analyzed, the code file of the specified programming language is generated based on the grammatical structure obtained by analysis, the target script file which can be used by the specified programming language can be directly generated by combining the preset script template, the script file does not need to be independently written, and the development efficiency and the reuse rate of the script file are improved. Meanwhile, when the original script file is analyzed, each flow link is properly decomposed, if the grammar of the original script file is changed, only the corresponding analysis link needs to be adjusted, the script generation link is flexible, and the applicability is wide.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present specification, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort.
FIG. 1 is a flowchart illustrating an embodiment of a script generation processing method provided by an embodiment of the present specification;
FIG. 2 is a schematic flow diagram of script file generation in an example scenario of the present specification;
FIG. 3 is a block diagram of an embodiment of a script generation processing apparatus provided in the present specification;
FIG. 4 is a schematic structural diagram of a script generation processing system in one embodiment of the present specification;
fig. 5 is a block diagram showing a hardware configuration of a script generation processing server in one embodiment of the present specification.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step should fall within the scope of protection of the present specification.
The script is the basis of the development, operation and maintenance of computer software, different programming languages may have different requirements on the format, the syntactic structure and the like of the script, and even the scripts with the same function cannot be directly used in different programming languages and running environments.
Fig. 1 is a flowchart illustrating an embodiment of a script generation processing method provided in an embodiment of the present specification. Although the present specification provides method steps or apparatus structures as shown in the following examples or figures, more or less steps or modules may be included in the method or apparatus, as may be conventional or necessary without inventive faculty. In the case of steps or structures which do not logically have the necessary cause and effect relationship, the execution order of the steps or the block structure of the apparatus is not limited to the execution order or the block structure shown in the embodiments or the drawings of the present specification. When the described method or module structure is applied to a device, a server or an end product in practice, the method or module structure according to the embodiment or the figures may be executed sequentially or in parallel (for example, in a parallel processor or multi-thread processing environment, or even in an implementation environment including distributed processing and server clustering).
A specific embodiment is shown in fig. 1, and in an embodiment of the script generation processing method provided in this specification, the method may be applied to a terminal device such as a computer, a tablet computer, a server, and a smart phone, and the method may include the following steps:
and 102, carrying out syntax analysis on the original script file to obtain a syntax tree list of the original script file.
In a specific implementation process, the original script file may be a script file that is already written and used but is different from a currently required programming language, and since the original script file cannot be directly used due to the different programming language, the original script file may be directly obtained from an existing programming system or program file.
In some embodiments of the present specification, before parsing the original script file, the original script file may be generated according to an operation record of a user on a device terminal. The operation record of the user on the equipment terminal can comprise: clicking, copying, sliding, text entry, etc., each operation of the user may be converted into an original script file using a programming language specified by the device terminal, such as: the operation of the user on the equipment terminal is recorded, and an original script file is generated in the operation process of the user on the terminal equipment during screen recording. The method and the device have the advantages that the original script file is automatically generated directly according to the operation of a user on the equipment terminal, and then the original script file is converted into the script file corresponding to the specified programming language, code compiling of the script file is not needed, and automatic generation of the script file is achieved.
The original script file is compiled by adopting a specific grammar, the grammar structure, the operating environment and the like of the original script file are different from the programming language currently used by the user, and the original script file needs to be interpreted and then converted into the script file of the programming language needed by the user. The embodiments of the present description may perform a series of operations such as parsing on an original script file, and generate a new script file that can be directly used using a programming language required by a user based on a result of the parsing. Firstly, the original script file needs to be parsed, the parsing can be understood as a logic stage of the compiling process, which is a process of combining word sequences into various grammar phrases on the basis of lexical analysis, and the lexical analysis can be understood as a process of converting character sequences into word (Token) sequences in computer science. When the grammar of the original script is analyzed, the lexical analysis can be firstly used for segmenting the original script file, the original script file is divided into phrases, each phrase is organized by the grammar analysis and converted into a sequence allowed by the grammar definition of the target language, and a grammar tree list is generated based on the grammar structure. The syntax tree list may include a plurality of syntax trees, and the syntax trees may be understood as a graphical representation of a sentence structure, which represents a derivation result of the sentence and facilitates understanding of a hierarchy of the sentence syntax structure. In particular use, the original script file may be parsed by some parser such as: antlr, antlr4, and the like.
And step 104, analyzing the syntax trees in the syntax tree list to obtain actions corresponding to each syntax tree.
In a specific implementation process, the script file is generally obtained by writing a certain syntax rule based on a series of actions, and therefore the script file includes a series of actions. The syntax tree list obtained after parsing the original script file may include a plurality of syntax trees, and each syntax tree may be understood as a syntax structure of each action in the original script file. After the syntax tree list is obtained, each syntax tree may be further analyzed to obtain actions corresponding to each syntax tree, such as: click, copy, swipe, hibernate, text input, etc.
And 106, converting the action corresponding to each syntax tree into a code file of a specified programming language by using a code generator.
In a specific implementation process, after obtaining the action corresponding to each syntax tree, the code generator may be used to convert the action corresponding to each syntax tree into a code file of a specified programming language. The code generator can be understood as software for outputting codes according to a specific coding specification, and the corresponding code generator can be configured in advance based on a specified programming language, and then the code generator is used for converting actions corresponding to each syntax tree into a code file of the specified programming language.
In some embodiments of the present specification, the converting, by a code generator, the action corresponding to each syntax tree into a code file in a specified programming language includes:
acquiring an action type corresponding to each syntax tree;
determining a code generator of the action corresponding to each syntax tree according to the action type corresponding to each syntax tree;
and converting the action corresponding to each syntax tree into a code file of a specified programming language by using the code generator.
In a specific implementation process, a code generator can be configured in advance for different types of actions, such as: the click action corresponds to a code generator for generating a code file of the click action, and the slide action corresponds to a code generator for generating a code file of the slide action. After the action corresponding to each syntax tree in the original script file is obtained, a corresponding code generator can be determined according to the action type of the action, and then the action corresponding to each syntax tree is converted into a code file by using the code generator corresponding to each syntax tree. And a code generator is created for each action in advance, so that the actions in the analyzed original script file can be directly converted into corresponding code files without compiling the script file.
In addition, in some embodiments of the present specification, the converting, by the code generator, the action corresponding to each syntax tree into a code file in a specified programming language includes:
sequentially adding the code generators corresponding to the actions into an action queue according to the sequence of the actions in the original script file;
and each code generator converts the corresponding actions into code files of the specified programming language in sequence according to the sequence in the action queue.
In a specific implementation process, there may be multiple actions in the original script file, and after parsing, multiple syntax trees are obtained, where each syntax tree corresponds to one code generator, so that there are multiple code generators. In the embodiment of the present specification, grammar generators corresponding to each action are sequentially added to an action queue according to the sequence of each action in an original script file, and when a code file is generated, each code generator sequentially converts the corresponding action into a code file of a specified programming language according to the sequence in the action queue, so that the sequence of the converted code file is the same as the sequence of codes in the original script file. The code generator is sequenced according to the sequence of each action in the original script file, and generates a code file of a series of actions according to the sequence, so that the generated code file can be ensured to be consistent with the action sequence in the original script file, and the accuracy of the finally generated target script file is ensured.
And 108, generating a target script file according to the script template corresponding to the specified programming language and the code file.
In a specific implementation process, only one section of code fragment is generated by the code generator, the format of a code file generated by the code generator may be incomplete, a complete target script file can be generated according to a script template corresponding to a specified programming language and the code file generated by the code generator, and the target script file can be directly applied to an operating environment of the specified programming language without independently writing the script file. The script template may include a format of a script file required by a designated programming language, such as: head, tail, etc. format requirements, etc. Generally, the target script file and the original script file correspond to two different programming languages, respectively, and the target script file that can be used by a user can be obtained by analyzing and transcoding the original script file. For example: the original script file may be a js (javascript) script file, and the target script file may be a Java script file, a python script file, or a script file of another programming language.
The script generation processing method provided by the embodiment of the specification analyzes the original script file, generates the code file of the specified programming language based on the grammatical structure obtained by analysis, and then directly generates the target script file which can be used by the specified programming language by combining with the pre-configured script template, so that the script file does not need to be written separately, and the development efficiency and the reuse rate of the script file are improved. Meanwhile, when the original script file is analyzed, each flow link is properly decomposed, if the grammar of the original script file is changed, only the corresponding analysis link needs to be adjusted, the script generation link is flexible, and the applicability is wide.
On the basis of the above embodiments, in some embodiments of the present specification, the method further includes:
pre-creating code generators and script templates corresponding to different programming languages;
the converting the action corresponding to each syntax tree into a code file of a specified programming language includes:
selecting a code generator of a corresponding type according to the specified programming language;
and converting the action corresponding to each syntax tree into a code file of a specified programming language by using the selected code generator.
In a specific implementation process, code generators and script templates corresponding to different programming languages can be created in advance according to syntax requirements, format requirements and the like based on the different programming languages, such as: code generators written in the Java language, code generators written in the python language, and script templates in the Java language and the python language can be created. After the original script file is parsed to obtain corresponding actions, a code generator corresponding to a programming language can be selected according to the programming language required by the target script file, for example: and if a script file of the Java language is needed, selecting a code generator corresponding to the written Java language, selecting a code generator of a corresponding type for the type of the action corresponding to each syntax tree, and converting the action corresponding to each syntax tree into a code file of a specified programming language such as the Java language by using the code generator. A code generator for the Java language may generate corresponding code fragments based on the Java syntax.
On the basis of the foregoing embodiments, in some embodiments of the present specification, the generating an object script file according to the script template corresponding to the specified programming language and the code file includes:
selecting a corresponding script template according to the specified programming language;
and adding the code file into the selected script template to generate the target script file.
In a specific implementation process, script templates corresponding to different programming languages can be created in advance based on syntax requirements, format requirements and the like of the different programming languages, after code files of various actions of an original script file are obtained, the corresponding script templates are selected based on the programming language required by a target script file, and the obtained code files are added to corresponding positions of the script templates, so that the target script file can be generated. By creating the code generators and the script templates of different programming languages, the automatic conversion of script files of various programming languages can be realized, the script files required by users can be automatically generated, and the development cost of the script files is reduced.
In this embodiment of the present specification, generation paths of script files of different programming languages may be created in advance based on actual needs, and a code generator and a script template required by the programming language correspond to the generation path of each script file. At the beginning of script file generation, a corresponding generation path can be selected based on the programming language required by the target script file, and then the target script file which can be directly used can be generated. The automatic generation of the script files is realized, independent operations such as code compiling and the like are not needed, the generation efficiency of the script files is improved, and the generation paths of the script files of various programming languages can be configured based on actual use requirements so as to realize the function of generating the script files corresponding to different programming languages.
Fig. 2 is a schematic flowchart of script file generation in an exemplary scenario of this specification, and the following specifically describes, with reference to fig. 2, a process of converting a JS script file into a Java script file in an embodiment of this specification:
1. the original JS script is input into the parser.
2. The grammar parser can parse the codes in the original Js scripts according to the configured rules. The grammar parser can generate a corresponding grammar tree for each operation in the JS script, and finally the whole JS script is generated into a grammar tree list.
3. Each syntax tree is traversed and further parsed with a syntax viewer.
4. After parsing by the syntax viewer, each syntax tree is converted into a corresponding action, and each action creates a corresponding code generator. The code generator is used for generating corresponding Java code segments according to the Java syntax.
5. And transmitting the code generator corresponding to each action into a grammar translator according to the sequence, wherein an action queue is maintained in the grammar translator, so that the sequence of the actions in the action queue is consistent with the sequence of the actions in the original script file.
6. And (4) transmitting the grammar translator into a script generator to prepare for the final script file generation.
7. The script generator itself maintains a script template.
8. In the process of generating the script finally, the script generator can use an incoming grammar translator for translation, namely, a code translator in the grammar translator converts corresponding actions into a Java code file, and the result after the last translation is combined with a script template to generate the Java script file finally.
In the embodiment of the present specification, the antlr, the JavaCC, or the JFlex may be used in the process of performing lexical analysis and syntax parsing on the original script file, where the parsing effect of the antlr4 is relatively good, and the parsing may be performed on a relatively complex syntax, for example: loop, branch, nest, etc.
The embodiment of the specification automatically converts the original script file into the script file of other programming languages after lexical and grammatical analysis, improves the development efficiency and the reusability of the script file, realizes the process of converting the whole script into the file, realizes the flow and modular design, properly decomposes each flow link, and only needs to be properly adapted in the links related to change if the grammar of the original script changes, thereby being flexible, convenient and easy to expand.
In the present specification, each embodiment of the method is described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. The relevant points can be obtained by referring to the partial description of the method embodiment.
Based on the script generation processing method, one or more embodiments of the present specification further provide an apparatus for script generation processing. The system may include devices (including distributed systems), software (applications), modules, components, servers, clients, etc. that use the methods described in embodiments of the present specification in conjunction with hardware where necessary to implement the apparatus. Based on the same innovative conception, embodiments of the present specification provide an apparatus as described in the following embodiments. Since the implementation scheme of the apparatus for solving the problem is similar to that of the method, the specific apparatus implementation in the embodiment of the present specification may refer to the implementation of the foregoing method, and repeated details are not repeated. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Specifically, fig. 3 is a schematic block diagram of an embodiment of a script generation processing apparatus provided in this specification, and as shown in fig. 3, the script generation processing apparatus provided in this specification may include:
a syntax parsing module 31, configured to perform syntax parsing on an original script file to obtain a syntax tree list of the original script file;
the action analysis module 32 is configured to analyze the syntax trees in the syntax tree list to obtain an action corresponding to each syntax tree;
a code conversion module 33, configured to convert, by using a code generator, the action corresponding to each syntax tree into a code file in a specified programming language;
and the script generating module 34 is configured to generate an object script file according to the script template corresponding to the specified programming language and the code file.
The script generation processing device provided by the embodiment of the present specification analyzes an original script file, generates a code file of a specified programming language based on a syntactic structure obtained by the analysis, and directly generates a target script file that can be used by the specified programming language by combining a pre-configured script template, without separately compiling the script file, thereby improving the development efficiency and the reuse rate of the script file. Meanwhile, when the original script file is analyzed, each flow link is properly decomposed, if the grammar of the original script file is changed, only the corresponding analysis link needs to be adjusted, the script generation link is flexible, and the applicability is wide.
In some embodiments of the present specification, the transcoding module is specifically configured to:
acquiring an action type corresponding to each syntax tree;
determining a code generator of the action corresponding to each syntax tree according to the action type corresponding to each syntax tree;
and converting the action corresponding to each syntax tree into a code file of a specified programming language by using the code generator.
In the embodiment of the specification, a code generator is created for each action in advance, and the actions in the analyzed original script file can be directly converted into corresponding code files without writing the script files.
It should be noted that the above-mentioned apparatus may also include other embodiments according to the description of the corresponding method embodiment. The specific implementation manner may refer to the description of the above corresponding method embodiment, and is not described in detail herein.
An embodiment of the present specification further provides a script generation processing apparatus, including: at least one processor and a memory for storing processor-executable instructions, the processor implementing the generation processing method of the above embodiment when executing the instructions, such as:
parsing an original script file to obtain a syntax tree list of the original script file;
analyzing the syntax trees in the syntax tree list to obtain actions corresponding to each syntax tree;
converting the action corresponding to each syntax tree into a code file of a specified programming language by using a code generator;
and generating a target script file according to the script template corresponding to the specified programming language and the code file.
Fig. 4 is a schematic structural diagram of a script generation processing system in an embodiment of this specification, and as shown in fig. 4, an embodiment of this specification further provides a script generation processing system, including: grammar parser, grammar viewer, code generator, grammar translator, script generator, among them:
the grammar parser is used for parsing the original script file to generate a grammar tree list;
the grammar viewer is used for carrying out grammar analysis on each grammar tree in the grammar tree list and converting each grammar tree into a corresponding action;
the code generator is used for converting the actions converted by the grammar viewer into code files corresponding to a specified programming language, wherein each action corresponds to one code generator;
the code generators transmit the code files generated by the code generators to the script generators according to the sequence of actions in the original script file;
and the script generator is used for generating a target script file according to the code file sent by the grammar translator and the script template corresponding to the specified programming language.
The working process of the script generation processing system may refer to the record of the embodiment corresponding to fig. 2, and is not described herein again.
It should be noted that the above description of the apparatus and system according to the method embodiments may also include other embodiments. The specific implementation manner may refer to the description of the related method embodiment, and is not described in detail herein.
The script generation processing apparatus provided in the present specification can be applied to various data analysis processing systems. The system or server or terminal or device may be a single server, or may include a server cluster, a system (including a distributed system), software (applications), actual operating devices, logical gate devices, quantum computers, and the like, which use one or more of the methods or one or more embodiments of the present disclosure, and terminal devices in combination with necessary hardware implementations. The system for checking for discrepancies may comprise at least one processor and a memory storing computer-executable instructions that, when executed by the processor, implement the steps of the method of any one or more of the embodiments described above.
The method embodiments provided by the embodiments of the present specification can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking the example of running on a server, fig. 5 is a block diagram of a hardware configuration of a script generation processing server in an embodiment of the present specification, and the computer terminal may be the script generation processing server or the script generation processing apparatus in the foregoing embodiment. As shown in fig. 5, the server 10 may include one or more (only one shown) processors 100 (the processors 100 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a non-volatile memory 200 for storing data, and a transmission module 300 for communication functions. It will be understood by those skilled in the art that the structure shown in fig. 5 is only an illustration and is not intended to limit the structure of the electronic device. For example, the server 10 may also include more or fewer components than shown in FIG. 5, and may also include other processing hardware, such as a database or multi-level cache, a GPU, or have a different configuration than shown in FIG. 5, for example.
The non-volatile memory 200 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the script generation processing method in the embodiments of the present specification, and the processor 100 executes various functional applications and resource data updates by executing the software programs and modules stored in the non-volatile memory 200. Non-volatile memory 200 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the non-volatile memory 200 may further include memory located remotely from the processor 100, which may be connected to a computer terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, office-to-network, mobile communication networks, and combinations thereof.
The transmission module 300 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission module 300 includes a Network adapter (NIC) that can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission module 300 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The foregoing description of specific embodiments has been presented for purposes of illustration and description. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The method or apparatus provided in this specification and described in the foregoing embodiments may implement service logic through a computer program and record the service logic on a storage medium, where the storage medium may be read and executed by a computer, and implement the effects of the solutions described in the embodiments of this specification, such as:
parsing an original script file to obtain a syntax tree list of the original script file;
analyzing the syntax trees in the syntax tree list to obtain actions corresponding to each syntax tree;
converting the action corresponding to each syntax tree into a code file of a specified programming language by using a code generator;
and generating a target script file according to the script template corresponding to the specified programming language and the code file.
The storage medium may include a physical device for storing information, and typically, the information is digitized and then stored using an electrical, magnetic, or optical media. The storage medium may include: devices that store information using electrical energy, such as various types of memory, e.g., RAM, ROM, etc.; devices that store information using magnetic energy, such as hard disks, floppy disks, tapes, core memories, bubble memories, and usb disks; devices that store information optically, such as CDs or DVDs. Of course, there are other ways of storing media that can be read, such as quantum memory, graphene memory, and so forth.
The script generation processing method or apparatus provided in the embodiments of the present specification may be implemented in a computer by a processor executing corresponding program instructions, for example, implemented in a PC end using a c + + language of a windows operating system, implemented in a linux system, or implemented in an intelligent terminal using android, iOS system programming languages, implemented in processing logic based on a quantum computer, or the like.
It should be noted that descriptions of the apparatus, the computer storage medium, and the system described above according to the related method embodiments may also include other embodiments, and specific implementations may refer to descriptions of corresponding method embodiments, which are not described in detail herein.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the hardware + program class embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to only the partial description of the method embodiment.
The embodiments of the present description are not limited to what must be consistent with industry communications standards, standard computer resource data updating and data storage rules, or what is described in one or more embodiments of the present description. Certain industry standards, or implementations modified slightly from those described using custom modes or examples, may also achieve the same, equivalent, or similar, or other, contemplated implementations of the above-described examples. The embodiments using the modified or transformed data acquisition, storage, judgment, processing and the like can still fall within the scope of the alternative embodiments of the embodiments in this specification.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium that stores computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, apparatuses, modules or units described in the above embodiments may be specifically implemented by a computer chip or an entity, or implemented by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Although one or more embodiments of the present description provide method operational steps as described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive approaches. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of sequences, and does not represent a unique order of performance. When the device or the end product in practice executes, it can execute sequentially or in parallel according to the method shown in the embodiment or the figures (for example, in the environment of parallel processors or multi-thread processing, even in the environment of distributed resource data update). The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, article, or apparatus that comprises the recited elements is not excluded. The terms first, second, etc. are used to denote names, but not any particular order.
For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, when implementing one or more of the present description, the functions of each module may be implemented in one or more software and/or hardware, or a module implementing the same function may be implemented by a combination of multiple sub-modules or sub-units, etc. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable resource data updating apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable resource data updating apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable resource data update apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable resource data update apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
As will be appreciated by one skilled in the art, one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
One or more embodiments of the specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification can also be practiced in distributed computing environments where tasks are performed by remote devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, and the relevant points can be referred to only part of the description of the method embodiments. In the description of the specification, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the specification. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Moreover, various embodiments or examples and features of various embodiments or examples described in this specification can be combined and combined by one skilled in the art without being mutually inconsistent.
The above description is merely exemplary of one or more embodiments of the present disclosure and is not intended to limit the scope of one or more embodiments of the present disclosure. Various modifications and alterations to one or more embodiments described herein will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of the present specification should be included in the scope of the claims.

Claims (10)

1. A script generation processing method, the method comprising:
parsing the grammar of an original script file to obtain a grammar tree list of the original script file, wherein the grammar tree list comprises a plurality of grammar trees, and each grammar tree is a grammar structure corresponding to each action of a user on a device terminal in the original script file;
analyzing the syntax trees in the syntax tree list to obtain actions corresponding to each syntax tree;
converting the action corresponding to each syntax tree into a code file of a specified programming language by using a code generator; wherein each action corresponds to a code generator;
and generating a target script file according to the script template corresponding to the specified programming language and the code file.
2. The method of claim 1, wherein converting the corresponding action of each syntax tree into a code file in a specified programming language using a code generator comprises:
acquiring an action type corresponding to each syntax tree;
determining a code generator of the action corresponding to each syntax tree according to the action type corresponding to each syntax tree;
and converting the action corresponding to each syntax tree into a code file of a specified programming language by using the code generator.
3. The method of claim 1, wherein said converting the corresponding actions of each syntax tree into a code file in a specified programming language using a code generator comprises:
sequentially adding the code generators corresponding to all the actions into an action queue according to the sequence of all the actions in the original script file;
each code generator sequentially converts the corresponding actions into code files of a specified programming language according to the sequence in the action queue.
4. The method of claim 1, further comprising:
pre-creating code generators and script templates corresponding to different programming languages;
the converting the action corresponding to each syntax tree into a code file of a specified programming language includes:
selecting a code generator of a corresponding type according to the specified programming language;
and converting the action corresponding to each syntax tree into a code file of a specified programming language by using the selected code generator.
5. The method of claim 4, wherein generating the target script file according to the script template corresponding to the specified programming language and the code file comprises:
selecting a corresponding script template according to the specified programming language;
and adding the code file into the selected script template to generate the target script file.
6. The method of claim 1, prior to parsing the original script file, the method further comprising:
and generating the original script file according to the operation record of the user on the equipment terminal.
7. A script generation processing apparatus comprising:
the grammar parsing module is used for parsing an original script file to obtain a grammar tree list of the original script file, wherein the grammar tree list comprises a plurality of grammar trees, and each grammar tree is a grammar structure corresponding to each action of a user on a device terminal in the original script file;
the action analysis module is used for analyzing the syntax trees in the syntax tree list to obtain actions corresponding to each syntax tree;
the code conversion module is used for converting the action corresponding to each syntax tree into a code file of a specified programming language by using a code generator; wherein each action corresponds to a code generator;
and the script generation module is used for generating a target script file according to the script template corresponding to the specified programming language and the code file.
8. The apparatus of claim 7, the transcoding module to be specifically configured to:
acquiring an action type corresponding to each syntax tree;
determining a code generator of the action corresponding to each syntax tree according to the action type corresponding to each syntax tree;
and converting the action corresponding to each syntax tree into a code file of a specified programming language by using the code generator.
9. A script generation processing apparatus comprising: at least one processor and a memory for storing processor-executable instructions, the processor implementing the method of any one of claims 1-6 when executing the instructions.
10. A script generation processing system comprising: grammar parser, grammar viewer, code generator, grammar translator, script generator, among them:
the grammar parser is used for parsing the grammar of the original script file to generate a grammar tree list, the grammar tree list comprises a plurality of grammar trees, and each grammar tree is a grammar structure corresponding to each action of a user on the equipment terminal in the original script file;
the grammar viewer is used for carrying out grammar analysis on each grammar tree in the grammar tree list and converting each grammar tree into a corresponding action;
the code generator is used for converting the actions converted by the grammar viewer into code files corresponding to a specified programming language, wherein each action corresponds to one code generator;
the code generators transmit the code files generated by the code generators to the script generators according to the sequence of actions in the original script file;
and the script generator is used for generating a target script file according to the code file sent by the grammar translator and the script template corresponding to the specified programming language.
CN202011208798.0A 2020-11-03 2020-11-03 Script generation processing method, device, equipment and system Active CN112269566B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011208798.0A CN112269566B (en) 2020-11-03 2020-11-03 Script generation processing method, device, equipment and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011208798.0A CN112269566B (en) 2020-11-03 2020-11-03 Script generation processing method, device, equipment and system

Publications (2)

Publication Number Publication Date
CN112269566A CN112269566A (en) 2021-01-26
CN112269566B true CN112269566B (en) 2022-09-02

Family

ID=74344529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011208798.0A Active CN112269566B (en) 2020-11-03 2020-11-03 Script generation processing method, device, equipment and system

Country Status (1)

Country Link
CN (1) CN112269566B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113158613B (en) * 2021-04-02 2022-08-12 上海国微思尔芯技术股份有限公司 Method and device for converting hypergraph structure into RTL (real time language) level HDL (high density description language) file
CN115390852A (en) * 2022-08-26 2022-11-25 支付宝(杭州)信息技术有限公司 Method and device for generating uniform abstract syntax tree and program analysis

Family Cites Families (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3230467B2 (en) * 1997-09-25 2001-11-19 日本電気株式会社 GDMO translator, GDMO translation method, and recording medium recording GDMO translator program
JP2000242485A (en) * 1999-02-24 2000-09-08 Nec Corp System and method for supporting programming language translation program development and recording medium
FR2812479B1 (en) * 2000-07-28 2003-01-31 Airsys Atm S A UNIVERSAL COMPUTER CODE GENERATOR
AU2012201466B2 (en) * 2005-06-27 2014-07-03 Csc Technology Singapore Pte Ltd Code Transformation
US7937684B2 (en) * 2006-06-15 2011-05-03 Research In Motion Limited System and method for enabling assisted visual development of incoming message handling operations for applications on a communication device
CN101261579A (en) * 2007-03-08 2008-09-10 青牛(北京)技术有限公司 Method for accomplishing VBScript language trans-platform uses
US8762962B2 (en) * 2008-06-16 2014-06-24 Beek Fund B.V. L.L.C. Methods and apparatus for automatic translation of a computer program language code
CN102156655B (en) * 2011-05-05 2014-04-02 北京大学深圳研究生院 Senior language code generation method and generator
CN102508669A (en) * 2011-11-14 2012-06-20 浙江鸿程计算机系统有限公司 Automatic program code generating method
CN102929680B (en) * 2012-10-19 2016-03-02 普华基础软件股份有限公司 TTCN-3 script is converted to a method for Java source code, device and system
CN107450899B (en) * 2016-06-01 2022-04-26 深圳市信锐网科技术有限公司 Method and device for generating terminal control script
CN106843858B (en) * 2016-12-30 2020-06-09 南京大学 Method for generating Spark code by converting primitive
CN107273117B (en) * 2017-05-25 2021-04-09 土巴兔集团股份有限公司 Programming-friendly agile code automatic generation system
CN108595171B (en) * 2018-04-27 2021-08-10 广州视源电子科技股份有限公司 Object model generation method, device, equipment and storage medium
CN108762764A (en) * 2018-06-05 2018-11-06 中国平安人寿保险股份有限公司 Code automatic generation method, device, computer equipment and storage medium
CN109597618B (en) * 2018-10-23 2020-06-23 深圳微迅信息科技有限公司 Program development method, program development device, computer device, and storage medium
CN111241801A (en) * 2018-11-29 2020-06-05 北京京东尚科信息技术有限公司 File generation method, device, equipment and computer readable storage medium
CN110647329A (en) * 2019-08-13 2020-01-03 平安科技(深圳)有限公司 Code obfuscation method, apparatus, computer device and storage medium
CN110825384A (en) * 2019-10-28 2020-02-21 国电南瑞科技股份有限公司 ST language compiling method, system and compiler based on LLVM
CN110928549B (en) * 2019-11-19 2023-03-21 北京明略软件系统有限公司 Method and device for re-editing front-end script program
CN110908640B (en) * 2019-11-26 2022-06-07 京东科技控股股份有限公司 Method for realizing service function and script engine
CN111506314A (en) * 2020-04-08 2020-08-07 网易(杭州)网络有限公司 Project development method, device, server and medium
CN111580799A (en) * 2020-04-09 2020-08-25 深圳壹账通智能科技有限公司 Domain specific language script assembling method and system

Also Published As

Publication number Publication date
CN112269566A (en) 2021-01-26

Similar Documents

Publication Publication Date Title
CN111708539B (en) Application program code conversion method and device, electronic equipment and storage medium
CN108628947B (en) Business rule matching processing method, device and processing equipment
US11334692B2 (en) Extracting a knowledge graph from program source code
US8762963B2 (en) Translation of programming code
WO2014153478A1 (en) Detecting serialization scheme used in software applications
CN111736840A (en) Compiling method and running method of applet, storage medium and electronic equipment
CN112269566B (en) Script generation processing method, device, equipment and system
CN101185116A (en) Using strong data types to express speech recognition grammars in software programs
CN115981791A (en) System interaction method, device, equipment and storage medium
US9886251B2 (en) Optimized compiling of a template function
CN110333867B (en) Multiparty secure computing data processing method, device and system
US9405652B2 (en) Regular expression support in instrumentation languages using kernel-mode executable code
CN110362792B (en) Method and device for converting RN file into applet file and conversion equipment
CN110007922B (en) Artificial intelligence-based graphical source code compiling method, device and equipment
CN113296759B (en) User interface processing method, user interface processing system, device and storage medium
CN115390852A (en) Method and device for generating uniform abstract syntax tree and program analysis
CN113312025A (en) Component library generation method and device, storage medium and electronic equipment
KR101670726B1 (en) Method for code conversion using debugging information of intermediate language code, apparatus and computer-readable recording medium with program therefor
CN117075912B (en) Method for program language conversion, compiling method and related equipment
CN117591104B (en) Model generation method and device, electronic equipment and storage medium
CN109814869B (en) Analysis method and system applied to robot and computer readable storage medium
CN117215561A (en) Code generation method and device and electronic equipment
CN110018816B (en) Virtual machine control system based on C/C + + compiling system and control method thereof
CN113946338A (en) C language compiling method and device based on RINSIM simulation platform
CN116339740A (en) Compiling method and device of RiscV MCU

Legal Events

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