Hi,

I figured that writing a math expression parser isn't that easy but I started this pet-project anyway and came to the conclusion that it is better to convert the expression into a different format. Here is what came out (no code, but the idea).

It is already coded but can't post it because it's a part of a much bigger thing. Anyway, here is the idea.

We have the following expression

15 * (10 + (6 * 5) / 2)

which converts to

* 6 5 / 2 + 10 * 15

another example

10 + 1 * SQR(16)

would be

16 SQR * 1 + 10

This should evaluate much easier since there are no parenthesis anymore.

I guess this is what's called Polish Notation. Has anyone here done the same thing and used the same approach ?

Cheers

Steven

I figured that writing a math expression parser isn't that easy but I started this pet-project anyway and came to the conclusion that it is better to convert the expression into a different format. Here is what came out (no code, but the idea).

It is already coded but can't post it because it's a part of a much bigger thing. Anyway, here is the idea.

We have the following expression

15 * (10 + (6 * 5) / 2)

which converts to

* 6 5 / 2 + 10 * 15

another example

10 + 1 * SQR(16)

would be

16 SQR * 1 + 10

This should evaluate much easier since there are no parenthesis anymore.

I guess this is what's called Polish Notation. Has anyone here done the same thing and used the same approach ?

Cheers

Steven

## Comment