I have rewritten bjarne stroustrup's calculator program to accept input from a file and parse it and evaluate it. Everything works fine except for the instance where the plus sign acts as a signed value. For example 3*+2.5 equals 7.5 but the program expects a parenthesis. How can I implement the change?
1 2 3 4 5 6 7 8 9 10
}
case MINUS : // unary minus
return -prim(true);
case LP :
{
double e = expr(true);
if (curr_tok != RP) return error("')' expected");
get_token(); //eat ')'
return e;
}
This is what is applied when a unary minus is used but I cannot add a unary plus statement since it creates an error that plus is already used.