Using DDMathStringTokenizer, while something like 2 + 4 tokenizes fine into 3 tokens (with the second being the + operator and the first and third being numbers), if I pass over a + alone, it fails to return it as a token.
This does not hold true for every other operator I've tried, such as / * - etc.
I can probably force this somehow but how can I get DDMathStringTokenizer to tokenize the + correctly?
To reproduce the issue:
The following will return an array with no objects. If you change the string value to another operator character it will return a valid array.
NSError *error = nil;
NSString *string = @"+";
DDMathOperatorSet *opSet = [DDMathOperatorSet defaultOperatorSet];
DDMathStringTokenizer *tokenizer = [[DDMathStringTokenizer alloc] initWithString:string operatorSet:opSet error:&error];
NSLog(@"Tokens:%@", [tokenizer allObjects]);
This is the tokenizer trying to be too smart. Since the
+character is the first token, it's assumed to be a unary operator (no left-hand-side). It then gets dropped on the floor, because unary+is a worthless operator: it doesn't affect evaluation, so it gets omitted from the token stream.I believe this is better on the 1.1 branch, but I haven't had time to finish integrating changes in to master.