ExtendedParser extends BaseParser { protected final float readExpression() throws ParserException { skipWhitespaces(); float result = readTerm(); skipWhitespaces(); while (available() && (peek() == '+' || peek() == '-')) { if (pop() == '+') { result += readTerm(); } else { result -= readTerm(); } skipWhitespaces(); } return result; } ExtendedParser(String toParse);   }
@Test public void testExpression() throws ParserException { ExtendedParser parser = new ExtendedParser("5 * (2+3)"); assertEquals(25f, parser.readExpression(), 0.0001); parser = new ExtendedParser(" (2)+((( (( ( ((7)))*1 ))) + 1)) * 3"); assertEquals(26f, parser.readExpression(), 0.0001); parser = new ExtendedParser("1 + 2 * 3 + 3"); assertEquals(10f, parser.readExpression(), 0.0001); }