objective c - DDMathParser failing to tokenize solitary plus character -
using ddmathstringtokenizer, while 2 + 4 tokenizes fine 3 tokens (with second being + operator , first , third being numbers), if pass on + alone, fails return token.
this not hold true every other operator i've tried, such / * - etc.
i can force somehow how can ddmathstringtokenizer tokenize + correctly?
to reproduce issue: following return array no objects. if change string value operator character return 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 tokenizer trying smart. since + character first token, it's assumed unary operator (no left-hand-side). gets dropped on floor, because unary + worthless operator: doesn't affect evaluation, gets omitted token stream.
i believe better on 1.1 branch, haven't had time finish integrating changes in master.
Comments
Post a Comment