Method, system and device for compiling and explaining high-level language of functional block and medium

By defining compilation rules and using a hash table to store the mapping relationship between keywords and opcodes, binary opcode files are generated, solving the problem of low compilation and interpretation efficiency of high-level languages ​​in DCS control systems and realizing the efficient execution of complex control strategies.

CN121349461APending Publication Date: 2026-01-16NANJING GUODIAN NANZI WEIMEIDE AUTOMATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511342336.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-19
Publication Date
2026-01-16

AI Technical Summary

Technical Problem

In existing DCS control systems, the compilation and interpretation efficiency of high-level languages ​​is low, making it impossible to achieve efficient execution of complex control strategies.

Method used

Define compilation rules to map keywords of the high-level language to opcodes, compile variables into operands, and use a hash table to store the mapping relationship between keywords and opcodes to generate a binary opcode file, which is then executed by the configuration interpreter.

Benefits of technology

It improves compilation and interpretation speed, enables efficient execution of complex control strategies, and has good passability and correctness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121349461A_ABST
    Figure CN121349461A_ABST
Patent Text Reader

Abstract

The invention discloses a compiling and explaining method, system and device for a high-level language of a functional block and a medium, and belongs to the technical field of industrial control systems.The compiling and explaining method comprises the steps that compiling rules are defined; reading a high-level language program file, and generating a binary operation code file according to the compiling rule; downloading the binary operation code file to a configuration interpreter for execution; wherein the step of generating the binary operation code file comprises the substeps of mapping a keyword of a high-level language into an operation code, and compiling a variable into an operand; according to the compiling and explaining method, system and device for the high-level language of the functional block and the medium, a set of compiling and explaining method is self-defined for compiling and explaining the high-level program language of a functional block combination, and program codes can be compiled into binary operation codes; the key codes and the operation codes are presented in the form of a hash table, so that the compiling and explaining speed is increased; the method has good trafficability, correctness and high efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial control system technology, specifically relating to a compilation and interpretation method, system, device, and medium for a high-level language of function blocks. Background Technology

[0002] DCS control systems are widely used in various industrial settings. The implementation of control strategies is one of their most critical functions. Control systems provide built-in, basic control logic, including mathematical algorithms and decision modules, to construct control strategies. However, for more complex control problems, the built-in control logic alone is insufficient to support the implementation of complex control strategies. Furthermore, the low compilation and interpretation efficiency of high-level languages ​​hinders the efficient execution of complex control strategies. Therefore, it is necessary to develop a new method, system, device, and medium for compiling and interpreting high-level functional block languages ​​to address these existing problems. Summary of the Invention

[0003] The purpose of this invention is to provide a method, system, device, and medium for compiling and interpreting high-level languages ​​with function blocks, so as to solve the problem of low compilation and interpretation efficiency of high-level languages ​​and the inability to achieve efficient execution of complex control strategies.

[0004] To achieve the above objectives, the present invention provides the following technical solution: a method for compiling and interpreting a function block high-level language, comprising: Define compilation rules; Read the high-level language program file and generate a binary opcode file according to the compilation rules; Download the binary opcode file to the configuration interpreter for execution; The generation of the binary opcode file includes: High-level language keywords are mapped to opcodes, and variables are compiled into operands.

[0005] Preferably, the compilation rules are stored in a hash table; including: the mapping relationship between keywords and opcodes, and the correspondence between functions and compilation results.

[0006] Preferably, the compilation rules include: Identifiers consist of letters, numbers, and underscores; The variable declaration syntax is Public [identifier] As [type], and supported types include Long, Float, Double, String, Bool, Complex, and Quality; Control structures include IF-ELSE-ELSEIF-ENDIF conditional statements.

[0007] Preferably, the hash table is used to look up the opcode corresponding to the keyword during the compilation phase.

[0008] Preferably, the hash table is also used to enable access to variables and invocation of functions during the interpretation phase.

[0009] Preferably, the format for generating the binary opcode file includes: [Line number address][Opcode][Operand].

[0010] Preferably, downloading the binary opcode file to the configuration interpreter for execution includes: An interpreter converts a binary stream into executable control logic.

[0011] The present invention also provides a compiler and interpreter system for a function block high-level language, the system comprising: Hash management module: Used to configure compilation rules, establish a mapping between keywords and opcodes, and accelerate the compilation and interpretation process; Compiler module: Reads the program file, compiles keywords into opcodes and parameters into operands, and generates a binary opcode file; Interpretation module: Interprets the binary opcode file into specific keywords and parameters.

[0012] The present invention further provides a compiler and interpreter for a function block high-level language, the apparatus comprising: Memory for storing non-transitory computer-readable instructions; and A processor for executing the computer-readable instructions such that, when the computer-readable instructions are executed by the processor, the compiler-interpretation method of the function block high-level language is implemented.

[0013] The present invention also provides a computer-readable storage medium for storing non-transitory computer-readable instructions, which, when executed by a computer, cause the computer to perform the compilation and interpretation method of the function block high-level language.

[0014] The technical effects and advantages of this invention are as follows: The compilation and interpretation method, system, device and medium for high-level programming languages ​​with function blocks define a set of compilation and interpretation methods for high-level programming languages ​​with function block combinations. It can compile program code into binary opcodes and present key code and opcodes in the form of hash tables, thereby improving compilation and interpretation speed. It has good passability, correctness and high efficiency. Attached Figure Description

[0015] Figure 1 This is a schematic diagram illustrating the compilation of a high-level language using the method of this invention; Figure 2This is a schematic diagram illustrating the high-level language explanation of the method of this invention; Figure 3 This is a diagram showing the correspondence between the compilation and interpretation rules of the high-level language in the method of this invention. Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] This invention provides, for example Figure 1 , Figure 2 The method for compiling and interpreting a high-level language with function blocks, as shown, includes: Define compilation rules to map keywords of the high-level language to opcodes and compile variables into operands; convert opcodes and operands into binary streams according to the format: [line number address][opcode][operand]; The compilation rules include: Identifiers consist of letters, numbers, and underscores. Consecutive underscores are prohibited and cannot be at the beginning or end of an identifier. In other words, identifiers can only be composed of a subset of the 26 English letters, 10 numbers, and underscores. Consecutive underscores are prohibited, and underscores cannot appear at the beginning or end of an identifier. They are not case-sensitive. They should be intuitive, easy to read, and self-explanatory. Some keywords, such as IF and ELSE, cannot be used as identifiers. The variable declaration syntax is Public [identifier] As [type], and supported types include Long, Float, Double, String, Bool, Complex, and Quality; For example, using the syntax Public A0 As Float, variable types include Long, Float, Double, String, Bool, Complex, Quality, etc. Constant representation: Constants can be represented in hexadecimal or decimal. For example, A0 = 10; Control structures include: IF-ELSE-ELSEIF-ENDIF conditional statements; IF ELSE ELSEIF ENDIF conditional compilation; Supported formats are: IF identifier Execution statement ELSE or ELSE IF identifier Execution statement ENDIF.

[0018] Function definitions: MAX, MIN, JUMP, AND, OR, SIN, COS, OUT, etc. Program comments: Single-line comments " / / ".

[0019] Standardize the syntax and semantics of high-level scripting languages, including identifiers, variable / constant declarations, conditional statements, function definitions, etc.

[0020] Read high-level language program files, identify keywords and compile them into opcodes, compile variables into operands, and generate binary opcode files; The program reads high-level language program files, identifies keywords and compiles them into corresponding opcodes, compiles variables into operands, and generates a compiled file containing line number addresses, opcodes, and operands. For example, the variable declaration "Public A0 As Float" is compiled into "INIT-VAR-F 1", corresponding to the binary stream "0008 51 01" (where 0008 is the line number address, 51 is the opcode, and 1 is the operand). See compilation and interpretation rules. Figure 3 The correspondence between the syntax and opcodes of the compiled high-level language; Taking `Public A0 As Float` as an example, it compiles to `INIT-VAR-F 1`, where `INIT-VAR-F` is the opcode corresponding to the initialized variable, and `1` is the corresponding operand A0. The opcode and operand can be translated into a binary stream 0008 51 01, where 0008 is the line number address used for debugging breakpoints and jumps; 51 is the opcode; and 1 is the operand. The interpretation process involves translating the binary stream 0008 5101 back into `Public A0 As Float`.

[0021] During compilation and interpretation, a hash table is used to store the mapping relationship between keywords and opcodes, and the correspondence between functions and compilation results; the hash table is used for: Compilation phase: Quickly find the opcode corresponding to the keyword; Interpretation phase: speeds up variable access and function calls; A hash table structure is introduced to store the mapping relationship between keywords, opcodes, and operands. Since the lookup complexity of a hash table is O(1), compared to O(n) for linear lookup, it can significantly improve the speed of accessing variables and functions during compilation and interpretation, reduce runtime overhead, and is especially suitable for scenarios with complex functions and a large number of variables.

[0022] The method for accelerating compilation and interpretation: A hash table is a data structure that stores data in key-value pairs in a mapping relationship, enabling fast insertion and lookup operations. It retrieves the corresponding value based on the key. When dealing with complex functions, a single function may compile into multiple opcodes and operands. If there are many such complex functions, compilation efficiency will decrease. Introducing a hash table can be considered. (See reference...) Figure 3 The table mapping directly associates the compilation result of each function with the function, improving compilation efficiency.

[0023] Download the compiled file to the configuration interpreter for execution; Interpreting and executing compiled files: The interpreter is used to debug the compiled file. Once it is error-free, it is downloaded to the configuration for execution. The interpreter converts the binary stream into executable control logic.

[0024] The present invention also provides a compiler and interpreter system for a function block high-level language, the system comprising: Hash management module: Used to configure compilation rules, establish a mapping between keywords and opcodes, and accelerate the compilation and interpretation process; Compiler module: Reads the program file, compiles keywords into opcodes and parameters into operands, and generates a binary opcode file; Interpretation module: Interprets the binary opcode file into specific keywords and parameters.

[0025] The present invention further provides a compiler and interpreter for a function block high-level language, the apparatus comprising: Memory for storing non-transitory computer-readable instructions; and A processor for executing the computer-readable instructions such that, when the computer-readable instructions are executed by the processor, the compiler-interpretation method of the function block high-level language is implemented.

[0026] The present invention also provides a computer-readable storage medium for storing non-transitory computer-readable instructions, which, when executed by a computer, cause the computer to perform the compilation and interpretation method of the function block high-level language.

[0027] The technical effects and advantages of this invention are as follows: The compilation and interpretation method, system, device and medium for high-level programming languages ​​with function blocks define a set of compilation and interpretation methods for high-level programming languages ​​with function block combinations. It can compile program code into binary opcodes and present key code and opcodes in the form of hash tables, thereby improving compilation and interpretation speed. It has good passability, correctness and high efficiency.

[0028] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0029] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0030] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0031] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0032] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0033] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

[0034] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method of compiling and interpreting a high-level language of a function block, characterized by: The system comprises: defining a compiling rule; reading a high-level language program file, and generating a binary operation code file according to the compiling rule; downloading the binary operation code file to a configuration interpreter for execution; wherein the generating of the binary operation code file comprises: mapping keywords of the high-level language into operation codes, and compiling variables into operation numbers.

2. The method for compiling and interpreting a high-level language of a function block according to claim 1, characterized in that: The compiling rule is stored in a hash table, and comprises: a mapping relationship between keywords and operation codes, and a corresponding relationship between functions and compiling results.

3. The method for compiling and interpreting a high-level language of a function block according to claim 1, wherein: The compiling rule comprises: an identifier is composed of letters, numbers and underscores; a variable declaration syntax is Public [identifier] As [type], and supported types include Long, Float, Double, String, Bool, Complex and Quality; a control structure comprises an IF-ELSE-ELSEIF-ENDIF conditional statement.

4. The method of claim 2, wherein: The hash table is used to find corresponding operation codes of keywords in a compiling stage.

5. The method of claim 2, wherein: The hash table is also used to access variables and call functions in an interpreting stage.

6. The method of claim 1, wherein: The format of the generated binary operation code file comprises: [a line number address][an operation code][an operation number].

7. The compilation and interpretation method for a function block high-level language according to claim 1, characterized in that: The downloading of the binary operation code file to the configuration interpreter for execution comprises: converting a binary stream into executable control logic by the interpreter.

8. A system for compiling and interpreting a high-level language of functional blocks, characterized in that: The system comprises: a hash management module, configured to configure the compiling rule, establish a mapping relationship between keywords and operation codes, and accelerate a compiling and interpreting process; a compiling module, configured to read a program file, compile keywords into operation codes, and compile parameters into operation numbers, and generate a binary operation code file; an interpreting module, configured to interpret the binary operation code file into specific keywords and parameters.

9. A compiler and interpreter for a function block-based high-level language, characterized in that: The apparatus comprises: a memory, configured to store non-transient computer readable instructions; and a processor, configured to run the computer readable instructions, so that the computer readable instructions are executed by the processor to implement a function block high-level language compiling and interpreting method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A non-transient computer readable instruction storage, configured to, when the non-transient computer readable instruction is executed by a computer, enable the computer to execute the function block high-level language compiling and interpreting method according to any one of claims 1 to 7.