Well it's OK to post odd segments of the code but really we can't solve it from that. You have to post the whole thing. The solution is probably to extend your definition of a number: where you are expecting 0-9, you must also expect a possible '-', and it is the context that will define whether that means subtract or minus. So -5+12 would see the - as negative rather than subtract, because at that point it is expecting a number. But 12+-5 would also see the - as a negative because it's already seen an operator so is now expecting a number. On the other hand 12-5 would see the - as subtract, because it is looking for an operator, and programmed correctly your program shouldn't be confused by 12--5 which would be interpreted as 12 minus (-5).
lady_krizzie like this