Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support for the degree sign as "dtor"

  • Loading branch information...
commit 6f4aa6cc57c2b01810204c6fc0b1f2a436698179 1 parent 4ce5ae4
@davedelong authored
View
6 DDMathParser/DDMathStringTokenizer.m
@@ -68,11 +68,7 @@ + (NSCharacterSet *)_functionCharacterSet {
static dispatch_once_t onceToken;
static NSCharacterSet *_functionSet = nil;
dispatch_once(&onceToken, ^{
- NSMutableCharacterSet * c = [NSMutableCharacterSet lowercaseLetterCharacterSet];
- [c formUnionWithCharacterSet:[NSCharacterSet uppercaseLetterCharacterSet]];
- [c formUnionWithCharacterSet:[NSCharacterSet decimalDigitCharacterSet]];
- [c addCharactersInString:@"_"];
- _functionSet = [c copy];
+ _functionSet = DD_RETAIN([NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01233456789_"]);
});
return _functionSet;
}
View
1  DDMathParser/DDParserTypes.h
@@ -42,6 +42,7 @@ extern NSString *const DDOperatorMultiply;
extern NSString *const DDOperatorModulo;
extern NSString *const DDOperatorBitwiseNot;
extern NSString *const DDOperatorFactorial;
+extern NSString *const DDOperatorDegree;
extern NSString *const DDOperatorPower;
extern NSString *const DDOperatorParenthesisOpen;
extern NSString *const DDOperatorParenthesisClose;
View
1  DDMathParser/DDParserTypes.m
@@ -30,6 +30,7 @@
NSString *const DDOperatorModulo = @"modulo";
NSString *const DDOperatorBitwiseNot = @"not";
NSString *const DDOperatorFactorial = @"factorial";
+NSString *const DDOperatorDegree = @"dtor";
NSString *const DDOperatorPower = @"pow";
NSString *const DDOperatorParenthesisOpen = @"open_paren";
NSString *const DDOperatorParenthesisClose = @"close_paren";
View
6 DDMathParser/_DDOperatorInfo.m
@@ -162,8 +162,12 @@ + (NSArray *)_buildOperators {
[operators addObject:[self infoForOperatorFunction:DDOperatorUnaryPlus token:@"+" arity:DDOperatorArityUnary precedence:precedence associativity:DDOperatorAssociativityRight]];
precedence++;
- // there's only one left associative unary operator
+ // all the left associative unary operators have the same precedence
[operators addObject:[self infoForOperatorFunction:DDOperatorFactorial token:@"!" arity:DDOperatorArityUnary precedence:precedence associativity:DDOperatorAssociativityLeft]];
+ // \u00ba is º (option-0); not necessary a degree sign, but common enough for it
+ [operators addObject:[self infoForOperatorFunction:DDOperatorDegree token:@"\u00ba" arity:DDOperatorArityUnary precedence:precedence associativity:DDOperatorAssociativityLeft]];
+ // \u00b0 is °
+ [operators addObject:[self infoForOperatorFunction:DDOperatorDegree token:@"\u00b0" arity:DDOperatorArityUnary precedence:precedence associativity:DDOperatorAssociativityLeft]];
precedence++;
[operators addObject:[self infoForOperatorFunction:DDOperatorPower token:@"**" arity:DDOperatorArityBinary precedence:precedence associativity:DDOperatorAssociativityRight]];
Please sign in to comment.
Something went wrong with that request. Please try again.