A method of expression processing based on VB6
By using VB6-based expression processing methods in the digital platform CBOM of elevator design BOM, verifying and analyzing expressions, the limitations of expression processing engine in the existing technology are solved, flexible calculation and real-time verification are realized, and improved Flexibility and accuracy of expression processing.
Patent Information
- Application Number
- CN202211054216.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-31
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-08-31
AI Technical Summary
The existing expression processing engine has limitations in the BOM digital platform CBOM of elevator design, and it is impossible to effectively verify and parse different types of expressions, resulting in a single calculation result and the accuracy of expressions cannot be verified in real time.
Using VB6-based expression processing method, by initializing the operator dictionary and priority dictionary, the expression is verified and parsed in steps, including operation item judgment, variable acquisition and calculation result output, to realize expression verification, variable acquisition and analytical calculation .
This method can calculate different results based on the expressions of different inputs, and verify in real time whether the expression is written correctly, improving the flexibility and accuracy of expression processing.
Smart Images

Figure CN115310424B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an expression processing engine, and in particular to an expression processing method based on VB6. Background Art
[0002] The elevator design BOM digital platform (CBOM for short) is a system that automatically obtains the entire elevator design BOM. In CBOM, the design of the drawing will be converted into logical data, and expressions need to be entered during the conversion. CBOM uses these logical data and the elevator parameter information entered by the user to automatically obtain the elevator design BOM. During the acquisition process, the expressions in the data need to be parsed. Therefore, the expression processing engine is one of the more critical technologies in CBOM.
[0003] Expressions can be divided into two types: constant expressions and expressions with variables. An expression is a string consisting of at least one operation item, where the operation items can be divided into two types: operands and operators. Operands can be divided into two types: constants and variables. Operators can be divided into two types: symbolic operators and function operators. Constants can be divided into two types: numeric constants and string constants. Variables can be divided into three types according to their storage types: numeric variables, string variables, and NULL variables.
[0004] Variable: A string of characters enclosed in English brackets, where the string is the variable name, such as [A1], the variable name of this variable is A1. Variables can store three different types: numeric values, strings, and NULL (unknown values). The following is an explanation of expression-related terms:
[0005] String constant: a set of strings enclosed in double quotes, where the string is the content of the string constant, such as "mm", where mm is the content of the string constant;
[0006] Numeric constant: a correct numeric string, such as 3.1415;
[0007] Constants: string constants and numeric constants are collectively referred to as constants;
[0008] Operands: Variables and constants are collectively called operands;
[0009] Symbolic operators: Symbols defined inside the expression engine, as shown in the following table:
[0010]
[0011] Function operator: A function defined inside the expression engine, which is a string consisting of English characters, as shown in the following table:
[0012]
[0013]
[0014]
[0015] Operator: Symbolic operators and functional operators are collectively called operators;
[0016] Operation items: Operands and operators can be collectively referred to as operation items;
[0017] Expression: a string consisting of at least one operation item, such as: ROUND([A1] / 3,1)&”mm”;
[0018] According to the requirements of CBOM, the expression processing engine mainly includes two functions: expression verification and acquisition of referenced variables and expression parsing and calculation.
[0019] Each existing expression processing engine has its own limitations, and each expression engine has its own special calling method, data calculation method and applicable special scenarios. When developers write program codes, they can only use one expression engine alone. However, using only one expression calculation engine brings the above limitations to the calculation of expressions. Summary of the invention
[0020] The purpose of the present invention is to overcome the deficiencies of the prior art and provide an expression processing method based on VB6 for processing expressions in a digital platform CBOM to meet the verification and parsing requirements of expressions in the CBOM.
[0021] The technical solution of the present invention is as follows:
[0022] An expression processing method based on VB6 includes two parts: expression verification and acquisition of referenced variables and expression parsing and calculation. Expression verification and acquisition of referenced variables include the following steps:
[0023] a1. Initialization
[0024] Load a dictionary object containing all internally defined operators for use as verification operation items; this step only needs to be performed once in a process;
[0025] a2. Input expression string
[0026] Receives an expression string;
[0027] a3. Read operation items
[0028] Read the operation item from the expression string, if the operation item is read, execute step a4, if the operation item is not read, jump to step a7;
[0029] a4. Verify operation items
[0030] Verify whether the operation item is one of a character constant, a numeric constant, a symbolic operator, a function operator, and a variable. If the operation item is one of a character constant, a numeric constant, a symbolic operator, a function operator, and a variable, execute step a5; otherwise, broadcast an error.
[0031] a5. Operation item judgment
[0032] Determine whether the operation item is a variable. If the operation item read in step a3 is a variable, execute step a6; otherwise, jump to step a3 to read the next frontmost operation item.
[0033] a6. Storage variable name
[0034] Store the variable name in the variable name array and jump to step a3 to read the next frontmost operation item;
[0035] a7. Output variable name array
[0036] Return the variable name array in step a6 and end the verification;
[0037] The parsing and evaluation of the expression includes the following steps:
[0038] b1. Initialization
[0039] Load a dictionary object containing all internally defined operators to obtain the number of operands required by the operator during calculation; load a dictionary object of the priority between two operators to determine the priority; this step only needs to be performed once in a process;
[0040] b2. Input expression string and two-dimensional array of variable name / variable value key-value pairs
[0041] Receive an expression string, a two-dimensional array of key-value pairs of variable name / variable value, convert them into a variable dictionary object, initialize the operator stack, the top of the operator stack, the operand stack, and the top of the operand stack;
[0042] b3. Read operation items
[0043] Read the first operation item from the expression string. If an operation item is read, execute step b4. If no operation item is read, jump to step b13.
[0044] b4. Operation item judgment
[0045] Determine whether the read operation item is an operator. If the operation item read in step b3 is an operator, execute step b5; otherwise, jump to step b10;
[0046] b5. Priority judgment
[0047] Determine the priority between the two operators based on the top of the operator stack and the operation item read in step b3. If the top of the operator stack has a higher priority, execute step b6. If the top of the operator stack has a lower priority, push the operator onto the stack and jump to step b3.
[0048] b6, pop the operand from the stack
[0049] Get the number of operands required at the top of the operator stack according to the operator dictionary object, and pop the operands according to this number;
[0050] b7. Calculation
[0051] The internal calculation function is called according to the top of the operator stack and the operand popped in step b6 to obtain the result;
[0052] b8, push operands onto the stack
[0053] Push the operation result obtained in step b7 into the operand stack;
[0054] b9, Operator pop
[0055] The operator is popped off the stack and the process goes to step b5 to determine the priority of the top of the current operator stack.
[0056] b10, whether it is a variable
[0057] Determine whether the operand is a variable. If the operand is a variable, execute step b11; otherwise, jump to step b12.
[0058] b11. Replace variables
[0059] Get the variable value from the variable dictionary object according to the variable name;
[0060] b12, push operands onto the stack
[0061] Push the variable value in step b11 or the operand in step b10 into the operand stack, and jump to step b3 to read the next frontmost operation item;
[0062] b13. Output calculation results
[0063] Return the calculation result and end.
[0064] Compared with the prior art, the beneficial effect of the present invention is that: the present invention provides an expression processing method based on VB6, which is used for CBOM. Through this expression processing method, different results can be calculated according to different inputs of the written expression, and whether the expression is written correctly can be verified in real time. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1 A flow chart of the method for verifying the expression and obtaining the referenced variables of the present invention;
[0067] Figure 2 The figure is a flow chart of the method for parsing and calculating the expression of the present invention. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. 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.
[0069] In order to illustrate the technical solution of the present invention, a specific embodiment is provided below for illustration.
[0070] Example
[0071] This embodiment provides an expression processing method based on VB6, which is used to process expressions in a digital platform CBOM, and includes two parts: expression verification and acquisition of referenced variables and expression parsing and calculation.
[0072] like Figure 1 As shown, the verification of the expression and the acquisition of the referenced variables include the following steps:
[0073] a1. Initialization
[0074] Load a dictionary object containing all internally defined operators for use as verification operation items; this step only needs to be performed once in a process;
[0075] a2. Input expression string
[0076] Receives an expression string;
[0077] a3. Read operation items
[0078] Read the operation item from the expression string, if the operation item is read, execute step a4, if the operation item is not read, jump to step a7;
[0079] a4. Verify operation items
[0080] Verify whether the operation item is one of a character constant, a numeric constant, a symbolic operator, a function operator, and a variable. If the operation item is one of a character constant, a numeric constant, a symbolic operator, a function operator, and a variable, execute step a5. Otherwise, broadcast an error globally so that the caller can obtain the error.
[0081] a5. Operation item judgment
[0082] Determine whether the operation item is a variable. If the operation item read in step a3 is a variable, execute step a6; otherwise, jump to step a3 to read the next frontmost operation item.
[0083] a6. Storage variable name
[0084] Store the variable name in the variable name array and jump to step a3 to read the next frontmost operation item;
[0085] a7. Output variable name array
[0086] Return the variable name array in step a6 to end the verification.
[0087] like Figure 2 As shown, the parsing and calculation of the expression includes the following steps:
[0088] b1. Initialization
[0089] Load a dictionary object containing all internally defined operators to obtain the number of operands required by the operator during calculation; load a dictionary object of the priority between two operators to determine the priority; this step only needs to be performed once in a process;
[0090] b2. Input expression string and two-dimensional array of variable name / variable value key-value pairs
[0091] Receive an expression string, a two-dimensional array of key-value pairs of variable name / variable value, convert them into a variable dictionary object, initialize the operator stack, the top of the operator stack, the operand stack, and the top of the operand stack;
[0092] b3. Read operation items
[0093] Read the first operation item from the expression string. If an operation item is read, execute step b4. If no operation item is read, jump to step b13.
[0094] b4. Operation item judgment
[0095] Determine whether the read operation item is an operator. If the operation item read in step b3 is an operator, execute step b5; otherwise, jump to step b10;
[0096] b5. Priority judgment
[0097] Determine the priority between the two operators based on the top of the operator stack and the operation item read in step b3. If the top of the operator stack has a higher priority, execute step b6. If the top of the operator stack has a lower priority, push the operator onto the stack and jump to step b3.
[0098] b6, pop the operand from the stack
[0099] Obtain the number of operands required at the top of the operator stack according to the operator dictionary object, and pop the operands according to the number, and execute step b7;
[0100] b7. Calculation
[0101] Call the internal calculation function to calculate the result according to the top of the operator stack and the operand popped in step b6, and execute step b8;
[0102] b8, push operands onto the stack
[0103] Push the operation result obtained in step b7 into the operand stack and execute step b9;
[0104] b9, Operator pop
[0105] The operator is popped off the stack and the process goes to step b5 to determine the priority of the top of the current operator stack.
[0106] b10, whether it is a variable
[0107] Determine whether the operand is a variable. If the operand is a variable, execute step b11; otherwise, jump to step b12.
[0108] b11. Replace variables
[0109] Obtain the variable value from the variable dictionary object according to the variable name, and execute step b12;
[0110] b12, push operands onto the stack
[0111] Push the variable value in step b11 or the operand in step b10 into the operand stack, and jump to step b3 to read the next frontmost operation item;
[0112] b13. Output calculation results
[0113] Return the calculation result and end.
[0114] When used in CBOM, this expression processing method can calculate different results according to different inputs of the written expression, and can also verify in real time whether the expression is written correctly.
[0115] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A VB6-based expression processing method for processing expressions in an elevator design BOM digital platform, including expression verification and acquisition of referenced variables and expression parsing and calculation, characterized in that: The verification of expressions and the acquisition of referenced variables include the following steps: a1. Initialization Load a dictionary object containing all internally defined operators for use as verification operation items; a2. Input expression string Receives an expression string; a3. Read operation items Read the operation item from the expression string, if the operation item is read, execute step a4, if the operation item is not read, jump to step a7; a4. Verify operation items Verify whether the operation item is one of a character constant, a numeric constant, a symbolic operator, a function operator, and a variable. If the operation item is one of a character constant, a numeric constant, a symbolic operator, a function operator, and a variable, execute step a5; otherwise, broadcast an error. a5. Operation item judgment Determine whether the operation item is a variable. If the operation item read in step a3 is a variable, execute step a6; otherwise, jump to step a3 to read the next frontmost operation item. a6. Storage variable name Store the variable name in the variable name array and jump to step a3 to read the next frontmost operation item; a7. Output variable name array Return the variable name array in step a6 and end the verification; The parsing and evaluation of the expression includes the following steps: b1. Initialization Load a dictionary object containing all internally defined operators, which is used to obtain the number of operands required by the operator during calculation; load a dictionary object of the priority between two operators, which is used for priority judgment; b2. Input expression string and two-dimensional array of variable name / variable value key-value pairs Receive an expression string, a two-dimensional array of key-value pairs of variable name / variable value, convert them into a variable dictionary object, initialize the operator stack, the top of the operator stack, the operand stack, and the top of the operand stack; b3. Read operation items Read the first operation item from the expression string. If an operation item is read, execute step b4. If no operation item is read, jump to step b13. b4. Operation item judgment Determine whether the read operation item is an operator. If the read operation item in step b3 is an operator, execute step b5; otherwise, jump to step b10. b5. Priority judgment Determine the priority between the two operators based on the top of the operator stack and the operation item read in step b3. If the top of the operator stack has a higher priority, execute step b6. If the top of the operator stack has a lower priority, push the operator onto the stack and jump to step b3. b6, operand pop Get the number of operands required at the top of the operator stack according to the operator dictionary object, and pop the operands according to this number; b7. Calculation The internal calculation function is called according to the top of the operator stack and the operand popped in step b6 to obtain the result; b8, push operands onto the stack Push the operation result obtained in step b7 into the operand stack; b9, Operator pop The operator is popped off the stack and the process goes to step b5 to determine the priority of the top of the current operator stack. b10, whether it is a variable Determine whether the operand is a variable. If the operand is a variable, execute step b11; otherwise, jump to step b12. b11. Replace variables Get the variable value from the variable dictionary object according to the variable name; b12, push operands onto the stack Push the variable value in step b11 or the operand in step b10 into the operand stack, and jump to step b3 to read the next frontmost operation item; b13. Output calculation results Return the calculation result and end.
2. The expression processing method based on VB6 according to claim 1, characterized in that: Step a1 only needs to be executed once in a process.
3. The expression processing method based on VB6 according to claim 1, characterized in that: Step b1 only needs to be performed once in a process.
