I am building a parser on top of the TDArithmeticParser.m of ParseKit Tests. I extended the TDArithmeticParserTest.m with the failing
test:
- (void)testMath {
s = @"10+(2*3)-15";
result = [p parse:s];
TDEquals((double)1.0, result); // result == 0.0
}
The problem is that I don't understand why the grammar is not working with this test. The corresponding BNF-grammar of the arithmetic parser is:
expr = term (plusTerm | minusTerm)*;
term = factor (timesFactor | divFactor)*;
plusTerm = '+' term;
minusTerm = '-' term;
factor = phrase exponentFactor | phrase;
timesFactor = '*' factor;
divFactor = '/' factor;
exponentFactor = '^' factor;
phrase = '(' expr ')' | Number;
I would be very thankful for any ideas that helps me identifying the problem.