CN114816425B - Method and system for converting an automation language program into a LUA language program - Google Patents

Method and system for converting an automation language program into a LUA language program Download PDF

Info

Publication number
CN114816425B
CN114816425B CN202210451766.6A CN202210451766A CN114816425B CN 114816425 B CN114816425 B CN 114816425B CN 202210451766 A CN202210451766 A CN 202210451766A CN 114816425 B CN114816425 B CN 114816425B
Authority
CN
China
Prior art keywords
program
language program
node type
node
automation
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
CN202210451766.6A
Other languages
Chinese (zh)
Other versions
CN114816425A (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.)
Zhuhai Auto Vision Technology Co ltd
Original Assignee
Zhuhai Auto Vision 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 Zhuhai Auto Vision Technology Co ltd filed Critical Zhuhai Auto Vision Technology Co ltd
Priority to CN202210451766.6A priority Critical patent/CN114816425B/en
Publication of CN114816425A publication Critical patent/CN114816425A/en
Application granted granted Critical
Publication of CN114816425B publication Critical patent/CN114816425B/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/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The technical scheme of the invention provides a method, a system, electronic equipment and a storage medium for converting an automatic language program into an LUA language program, wherein the method comprises the following steps: responding to the program conversion request, analyzing the automatic language program, and determining the node type contained in the automatic language program and the field information corresponding to the node type; generating a syntax tree according to the node type and the field information corresponding to the node type; selecting a corresponding generation template for the node type contained in the grammar tree; and generating the LUA language program for the root node of the syntax tree by combining the generation template and the field information. By adopting the technical scheme, the automatic language program can be quickly executed, the control of the automatic control algorithm on the automatic equipment is realized, and the automatic control algorithm can be quickly developed and then can be implemented on the ground.

Description

Method and system for converting an automation language program into a LUA language program
Technical Field
The invention relates to the field of automatic control algorithm development, in particular to a method, a system, electronic equipment and a storage medium for converting an automatic language program into an LUA language program.
Background
The automatic language program is a configuration text specially designed for an automatic control algorithm and is compiled by a language wlan suitable for the automatic control algorithm.
The automation control algorithm is executed by a computer system of the automation device control system and is responsible for implementing a complete control logic consisting of a large number of processing tasks. Because the wlang language is internally provided with an expression method for key functions (serial, concurrent, synchronous control, time sequence control and the like) required by the automatic control algorithm, the language has the advantages of being simpler and more convenient than a universal language in the field of automatic control algorithm development, and the development and debugging work of the automatic control algorithm can be accelerated.
However, in order to implement an automation control algorithm on a computer system, it is necessary to convert an automation language program into a program written in a script language, and the LUA language is the fastest to execute, so that it is necessary to implement conversion from the automation language program to the LUA language program in order to ensure that the automation language program is executed in a fast interpretation manner.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The embodiment of the invention provides a method, a system, electronic equipment and a storage medium for converting an automatic language program into an LUA language program, so that the automatic language program can be quickly executed, the control of an automatic control algorithm on the automatic equipment is realized, and the automatic control algorithm can be quickly developed and then can be implemented on the ground.
In a first aspect, an embodiment of the present invention provides a method for converting an automation language program into an LUA language program, including:
responding to a program conversion request, analyzing an automation language program, and determining a node type contained in the automation language program and field information corresponding to the node type;
generating a syntax tree according to the node type and field information corresponding to the node type;
selecting a corresponding generation template for the node type contained in the grammar tree;
and generating the LUA language program for the root node of the syntax tree by combining the generation template and the field information.
In a second aspect, an embodiment of the present invention provides a system for converting an automation language program into an LUA language program, where the system includes:
the analysis module is used for responding to a program conversion request, analyzing an automatic language program and determining a node type contained in the automatic language program and field information corresponding to the node type; the storage module is used for generating a syntax tree according to the node type and the field information corresponding to the node type;
a selection module for selecting a corresponding generation template for the node type contained in the syntax tree;
and the generating module is used for generating the LUA language program for the root node of the syntax tree by combining the generating template and the field information.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes a processor, a memory, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, and the program is executed by the processor to implement the method for converting an automation language program into an LUA language program according to the first aspect.
In a fourth aspect, the present invention further provides a computer-readable storage medium, which is characterized in that a program instruction that is executable by a processor is stored, and the program instruction is used for executing the method for converting an automation language program into an LUA language program, which implements the first aspect.
The embodiment of the invention at least comprises the following beneficial effects: the method of converting an automation language program to a LUA language program in an embodiment is capable of converting an automation language wlan to a LUA language that is completely different and unrelated to wlan syntax. The functionality of the wlan language is macroscopic and the LUA is a universal scripting language, each macroscopic function in the wlan language can be implemented using the LUA language by generating a syntax tree for the wlan language, by creating a generation template in advance for each node type in the syntax tree, and by generating the LUA language program using the generation template and field information corresponding to the node type. Because much less code is written in the wlan language than in the LUA language for each macro function, the implementation of wlan language to LUA language conversion enables the rapid and simple development of automation control algorithms.
Drawings
Fig. 1 is a flowchart of a method for converting an automation language program into an LUA language program according to an embodiment of the present invention.
Fig. 2 is a schematic diagram of generating LUA language program fragments according to an embodiment of the present invention.
FIG. 3 is a diagram of a syntax tree according to an embodiment of the present invention.
Fig. 4 is a schematic diagram of a system for converting an automation language program into an LUA language program according to an embodiment of the present invention.
Fig. 5 is a structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be understood that if orientation descriptions are referred to in the specification and claims and the above drawings, such orientation or positional relationships as indicated by upper, lower, front, rear, left, right, etc., are based on the orientation or positional relationship shown in the drawings, only for convenience of description and simplicity of description, and do not indicate or imply that the device or element so referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus should not be construed as limiting the present invention.
It should be noted that at least one means one or more, a plurality of means two or more, and that larger, smaller, larger, etc. are understood as excluding the number, and that larger, smaller, etc. are understood as including the number. If there is a description that the first and second are for the purpose of distinguishing technical features, they are not to be interpreted as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
Referring to fig. 1, a flowchart of a method for converting an automation language program into an LUA language program according to an embodiment of the present invention includes, but is not limited to, the following steps:
step S100: and responding to the program conversion request, analyzing the automatic language program, and determining the node type contained in the automatic language program and the field information corresponding to the node type.
In this embodiment, to implement the automation operation of the device, software for controlling the device needs to be developed, and since the automation language wlan can be used to develop the control software simply and quickly, the automation language program of the software is written in wlan language first, and then converted into a script language program, i.e., LUA language program, which can be executed by the device. The automatic language program is characterized in that the automatic language program has node types divided according to functions, each node type corresponds to different types of fields and different numbers of fields, the value of each field is called field information, and as shown in table 1, the summary of the various node types and the fields contained in the various node types is shown. By parsing the automation language program, it can be determined which node types the program contains, which fields the node types correspond to, and the values of the individual fields, i.e. the field information.
Figure 79632DEST_PATH_IMAGE001
TABLE 1
Further, the step S100 may include, but is not limited to, the following steps:
step S101: and analyzing the automatic language program and determining the subprogram segments contained in the automatic language program.
As an example, in order to implement automatic operation and control of a wafer defect inspection apparatus, control software of the wafer defect inspection apparatus needs to be written, where the wafer defect inspection apparatus includes:
the three-dimensional motion platform is used for bearing the wafer to be tested and moving in the XYZ three directions;
the camera subsystem is used for taking a picture of the wafer and transmitting the picture to the central computer;
the focusing subsystem is used for taking charge of focusing the lens, and the action is driven by the central computer;
and the detection algorithm subsystem is used for being responsible for defect target detection and target number statistics.
The following is an automation language program written for the control software using an automation language, saved as demo.w:
move(“x”,100)//move(“y”,100)//move(“z”,10)
img= snap()
count= !inspect(img)
if count<T then
passed=1
then
passed=0
end
analyzing the above-mentioned automated language program demo.w, according to the function realized by each program statement, the program can be divided into four sub-program segments with different functions, which are:
subroutine segment 1: move ("x", 100)// move ("y", 100)// move ("z", 10);
subroutine segment 2: img = snap ();
subroutine segment 3: count =! instect (img);
subroutine segment 4: if count < T the past =1 the past =0 end;
the symbol "/" in the subroutine segment 1 indicates that three sentences are executed concurrently, that is, the three-dimensional motion table is controlled to start in three directions of XYZ simultaneously, the lens focusing of the focusing subsystem is controlled through the subroutine segment 2, the camera subsystem takes a picture of the wafer and transmits the picture to the central computer, and then the number of the defect targets is counted through the subroutine segment 3, wherein the symbol! "indicates that the task is assigned to a separate central processing unit CPU to run, and whether the wafer meets the standard is judged through the subroutine segment 4.
The task functions built in the wafer defect detection device called in the above procedure are respectively:
motion control function of motion stage: move (axix, position);
camera acquisition image function: snap ();
the detection algorithm function is as follows: the insert () returns the number of defect targets;
user-defined logic: and if the number of the defect targets is less than the threshold value (T), the product is qualified, otherwise, the product is unqualified.
Step S102: and analyzing the subprogram segment, and determining the node type contained in the subprogram segment and the field information corresponding to the node type.
As an example, by means of the preliminary analysis automation program demo.w, it can be determined that the node type contained therein has a program segment; further, referring to the node types in table 1, it can be determined that the node types corresponding to the sub-program segments 1 to 4 included in the program segment are: concurrent statements, assignment statements, and branches; still further, by analyzing the sub-program segments 1 to 4, the node types included in the four sub-program segments, and the field information corresponding to the various node types can be determined. Specifically, by referring to the node types in table 1, the node types and the field information corresponding to the node types included in the automation language program demo.w shown in table 2 can be obtained:
Figure 934456DEST_PATH_IMAGE002
TABLE 2
Step S200: and generating a syntax tree according to the node type and the field information corresponding to the node type.
In this embodiment, the syntax tree is a tree structure, and macro components and specific components of the program are recorded from the root node to the leaf nodes respectively.
Further, step S200 may include, but is not limited to, the following steps:
step S201: and storing the field information corresponding to the node type in a tree structure according to the node type.
As an example, as shown in fig. 3, a schematic diagram of a syntax tree generated according to a node type and field information corresponding to the node type in table 2 is specifically shown:
the node type of the root node is a program segment and is used for recording the composition of the whole automatic language program demo.w, and by comparing the field information corresponding to the program segment in the table 2, it can be known that the data structure recorded by the root node points to four subprogram segments respectively, and the node types corresponding to the four subprogram segments are respectively: the syntax tree comprises concurrent statements, assignment statements 1, assignment statements 2 and branches, wherein four sub-nodes of a root node in the syntax tree can respectively record the composition components of four sub-program segments.
According to the execution sequence of the subprogram segments, the node type of the first subprogram node is a concurrency statement, the node can record the composition of the subprogram segment 1, the field information corresponding to the concurrency statement in the table 2 is compared, it can be known that the data structure recorded by the node sequentially points to three tasks which are concurrently executed and have no return value, and the node types of the node are respectively corresponding to the task call 1, the task call 2 and the task call 3 in the table 2; the first child node can point to three child nodes with node types as assignment statements respectively, taking a first left sub-tree of the node from left to right as an example, the assignment statement node can point to two child nodes, the left child node is empty and represents that no variable needs to be assigned, the right child node records part of components of the subroutine segment 1, the node type of the right child node is task call 1, and by comparing field information corresponding to the task call 1 in the table 2, it can be known that the right child node records a symbol table, two items are in the symbol table, the first item has a symbol name of "taskanme", the right child node points to a left leaf child node recorded with a value of "move", the task name of the call is represented, the second item has a symbol name of "args", the right leaf child node recorded with values of "x" and "100" is represented, and the input parameters are represented; by analogy, the first child node may sequentially point to the second and third root nodes as subtrees of the assignment statement, and record other components of the program segment 1, and the leaf nodes record field information corresponding to the node types of the invocation 2 and the task invocation 3, respectively.
According to the execution sequence of the subroutine segments, the node type of the second sub-node is an assignment statement 1, the node can record the composition of a subroutine segment 2, a field corresponding to the assignment statement 1 in a comparison table 1 can be known, the field recorded by the node has a left value symbol name and a right value node, a field information corresponding to the assignment statement 1 in the comparison table 2 can be known, the assignment statement 1 node records a symbol table and has two items, the first item is a left value symbol name lv and points to a left leaf sub-node recorded with a value img, the second item is a right value node rv and points to a function call task node with a return value, the node type is a task call 4, the field information corresponding to the task call 4 in the comparison table 2 can be known, the task call 4 node records a symbol table and has two items, the first item is a task name taskanme and points to a left leaf sub-node recorded with a value snap and indicates that the called task name, the second item is an input parameter args and indicates that no input sub-leaf parameter points to an input parameter.
According to the execution sequence of the subroutine segments, the node type of the third sub-node is an assignment statement 2, the node can record the composition of the sub-routine segment 2, a field corresponding to the assignment statement 2 in a comparison table 1 can be known, the field recorded by the node has a left value symbol name and a right value node, a field information corresponding to the assignment statement 2 in the comparison table 2 can be known, the assignment statement 2 node records a symbol table and has two items, the first item is a left value symbol name lv and points to a left leaf sub-node recorded with a value count, the second item is a right value node rv and points to a function call task node with a return value, the node type is a task call 5, the field information corresponding to the task call 5 in the comparison table 2 can be known, the task call 5 node records a symbol table and has three items, the first item is an independent CPU mark CPU and points to a first leaf node recorded with a value yes, the second item is a task name taskana taskanmame, the second item points to a field information recorded with a value gpe, the first leaf node recorded with a leaf name and points to a second input parameter gct, and the input parameter of the input parameter gct is a leaf name of the input parameter gct.
According to the execution sequence of the sub-program segments, the node type of the fourth sub-node is a branch, the node can record the composition of the sub-program segment 4, the corresponding field of the branch in the table 1 is compared to know that the field recorded by the node has an arithmetic logic expression and a program segment, the corresponding field information of the branch in the table 2 is compared to know that the branch node records a symbol table and has three items, the first item is an arithmetic logic expression 'condition' and points to the first sub-node with a value 'count < T' recorded from left to right; the second item is a program segment 'stmt 1' and points to a second child node of which the node type is an assignment statement 3; the third item is a program segment 'stmt 2' and points to a third child node of which the node type is an assignment statement 4; by comparing the field information corresponding to the assignment statement 3 in the table 2, it can be known that the assignment statement 3 node records a symbol table and has two items, the first item is a left value symbol name "lv" and points to a left leaf child node recorded with a value "past", the second item is a right value node "rv" and points to a right leaf child node recorded with a value "1"; by comparing the field information corresponding to the assignment statement 4 in the table 2, it can be known that the assignment statement 4 node records a symbol table, and has two items, the first item is a left-valued symbol name "lv" and points to a left leaf child node recorded with a value "past", and the second item is a right-valued node "rv" and points to a right leaf child node recorded with a value "0".
Step S300: and selecting a corresponding generation template for the node type contained in the grammar tree.
In this embodiment, the generation template is a pre-written program fragment. As shown in table 3, the symbols of various node types in the corresponding generated templates are summarized; as shown in table 4, various node types and corresponding generated templates in this embodiment are summarized. By looking up various node types contained in the syntax tree from the table 4, the generation templates corresponding to the node types are determined.
Figure 448613DEST_PATH_IMAGE003
TABLE 3
Figure DEST_PATH_IMAGE005
TABLE 4
In some embodiments, step S300 may be preceded by:
and according to the grammatical relation between the automation language and the LUA language, creating a generation template corresponding to the node type for each node type in the automation language, wherein the generation template comprises a fixed program segment and a variable program segment.
In this embodiment, the variable program fragments are annotated in the generated template with special labels, e.g., two "$" are used to contain an identifier, such as: $ taskName $, where the taskName part may be replaced. The syntax of the wlan language used by the automation language program is as follows, the LUA language is a general script language and is not described here:
1 program segment
stmt1
stmt2
stmt n
stmt1, stmt2, stmtn represent different statements. The program segment is composed of a plurality of statements, and is separated by line breaks. The execution mode of the program segment is as follows: and the execution is started from stmt1, and after the execution is finished, stmt2 is executed, and the like.
2 task definition
task () stmts end
stmts is an arbitrary program segment.
3 task calling expression
a) task ( in )
b) ! task ( in )
task is the task name, which is user-defined, composed of English letters, and in is the name input by the task. Adding | before the task name indicates that the independent CPU is running, i.e., the task will be assigned to run by an independent CPU core.
4 assignment statement
var = expression
var is any custom symbol, and expression is any expression.
5 concurrent execution of statements
o1 = t1 ( a1 ) // o2 = t2 ( a2 )
Consists of a plurality of 'task call' assignment statements connected by double slashes. The 2 tasks are executed (concurrent) at the same time, and after all the tasks are executed, the statement is executed.
6 branches
if condition then stmt1 else stmt2 end
condition is an arithmetic logic expression, stmt1 and stmt2 are program segments, stmt1 is executed when condition is not zero, and stmt2 is executed otherwise.
7 cycles
while condition do stmt end
condition is an arithmetic logic expression, stmt is a program segment, and stmt is executed cyclically when condition is not zero.
8 arithmetic logic expression
The specific grammar is the same as the LUA language, but the participated in the operation can only be symbols and can not be task call. For example: a + b/2 is true and a + t1 (b) is false.
9 single quantity expression
Single constants or variables, such as: 10, x and var.
10 expression
The method is divided into 3 types: task calls, single quantity expressions, arithmetic logic expressions.
11 trigger signal statement
-> signal
The method is used in cooperation with the signal waiting statement for realizing a synchronization function between concurrent tasks, one task generates a signal by using the statement, and the other task executes the signal waiting statement to wait for the generation of the signal.
12 waiting signal
@ signal
The method is matched with a trigger signal statement for use and is used for realizing a synchronization function between concurrent tasks, one task executes the statement to wait for generation of a signal, and the other task generates the signal by using the trigger signal statement.
13 reset clock statement
reset clock
clock is a user-defined symbol. This statement creates and resets a clock variable clock.
14 wait for clock statement
@ clock > expression
clock is the clock name and expression is the arithmetic expression, representing time in milliseconds. And waiting when the clock is less than or equal to the expression.
Step S400: and generating the LUA language program for the root node of the syntax tree by combining the generation template and the field information.
In this embodiment, the root node represents the entire automation language program, and the LUA language program is generated for the root node, that is, the entire automation language program is converted into the root node type. The root node records a node list, and sequentially accesses the child nodes along the node path according to the child nodes pointed by the node list, so that the node types of the accessed nodes can be sequentially obtained. As shown in fig. 2, a schematic diagram of LUA program fragment generation using a generation template and field information is shown, where the generation template in fig. 2 corresponds to a node type of a root node, and a field value of the node is input by a user, that is, a right part of each expression in a column of field information in table 2. When the code is generated, the variable part is replaced with the entered text and the other part is copied directly to the target area.
As an example, the LUA language program of the syntax tree root node of the automation language level demo.w may be generated by step S400:
OBJECT={}
para(move, {“x”, 100}, move, {“y”, 100}, move{“z”, 10} )
img = snap()
_res =run( inspect, {img} )
res.wait()
count = _res.get()
wherein, OBJECT = { } indicates that the global variable table is empty.
In some embodiments, step S400 may be followed by:
creating a text storage area, wherein the text storage area comprises an initialization area and a code area;
the LUA language program is divided into a first program fragment and a second program fragment, the first program fragment is stored in the initialization area, and the second program fragment is stored in the code area.
The first program segment may be a program segment for initialization, and the second program segment may be a program segment other than the first program segment.
In this embodiment, the text storage area is used to store the generated LUA language program, and the text storage area may be a file in a computer or a memory of the computer, which is not limited herein and may be selected as needed.
The method for converting the automation language program into the LUA language program provided by the embodiment of the invention can further include:
when the node type is at least one of a trigger signal, a waiting signal, a reset clock and a waiting clock, creating a global object table to store field information corresponding to the node type;
and reading field information corresponding to the node type in the global object table when the LUA language program is generated for the root node of the syntax tree.
In this embodiment, the global object table of the automation language program is used to store the necessary internal objects. If the global object table is not empty, when the LUA language program is generated, the node type in the global object table needs to be read, a corresponding template is selected, and the LUA language statement corresponding to the content in the global object table is generated by combining the field information.
The method for converting the automation language program into the LUA language program provided by the embodiment of the invention can further include:
generating a syntax analysis program of the automation language program through a compiling tool;
and analyzing the automatic language program through a grammar analysis program to generate a grammar tree.
In this embodiment, a syntax parser wparser for parsing an automated language wlan is generated by using lex and yacc compiling tools, and the wlan language program is parsed by using the wparser to generate a syntax tree.
The embodiment of the invention at least comprises the following beneficial effects: an automated language wlan g can be converted to LUA language that is completely different and non-corresponding to wlan g syntax. The functionality of the wlan language is macroscopic and the LUA is a universal scripting language, each macroscopic function in the wlan language can be implemented using the LUA language by generating a syntax tree for the wlan language, by creating a generation template in advance for each node type in the syntax tree, and by generating the LUA language program using the generation template and field information corresponding to the node type. Because the code written by the wlan language is much less than that written by the LUA language for realizing each macro function, the realization of the conversion from the wlan language to the LUA language can enable the rapid and simple development of the automation control algorithm.
Referring to fig. 4, an embodiment of the present invention provides a system diagram for converting an automation language program into an LUA language program, including but not limited to:
the analysis module 401 is configured to analyze the automation language program in response to the program conversion request, and determine a node type and field information corresponding to the node type included in the automation language program;
a storage module 402, configured to generate a syntax tree according to the node type and field information corresponding to the node type;
a selecting module 403, configured to select a corresponding generating template for the node type included in the syntax tree;
and a generating module 404, configured to generate an LUA language program for a root node of the syntax tree in combination with the generating template and the field information.
An embodiment of the present invention provides an electronic device, as shown in fig. 5, the electronic device includes a memory 501 and a processor 502; a memory 501 for storing one or more computer programs; the processor 502 is configured to implement the method for converting the automation language program into the LUA language program according to the embodiment of the present invention when executing the program stored in the memory 501.
Embodiments of the present invention provide a computer-readable storage medium, which stores instructions that, when executed on a computer, cause the computer to perform a method for converting an automation language program into an LUA language program according to embodiments of the present invention.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to be performed in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optics, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), among others.
It should be noted that, in this document, 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, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related 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 electronic device and computer-readable storage medium embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (8)

1. A method for converting an automation language program to a LUA language program, comprising:
responding to a program conversion request, analyzing an automation language program, and determining a node type contained in the automation language program and field information corresponding to the node type, wherein the automation language program is provided with the node types divided according to functions, and the method specifically comprises the following steps: when the node type is at least one of a trigger signal, a waiting signal, a reset clock and a waiting clock, creating a global object to store the field information corresponding to the node type;
generating a syntax tree according to the node type and field information corresponding to the node type;
according to the grammatical relation between the automation language and the LUA language, aiming at each node type contained in the automation language, creating a generation template corresponding to the node type, wherein the generation template comprises a fixed program segment and a variable program segment, and annotating the variable program segment in the generation template by using a special mark;
selecting a corresponding generation template for the node type contained in the grammar tree;
generating an LUA language program for the root node of the syntax tree by combining the generation template and the field information, specifically comprising: and reading the field information corresponding to the node type in the global object.
2. The method of converting an automation language program into a LUA language program as claimed in claim 1, wherein said parsing the automation language program to determine the node type contained in the automation language program and the field information corresponding to the node type comprises:
analyzing the automatic language program, and determining a subprogram segment contained in the automatic language program;
and analyzing the subprogram segment, and determining the node type contained in the subprogram segment and the field information corresponding to the node type.
3. The method of converting an automation language program into a LUA language program as claimed in claim 1, wherein the generating a syntax tree based on the node type and the field information corresponding to the node type comprises:
and storing the field information corresponding to the node type in a tree structure according to the node type.
4. A method of converting an automation language program to a LUA language program as claimed in claim 1 further comprising, after generating the LUA language program for a root node of the syntax tree:
creating a text storage area, wherein the text storage area comprises an initialization area and a code area;
splitting the LUA language program into a first program fragment and a second program fragment, storing the first program fragment in the initialization area, and storing the second program fragment in the code area.
5. The method of converting an automation language program to a LUA language program as claimed in claim 1, further comprising:
generating a parser for the automation language program through a compilation tool;
and analyzing the automatic language program through the grammar analysis program to generate the grammar tree.
6. A system for converting an automation language program into an LUA language program, comprising:
the analysis module is configured to analyze an automation language program in response to a program conversion request, and determine a node type included in the automation language program and field information corresponding to the node type, where the automation language program has node types divided according to functions, and specifically includes: when the node type is at least one of a trigger signal, a waiting signal, a reset clock and a waiting clock, creating a global object to store the field information corresponding to the node type;
the storage module is used for generating a syntax tree according to the node type and the field information corresponding to the node type;
a selecting module, configured to create, according to a syntactic relation between the automation language and the LUA language, a generation template corresponding to each node type included in the automation language, where the generation template includes a fixed program segment and a variable program segment, annotates the variable program segment in the generation template with a special tag, and selects a corresponding generation template for the node type included in the syntax tree;
a generating module, configured to generate a LUA language program for a root node of the syntax tree in combination with the generating template and the field information, and specifically includes: and reading the field information corresponding to the node type in the global object.
7. An electronic device comprising a processor, a memory, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the method of converting an automation language program to a LUA language program as claimed in any one of claims 1 to 5.
8. A computer-readable storage medium, having stored thereon program instructions executable by a processor for performing the method of converting an automation language program into a LUA language program as claimed in any one of claims 1 to 5.
CN202210451766.6A 2022-04-27 2022-04-27 Method and system for converting an automation language program into a LUA language program Active CN114816425B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210451766.6A CN114816425B (en) 2022-04-27 2022-04-27 Method and system for converting an automation language program into a LUA language program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210451766.6A CN114816425B (en) 2022-04-27 2022-04-27 Method and system for converting an automation language program into a LUA language program

Publications (2)

Publication Number Publication Date
CN114816425A CN114816425A (en) 2022-07-29
CN114816425B true CN114816425B (en) 2023-03-24

Family

ID=82509538

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210451766.6A Active CN114816425B (en) 2022-04-27 2022-04-27 Method and system for converting an automation language program into a LUA language program

Country Status (1)

Country Link
CN (1) CN114816425B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104391730A (en) * 2014-08-03 2015-03-04 浙江网新恒天软件有限公司 Software source code language translation system and method
CN113504900A (en) * 2021-07-26 2021-10-15 中国工商银行股份有限公司 Programming language conversion method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130227533A1 (en) * 2008-11-06 2013-08-29 Albert Donald Tonkin Code transformation
US9645800B2 (en) * 2014-12-19 2017-05-09 Veracode, Inc. System and method for facilitating static analysis of software applications
CN108182069B (en) * 2017-12-28 2021-03-02 深圳市创梦天地科技股份有限公司 Program language conversion method, terminal device and computer readable medium
CN112015430B (en) * 2020-09-07 2024-08-16 平安国际智慧城市科技股份有限公司 JavaScript code translation method, device, computer equipment and storage medium
CN112363727A (en) * 2020-11-10 2021-02-12 中国平安人寿保险股份有限公司 JAVA conversion method and device of SQL (structured query language) code, computer equipment and storage medium
CN113791768B (en) * 2021-09-22 2023-04-14 海通证券股份有限公司 Code generation method and device, storage medium and terminal

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104391730A (en) * 2014-08-03 2015-03-04 浙江网新恒天软件有限公司 Software source code language translation system and method
CN113504900A (en) * 2021-07-26 2021-10-15 中国工商银行股份有限公司 Programming language conversion method and device

Also Published As

Publication number Publication date
CN114816425A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
CN106919434B (en) Code generation method and device
US8875110B2 (en) Code inspection executing system for performing a code inspection of ABAP source codes
US11579856B2 (en) Multi-chip compatible compiling method and device
US11675575B2 (en) Checking source code validity at time of code update
KR101106595B1 (en) Method and apparatus for automated testing for software program
US20110271250A1 (en) Software Development Tool
CN105743736B (en) Automated testing method and system
CN111736840A (en) Compiling method and running method of applet, storage medium and electronic equipment
CN109542412A (en) Interface message generation method, device, computer equipment and storage medium
US10303467B2 (en) Target typing-dependent combinatorial code analysis
JP2012063868A (en) Method to generate combined parser by combining language processing parsers, and its computer and computer program
CN107203535B (en) Information query method and device
CN111143228B (en) Test code generation method and device based on decision table method
CN115509514B (en) Front-end data simulation method, device, equipment and medium
US20210089284A1 (en) Method and system for using subroutine graphs for formal language processing
CN115639980A (en) Draggable front-end logic arrangement method and device for low-code platform
CN115796190B (en) Front-end internationalization multi-language conversion method and system based on vue and weback
US8776010B2 (en) Data type provider for a data store
CN114138281A (en) Compiling method, device, equipment and medium of software engineering
CN112286784B (en) Test case generation method, device, server and storage medium
CN111736812A (en) Document code execution method and device, computer equipment and storage medium
CN114791808A (en) Data flow graph generation method and device
CN112199261A (en) Application program performance analysis method and device and electronic equipment
CN118259906A (en) Multi-terminal page adaptation method, equipment and medium based on PaaS framework
CN114816425B (en) Method and system for converting an automation language program into a LUA language program

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