Hi,
I am trying figure out, best way to order execution sequence of equation, from pseudo code string.
These code my vary, so is not fixed.
Lets consider following example:
a = i * ((4  k * (3 + 1)) + pow(i, 2  sin(45 / 180 * PI)));
For simplicity, narrowing the problem down to:
i * (4  k * (3 + 1) )
So, I got this equation as string.
Now I am thinking to split it into terms and store into array, or list.
For example:
 i

 (
 4

 k

 (
 3

 1
 )
 )
However, from that form, it is hard to extract relevant groups and set ordering.
Another thought was, to use array / list with nested class.
For example:
class Term
{
Term [] localTerms ;
}
Now I can store nested structure, where brackets are involved.
So at depth level 0, I would have something like:
localTerms [0] = 1
localTerms [1] = *
localTerms [2] = 4  k * (3 + 1)
Them at depth 1, localTerms [2], I can have
localTerms [0] = 4
localTerms [1] = 
localTerms [2] = k
localTerms [3] = *
localTerms [4] = 3 + 1
And finally at dept 2, localTerms [4]
localTerms [0] = 3
localTerms [1] = +
localTerms [2] = 1
From this case, I am mostly concerned, regarding dept 1, where I have both  and * signs.
Of course * equation should be executed before .
What I am thinking of, is adding some sort of weight, to mathematical signs.
For example,

 = 0

 = 0

 = 1
 / = 1
Then from here, I probably could prioritize and sort pairs of terms, to execute in right order.
But I am not convinced, this is best approach.
Have you any better thoughts, how to bite the problem?