Programming language conversion method and system, computer equipment and readable storage medium

By parsing and converting instruction list language codes and using intermediate variables to simulate running status, the conversion from instruction list language to structured text language is realized, compatibility issues between PLC programming languages ​​are solved, and seamless transplantation of PLC programs is achieved.

CN118626090APending Publication Date: 2024-09-10BEIJING WANWANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410836831.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

The existing PLC programming language conversion technology cannot realize the conversion from the instruction list language to the structured text language, making it difficult to transplant programs between different PLC devices.

Method used

By obtaining the code to be converted in the instruction list language text, parsing and determining the instructions and operands, outputting the corresponding structured text language assembly based on the conversion function, using intermediate variables to simulate the running status of the instruction list language, and realizing the instruction list language to structure Text language conversion.

Benefits of technology

It achieves seamless conversion from instruction list language to structured text language, maintains the consistency of running results, and solves the compatibility problem between PLC programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626090A
    Figure CN118626090A
Patent Text Reader

Abstract

The invention provides a programming language conversion method and system, computer equipment and a readable storage medium. The configuration method comprises the steps of obtaining a to-be-converted code in an instruction list language text, analyzing the to-be-converted code, and determining a first instruction and a first operand; and determining a first conversion function based on the first instruction, and outputting a first program set corresponding to the logic of the first instruction based on a first operand and / or a first intermediate variable through the first conversion function, or outputting the first program set based on the logic of the first instruction through the first conversion function. Wherein the programming language of the first program set is a structured text language, and the first intermediate variable is used for simulating the memory space when the instruction list language runs. By means of the method, conversion from the instruction list language to the structured text language can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of soft PLC technology, and in particular to a programming language conversion method and system, a computer device, and a readable storage medium. Background Art

[0002] In the early days of PLC (Programmable Logic Controller) programming, different electrical equipment providers had their own PLC programming language specifications. This caused great difficulties in the PLC program migration between different manufacturers' equipment. In order to solve this difficulty, the International Electrotechnical Commission promulgated the international standard IEC61131-3 for PLC programming. This standard unified the specifications of five PLC programming languages ​​(ladder diagram, function block diagram, sequential function table diagram, structured text and instruction table language), thus proposing a solution to the problem of PLC program migration between different devices.

[0003] In order to meet the needs of different PLC programmers and adapt to different PLC application scenarios, the five types of languages ​​in IEC61131-3 have different characteristics. Among them, the ladder diagram language originates from the electrical system logic control diagram. The function block diagram originates from the signal processing field. The sequential function table diagram is used to describe the process, function and characteristics of the sequential function system. The instruction list language is similar to the assembly language and is a relatively low-level language, while the structured text language is a higher-level text language.

[0004] Based on the basic characteristics of different languages, there are some conversions between PLC languages, such as the conversion from ladder diagram to structured text language, the conversion from sequential function table diagram to structured text language, etc., but the conversion from instruction list language to structured text language cannot be realized. Therefore, realizing the conversion from instruction list language to structured text language is an urgent problem to be solved. Summary of the invention

[0005] Based on this, the present application provides a programming language conversion method and system, a computer device and a readable storage medium to solve the above technical problems.

[0006] A programming language conversion method, comprising: Obtaining the code to be converted in the instruction table language text, parsing the code to be converted, and determining the first instruction and the first operand; Determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function; The programming language of the first program set is a structured text language, and the first intermediate variable is used to simulate the memory space when the instruction list language is running.

[0007] In one embodiment, the steps of obtaining the code to be converted in the instruction table language text, parsing the code to be converted, and determining the first instruction and the first operand include: A first program segment in the instruction table language text is obtained, and the first program segment is parsed line by line to determine the first instruction and the first operand corresponding to each line of the code to be converted.

[0008] In one embodiment, the programming language conversion method further includes: Obtaining a second program segment in the instruction table language text, analyzing and determining whether the second program segment and the first program segment belong to the same program block; In response to the second program segment and the first program segment belonging to the same program block, the first intermediate variable is reused when parsing the second program segment line by line.

[0009] In one embodiment, the programming language conversion method further includes: Analyze and determine whether the first instruction corresponding to the current code line to be converted is a block call instruction; In response to the first instruction being a block call instruction, continuing to parse the first program segment line by line, and determining the second operand based on the parameter passing statement; A second conversion function is determined based on the block call instruction, and a second program set corresponding to the block call instruction is output based on the second operand through the second conversion function, wherein the programming language of the second program set is a structured text language.

[0010] In one embodiment, in response to the first instruction being a block call instruction, the step of continuing to parse the first program segment line by line and determining the second operand based on the parameter passing statement includes: In response to the first instruction being a block call instruction, continuing to parse the first program segment line by line, and determining whether to end the parsing based on the parameter transfer statement; If the code behavior to be converted is identified as a parameter passing statement when parsing the first program segment line by line, then continue parsing the first program segment line by line; If the code behavior to be converted is identified as a non-parameter passing statement when parsing the first program segment line by line, the parsing is terminated and the second operand is determined.

[0011] In one embodiment, the programming language conversion method further includes: Analyze and determine whether the first instruction corresponding to the current code line to be converted is a label instruction; In response to the first instruction being a label instruction, determining a third conversion function based on the label instruction, and outputting a third program set corresponding to the logic of the label instruction based on the first intermediate variable and the second intermediate variable through the third conversion function; The programming language of the third program set is a structured text language, and the second intermediate variable is used to store current data of the first intermediate variable.

[0012] In one embodiment, the step of determining the first conversion function based on the first instruction includes: The identification information of the first instruction is obtained, and a first conversion function corresponding to the first instruction in the matching mapping table is matched based on the identification information.

[0013] A programming language conversion system, the conversion system comprising: A parsing unit, used for obtaining the code to be converted in the instruction table language text, and parsing the code to be converted to determine the first instruction and the first operand; a conversion unit connected to the parsing unit, configured to determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function; The programming language of the first program set is a structured text language, and the first intermediate variable is used to simulate the memory space when the instruction list language is running.

[0014] A computer device comprises: a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any method in the above embodiments when executing the computer program.

[0015] A computer-readable storage medium stores a computer program, which implements the steps of any method in the above embodiments when executed by a processor.

[0016] Compared with the traditional technology, the above-mentioned programming language conversion method and system, computer device and readable storage medium. The programming language conversion method first obtains the code to be converted in the instruction table language text, and parses the code to be converted to determine the first instruction and the first operand; then determines the first conversion function based on the first instruction, and outputs the first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or outputs the first program set based on the logic of the first instruction through the first conversion function; wherein, the programming language of the first program set is a structured text language, and the first intermediate variable is used to simulate the memory space when the instruction table language is running. The present application adopts the above-mentioned method, simulates the real state of the instruction table language when running through the first intermediate variable, keeps the register and status bit data consistent with the real running time, and outputs a structured text language (i.e., the first program set) that conforms to the logic of the instruction table language and the running result is completely consistent with the running result of the instruction table language, thereby realizing the conversion from the instruction table language to the structured text language. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0018] Figure 1 A first flow chart of a programming language conversion method provided in one embodiment of the present application; Figure 2 A second flow chart of a programming language conversion method provided in an embodiment of the present application; Figure 3 A third flow chart of a programming language conversion method provided in one embodiment of the present application; Figure 4 A structural block diagram of a programming language conversion system provided by another embodiment of the present application; Figure 5 This is a diagram of the internal structure of a computer device provided in accordance with another embodiment of the present application.

[0019] Description of reference numerals: 10. Programming language conversion system; 100. Parsing unit; 200. Conversion unit. DETAILED DESCRIPTION

[0020] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0021] The serial numbers assigned to the components herein, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning. The "connection" and "coupling" mentioned in this application, unless otherwise specified, include direct and indirect connections (couplings). In the description of this application, it should be understood that the terms "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", etc. indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing this application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on this application.

[0022] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be an intermediate element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be an intermediate element at the same time.

[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0024] See also Figure 1 and Figure 2 , an embodiment of the present application provides a programming language conversion method. The programming language conversion method includes: S102: Obtain the code to be converted in the instruction table language text, and parse the code to be converted to determine the first instruction and the first operand.

[0025] In some embodiments, the instruction table language includes STL (Statement List) language and IL (Instruction List) language. Taking STL language as an example, STL language is a text-based programming language, and STL language text is usually divided into several program segments. Each program segment may contain one or more lines of statements, and each line can only specify one STL instruction. A single STL instruction or an STL instruction with one or more operands constitutes a line of STL statements. Each statement represents a CPU instruction. The CPU will execute CPU instructions from top to bottom. In some embodiments, an STL instruction may contain one or more operands to specify the specific operation object of the instruction.

[0026] In some embodiments, the code to be converted in the instruction table language text can be obtained through the virtual machine object, and the code to be converted can be parsed to determine the first instruction and the first operand. Specifically, each code segment in the instruction table language text can be read through the virtual machine object, and each line of the code to be converted in each code segment can be parsed, and the first instruction and the first operand corresponding to each line of the code to be converted can be determined. In some embodiments, each line of the code to be converted can be parsed in a split manner and decomposed into the first instruction and the first operand.

[0027] In some embodiments, the virtual machine object obtains the code to be converted in any manner. For example, the code to be converted can be directly input into the virtual machine object, or an instruction table language text can be input into the virtual machine object, and then the virtual machine object obtains the code to be converted from the input instruction table language text. The specific manner in which the virtual machine object obtains the code to be converted can be selected according to actual needs.

[0028] S104: Determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function. The programming language of the first program set is a structured text language. The first intermediate variable is used to simulate the memory space when the instruction table language is running. In some embodiments, the first intermediate variable includes one or more intermediate sub-variables. In some embodiments, the structured text language includes ST (Struct Text) language and SCL (Structured control language).

[0029] In some embodiments, a first conversion function may be determined based on a first instruction through a virtual machine object, and a first program set corresponding to the logic of the first instruction may be output through the first conversion function based on a first operand and / or a first intermediate variable, or the first program set may be output based on the logic of the first instruction through the first conversion function. In some embodiments, the virtual machine object determines the first conversion function corresponding to the first instruction based on the instruction name corresponding to the first instruction. Specifically, the virtual machine object matches the conversion function corresponding to the instruction name (i.e., the first conversion function) from the conversion function library based on the instruction name.

[0030] In some embodiments, after determining the first conversion function, the first conversion function may output a first program set corresponding to the logic of the first instruction based on the first operand and the first intermediate variable. The first conversion function may also output a first program set corresponding to the logic of the first instruction based on the first operand or the first intermediate variable. It should be noted that the programming language of the first program set is a structured text language.

[0031] In some embodiments, taking the processing of the "floating point number division" instruction as an example, first, by including pre-declared unsigned intermediate sub-variables AU1 and AU2 (that is, the first intermediate variable includes two intermediate sub-variables AU1 and AU2) to simulate the virtual machine object of the real register memory to process the L1 instruction (that is, the first instruction is the L1 instruction), and according to the instruction name of the L1 instruction, the conversion function X1 (that is, the first conversion function) corresponding to the instruction name is matched from the conversion function library. Then, the conversion function X1 outputs the first program set corresponding to the logic of the L1 instruction based on operand 1 (that is, the operand corresponding to the L1 instruction) and the intermediate sub-variable AU1. Specifically, the conversion function X1 simulates the register memory loading of operand 1 by copying operand 1 to the intermediate sub-variable AU1. That is, the conversion function X1 copies operand 1 to the intermediate sub-variable AU1 by memory copying. In this way, the conversion function X1 outputs the first program set corresponding to the logic of the L1 instruction based on operand 1 and the intermediate sub-variable AU1. It not only ensures that the program running results before and after the conversion process are completely consistent, but also realizes the conversion of L1 instructions from instruction list language to structured text language.

[0032] When the virtual machine object processes the L2 instruction, the conversion function X2 (i.e., the first conversion function) corresponding to the instruction name is matched from the conversion function library according to the instruction name of the L2 instruction, and then the conversion function X2 outputs the first program set corresponding to the logic of the L2 instruction based on operand 2 (i.e., the operand corresponding to the L2 instruction), intermediate sub-variables AU1 and AU2. Specifically, the conversion function X2 can first copy the operand 1 corresponding to the intermediate sub-variable AU1 to the intermediate sub-variable AU2, that is, the conversion function X2 copies the memory value corresponding to the intermediate sub-variable AU1 to the intermediate sub-variable AU2 by memory copying. Then, the conversion function X2 copies the operand 2 to the intermediate sub-variable AU1 by memory copying. In this way, the conversion function X2 outputs the first program set corresponding to the logic of the L2 instruction based on operand 2 and intermediate sub-variables AU1 and AU2. Not only does it ensure that the program running results before and after the L2 instruction conversion process are completely consistent, but it also realizes the conversion of the L2 instruction from the instruction table language to the structured text language.

[0033] When the virtual machine object processes the floating point division ( / R) instruction, it first declares the operand sub-variable 1, operand sub-variable 2, and calculation result sub-variable of the floating point type. Then, according to the instruction name of the floating point division ( / R) instruction, the conversion function Y (i.e., the first conversion function) corresponding to the instruction name is matched from the conversion function library. Through the conversion function Y, the memory value corresponding to the intermediate sub-variable AU1 is copied to the operand sub-variable 1, and the memory value corresponding to the intermediate sub-variable AU2 is copied to the operand sub-variable 2. Then, the operand sub-variables are divided and the calculation result is assigned to the calculation result sub-variable. Finally, the calculation result subvariable is copied to the intermediate subvariable AU1 memory (that is, the calculation result is copied to the intermediate subvariable AU1), and the first program set corresponding to the logic of the L2 instruction is output based on the intermediate subvariables AU1 and AU2, operand subvariable 1, operand subvariable 2, and calculation result subvariable through the conversion function Y, thereby completing the conversion process of the floating-point division instruction from the instruction list language to the structured text language, ensuring that the program running results before and after the conversion process are completely consistent.

[0034] In some embodiments, the virtual machine object can also output the first program set based on the logic of the first instruction through the first conversion function. Specifically, when the virtual machine object processes the block end instruction (that is, the first instruction is the block end instruction), the conversion function Z (that is, the first conversion function) corresponding to the instruction name is matched from the conversion function library according to the instruction name of the block end instruction. Then the conversion function Z outputs the first program set corresponding to the logic of the block end instruction. Thus, the conversion function Z outputs the corresponding first program set based on the block end instruction. Similarly, when the virtual machine object processes the unconditional block end instruction (that is, the first instruction is the unconditional block end instruction), the conversion method is the same as that of the block end instruction, which will not be repeated here. Using the above method, the real state of the instruction table language when running is simulated through the first intermediate variable, the register and status bit data are kept consistent with the real run time, and the structured text language (that is, the first program set) that conforms to the logic of the instruction table language and the running result is completely consistent with the running result of the instruction table language is output, thereby realizing the conversion from the instruction table language to the structured text language.

[0035] In some embodiments, the steps of obtaining the code to be converted in the instruction table language text, parsing the code to be converted, and determining the first instruction and the first operand include: obtaining the first program segment in the instruction table language text, parsing the first program segment line by line, and determining the first instruction and the first operand corresponding to each line of the code to be converted. Specifically, the first program segment in the instruction table language text can be obtained through the virtual machine object, and the first program segment can be parsed line by line to determine the first instruction and the first operand corresponding to each line of the code to be converted.

[0036] In some embodiments, Figure 3 As shown, the programming language conversion method also includes: obtaining a second program segment in the instruction table language text, analyzing and determining whether the second program segment and the first program segment belong to the same program block. In response to the second program segment and the first program segment belonging to the same program block, the first intermediate variable is reused when parsing the second program segment line by line.

[0037] In some embodiments, when the virtual machine object obtains the second program segment in the instruction table language text, it first analyzes and determines whether the second program segment and the first program segment belong to the same program block. Specifically, it can be determined whether the second program segment and the first program segment belong to the same program block based on the program logic relationship between the two. In response to the second program segment and the first program segment belonging to the same program block, the first intermediate variable when parsing the first program segment is reused when parsing the second program segment line by line.

[0038] During the process of converting the first program segment by the virtual machine object, the virtual machine object will pre-declare the first intermediate variable corresponding to the first program segment. When it is confirmed that the second program segment and the first program segment belong to the same program block, during the process of converting the second program segment by the virtual machine object, the virtual machine object and the first intermediate variable corresponding to the first program segment will be directly reused without replacing the virtual machine object and declaring a new intermediate variable again. By adopting the above method, the same intermediate variable in the virtual machine object can be reused for different program segments under the same program block, thereby ensuring that when the program segment conversion process is in progress, the state of the first intermediate variable is consistent with that at the end of the previous program segment.

[0039] In some embodiments, it is assumed that the program block contains program segment No. 1, program segment No. 2, and program segment No. 3. Among them, the programming languages ​​of program segment No. 1 and program segment No. 3 are both instruction table languages, and the programming language of program segment No. 2 is ladder diagram language (LD). First, program segment No. 1 is converted through virtual machine object 1, and the first intermediate variable is pre-declared before the conversion. After the conversion of program segment No. 1 is completed, program segment No. 2 is converted. Since the programming language of program segment No. 2 is different from the programming language of program segment No. 1, program segment No. 2 is converted through virtual machine object 2, and the specific conversion logic can be implemented by traditional methods. When converting program segment No. 3, since the programming languages ​​of program segment No. 3 and program segment No. 1 are both instruction table languages, and program segment No. 3 and program segment No. 1 belong to the same program block. Therefore, virtual machine object 1 can be directly reused to convert program segment No. 3, and the first intermediate variable corresponding to the conversion of program segment No. 1 can be reused at the same time. In this way, the same intermediate variable in the same virtual machine object can be reused for different program segments under the same program block, thereby ensuring that when the program segment conversion is processed, the state of the first intermediate variable is consistent with the end of the previous program segment, ensuring that the program logic in the mixed programming program block containing other languages ​​can be maintained across program segments, thereby avoiding errors in the conversion process.

[0040] In some embodiments, the programming language conversion method further includes: analyzing and determining whether the first instruction corresponding to the current line of code to be converted is a block call instruction. In response to the first instruction being a block call instruction, the first program segment is continuously parsed line by line, and the second operand is determined based on the parameter transfer statement. A second conversion function is determined based on the block call instruction, and a second program set corresponding to the block call instruction is output based on the second operand through the second conversion function. The programming language of the second program set is a structured text language.

[0041] In some embodiments, after the current line of code to be converted is parsed through the virtual machine object, further analysis is performed to determine whether the first instruction corresponding to the current line of code to be converted is a block call instruction. The specific analysis method can adopt a traditional method, which is not repeated here. Among them, the current line of code to be converted belongs to a line of code in the first program segment. When it is confirmed that the first instruction is a block call instruction, the first program segment is continued to be parsed line by line, and the second operand is determined based on the parameter transfer statement.

[0042] Specifically, in response to the first instruction being a block call instruction, the first program segment continues to be parsed line by line, and it is determined whether to end the parsing based on the parameter passing statement. If the code behavior to be converted is identified as a parameter passing statement when the first program segment is parsed line by line, the first program segment continues to be parsed line by line. If the code behavior to be converted is identified as a non-parameter passing statement when the first program segment is parsed line by line, the parsing is ended and the second operand is determined. In other words, when the code behavior to be converted is identified as a parameter passing statement during parsing, the first program segment continues to be parsed line by line until the code behavior to be converted is identified as a non-parameter passing statement, then the parsing is ended, and all the data parsed before the end of the parsing is determined as the second operand.

[0043] In some embodiments, the virtual machine object can match the second conversion function corresponding to the instruction name from the conversion function library based on the instruction name of the block call instruction. Then, the second conversion function outputs the second program set corresponding to the block call instruction based on the second operand. Thus, the second conversion function outputs the second program set corresponding to the logic of the block call instruction based on the second operand. Not only does it ensure that the program running results before and after the conversion process are completely consistent, but it also realizes the conversion of the block call instruction from the instruction table language to the structured text language.

[0044] In some embodiments, the programming language conversion method further includes: analyzing and determining whether the first instruction corresponding to the current line of code to be converted is a label instruction. In response to the first instruction being a label instruction, a third conversion function is determined based on the label instruction, and a third program set corresponding to the logic of the label instruction is output based on the first intermediate variable and the second intermediate variable through the third conversion function. The programming language of the third program set is a structured text language. The second intermediate variable is used to store the current data of the first intermediate variable. In some embodiments, the current data refers to the data before the jump label instruction.

[0045] In some embodiments, the first instruction corresponding to the current line of code to be converted can be analyzed and determined by the virtual machine object whether it is a label instruction. Specifically, the virtual machine object can determine whether the first instruction is a label instruction according to the label instruction syntax. After determining that the first instruction is a label instruction, the second intermediate variable can be further declared, and the third conversion function corresponding to the instruction name can be matched from the conversion function library based on the instruction name of the label instruction. Then the third conversion function outputs the third program set corresponding to the label instruction based on the first intermediate variable and the second intermediate variable. Thus, the third program set corresponding to the logic of the label instruction is outputted by the third conversion function based on the first intermediate variable and the second intermediate variable. Not only does it ensure that the program running results before and after the conversion process are completely consistent, but it also realizes the conversion of the label instruction from the instruction table language to the structured text language. At the same time, it further confirms the previous program set corresponding to the logic output of the instruction based on the conversion function through the conversion function.

[0046] In some embodiments, the step of determining the first conversion function based on the first instruction includes: obtaining identification information of the first instruction, and matching the first conversion function corresponding to the first instruction in the mapping table based on the identification information. In some embodiments, the identification information includes but is not limited to the instruction name, address information, label, etc.

[0047] In some embodiments, after obtaining each program segment in the instruction table language text, each program segment needs to be formatted to form a program segment in a standard format. Specific formatting includes but is not limited to processing blank lines, processing comments, splitting multiple lines by colon, classifying spaces, etc.

[0048] In some embodiments, after outputting each assembly, the virtual machine object needs to format each assembly and then output a standard ST program segment corresponding to the program segment in the instruction list language text.

[0049] See also Figure 4 Another embodiment of the present application provides a programming language conversion system 10. The programming language conversion system 10 includes: a parsing unit 100 and a conversion unit 200. The parsing unit 100 is used to obtain the code to be converted in the instruction table language text, and parse the code to be converted to determine the first instruction and the first operand. The conversion unit 200 is connected to the parsing unit 100. The conversion unit 200 is used to determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function. Among them, the programming language of the first program set is a structured text language. The first intermediate variable is used to simulate the memory space when the instruction table language is running.

[0050] In some embodiments, the specific structure of the parsing unit 100 is not limited, as long as it has the function of obtaining the code to be converted in the instruction table language text, parsing the code to be converted, and determining the first instruction and the first operand. For example, the parsing unit 100 can be a compiler or a processor. For how the parsing unit 100 obtains the code to be converted in the instruction table language text, parses the code to be converted, and determines the first instruction and the first operand, please refer to the above embodiment, which will not be repeated here.

[0051] In some embodiments, the specific structure of the conversion unit 200 is not limited, as long as it has the function of determining the first conversion function based on the first instruction, and outputting the first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or outputting the first program set based on the logic of the first instruction through the first conversion function. For example, the conversion unit 200 can be a compiler or an integrated processor, etc. For the implementation of how the conversion unit 200 determines the first conversion function based on the first instruction, and outputs the first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or outputs the first program set based on the logic of the first instruction through the first conversion function, please refer to the above embodiments, which will not be repeated here.

[0052] In this embodiment, the above-mentioned programming language conversion system 10 can realize the real state of the instruction table language during runtime based on the first intermediate variable simulation, keep the register and status bit data consistent with the real runtime, and output a structured text language (i.e., the first program set) that conforms to the logic of the instruction table language and whose running results are completely consistent with the running results of the instruction table language, thereby realizing the conversion from instruction table language to structured text language.

[0053] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a programming language conversion method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0054] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0055] See also Figure 5 Another embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the programming language conversion method in any one of the above embodiments are implemented.

[0056] In one embodiment, when the processor executes the computer program, the following steps are implemented: S102: Obtain the code to be converted in the instruction table language text, and parse the code to be converted to determine the first instruction and the first operand; S104: Determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function; wherein the programming language of the first program set is a structured text language, and the first intermediate variable is used to simulate the memory space when the instruction table language is running.

[0057] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the programming language conversion method in any one of the above embodiments are implemented.

[0058] In one embodiment, the computer program, when executed by a processor, implements the following steps: S102: Obtain the code to be converted in the instruction table language text, and parse the code to be converted to determine the first instruction and the first operand; S104: Determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on the first operand and / or the first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function; wherein the programming language of the first program set is a structured text language, and the first intermediate variable is used to simulate the memory space when the instruction table language is running.

[0059] The above-mentioned computer device and computer-readable storage medium, through steps 102 to S104, can enable the programming language conversion method to simulate the actual state of the instruction table language during runtime based on the first intermediate variable, keep the register and status bit data consistent with the actual runtime, and output a structured text language (i.e., the first program set) that conforms to the logic of the instruction table language and whose running results are completely consistent with the running results of the instruction table language, thereby realizing the conversion from the instruction table language to the structured text language.

[0060] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0061] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0062] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A programming language conversion method, characterized in that: The method comprises: Obtaining the code to be converted in the instruction table language text, and parsing the code to be converted to determine the first instruction and the first operand; Determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on a first operand and / or a first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function; The programming language of the first assembly is a structured text language, and the first intermediate variable is used to simulate the memory space when the instruction list language is running.

2. The programming language conversion method according to claim 1, characterized in that: The step of obtaining the code to be converted in the instruction table language text, parsing the code to be converted, and determining the first instruction and the first operand includes: A first program segment in the instruction table language text is obtained, and the first program segment is parsed line by line to determine the first instruction and the first operand corresponding to each line of code to be converted.

3. The programming language conversion method according to claim 2, characterized in that: The method further comprises: Obtaining a second program segment in the instruction table language text, analyzing and determining whether the second program segment and the first program segment belong to the same program block; In response to the second program segment and the first program segment belonging to the same program block, the first intermediate variable is reused when parsing the second program segment line by line.

4. The programming language conversion method according to claim 2, characterized in that: The method further comprises: Analyze and determine whether the first instruction corresponding to the current code line to be converted is a block call instruction; In response to the first instruction being a block call instruction, continuing to parse the first program segment line by line, and determining a second operand based on a parameter passing statement; A second conversion function is determined based on the block call instruction, and a second program set corresponding to the block call instruction is output based on the second operand through the second conversion function, wherein a programming language of the second program set is a structured text language.

5. The programming language conversion method according to claim 4, characterized in that: In response to the first instruction being a block call instruction, the step of continuing to parse the first program segment line by line and determining the second operand based on the parameter passing statement includes: In response to the first instruction being the block call instruction, continuing to parse the first program segment line by line, and determining whether to end the parsing based on the parameter transfer statement; If the code behavior to be converted is identified as the parameter passing statement when parsing the first program segment line by line, continue parsing the first program segment line by line; If it is identified that the code behavior to be converted is not the parameter passing statement when parsing the first program segment line by line, the parsing is terminated and the second operand is determined.

6. The programming language conversion method according to claim 2, characterized in that: The method further comprises: Analyze and determine whether the first instruction corresponding to the current code line to be converted is a label instruction; In response to the first instruction being a label instruction, determining a third conversion function based on the label instruction, and outputting a third program set corresponding to the logic of the label instruction based on the first intermediate variable and the second intermediate variable through the third conversion function; The programming language of the third program set is a structured text language, and the second intermediate variable is used to store current data of the first intermediate variable.

7. The programming language conversion method according to claim 1, characterized in that: The step of determining the first conversion function based on the first instruction comprises: Acquire identification information of the first instruction, and match a first conversion function corresponding to the first instruction in a mapping table based on the identification information.

8. A programming language conversion system, characterized in that: The conversion system comprises: A parsing unit, used for obtaining the code to be converted in the instruction table language text, and parsing the code to be converted to determine the first instruction and the first operand; a conversion unit connected to the parsing unit, configured to determine a first conversion function based on the first instruction, and output a first program set corresponding to the logic of the first instruction based on a first operand and / or a first intermediate variable through the first conversion function, or output the first program set based on the logic of the first instruction through the first conversion function; The programming language of the first assembly is a structured text language, and the first intermediate variable is used to simulate the memory space when the instruction list language is running.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.