Permalink
Browse files

Fix operator resolution case

An unresolved operator can be preceded by an operator of unknown arity, which means that the unresolved operator should most likely be a unary operator.
  • Loading branch information...
1 parent 8d12bd9 commit 3351b508a1c9cb38ae71bdd1e9cab68a79888df7 @davedelong committed Aug 18, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 DDMathParser/DDMathStringTokenizer.m
@@ -169,6 +169,10 @@ - (BOOL)_processUnknownOperatorToken:(DDMathStringToken *)token withError:(NSErr
// a right-assoc unary operator can be followed by another unary operator
// (a left-assoc unary followed by a left-assoc unary is handled below)
shouldBeUnary = YES;
+ } else if ([previousToken operatorArity] == DDOperatorArityUnknown) {
+ // the previous operator has unknown arity. this _should_ only happen when preceded by a comma,
+ // so we'll assume that this should be a unary operator
+ shouldBeUnary = YES;
}
}

0 comments on commit 3351b50

Please sign in to comment.