Home > Back-end >  How to generate operating analytical expression tree?
How to generate operating analytical expression tree?

Time:03-01

Suppose I have expressions such as this form

 
"1 + 2-3 * 4/5 (6/7 * 8-2) +"


Assume that the operands forever only 0-9
Operators are also forever only + - */
Priority in also will only appear ()

Could you tell me how to parse expression, expression is obtained by generating operation trees to the calculation results of double
I can hand operation of born into a tree, but I can't write out how to generate the
(this is close to write a simple compiler, parsed token, generating operation tree, operand stack into voltage, and then execute, then can assume that the input right forever, there will be no grammatical errors, because the token resolution I can write, but the parsed token transfer operation tree or pressure stack won't)
  • Related