A standard form function like A\*B+A\*B' is easy to parse (spliting by + and then spliting by \*). How do you parse a function, if it doesn't take a standard form?
Example: a function can take the following forms:

```
A*B+A(A+B')
A*B+(A+B')A
A*B+A*B(A+B)

```

Any ideas?

P.S: I would like to parse the function in Java.