String interpretation method, device, terminal device and storage medium

By using a string interpreter in the motor drive to interpret the command strings entered by the user, the driver can be compiled and run instructions are generated, which solves the problem of multiple and complex motor drive parameters, and achieves simplified operation and improved development efficiency.

CN114004215BActive Publication Date: 2025-05-09SHENZHEN YAKO AUTOMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111119201.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-23
Publication Date
2025-05-09
Estimated Expiration
2041-09-23

AI Technical Summary

Technical Problem

The parameters of the motor driver are numerous and complex, which leads to complex operations when designing the control instructions for the driver parameters, affecting the normal progress of technical development.

Method used

By calling the target parser from the preset parser component library according to the configuration instructions entered by the user, forming a string interpreter, using this interpreter to interpret the command string, and generating the target string that the motor driver can directly compile and run.

Benefits of technology

It simplifies user operations, reduces the demand for instruction conversion, improves the efficiency of technology development, and meets user personalized needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114004215B_ABST
    Figure CN114004215B_ABST
Patent Text Reader

Abstract

The present invention discloses a string interpretation method, which includes: according to the configuration instruction input by the user, calling at least one target parser from a preset parser component library to form a string interpreter, wherein the string interpreter includes a prompt command for the user to edit the command string; according to the user's operation instruction for the prompt command, generating a command string to be interpreted; using the string interpreter to interpret the command string to obtain a target string. The present invention also discloses a string interpretation device, a terminal device and a storage medium. The present invention can flexibly interpret different types of strings according to the user's parsing requirements through the user's custom configuration of the parser required, without the user having to perform operations such as conversion of the instructions edited by the user, and can simplify the user's operation on the premise of meeting the user's personalized needs, thereby ensuring the normal progress of technical development work and improving the user's development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a string interpretation method, device, terminal equipment and storage medium. Background Art

[0002] With the rapid development of automation technology, as one of the terminal execution components of automation technology, the related technologies of motor drivers are also developing rapidly. Drivers and host computer software mostly use communication protocols such as Modbus, and cannot directly compile or run various types of high-level programming languages. A driver has dozens or hundreds of parameters, each of which corresponds to different drive instructions. When developers drive and control the driver, they often cannot fully remember all the parameters of the driver and the digital commands corresponding to each parameter. When designing the control instructions of the driver parameters, they often have to obtain the various parameters of the driver through other means, write the control instructions in a high-level programming language, and then convert the high-level programming language into a language that the driver can directly compile and run. The operation is complicated and is not conducive to the normal progress of technical development work. Summary of the invention

[0003] The main purpose of the present invention is to provide a string interpretation method, device, terminal device and storage medium, aiming to solve the technical problem in the prior art that the motor driver has many parameters and the digital commands corresponding to each parameter are complex, resulting in complex operations when designing control instructions for each parameter of the motor driver.

[0004] In addition, to achieve the above object, the present invention also provides a string interpretation method, which comprises the following steps:

[0005] According to the configuration instruction input by the user, at least one target parser is called from a preset parser component library to form a string interpreter, wherein the string interpreter includes a prompt command for the user to edit the command string;

[0006] Generate a command string to be interpreted according to the user's operation instruction on the prompt command;

[0007] The command character string is interpreted by using the character string interpreter to obtain a target character string.

[0008] Optionally, the command character string includes a mixed character string including characters of at least two data types, and the step of using the character string interpreter to interpret the command character string to obtain the target character string includes:

[0009] Using the target parsers in the string interpreter to split and parse the command string in sequence, each of the target parsers parses characters of corresponding data types from the command string to obtain multiple substrings;

[0010] Each of the substrings is labeled and integrated to obtain a target string.

[0011] Optionally, the command string includes a calculation formula, and the step of using the string interpreter to interpret the command string to obtain a target string includes:

[0012] The string interpreter is used to interpret the operation formula from an infix expression to a postfix expression to obtain a target string.

[0013] Optionally, the step of using the string interpreter to interpret the operation formula from an infix expression to a postfix expression to obtain a target string includes:

[0014] Create an initialized character stack;

[0015] Using the string interpreter to sequentially read each operation character in the operation formula from left to right, and pushing each operation character into the character stack in order of priority;

[0016] The operation characters in the character stack are popped out and outputted in sequence to obtain a target character string.

[0017] Optionally, each operation character in the operation formula includes an operand, an operator, a left bracket and a right bracket, the character stack includes a temporary stack and a target stack, and the step of using the string interpreter to sequentially read each operation character in the operation formula from left to right and push the operation characters into the character stack in order of priority includes:

[0018] If the operation character is an operation operand, the operation operand is pushed into the target stack;

[0019] If the operation character is an operation operator, then detecting whether the temporary stack is empty, if the temporary stack is empty, directly pushing the operation operator into the temporary stack, if the temporary stack is not empty, then comparing the operation operator with the operation priority of the top element of the temporary stack;

[0020] If the operation priority of the operation operator is greater than the top element of the stack, the operation operator is pushed into the temporary stack;

[0021] If the priority of the operation operator is less than or equal to the top element of the stack, the top elements of the temporary stack are popped out and pushed into the target stack in sequence, until the priority of the operation operator is greater than the top element of the temporary stack, or the temporary stack is empty, the operation operator is pushed into the temporary stack;

[0022] If the operation character is a left bracket, the left bracket is directly pushed into the temporary stack;

[0023] If the operation character is a right bracket, the top element in the temporary stack is popped out and pushed into the target stack until the top element is a left bracket, and the right bracket and the left bracket are discarded;

[0024] When all operation characters in the operation formula are read, the elements in the temporary stack are popped out in sequence and pushed into the target stack.

[0025] Optionally, before the step of using the string interpreter to interpret the command string, the step further includes:

[0026] The command character string is checked according to the prompt command, and when an erroneous instruction is checked, the erroneous instruction is located and an error prompt message is output.

[0027] Optionally, the parser component library includes a multi-language parser for interpreting character strings of different language types and / or different data types.

[0028] In addition, to achieve the above object, the present invention further provides a string interpretation device, the string interpretation device comprising:

[0029] A parser configuration module, used to call at least one target parser from a preset parser component library to form a string interpreter according to a configuration instruction input by a user, wherein the string interpreter includes a prompt command for the user to edit a command string;

[0030] A command generation module, used for generating a command string to be interpreted according to the user's operation instruction on the prompt command;

[0031] The command interpretation module is used to interpret the command string using the string interpreter to obtain a target string.

[0032] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal device, which includes: a memory, a processor, and a string interpretation program stored in the memory and executable on the processor, and the string interpretation program implements the steps of the above-mentioned string interpretation method when executed by the processor.

[0033] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a string interpretation program is stored, and when the string interpretation program is executed by a processor, the steps of the string interpretation method as described above are implemented.

[0034] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned character string interpretation method are implemented.

[0035] A string interpretation method, device, terminal device and storage medium proposed in the embodiment of the present invention. In the prior art, the motor driver cannot directly compile and run the driving command of the high-level programming language, and the motor driver has many parameters. When designing the control instructions of the driver parameters, it is often necessary to first obtain the various parameters of the driver through other means, write the control instructions through the high-level programming language, and then convert the high-level programming language into a language that the driver can directly compile and run, which is complicated. In the embodiment of the present invention, at least one target parser is called from a preset parser component library according to the configuration instructions input by the user to form a string interpreter, wherein the string interpreter includes a prompt command for the user to edit the command string; according to the user's operation instruction for the prompt command, a command string to be interpreted is generated; and the command string is interpreted by the string interpreter to obtain the target string. By customizing the parser required by the user to configure, different types of strings can be flexibly interpreted according to the user's parsing requirements, without the user having to perform operations such as converting the instructions edited by himself, and on the premise of meeting the personalized needs of the user, the user operation can be simplified, thereby ensuring the normal progress of technical development work and improving the user's development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A schematic diagram of the hardware structure of a terminal device according to an embodiment of the present invention;

[0037] Figure 2 It is a flowchart of the first embodiment of the character string interpretation method of the present invention;

[0038] Figure 3 This is a schematic diagram of a string interpretation result in the second embodiment of the string interpretation method of the present invention;

[0039] Figure 4 A schematic diagram of a character string interpretation process in the second embodiment of the character string interpretation method of the present invention;

[0040] Figure 5 is another schematic diagram of a string interpretation result in the second embodiment of the string interpretation method of the present invention;

[0041] Figure 6 A schematic diagram of operation characters split in an operation formula in the second embodiment of the character string interpretation method of the present invention;

[0042] Figures 7 and 8 is a schematic diagram of another string interpretation result in the second embodiment of the string interpretation method of the present invention;

[0043] Fig. 9 Schematic diagram of functional modules of an embodiment of a string interpretation device of the present invention.

[0044] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0045] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0046] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.

[0047] The string interpretation terminal (also called terminal, device or terminal equipment) of the embodiment of the present invention may be a PC, or a mobile terminal equipment with display and data processing functions such as a smart phone, a tablet computer and a portable computer.

[0048] like Figure 1 As shown, the terminal may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0049] Optionally, the terminal may also include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, and the like. Among them, sensors include light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display screen according to the brightness of the ambient light, and the proximity sensor may turn off the display screen and / or backlight when the mobile terminal is moved to the ear. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile terminal (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; of course, the mobile terminal may also be equipped with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which will not be repeated here.

[0050] Those skilled in the art will understand that Figure 1 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0051] like Figure 1 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a string interpreter.

[0052] exist Figure 1 In the terminal shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the string interpretation program stored in the memory 1005. When the string interpretation program is executed by the processor, the operations in the string interpretation method provided in the following embodiment are implemented.

[0053] Based on the above device hardware structure, an embodiment of the string interpretation method of the present invention is proposed.

[0054] Reference Figure 2 In a first embodiment of the string interpretation method of the present invention, the string interpretation method includes:

[0055] Step S10, according to the configuration instruction input by the user, calling at least one target parser from a preset parser component library to form a string interpreter, wherein the string interpreter includes a prompt command for the user to edit the command string;

[0056] The string interpretation method in the embodiment of the present invention is implemented on a terminal device such as a personal computer or a tablet computer, and is applied to a motor driver and a host computer software. The strings corresponding to different types of languages ​​can be interpreted as languages ​​that can be compiled and run by the motor driver, which is convenient for technicians to develop the motor driver. It can be seen that the motor driver and the host computer software use communication protocols such as Modbus, and cannot directly compile and run high-level programming languages. A driver has hundreds of parameters. When the developer drives and controls the motor driver, it may be necessary to design control instructions for multiple parameters, and then convert the control instructions for each parameter from the high-level programming language to a program language that the driver can compile and run. For technicians who are not familiar with the driver program language, the language conversion process is complicated, which is not conducive to the normal development of the development work, thereby affecting the development efficiency.

[0057] In this embodiment, a user-configurable string interpretation method is proposed, which is applied to a motor driver and a host computer software. In the host computer software, received instructions of different language types are compiled, and at least one target parser is called from a preset parser component library to form a string interpreter according to the configuration instructions input by the user, wherein the preset parser component library includes a multi-language parser, which can be used to interpret strings of different language types and / or different data types, and the strings of different language types include at least natural languages, such as Chinese and English, and high-level programming languages, such as C language and JAVA, etc. The multi-language parser in the preset parser component library can not only interpret the same instruction in different natural languages, but also interpret the same instruction in different programming languages. Furthermore, the composed string interpreter includes a prompt command, which can be used by the user to edit the command string. The prompt command is provided with a quick operation button and a dialog box, wherein the dialog box is used by the user to edit the command string to be interpreted, and the operation button includes various parameters of the motor driver, such as acceleration time, deceleration time, speed, relative displacement, absolute displacement and other motion control parameters. When the user needs to design a control instruction for a certain parameter, the corresponding parameter instruction can be quickly entered in the dialog box by clicking the operation button in the prompt command, and then the corresponding parameter value can be entered. The user can select one or more target parsers to form the interpreter according to the natural language, programming language and / or string type used in the program development, etc. When the user selects multiple parsers, the multiple parsers can be of the same language type or different language types.

[0058] Step S20, generating a command character string to be interpreted according to the user's operation instruction for the prompt command;

[0059] Furthermore, based on the user's operation instructions for the prompt command in the interpreter, a command string to be interpreted is generated. The user can trigger the corresponding operation instruction and generate a string of the corresponding instruction in the prompt command dialog box by inputting, clicking an operation button, etc.

[0060] Step S30, using the string interpreter to interpret the command string to obtain a target string.

[0061] The generated command string is interpreted by a string interpreter to obtain a target string, which is an instruction that can be directly compiled and run by the motor driver.

[0062] Furthermore, before interpreting the generated string, the string interpreter will also verify the string to be interpreted to detect whether there is an erroneous instruction in the string. Specifically, after the user completes the editing, the string to be interpreted is uniformly verified according to the user's verification instruction, or when the user edits the command string to be interpreted, the user's edited content is verified in real time. When an erroneous instruction is detected, the erroneous instruction is located and an error prompt message is output to prompt the user to adjust or change the erroneous instruction.

[0063] Specifically, referring to step S3001, the command string is checked according to the prompt command, and when an erroneous instruction is detected, the erroneous instruction is located and an error prompt message is output.

[0064] By using the operation buttons corresponding to the parameters in the prompt command, the instructions in the string to be interpreted are checked to determine whether there are erroneous instructions in the string to be interpreted, and the erroneous instructions include parameter errors, syntax errors, and parameter assignment errors. When an erroneous instruction is detected, the erroneous instruction is located by highlighting and other methods, and an error prompt message is output. The error prompt message contains instruction error information and modification suggestions, so that the user can quickly locate the error and modify it. Among them, the output method of the error prompt message can be a pop-up dialog box, which outputs all error information and corresponding modification suggestions in a list, or a floating box. On each highlighted erroneous instruction, when the user clicks or the mouse cursor floats on the erroneous instruction, the error information and corresponding modification suggestions of the erroneous instruction are displayed, which is not specifically limited here.

[0065] In this embodiment, at least one target parser is called from a preset parser component library to form a string interpreter according to the configuration instructions input by the user, wherein the string interpreter includes a prompt command for the user to edit the command string; a command string to be interpreted is generated according to the user's operation instructions for the prompt command; and the command string is interpreted by the string interpreter to obtain a target string. By customizing the parser required by the user, different types of strings can be flexibly interpreted according to the user's parsing requirements, without the user having to perform operations such as conversion of the instructions edited by the user. Under the premise of meeting the user's personalized needs, the user operation can be simplified, thereby ensuring the normal progress of technical development work and improving the user's development efficiency.

[0066] Furthermore, based on the above-mentioned embodiment of the present invention, a second embodiment of the character string interpretation method of the present invention is proposed.

[0067] This embodiment is a refinement of step S30 in the first embodiment. The difference between this embodiment and the above-mentioned embodiment of the present invention is that, in this embodiment, the character string to be interpreted includes multiple types, including at least a mixed character string and an operation formula. The mixed character string is a character string containing multiple data types and can be user-defined.

[0068] For mixed strings, the steps of interpreting them using a string interpreter include:

[0069] Step S301, using the target parser in the string interpreter to split and parse the command string in sequence, each of the target parsers parses characters of corresponding data types from the command string to obtain multiple substrings;

[0070] Step S302: Mark and integrate the substrings to obtain a target string.

[0071] Reference Figure 3 , Figure 3 It is a schematic diagram of the target string obtained by interpreting the mixed string. Figure 3 In the example, the mixed string input is a user-defined command string, specifically: "VEC-200; QST; ACC0; DC300; DC100; FP; MST; REL; FL; s0;". The command string contains different data types. According to the parser selected by the user, a string interpreter is formed. The target parser in the string interpreter is used to split and parse each character in the command string in turn. Different parsers are used to parse the corresponding types of characters to obtain multiple substrings, and then each substring is marked and integrated to obtain Figure 3 The schematic diagram of the interpretation results is shown. Figure 3In the text, each character is only used to illustrate the present embodiment and has no practical significance. The marking of characters or character strings of different data types is mainly used to distinguish the data types of each character or character string, such as character type, integer type or floating point type, etc., which is specifically reflected by displaying the characters in different rows, wherein the data types of characters or character strings such as VEC, QST, ACC, DC, MST, REL, FL, etc. located in the same row are the same, and the data types of characters or character strings located in different rows are different. VEC, QST, ACC, DC, MST, REL, FL can represent driver parameters or variables, -200, 0, 100, etc. are parameter values ​​or variable values, and s0 can be the initial value of the control variable. Further, the interpretation process of the above mixed character string is as follows: Figure 4 As shown, the user selects multiple target parsers from the preset parser component library to form an interpreter according to the actual interpretation requirements, and uses each parser to split and parse the command characters to be interpreted in turn. Each parser parses the string of the corresponding data type from the string, and marks and integrates the strings of different data types to obtain the interpretation result of the command string, that is, the target string. In the interpretation result, characters or strings of different data types are displayed in different rows for distinction.

[0072] Furthermore, for motor drivers and host computer software, motion control instructions are often required. When the user does not know the corresponding parameter name of the parameter he wants to control in the driver, he can directly enter the parameter name and the corresponding parameter value in the natural language state in the prompt command dialog box, for example, "acceleration time 500ms; deceleration time 500ms, speed 600r / min, relative displacement 100000 instruction pulses", and use the string interpreter to interpret the natural language to obtain the following Figure 5 The character string shown corresponds to the motion control instruction. The motion control of the motor can be realized by compiling the character string through the host computer software and sending it to the driver for execution.

[0073] Further, for the operation formula, the conventional operation formula is an infix expression in the form of "a+b", and the operator is in the middle of the operand. However, based on the communication protocol between the motor driver and the host computer software, the motor driver and the host computer software cannot directly compile and run the high-level programming language like a computer, and calculate the operation formula according to the conventional infix expression. Therefore, it is necessary to change the infix expression in the general operation formula to a suffix expression that can be compiled by the host computer of the driver and executed by the driver, so as to obtain the target string. The suffix expression is in the form of "ab+", and the operator is behind the operation, which is called a suffix expression. Since the suffix expression does not conform to the editing habits of most people for the operation formula, if the suffix expression is directly input, the user is required to perform complex conversion operations. In this embodiment, the use of a parser can realize the rapid parsing of the operation formula, and the infix expression in the operation formula is converted into a suffix expression, thereby simplifying the user operation.

[0074] Specifically, the process of converting the infix expression of the operation formula into a postfix expression includes:

[0075] Step S303, creating an initialized character stack;

[0076] Step S304, using the string interpreter to sequentially read each operation character in the operation formula from left to right, and push each operation character into the character stack in order of priority;

[0077] Step S305, popping out and outputting the operation characters in the character stack in sequence to obtain a target character string.

[0078] In this embodiment, the parsing of the operation formula is based on a stack. First, an initialized character stack is created, and the character interpreter is used to read each operation character in the operation formula from left to right in turn, and push them into the created character stack in order of priority. When all the characters in the operation formula are read, each character in the character stack is popped out and output in turn to obtain the target character string.

[0079] Furthermore, the operation formula includes multiple operators, and the operation priorities of different operators may be the same or different. There may also be parentheses in the operation formula. In the above step S304, the step of pushing each operation character in the operation formula into the stack in order of priority may include:

[0080] Step A1, if the operation character is an operation operand, the operation operand is pushed into the target stack;

[0081] Step A2, if the operation character is an operation operator, detecting whether the temporary stack is empty, if the temporary stack is empty, directly pushing the operation operator into the temporary stack, if the temporary stack is not empty, comparing the operation operator with the operation priority of the top element of the temporary stack;

[0082] Step A3, if the operation priority of the operation operator is greater than the top element of the stack, the operation operator is pushed into the temporary stack;

[0083] Step A4: if the priority of the arithmetic operator is less than or equal to the top element of the stack, the top elements of the temporary stack are popped out in sequence and pushed into the target stack, until the priority of the arithmetic operator is greater than the top element of the temporary stack, or when the temporary stack is empty, the arithmetic operator is pushed into the temporary stack;

[0084] Step A5, if the operation character is a left bracket, directly push the left bracket into the temporary stack;

[0085] Step A6, if the operation character is a right bracket, pop the top element in the temporary stack and push it into the target stack, until the top element is a left bracket, then discard the right bracket and the left bracket;

[0086] Step A7, when all operation characters in the operation formula are read, the elements in the temporary stack are popped out in sequence and pushed into the target stack.

[0087] The created character stack includes a temporary stack and a target stack. The interpreter is used to read the various operation characters in the operation formula from left to right in turn. When the operand is read, it is directly pushed into the target stack. When the operator is read, it is pushed into the temporary stack. Specifically, the process of pushing the operator into the temporary stack is: first determine whether the temporary stack is empty. If it is empty, the operator is directly pushed into the stack. If the temporary stack is not empty, the operator is compared with the operation priority of the top element in the temporary stack. If the operation priority of the operator is higher than the top element, the operator is pushed into the temporary stack. If the operation priority of the operator is less than or equal to the top element, the top element in the temporary stack is popped out in turn and pushed into the target stack until the operation priority of the top element is lower than the operator, or the temporary stack is empty, and the operator is pushed into the temporary stack. When a left parenthesis is read, since the parentheses have the highest operation priority, they are directly pushed into the temporary stack. When a right parenthesis is read, the operator before the right parenthesis has the highest operation priority, so the top element of the stack is popped and pushed into the target stack, until the top element of the stack is a left parenthesis, then the left parenthesis is popped and discarded together with the right parenthesis.

[0088] Specifically, take the arithmetic operation "(1+2*3)*4" as an example, convert it from an infix expression to a postfix expression, and explain the parsing process of the operation formula in detail. First, use the interpreter to read from left to right Figure 6 As shown in the figure, for each operation character, when a left bracket is read, it is pushed into the temporary stack, then operand 1 is read and pushed into the target stack, then the plus sign "+" is read and pushed into the temporary stack, and operand 2 is read and pushed into the target stack, and then the multiplication sign "*" is read. At this time, the top element of the temporary stack is "+", and the operation priority is low, so "*" is pushed into the temporary stack, and operand 3 is read and also pushed into the target stack, and then the left bracket is read, and the "*" and "+" in the temporary stack are popped out and pushed into the target stack in turn, and the left bracket and right bracket are discarded, and then the multiplication sign "*" is read. At this time, the temporary stack is empty and is directly pushed into the temporary stack, and finally operand 4 is read and pushed into the target stack. At this time, the reading of all operation characters in the operation formula is completed, and all operation characters in the temporary stack are popped out and pushed into the target stack. The operation characters in the target stack are "123*+4*" in turn, and the operation characters in the target stack are popped out in turn to obtain the target string "123*+4*".

[0089] When all the operation characters in the operation formula are read, the operators in the temporary stack are popped out one by one and pushed into the target stack, and then the characters in the target stack are popped out one by one and output for display, thereby obtaining the interpretation result of the operation formula. The display of the interpretation result of the operation formula can be as follows: Figure 7 As shown, it is displayed in the actual order of the suffix expression, or it can be displayed as follows Figure 8 The result shown is similar to the interpretation result of the mixed string, where operators with different operation priorities and their corresponding operands are displayed on the same line, and operators with different operation priorities and their operands are displayed on different lines.

[0090] In this embodiment, a multi-language parser is used to interpret the string level of different language types and / or different data types to obtain a target string that can be compiled and run by the motor driver and its host computer software. Developers do not need to convert the language themselves according to the programming language they use. At the same time, users are supported to use functional natural language to design drive instructions, which can simplify user operations and improve user development efficiency.

[0091] In addition, refer to Fig. 9 The embodiment of the present invention further provides a string interpretation device, the string interpretation device comprising:

[0092] The parser configuration module 10 is used to call at least one target parser from a preset parser component library to form a string interpreter according to the configuration instruction input by the user, wherein the string interpreter includes a prompt command for the user to edit the command string;

[0093] The command generating module 20 is used to generate a command string to be interpreted according to the user's operation instruction for the prompt command;

[0094] The command interpretation module 30 is used to interpret the command string using the string interpreter to obtain a target string.

[0095] Optionally, the command interpretation module 30 is further used to:

[0096] Using the target parsers in the string interpreter to split and parse the command string in sequence, each of the target parsers parses characters of corresponding data types from the command string to obtain multiple substrings;

[0097] Each of the substrings is labeled and integrated to obtain a target string.

[0098] Optionally, the command interpretation module 30 is further used to:

[0099] The string interpreter is used to interpret the operation formula from an infix expression to a postfix expression to obtain a target string.

[0100] Optionally, the command interpretation module 30 is further used to:

[0101] Create an initialized character stack;

[0102] Using the string interpreter to sequentially read each operation character in the operation formula from left to right, and pushing each operation character into the character stack in order of priority;

[0103] The operation characters in the character stack are popped out and outputted in sequence to obtain a target character string.

[0104] Optionally, the command interpretation module 30 is further used to:

[0105] If the operation character is an operation operand, the operation operand is pushed into the target stack;

[0106] If the operation character is an operation operator, then detecting whether the temporary stack is empty, if the temporary stack is empty, directly pushing the operation operator into the temporary stack, if the temporary stack is not empty, then comparing the operation operator with the operation priority of the top element of the temporary stack;

[0107] If the operation priority of the operation operator is greater than the top element of the stack, the operation operator is pushed into the temporary stack;

[0108] If the priority of the operation operator is less than or equal to the top element of the stack, the top elements of the temporary stack are popped out and pushed into the target stack in sequence, until the priority of the operation operator is greater than the top element of the temporary stack, or the temporary stack is empty, the operation operator is pushed into the temporary stack;

[0109] If the operation character is a left bracket, the left bracket is directly pushed into the temporary stack;

[0110] If the operation character is a right bracket, the top element in the temporary stack is popped out and pushed into the target stack until the top element is a left bracket, and the right bracket and the left bracket are discarded;

[0111] When all operation characters in the operation formula are read, the elements in the temporary stack are popped out in sequence and pushed into the target stack.

[0112] Optionally, the string interpretation device further includes a command checking module, which is used to:

[0113] The command character string is checked according to the prompt command, and when an erroneous instruction is checked, the erroneous instruction is located and an error prompt message is output.

[0114] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a string interpretation program is stored. When the string interpretation program is executed by a processor, the operations in the string interpretation method provided in the above embodiment are implemented.

[0115] In addition, an embodiment of the present invention further provides a computer program product, including a computer program, which implements the operations in the string interpretation method provided in the above embodiment when executed by a processor.

[0116] The various embodiments of the device, computer program product, and computer-readable storage medium of the present invention may all refer to the various embodiments of the string interpretation method of the present invention, and will not be described in detail here.

[0117] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such actual relationship or order between these entities / operations / objects; the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0118] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment. The device embodiment described above is only illustrative, and the units described as separate components may or may not be physically separated. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the present invention. Those of ordinary skill in the art can understand and implement it without paying creative work.

[0119] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0120] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the string interpretation method described in each embodiment of the present invention.

[0121] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for interpreting a character string, characterized in that: Applied to the motor driver and the host computer software, the string interpretation method comprises the following steps: According to the configuration instruction input by the user, at least one target parser is called from a preset parser component library to form a string interpreter, wherein the string interpreter includes a prompt command, the prompt command is provided with a quick operation button and a dialog box, the dialog box is used for the user to edit the command string to be interpreted, the operation button includes various parameters of the motor driver, the parser component library includes a multi-language parser, and at least one target parser is called from the multi-language parser to interpret strings of different language types and / or different data types, and the language type includes at least natural language and high-level programming language; Generate a command string to be interpreted according to the user's operation instruction for the prompt command, wherein the command string includes a calculation formula; The string interpreter is used to interpret the operation formula from an infix expression to a postfix expression to obtain a target string. The target string is an instruction that can be directly compiled by the motor driver. The command string is compiled by the host computer software and sent to the motor driver for execution to realize the motion control of the motor.

2. The string interpretation method according to claim 1, characterized in that: The command string includes a mixed string, the mixed string includes characters of at least two data types, and the step of using the string interpreter to interpret the command string to obtain a target string includes: Using the target parsers in the string interpreter to split and parse the command string in sequence, each of the target parsers parses characters of corresponding data types from the command string to obtain multiple substrings; Each of the substrings is labeled and integrated to obtain a target string.

3. The string interpretation method according to claim 1, wherein: The step of using the string interpreter to interpret the operation formula from an infix expression to a postfix expression to obtain a target string includes: Create an initialized character stack; Using the string interpreter to sequentially read each operation character in the operation formula from left to right, and pushing each operation character into the character stack in order of priority; The operation characters in the character stack are popped out and outputted in sequence to obtain a target character string.

4. The string interpretation method according to claim 3, characterized in that: The operation characters in the operation formula include operands, operators, left brackets and right brackets, the character stack includes a temporary stack and a target stack, and the step of using the string interpreter to sequentially read the operation characters in the operation formula from left to right and push the operation characters into the character stack in order of priority includes: If the operation character is an operation operand, the operation operand is pushed into the target stack; If the operation character is an operation operator, then detecting whether the temporary stack is empty, if the temporary stack is empty, directly pushing the operation operator into the temporary stack, if the temporary stack is not empty, then comparing the operation operator with the operation priority of the top element of the temporary stack; If the operation priority of the operation operator is greater than the top element of the stack, the operation operator is pushed into the temporary stack; If the priority of the operation operator is less than or equal to the top element of the stack, the top elements of the temporary stack are popped out and pushed into the target stack in sequence, until the priority of the operation operator is greater than the top element of the temporary stack, or the temporary stack is empty, the operation operator is pushed into the temporary stack; If the operation character is a left bracket, the left bracket is directly pushed into the temporary stack; If the operation character is a right bracket, the top element in the temporary stack is popped out and pushed into the target stack until the top element is a left bracket, and the right bracket and the left bracket are discarded; When all operation characters in the operation formula are read, the elements in the temporary stack are popped out in sequence and pushed into the target stack.

5. The character string interpretation method according to claim 1, wherein: Before the step of using the string interpreter to interpret the operation formula from an infix expression to a postfix expression to obtain a target string, the step further includes: The command character string is checked according to the prompt command, and when an erroneous instruction is checked, the erroneous instruction is located and an error prompt message is output.

6. A string interpretation device, characterized in that: The character string interpretation device comprises: A parser configuration module, used for calling at least one target parser from a preset parser component library to form a string interpreter according to a configuration instruction input by a user, wherein the string interpreter includes a prompt command, the prompt command is provided with a quick operation button and a dialog box, the dialog box is used for the user to edit the command string to be interpreted, the operation button includes various parameters of the motor driver, the parser component library includes a multi-language parser, and at least one target parser is called from the multi-language parser to interpret strings of different language types and / or different data types, and the language type includes at least natural language and high-level programming language; A command generation module, used to generate a command string to be interpreted according to the user's operation instruction for the prompt command, wherein the command string includes an operation formula; The command interpretation module uses the string interpreter to interpret the operation formula from an infix expression to a postfix expression to obtain a target string. The target string is an instruction that can be directly compiled by the motor driver. The command string is compiled by the host computer software and sent to the motor driver for execution to realize the motion control of the motor.

7. A terminal device, characterized in that: The terminal device comprises: a memory, a processor, and a string interpretation program stored in the memory and executable on the processor, wherein the string interpretation program implements the steps of the string interpretation method according to any one of claims 1 to 5 when executed by the processor.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a character string interpretation program, and when the character string interpretation program is executed by a processor, the steps of the character string interpretation method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Digital oscilloscope mathematical operation processing method based on inverse Polish algorithm

    CN111767004A

  • Method and apparatus for a hierarchical object model-based constrained language interpreter-parser

    US20050091036A1