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?
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.Code:} 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; }



LinkBack URL
About LinkBacks


