Software function implementation method, storage medium and computer equipment

By compiling the Chinese writing function nodes in the configuration software and generating computer-executable code, the problem of users needing to master specific programming languages is solved, and the convenience of Chinese programming and user experience is improved.

CN120371306APending Publication Date: 2025-07-25QINGDAO HAIER AIR CONDITIONING ELECTRONICS CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410669565.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

The writing of functional nodes in existing configuration software requires mastering specific programming languages, resulting in high professional requirements for users and affecting the user experience.

Method used

Provides a method to generate computer-executable code, including lexical analysis, grammatical analysis and semantic checking, by compiling functional nodes written in Chinese in configuration software, to realize software functions.

Benefits of technology

It reduces the difficulty of user programming, enables users to directly use Chinese programming, and improves user experience and system readability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371306A_ABST
    Figure CN120371306A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software function implementation, and particularly provides a software function implementation method, a storage medium and computer device.The method comprises the steps that a configuration program written through configuration software is compiled, and computer executable codes are obtained; wherein the configuration program comprises a plurality of predefined function nodes, and the plurality of predefined function nodes comprise at least one function node written in Chinese; and executing the computer executable code to realize a software function corresponding to the configuration program. According to the technical scheme provided by the invention, the user can utilize Chinese programming in the configuration software, so that the programming difficulty is greatly reduced, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of software function implementation, and specifically provides a software function implementation method, a storage medium, and a computer device. Background Art

[0002] Using configuration software, users can, in a way similar to "building blocks", complete the required software functions according to their own needs. For complex logical functions, they usually need to be implemented through programming function nodes in the configuration software, and users need to write their own code to implement the corresponding business logic.

[0003] In the related art, according to the type of configuration software, users need to master a specific programming language to complete the writing of function node code, which undoubtedly poses relatively high professional requirements on users and affects the user experience. Summary of the Invention

[0004] To solve the above technical problems, this application proposes a software function implementation method, a storage medium, and a computer device, which enable users to program in Chinese in the configuration software, thereby greatly reducing the programming difficulty and improving the user experience.

[0005] To achieve the above object, the technical solution of this application is implemented as follows:

[0006] In a first aspect, this application provides a software function implementation method, and the method includes:

[0007] Compiling a configuration program written with a configuration software to obtain computer-executable code; wherein, the configuration program includes a plurality of predefined function nodes, and the plurality of predefined function nodes include at least one function node written in Chinese;

[0008] Executing the computer-executable code to implement the software function corresponding to the configuration program.

[0009] In some embodiments, the compiling the configuration program written with a configuration software to obtain computer-executable code includes:

[0010] Performing a first compilation on each function node written in Chinese respectively to obtain program code corresponding to each function node written in Chinese; wherein, the program code is written in a predetermined programming language;

[0011] Performing a second compilation on the function nodes other than the function nodes written in Chinese among the plurality of predefined function nodes, and the program code corresponding to each function node written in Chinese, to obtain the computer-executable code.

[0012] In some embodiments, function nodes among the multiple predefined function nodes other than the function nodes written in Chinese are written in the predetermined programming language.

[0013] In some embodiments, the first compilation is separately performed on each of the function nodes written in Chinese to obtain program codes corresponding to each of the function nodes written in Chinese, including:

[0014] For each of the function nodes written in Chinese, the following operations are performed:

[0015] Read the Chinese source code in this function node;

[0016] Convert the Chinese source code into an abstract syntax tree;

[0017] Based on the abstract syntax tree, obtain the program code corresponding to this function node.

[0018] In some embodiments, the conversion of the Chinese source code into an abstract syntax tree includes:

[0019] Perform lexical analysis on the Chinese source code to decompose the Chinese source code into multiple lexical units; wherein, the lexical unit is the smallest constituent unit of the Chinese source code;

[0020] Based on the syntax rules of the predetermined programming language, combine the lexical units to create multiple tree nodes;

[0021] Construct the abstract syntax tree based on the multiple tree nodes.

[0022] In some embodiments, the obtaining of the program code corresponding to this function node based on the abstract syntax tree includes:

[0023] Based on the predetermined matching rules between Chinese grammar and the syntax of the predetermined programming language, convert each tree node in the abstract syntax tree into an expression in the predetermined programming language to obtain a converted abstract syntax tree;

[0024] Based on the converted abstract syntax tree, obtain the program code corresponding to this function node.

[0025] In some embodiments, for each of the function nodes written in Chinese, the following operations are further performed:

[0026] Perform semantic checking on each tree node of the abstract syntax tree;

[0027] The obtaining of the program code corresponding to this function node based on the abstract syntax tree includes:

[0028] When the semantics of each of the tree nodes are correct, based on the abstract syntax tree, obtain the program code corresponding to the function node.

[0029] In some embodiments, for each of the function nodes written in Chinese, the following operations are further performed:

[0030] When there is an error in the semantics of the tree node, perform an error reporting operation.

[0031] In a second aspect, the present application provides a computer-readable storage medium, in which multiple program codes are stored, and the program codes are adapted to be loaded and run by a processor to execute the software function implementation method described in any one of the technical solutions in the first aspect above.

[0032] In a third aspect, the present application provides a computer device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, a computer program is stored in the memory, and when the computer program is executed by the at least one processor, the software function implementation method described in any one of the technical solutions in the first aspect above is implemented.

[0033] The software function implementation method, storage medium, and computer device provided by the embodiments of the present application compile a configuration program written with a configuration software to obtain computer-executable code. Among them, the configuration program includes multiple predefined function nodes, and the multiple predefined function nodes include at least one function node written in Chinese. Execute the computer-executable code to implement the software function corresponding to the configuration program, so that the system can compile the function nodes written in Chinese, that is, the function nodes written in Chinese can also be compiled into computer-executable code. In this way, the user can directly write function nodes in Chinese without having to master a specific programming language. It can be seen that the technical solution provided by the embodiments of the present application enables the user to program in Chinese in the configuration software, thereby greatly reducing the programming difficulty and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Referring to the accompanying drawings, the disclosure of the present application will become more understandable. It is easy for those skilled in the art to understand that: these drawings are only for the purpose of illustrating the present application and are not intended to limit the protection scope of the present application. In addition, similar numbers in the figures are used to represent similar components, where:

[0035] Figure 1 is the main step flowchart of the software function implementation method provided by the embodiments of the present application;

[0036] Figure 2A flowchart for compiling functional nodes written in Chinese provided by the embodiments of this application. Detailed implementation manners

[0037] Some implementation manners of this application will be described below with reference to the accompanying drawings. Those skilled in the art should understand that these implementation manners are only used to explain the technical principle of this application and are not intended to limit the protection scope of this application.

[0038] In the description of this application, "module" and "processor" may include hardware, software, or a combination of both. A module may include a hardware circuit, various suitable sensors, communication ports, memories, and may also include a software part, such as program code, or may be a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in a software manner, a hardware manner, or a combination of both. The non-transitory computer-readable storage medium includes any suitable medium for storing program code, such as magnetic disks, hard disks, optical disks, flash memories, read-only memories, random access memories, and so on. The term "A and / or B" represents all possible combinations of A and B, such as only A, only B, or A and B. The term "at least one A or B" or "at least one of A and B" has a meaning similar to "A and / or B" and may include only A, only B, or A and B. The singular terms "a" and "this" may also include the plural form.

[0039] Logic configuration is widely used in various fields, especially in industrial automation and control systems. Using configuration software, users can, in a way similar to "building blocks", complete the required software functions according to their own needs. For complex logic functions, they usually need to be implemented through programming functional nodes in the configuration software, and users need to write their own code to implement the corresponding business logic.

[0040] In the related art, according to the type of configuration software, users need to master a specific programming language (such as JavaScript) to complete the writing of functional node code, which undoubtedly poses relatively high professional requirements for users and affects the user experience.

[0041] To solve the above technical problems, this application provides a Chinese programming node, which enables users to program and configure the system more conveniently in Chinese. This not only lowers the programming threshold, enabling more non-professionals to participate in the design and implementation of automation systems, but also improves the readability and maintainability of the system.

[0042] Based on the above idea, this application provides a software function implementation method, such as Figure 1As shown in the figure, the software function implementation method in the embodiments of the present application mainly includes the following steps S101 - S102:

[0043] Step S101: Compile the configuration program written with the configuration software to obtain computer - executable code; wherein, the configuration program includes multiple predefined function nodes, and the multiple predefined function nodes include at least one function node written in Chinese.

[0044] In this embodiment, the configuration software refers to the dedicated software for data acquisition and process control, and also refers to the software platform and development environment at the monitoring layer of the automatic control system. These software provide users with a general - level software tool for quickly constructing the monitoring function of the industrial automatic control system through a flexible logic configuration method.

[0045] The logic configuration implemented through the configuration software is a development method of online programming and deployment. After writing, one - key deployment takes effect immediately, without the need to wait for the program to be released and the new program to be installed to take effect as in the traditional program development process. For example, in the prior art, when replacing device hardware and changing energy - consumption calculation parameters, it is necessary to modify the control program to support new device points and fields, and modify the energy - consumption calculation parameter ratio, and the new requirement scenario can be supported only after the program is released. However, through logical configuration, online programming and immediate effect can be achieved, greatly improving the programming efficiency.

[0046] In a specific implementation manner, the configuration software can be the programming tool Node - RED. In the logic configuration programming tool Node - RED, users are allowed to create data streams by connecting different function nodes to realize the connection and integration of hardware devices, APIs (Application Programming Interfaces), and online services. At the same time, function nodes are provided, which allow users to directly write JavaScript code to process the data in the data stream. Through function nodes, users can perform various complex calculations, data conversions, and logical operations to meet specific business requirements.

[0047] Any valid JavaScript code can be written in the existing function nodes to process messages, and all operations from simple mathematical operations to complex logical judgments and data processing can be realized. However, this also means that users need to have a certain foundation in JavaScript programming to effectively use function nodes. And in this embodiment, the function nodes written in Chinese can be compiled and converted into computer - executable code, enabling users to directly write function nodes in Chinese, greatly reducing the professional requirements for users and improving the user experience.

[0048] In this embodiment, when users write function nodes in Chinese, they still need to follow certain programming syntax rules. For example, some basic statements and syntax structures can be predefined as follows:

[0049]

[0050]

[0051] Syntax rules are the foundation of programming language structures, including the way of organizing code, the definition methods of variables and functions, and the control of program flow, etc. Since the final Chinese code needs to be converted into JavaScript, the idea of defining syntax rules is to match the existing syntax of JavaScript as much as possible. The matching rules between Chinese grammar and JavaScript grammar can be written into a configuration file, which is read by the subsequent compiler, and the Chinese code is compiled into JavaScript code according to these rules; for example, "if" matches "if", "otherwise" matches "else", "variable" matches "var", "print" matches "console.log", etc.

[0052] In order to effectively compile the configuration program containing function nodes written in Chinese, the configuration program written by the configuration software in this embodiment is compiled to obtain computer-executable code, including: performing first compilation on each of the function nodes written in Chinese to obtain program code corresponding to each of the function nodes written in Chinese; wherein, the program code is written in a predetermined programming language; performing second compilation on the function nodes other than the function nodes written in Chinese among the multiple predefined function nodes, and the program code corresponding to each of the function nodes written in Chinese to obtain the computer-executable code.

[0053] That is, in this embodiment, first, the function nodes written in Chinese are converted into program code written in a predetermined programming language through the first compilation operation, and then the other function nodes in the configuration program and the program code obtained through the first compilation operation are converted into computer-executable code through the second compilation operation, so that the system can execute the computer-executable code to implement the corresponding software function. The flowchart of compiling the function nodes written in Chinese is as Figure 2 shown.

[0054] In order to obtain the above computer-executable code more conveniently and effectively, in this embodiment, the function nodes other than the function nodes written in Chinese among the multiple predefined function nodes are written in the predetermined programming language.

[0055] That is, in this embodiment, through the above-mentioned first compilation operation, the function nodes written in Chinese are converted into program codes with the same programming language as other nodes in the configuration program, so that the system can perform a unified second compilation operation on them, thereby obtaining the above-mentioned computer-executable code more conveniently and effectively.

[0056] Specifically, taking the configuration software as Node-RED and the predetermined programming language as JavaScript as an example, since the predefined function nodes in Node-RED are generally written in JavaScript, that is, the default programming language that can be compiled in Node-RED is JavaScript. Therefore, when the user writes a certain function node in Chinese, the system first converts it into JavaScript code, and then compiles the obtained JavaScript code and other function nodes according to the existing compilation process for JavaScript code to obtain computer-executable code.

[0057] Among them, when compiling the JavaScript code, it is carried out in the Node.js environment. Node.js is a JS runtime environment built based on the Chrome V8 engine. This runtime environment provides the VM module, which is a virtual machine that dynamically executes JS code in the Node.js environment. The VM module provides an API that allows compiling and running code in the Chrome V8 engine.

[0058] In order to compile the function nodes written in Chinese conveniently and effectively, the first compilation of each function node written in Chinese in this embodiment to obtain the program code corresponding to each function node written in Chinese includes: for each function node written in Chinese, perform the following operations: read the Chinese source code in the function node; convert the Chinese source code into an abstract syntax tree; based on the abstract syntax tree, obtain the program code corresponding to the function node.

[0059] In this embodiment, the abstract syntax tree is an abstract representation of the source code syntax structure. It represents the syntax structure of the programming language in a tree-like form, and each node on the tree represents a structure in the source code.

[0060] In this embodiment, by converting the Chinese source code into an abstract syntax tree and then obtaining the program code corresponding to the function node written in Chinese through the abstract syntax tree, it can effectively avoid program syntax errors during the compilation process, thereby conveniently and effectively obtaining the above-mentioned program code.

[0061] Specifically, still taking the configuration software as Node-RED and the predetermined programming language as JavaScript as an example, we need to develop a compiler or interpreter that can read the source code of the Chinese programming language and convert it into JavaScript code. The compiler or interpreter will convert the Chinese source code into an Abstract Syntax Tree (AST), and then traverse the AST to generate the corresponding JavaScript code.

[0062] In order to accurately convert the Chinese source code into an abstract syntax tree, the conversion of the Chinese source code into an abstract syntax tree described in this embodiment includes: performing lexical analysis on the Chinese source code to decompose the Chinese source code into multiple lexical units; where the lexical unit is the smallest component unit of the Chinese source code; combining the lexical units based on the syntax rules of the predetermined programming language to create multiple tree nodes; and constructing the abstract syntax tree based on the multiple tree nodes.

[0063] In this embodiment, in the above compiler or interpreter, we need to implement a lexical analyzer (or scanner or lexer) to decompose the Chinese source code into a series of tokens / lexical units. Then, the parser will combine these tokens / lexical units into an abstract syntax tree. That is, for the compilation of the above Chinese source code, first perform lexical analysis on it to obtain a series of lexical units, and then perform syntax analysis on these lexical units to create an abstract syntax tree.

[0064] Specifically, lexical analysis is the first step in the code interpretation process, and tokens / lexical units are the smallest syntactic units in the source code during the lexical analysis process. Lexical units can include variable names, function names, operators (such as +, -, *), delimiters (such as commas, semicolons), and literals (such as numbers, strings), etc. Once the lexical analysis is completed and tokens / lexical units are generated, the subsequent syntax analysis stage will combine these lexical units into meaningful expressions, statements, and code blocks, thereby constructing an abstract syntax tree representing the program's syntactic structure.

[0065] Suppose we have the following Chinese code snippet:

[0066] Variable value = 5 + 3;

[0067] The lexical analysis process for the above Chinese code snippet is as follows:

[0068] (1) Initialization: The lexical analyzer starts reading the first character of the source code.

[0069] (2) Reading characters: When the word "change" is read, a token is not generated immediately. More information is needed to determine whether it is a complete token.

[0070] (3) Identify keywords: Continue reading until "量", and compare them with known keywords. Identify that "变量" is a keyword in Chinese grammar, and generate a token with type "KEYWORD" and value "变量".

[0071] (4) Identify whitespace characters: Continue reading and skip whitespace characters, such as spaces, tabs, and newlines.

[0072] (5) Identify the variable name: Read the character "值" and recognize it as the beginning of an identifier; continue reading subsequent characters until a non-recognition character (such as a space, operator, semicolon, etc.) is encountered; in this example, there are no more characters after "值", and the lexical analyzer generates a token with a type of value "IDENTIFIER" and a value of "值".

[0073] (6) Identify the assignment operator: Read the character "=" and identify it as an assignment operator. Generate a token of type "ASSIGNMENT" and value "=".

[0074] (7) Identify the assignment operator: After reading the character "5", it recognizes that it is the beginning of a number; continue reading subsequent characters until a non-numeric character is encountered; in this case, "5" is followed by a space and a plus sign, and the lexical analyzer generates a token with a type of "NUMBER" and a value of "5".

[0075] (8) Identify the plus operator: Read the character “+” and recognize it as an addition operator; generate a symbol with type “PLUS” and value “+”.

[0076] (9) Recognize another numeric literal: read and recognize “3”, and generate a token with type “NUMBER” and value “3”.

[0077] (10) Identify the end of a statement: In this example, the code snippet ends with a semicolon, and the lexical analyzer generates a “;” marker.

[0078] (11) Output tokens / lexical units: The lexical analyzer passes the generated tokens / lexical units to the syntax analyzer for further processing.

[0079] Example output of tokens / tokens is as follows:

[0080] KEYWORD:'variable'

[0081] IDENTIFIER:'value'

[0082] ASSIGNMENT: '='

[0083] NUMBER: 5

[0084] PLUS: '+'

[0085] NUMBER: 3 ;

[0087] This sequence of tokens is then used by the parser to construct the Abstract Syntax Tree.

[0088] After that, the system enters the parsing phase. Parsing (also known as syntactic analysis or parsing) is the second main phase in which a compiler or interpreter processes the source code, following lexical analysis. In the lexical analysis phase, the source code is broken down into a sequence of lexical units (tokens), and in the parsing phase, these tokens are combined into higher-level syntactic structures such as expressions, statements, and code blocks.

[0089] As mentioned above, the Abstract Syntax Tree (AST) is a tree-like representation of the syntactic structure of the source code. Each node of the tree represents a structure in the source code. The nodes of the AST can represent variable declarations, function calls, control flow statements (such as if statements or for loops), etc.

[0090] The system constructs the Abstract Syntax Tree through the following parsing:

[0091] (1) Read tokens: The parser receives tokens from the lexical analyzer and starts reading them.

[0092] (2) Match grammar rules: The parser knows the grammar rules of JavaScript. For example, it knows that an if statement should start with the if keyword, followed by a conditional expression, and then a code block (enclosed by curly braces {}). When the parser reads tokens that match these rules, it tries to combine them into a syntactic structure.

[0093] (3) Construct tree nodes: For each syntactic structure (such as an if statement, a function call, etc.), the parser creates a tree node to represent it. These tree nodes contain information about the structure, such as its type (whether it is an if statement or a function call) and its child nodes (for example, the conditional expression and code block of an if statement).

[0094] (4) Combine nodes: The parser continues to read tokens and combines them into larger syntactic structures. These structures are represented as tree nodes of the Abstract Syntax Tree and are added to the tree. Each tree node may have one or more child nodes, which represent the components of the structure.

[0095] (5) Handling Errors: If the parser encounters a sequence that cannot be matched with any grammar rule while reading tokens, it reports a syntax error. This usually means that there is an error in the source code, such as a spelling error, a missing semicolon, or mismatched brackets.

[0096] (6) Completion of building the abstract syntax tree: When the parser has read all the tokens and successfully combined them into a grammatical structure, it has completed the construction of the abstract syntax tree. This abstract syntax tree is then used in subsequent stages such as semantic analysis and code generation.

[0097] In order to accurately and effectively obtain the program code corresponding to the function node written in Chinese, the present embodiment obtains the program code corresponding to the function node based on the abstract syntax tree, including: based on a predetermined matching rule between Chinese grammar and the grammar of the predetermined programming language, converting each tree node in the abstract syntax tree into an expression in the predetermined programming language to obtain a converted abstract syntax tree; based on the converted abstract syntax tree, obtaining the program code corresponding to the function node.

[0098] In this embodiment, a matching rule between the Chinese grammar and the grammar of the predetermined programming language is pre-formulated, for example, a matching rule between the Chinese grammar and the JavaScript grammar is pre-formulated.

[0099] Syntax rules are the basis of programming language structure, including the organization of code, the definition of variables and functions, and the control of program flow. In this embodiment, since the final Chinese code is to be converted into JavaScript, the idea of defining Chinese grammar rules is to match the existing JavaScript grammar as much as possible. The matching rules of Chinese grammar and JavaScript grammar can be written into a configuration file, which is read by the compiler behind, and the Chinese code is compiled into JavaScript code according to these rules. For example, "if" matches "if", "otherwise" matches "else", "variable" matches "var", "print" matches "console.log", etc.

[0100] In order to ensure the correctness of the obtained program code, in this embodiment, for each function node written in Chinese, the following operations are further performed: semantic check is performed on each tree node of the abstract syntax tree. Under this premise, the program code corresponding to the function node is obtained based on the abstract syntax tree in this embodiment, including: when the semantics of each tree node are correct, the program code corresponding to the function node is obtained based on the abstract syntax tree.

[0101] That is, in this embodiment, the system also needs to perform semantic checks on each tree node in the abstract syntax tree. Only when the semantics of each tree node are correct can subsequent program code conversion operations be performed.

[0102] In order to effectively remind the user when there are errors in the program semantics, in this embodiment, for each of the function nodes written in Chinese, the following operations are also performed: when there is an error in the semantics of the tree node, an error reporting operation is performed.

[0103] In this embodiment, still taking the configuration software as Node-RED and the predetermined programming language as JavaScript as an example, based on the abstract syntax tree generated above, we can perform semantic analysis, check the legality of the code, and generate the final JavaScript code. This step requires detailed processing of each construct in the Chinese programming language and mapping it to the corresponding JavaScript construct.

[0104] Specifically, semantic analysis is performed on the abstract syntax tree. During compilation or interpretation, the source code is first decomposed into a series of tokens / lexical units through lexical analysis, and then these tokens / lexical units are combined into an abstract syntax tree through syntactic analysis. The abstract syntax tree is a tree-like representation of the syntactic structure of the source code, which maps statements, expressions, and other syntactic structures in the source code to nodes in the tree. Once the abstract syntax tree is constructed, the semantic analyzer will traverse this tree and perform semantic checks on each node to ensure that the semantics of the source code are correct. The "source code" here refers to the content of the Chinese source code.

[0105] In the semantic analysis stage, the analyzer will check issues such as types, scopes, and control flows. For example, it will check whether the type of a variable matches the value it is assigned or the operation it expects, determine the scopes of variables and functions, and check whether control flow statements (such as if statements, loops) are used correctly. In addition, the semantic analyzer will also check whether the definitions of functions and classes, the use of operators and expressions, etc. conform to the semantic rules of the language.

[0106] If any errors or non-conformities with the language specifications are found during semantic analysis, the analyzer will report these errors and may stop the compilation or interpretation process. Through semantic analysis, it can be ensured that the intention or meaning of the source code is correct and conforms to the language specifications.

[0107] After passing the semantic analysis, the system replaces or maps variables, functions, control flow statements, etc. in the Chinese source code to the corresponding variables, functions, control flow statements in the JavaScript code based on the previously defined "matching rules between Chinese grammar and JavaScript grammar" and the content of the abstract syntax tree.

[0108] For example, for the Chinese code snippet example above:

[0109] Variable value = 5 + 3;

[0110] And the abstract syntax tree during lexical analysis and syntax analysis:

[0111] KEYWORD: 'Variable'

[0112] IDENTIFIER: 'value'

[0113] ASSIGNMENT: '='

[0114] NUMBER: 5

[0115] PLUS: '+'

[0116] NUMBER: 3 ;

[0118] The Chinese compiler implemented by this embodiment reads the types of nodes in the abstract syntax tree, such as "KEYWORD" and "IDENTIFIER", and the corresponding values, such as "Variable" and "value". Combining with the "matching rules between Chinese grammar and JavaScript grammar", "Variable" in the Chinese code can be mapped to "var" in JavaScript; the variable name "value" can be mapped to the variable name (JavaScript supports using Chinese characters as variable names) "value" in JavaScript. The mathematical operation expressions and operators in the matching rules are the same, and "=", "5", "+", and "3" are respectively mapped to the primitive values. The finally generated JavaScript code is as follows:

[0119] var value = 5 + 3;

[0120] This generated JavaScript code can be executed as a normal JavaScript code program.

[0121] Another example is that the user writes the following code in the Chinese programming language:

[0122]

[0123] After being processed by the compiler, the following JavaScript code may be generated:

[0124]

[0125] After that, the system processes the above JavaScript code according to the normal process of processing JavaScript code.

[0126] Step S102, execute the computer-executable code to implement the software functions corresponding to the configuration program.

[0127] In this embodiment, the JavaScript code is compiled through a corresponding compiler / interpreter to generate a machine code program for the corresponding platform, which can then be executed by the CPU of the computer. The process of the system executing the computer-executable code is the process of implementing the software functions corresponding to the written configuration program.

[0128] Based on the above steps S101 - S102, the present application can solve the technical problems that in a configuration software, a specific programming language must be used to write function nodes, resulting in a relatively high requirement for user professionalism and affecting the user experience.

[0129] The technical solution provided by the embodiment of the present application compiles the configuration program written using the configuration software to obtain computer-executable code, where the configuration program includes multiple predefined function nodes, and the multiple predefined function nodes include at least one function node written in Chinese. Execute the computer-executable code to implement the software functions corresponding to the configuration program, so that the system can compile the function nodes written in Chinese, that is, the function nodes written in Chinese can also be compiled into computer-executable code. In this way, users can directly write function nodes in Chinese without having to master a specific programming language. It can be seen that the technical solution provided by the embodiment of the present application enables users to program in Chinese in the configuration software, thereby greatly reducing the programming difficulty and improving the user experience.

[0130] The existing function node programming method requires users to have a JavaScript programming foundation, increasing the usage difficulty and being unfriendly to non-professionals. The present application provides a custom function node that allows users to write programs in Chinese. The programming instructions and logic are easier to understand and remember, reducing the usage threshold and making it easier to attract users to use.

[0131] The present application also has the following advantages:

[0132] 1. Implement Chinese programming in the logic configuration tool Node-RED;

[0133] 2. It can run on a local server and be used within a local area network, without the need for an external network, and has low resource consumption;

[0134] 3. Users write programs in Chinese, and the programming instructions and logic are easier to understand and remember, making it easier to attract users to use.

[0135] It should be noted that although the above embodiments describe the various steps in a specific order, those skilled in the art can understand that in order to achieve the effects of the present application, it is not necessary to execute the different steps in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are within the protection scope of the present application.

[0136] Furthermore, on the other hand, the present application also provides a computer-readable storage medium. In an embodiment of the computer-readable storage medium according to the present application, the computer-readable storage medium can be configured to store a program for implementing the software function implementation method of the above method embodiment. This program can be loaded and run by a processor to implement the above software function implementation method. For the sake of convenience of description, only the parts related to the embodiments of the present application are shown. For the specific technical details not disclosed, please refer to the method part of the embodiments of the present application. The computer-readable storage medium can be a storage device formed by various electronic devices. Optionally, in the embodiments of the present application, the computer-readable storage medium is a non-transitory computer-readable storage medium.

[0137] Furthermore, on the other hand, the present application also provides a computer device, which may include at least one processor; and a memory communicatively connected to the at least one processor; wherein, a computer program is stored in the memory, and when the computer program is executed by the at least one processor, it implements the software function implementation method described in any of the above embodiments.

[0138] The program for implementing the software function implementation method of the above method embodiment can be divided into multiple sub-programs, and each sub-program can be loaded and run by a processor to execute different steps of the software function implementation method of the above method embodiment. Specifically, each sub-program can be stored in different memories respectively, and each processor can be configured to execute the programs in one or more memories to jointly implement the software function implementation method of the above method embodiment, that is, each processor respectively executes different steps of the above method embodiment to jointly implement the software function implementation method of the above method embodiment.

[0139] The above-mentioned multiple processors can be processors deployed on the same device. For example, the above computer device can be a computer device composed of multiple processors, and the above multiple processors can be the processors configured on the computer device. In addition, the above multiple processors can also be processors deployed on different devices. For example, the above computer device can be a server cluster, and the above multiple processors can be the processors on different servers in the server cluster.

[0140] Those skilled in the art can understand that all or part of the processes in the methods of the above-mentioned embodiments of the present application can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable storage medium can include: any entity or device, medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory, random access memory, electrical carrier signal, telecommunication signal, and software distribution medium that can carry the computer program code, etc.

[0141] So far, the technical solutions of the present application have been described in combination with the preferred embodiments shown in the drawings. However, those skilled in the art can easily understand that the protection scope of the present application is obviously not limited to these specific embodiments. Without departing from the principle of the present application, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the protection scope of the present application.

Claims

1. A method for implementing software functions, characterized in that, The method includes: Compiling the configuration program written with a configuration software to obtain computer-executable code; wherein, the configuration program includes multiple predefined function nodes, and the multiple predefined function nodes include at least one function node written in Chinese; Executing the computer-executable code to implement the software functions corresponding to the configuration program.

2. The software function implementation method according to claim 1, wherein The compiling the configuration program written with a configuration software to obtain computer-executable code includes: Performing first compilation on each of the function nodes written in Chinese to obtain program code corresponding to each of the function nodes written in Chinese; wherein, the program code is written in a predetermined programming language; Performing second compilation on the function nodes other than the function nodes written in Chinese among the multiple predefined function nodes, and the program code corresponding to each of the function nodes written in Chinese, to obtain the computer-executable code.

3. The software function implementation method according to claim 2, wherein The function nodes other than the function nodes written in Chinese among the multiple predefined function nodes are written in the predetermined programming language.

4. The software function implementation method according to claim 2, characterized in that, The performing first compilation on each of the function nodes written in Chinese to obtain program code corresponding to each of the function nodes written in Chinese includes: For each of the function nodes written in Chinese, perform the following operations: Read the Chinese source code in the function node; Convert the Chinese source code into an abstract syntax tree; Based on the abstract syntax tree, obtain the program code corresponding to the function node.

5. The software function implementation method according to claim 4, wherein The converting the Chinese source code into an abstract syntax tree includes: Performing lexical analysis on the Chinese source code to decompose the Chinese source code into multiple lexical units; wherein, the lexical unit is the smallest constituent unit of the Chinese source code; Combining the lexical units based on the syntax rules of the predetermined programming language to create multiple tree nodes; Construct the abstract syntax tree based on the multiple tree nodes.

6. The software function implementation method according to claim 4, wherein The obtaining the program code corresponding to the function node based on the abstract syntax tree includes: Based on a predetermined matching rule between Chinese syntax and the syntax of the predetermined programming language, convert each tree node in the abstract syntax tree into an expression in the predetermined programming language to obtain a converted abstract syntax tree; Based on the converted abstract syntax tree, obtain the program code corresponding to the function node.

7. The software function implementation method according to claim 4, wherein For each of the function nodes written in Chinese, also perform the following operations: Perform semantic checking on each tree node of the abstract syntax tree; The obtaining the program code corresponding to the function node based on the abstract syntax tree includes: When the semantics of each tree node are correct, based on the abstract syntax tree, obtain the program code corresponding to the function node.

8. The software function implementation method according to claim 7, wherein For each of the function nodes written in Chinese, also perform the following operations: When there is an error in the semantics of the tree node, perform an error reporting operation.

9. A computer-readable storage medium storing multiple program codes, characterized in that, The program code is suitable for being loaded and run by a processor to execute the software function implementation method according to any one of claims 1 to 8.

10. A computer device, characterized in that, Includes: At least one processor; and a memory communicatively connected to the at least one processor; wherein a computer program is stored in the memory, and when the computer program is executed by the at least one processor, the software function implementation method according to any one of claims 1 to 8 is implemented.