To describe with EBNF:

expression = term { addop term }.

term = factor { mulop factor }.

factor = "(" expression ")" | number.

addop = "+" | "-".

mulop = "*" | "/".

(I've been using 64 bit integers, so there shouldn't be any problem with integer range things.. right?)

I tried to handle negative numbers too. Will this make any problem? :'(

Are there any tricky cases or those sort of things? Or are there fractions like 1|2|3|4|5 ??

Some inputs and outputs:

Which are obvious..1/5-1/2

-3|10

1/2/3/4/5/6/7*8*7*6*5*4*3*2*1

8

(3+1/2*6)+1/2

13|2

132/((3+1/2*6)+1/2-(3+1/2*6)-1/2)

INVALID

13/(1*2*3*4*5*6*0)

INVALID

1|2+-1|2

0

1|2--1|2

1

Any suggestions?

Thanks in advance.