AST-based mathematical expression calculation algorithm

A technique for mathematical expressions and calculation algorithms, applied in the field of operations, to solve problems such as inability to handle unary operators and relational expression statements

Pending Publication Date: 2022-01-28
山东新汉唐数据科技有限公司
View PDF0 Cites 4 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0009] The main disadvantage of the prior art is that it cannot handle unary operators and relational expression sentences: for example: d>20, h=20*d; d<=20, h=300; when the steel bar diameter is greater than 20, h takes The value of 20*diameter, when d is not greater than, h is 300; this kind of expression statement can be found everywhere in the steel bar specification atlas
The traditional calculation based on suffix expressions cannot realize the calculation of two meanings of a character

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • AST-based mathematical expression calculation algorithm
  • AST-based mathematical expression calculation algorithm

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0098] The specific embodiment of the present invention will be further described below in conjunction with accompanying drawing and specific embodiment:

[0099] Explanation of terms:

[0100] Finite Automata: It is a computational model abstracted for the study of computational processes with limited memory and certain language classes. A finite state machine has a finite number of states, each state can transition to zero or more states, and the input string determines which state transition to perform.

[0101] Regular expression: A regular expression is a logical formula for string operations. It is to use some specific characters defined in advance and the combination of these specific characters to form a "rule string". This "rule string" is used To express a filtering logic for strings.

[0102] Backtracking: The backtracking algorithm is actually a search attempt process similar to enumeration, mainly to find the solution to the problem during the search attempt pro...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention provides an AST-based mathematical expression calculation algorithm. The AST-based mathematical expression calculation algorithm comprises the following steps of 1, converting an expression input by a user into Token and identifying the Token, wherein the input is a user expression, and the output is Token, 2, forming an AST syntax tree by the Token identified in the previous step, wherein the input is Token, and the output is the AST syntax tree, and 3, analyzing the AST syntax tree to calculate the value of the expression, wherein the input is the AST syntax tree, and the output is the value of the expression. The algorithm has the following beneficial effects that 1, whether the input is legal or not can be checked when a user inputs the expression containing the identifier; and 2, if the built-in mathematical function cannot meet the requirements of the user, a self-defined function calling calculation function is also provided, that is, calling of the function defined by the user is supported, and the function of calculating the expression is greatly expanded; and 3, expression statements can be processed, and calculation formulas can be selected according to conditions, so that a user does not have any learning cost during use.

Description

technical field [0001] The invention belongs to the technical field of computing, and relates to a mathematical expression, in particular to an AST-based mathematical expression calculation algorithm. Background technique [0002] Reinforcement calculation requires a large number of calculation formulas; it is difficult for users to verify the correctness of the formula when they input it, and the user can only be prompted to modify a certain formula when it is called. Because there are many nodes and the formula is messy, users use it It is not convenient, so it has become an urgent problem to solve whether the verification formula is correct when the user inputs. [0003] The current commonly used formula calculation method: [0004] 1. Scan the entire suffix expression sequentially from left to right; [0005] 2. If it is an operand, push the operand onto the stack; [0006] 3. If it is an operator, pop the corresponding operand from the stack, pay attention to the ord...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F17/10
CPCG06F17/10
Inventor 高玉生马仁怀朱明龙
Owner 山东新汉唐数据科技有限公司
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products